Skip to content

Add mask intersection post-processing #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions synapse_net/tools/postprocessing_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Loading