From 6e3820f8523c4377a6d5b8f4269ae76672b89add Mon Sep 17 00:00:00 2001 From: Constantin Pape Date: Wed, 12 Mar 2025 15:32:48 +0100 Subject: [PATCH] Add mask intersection post-processing --- synapse_net/tools/postprocessing_widget.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/synapse_net/tools/postprocessing_widget.py b/synapse_net/tools/postprocessing_widget.py index 93551092..66e18ef3 100644 --- a/synapse_net/tools/postprocessing_widget.py +++ b/synapse_net/tools/postprocessing_widget.py @@ -46,9 +46,14 @@ def __init__(self): # Second postprocessing option: intersect with boundary of the mask. self.button2 = QPushButton("Intersect with Boundary") - self.button2.clicked.connect(self.on_intersect) + self.button2.clicked.connect(self.on_intersect_boundary) layout.addWidget(self.button2) + # Third postprocessing option: intersect with the mask. + self.button3 = QPushButton("Intersect") + self.button3.clicked.connect(self.on_intersect) + layout.addWidget(self.button3) + # Add the widgets to the layout. self.setLayout(layout) @@ -82,10 +87,17 @@ def on_filter(self): segmentation[np.isin(segmentation, filter_ids)] = 0 self._write_pp(segmentation) - def on_intersect(self): + def on_intersect_boundary(self): if not self._conditions_met(): return segmentation, mask = self._get_segmentation_and_mask() boundary = find_boundaries(mask) segmentation = np.logical_and(segmentation > 0, boundary).astype(segmentation.dtype) self._write_pp(segmentation) + + def on_intersect(self): + if not self._conditions_met(): + return + segmentation, mask = self._get_segmentation_and_mask() + segmentation = np.logical_and(segmentation > 0, mask > 0).astype(segmentation.dtype) + self._write_pp(segmentation)