cellpose
cellpose copied to clipboard
min_size parameter is ignored in slice-by-slice stack segmentation
When launching a segmentation on a stack with the do_3D parameter set to False, the value set for the parameter min_size is ignored, and actually the defaul value of 15 is used for screening each single slice in the label stack.
I found that you can overcome this issue by imposing a min_size vaue of -1 when computing the mask for each slice https://github.com/MouseLand/cellpose/blob/d9c9f28c1cc45025de6a02402de20f3b18e246d0/cellpose/models.py#L651 and perform the screening right after the stitching, i.e. at https://github.com/MouseLand/cellpose/blob/d9c9f28c1cc45025de6a02402de20f3b18e246d0/cellpose/models.py#L663 by adding the line
masks = utils.fill_holes_and_remove_small_masks(masks, min_size=min_size)
However I am not sure this is the correct or most elegant solution.