vanvalenlab / deepcell-tf

Deep Learning Library for Single Cell Analysis
https://deepcell.readthedocs.io
Other
413 stars 95 forks source link

Link nucleus to whole cell segmentation mask mesmer #696

Closed janinemelsen closed 11 months ago

janinemelsen commented 11 months ago

I would like to synchronise the whole cell and nucleus segmentation mask, so that they both contain the exact same number of cells (for instance 'cells' with only a membrane but not a nucleus should be removed from the whole cell mask) Is there any way to do this?

Thanks!

Janine

rossbar commented 11 months ago

The masks are numpy arrays, so computing intersections/unions and other correspondences should be straightforward with boolean masking and logical operators. I don't think adding dedicated functionality to deepcell-tf (assuming I've understood you correctly) makes sense, as that would just be a layer of indirection on top of generic, fundamental array operations.

ngreenwald commented 11 months ago

Hi Janine, as you noted, the default output from Mesmer will have non-matching label IDs across the two prediction tasks. We added a post-processing step in ark which harmonizes the labels. You are welcome to either run the segmentation notebook, or take a look at the matching logic and repurpose it.

rossbar commented 11 months ago

I'll go ahead and close this one as "not-planned" since there are existing solutions either working with arrays directly or with third party libraries. Thanks for the suggestion!