MouseLand / cellpose

a generalist algorithm for cellular segmentation with human-in-the-loop capabilities
https://www.cellpose.org/
BSD 3-Clause "New" or "Revised" License
1.33k stars 382 forks source link

[FEATURE] Extracting information from original image using Cellpose masks #945

Closed sakethkar closed 2 weeks ago

sakethkar commented 4 months ago

Hello! I am working with some NanoString datasets outside their AtoMx SIP. I have used Cellpose GUI to run some segmentations which I like, but I am unable to extract any information from the resulting masks, viz. pixel co-ordinates of the cells, transcript locations etc.

I would also like to extract information (such as staining intensities) from the original image using Cellpose generated masks. Any help is appreciated. Thanks!

carsen-stringer commented 2 weeks ago

we are not going to support this in cellpose, but scipy.ndimage has nice functions for this, e.g.: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.mean.html#scipy.ndimage.mean

you can use the mean to compute the staining intensity per cell, e.g. with a given img with your stain, you can use the cellpose masks as follows

from scipy.ndimage import mean
intensities = mean(img, masks)