Skip to content

Commit

Permalink
shortened layer names in segmentation widget and changed default beha…
Browse files Browse the repository at this point in the history
…viour for selected structure2 in vesicle_pool_widget to ignore structure2 if its the same as structure1
  • Loading branch information
lufre1 committed Dec 10, 2024
1 parent 1713639 commit 4cd4d01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion synapse_net/tools/segmentation_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def on_predict(self):
for name, seg in segmentation.items():
self.viewer.add_labels(seg, name=name, metadata=metadata)
else:
self.viewer.add_labels(segmentation, name=f"{model_type}-segmentation", metadata=metadata)
self.viewer.add_labels(segmentation, name=f"{model_type}", metadata=metadata)
show_info(f"INFO: Segmentation of {model_type} added to layers.")

def _create_settings_widget(self):
Expand Down
6 changes: 4 additions & 2 deletions synapse_net/tools/vesicle_pool_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def on_pool_vesicles(self):
distance_layer = self._get_layer_selector_layer(self.dist_selector_name1)
distances = None if distance_layer is None else distance_layer.properties
distance_layer2 = self._get_layer_selector_layer(self.dist_selector_name2)
# Check if the second distance is the same as the first.
if distance_layer2.name == distance_layer.name:
distance_layer2 = None
distances2 = None if distance_layer2 is None else distance_layer2.properties

if segmentation is None:
Expand Down Expand Up @@ -153,12 +156,11 @@ def _compute_vesicle_pool(
# Add distances2 if present.
if distances2 is not None:
distance_ids = distances2.get("label", [])
if set(distance_ids) != set(morphology_ids):
if set(distance_ids) != set(merged_df.label):
show_info("ERROR: The IDs in distances2 and morphology are not identical.")
return
distances2 = pd.DataFrame(distances2).drop(columns=["index"])
merged_df = merged_df.merge(distances2, left_on="label", right_on="label", suffixes=("", "2"))
print(merged_df)
# Assign the vesicles to the current pool by filtering the mergeddataframe based on the query.
filtered_df = self._parse_query(query, merged_df)
if len(filtered_df) == 0:
Expand Down

0 comments on commit 4cd4d01

Please sign in to comment.