From 4cd4d019c6d9d3f1bb557753d037444a018e6baa Mon Sep 17 00:00:00 2001 From: Luca Freckmann Date: Tue, 10 Dec 2024 11:26:58 +0100 Subject: [PATCH] shortened layer names in segmentation widget and changed default behaviour for selected structure2 in vesicle_pool_widget to ignore structure2 if its the same as structure1 --- synapse_net/tools/segmentation_widget.py | 2 +- synapse_net/tools/vesicle_pool_widget.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/synapse_net/tools/segmentation_widget.py b/synapse_net/tools/segmentation_widget.py index 6fbb0cc..f74e078 100644 --- a/synapse_net/tools/segmentation_widget.py +++ b/synapse_net/tools/segmentation_widget.py @@ -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): diff --git a/synapse_net/tools/vesicle_pool_widget.py b/synapse_net/tools/vesicle_pool_widget.py index 301dd20..2e95e5d 100644 --- a/synapse_net/tools/vesicle_pool_widget.py +++ b/synapse_net/tools/vesicle_pool_widget.py @@ -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: @@ -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: