Skip to content

Commit

Permalink
Merge pull request #15 from LorenzLamm/rainbow_distances
Browse files Browse the repository at this point in the history
readd all-storing option and fix issue
  • Loading branch information
LorenzLamm authored Sep 19, 2024
2 parents fe91737 + 37bef19 commit fc75799
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions src/lasso_3d/_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ def __init__(self, viewer: "napari.viewer.Viewer"):
self._layer_selection_widget_connected_components = magicgui(
self._connected_components,
mask_layer={"choices": self._get_valid_image_layers},
remove_small_objects_size={"value": 100},
remove_small_objects_size={
"value": 100,
"widget_type": "SpinBox",
"min": 0,
"max": 100000,
},
call_button="Connected Components",
)
self.connected_components_box.addWidget(
Expand Down Expand Up @@ -87,20 +92,20 @@ def __init__(self, viewer: "napari.viewer.Viewer"):
)
self.store_tomogram_box.addWidget(self.store_tomogram_widget.native)

# self.store_all_components_box = QHBoxLayout()
# self.store_all_components_widget = magicgui(
# self._store_all_components,
# image_layer={"choices": self._get_valid_image_layers},
# foldername={
# "widget_type": "FileEdit",
# "mode": "d",
# "label": "Folder Path",
# },
# call_button="Store All Components",
# )
# self.store_all_components_box.addWidget(
# self.store_all_components_widget.native
# )
self.store_all_components_box = QHBoxLayout()
self.store_all_components_widget = magicgui(
self._store_all_components,
image_layer={"choices": self._get_valid_image_layers},
foldername={
"widget_type": "FileEdit",
"mode": "d",
"label": "Folder Path",
},
call_button="Store All Components",
)
self.store_all_components_box.addWidget(
self.store_all_components_widget.native
)

self.color_distances_box = QHBoxLayout()
color_point = QPushButton("Points")
Expand All @@ -126,7 +131,7 @@ def __init__(self, viewer: "napari.viewer.Viewer"):
self.layout().addLayout(self.connected_components_box)
self.layout().addLayout(self.display_connected_components_box)
self.layout().addLayout(self.store_tomogram_box)
# self.layout().addLayout(self.store_all_components_box)
self.layout().addLayout(self.store_all_components_box)
self.layout().addLayout(self.color_distances_box)

viewer.layers.events.inserted.connect(self._on_layer_change)
Expand Down Expand Up @@ -154,9 +159,9 @@ def _on_layer_change(self, event):
self.store_tomogram_widget.image_layer.choices = (
self._get_valid_labels_layers(None)
)
# self.store_all_components_widget.image_layer.choices = (
# self._get_valid_labels_layers(None)
# )
self.store_all_components_widget.image_layer.choices = (
self._get_valid_labels_layers(None)
)
self.color_distances_widget.image_layer.choices = (
self._get_valid_labels_layers(None)
)
Expand Down Expand Up @@ -443,13 +448,15 @@ def _store_all_components(
image_layer: napari.layers.Image,
foldername: str,
):
print("Storing all components")
if image_layer is None:
return
out_data = image_layer.data
for i in range(1, np.max(out_data) + 1):
print("Storing component", i)
out_data_i = (out_data == i) * 1.0
out_data_i = np.transpose(out_data_i, (2, 1, 0))
store_tomogram(foldername + f"/component_{i}.mrc", out_data_i)
store_tomogram(str(foldername) + f"/component_{i}.mrc", out_data_i)

def _get_valid_points_layers(
self, combo_box
Expand Down

0 comments on commit fc75799

Please sign in to comment.