Skip to content

Commit 105caf7

Browse files
"Add remove edge cells functionality" (#169)
1 parent ae79b25 commit 105caf7

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

runcellpose.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy
22
import os
3-
from cellpose import models, io, core
3+
from cellpose import models, io, core, utils
44
from skimage.transform import resize
55
import importlib.metadata
66

@@ -268,6 +268,15 @@ def set_directory_fn(path):
268268
minval=-1,
269269
doc="""\
270270
Minimum number of pixels per mask, can turn off by setting value to -1
271+
""",
272+
)
273+
274+
self.remove_edge_masks = Binary(
275+
text="Remove objects that are touching the edge?",
276+
value=True,
277+
doc="""
278+
If you do not want to include any object masks that are not in full view in the image, you can have the masks that have pixels touching the the edges removed.
279+
The default is set to "Yes".
271280
""",
272281
)
273282

@@ -293,6 +302,7 @@ def settings(self):
293302
self.min_size,
294303
self.omni,
295304
self.invert,
305+
self.remove_edge_masks
296306
]
297307

298308
def visible_settings(self):
@@ -310,7 +320,7 @@ def visible_settings(self):
310320

311321
vis_settings += [self.expected_diameter, self.cellprob_threshold, self.min_size, self.flow_threshold, self.y_name, self.invert, self.save_probabilities]
312322

313-
vis_settings += [self.do_3D, self.stitch_threshold]
323+
vis_settings += [self.do_3D, self.stitch_threshold, self.remove_edge_masks]
314324

315325
if self.do_3D.value:
316326
vis_settings.remove( self.stitch_threshold)
@@ -431,6 +441,9 @@ def run(self, workspace):
431441
invert=self.invert.value,
432442
)
433443

444+
if self.remove_edge_masks:
445+
y_data = utils.remove_edge_masks(y_data)
446+
434447
y = Objects()
435448
y.segmented = y_data
436449

0 commit comments

Comments
 (0)