Hello,

I would like to know the best way to save ‘numbered mask’ images. That is, an image that consists of masks, where each mask is numbered differently for each cell (similar to running bwlabel() on an image of discrete masks). However I require that the numbering of the masks be consistent with the numbering of the cells as done by the cellprofiler analysis. My objective is to use the masks to identify the same cells and to run secondary analyses to be used in conjunction with the cellprofiler metrics.

Currently I have been saving the cytoplasm masks as grayscale. This produces an image of masks where each cell is numbered differently. However I need to divide by 768 to convert the mask numbers into consecutive integers (likely a bit-depth issue I imagine). Moreover, I have found that the numbers skip values. As an example, in an image for which cellprofiler identifies 65 cells, the mask numbers go up to 85, with 20 skipped values. My guess is that discarded (e.g. edge) cells are the reason for the skipped values. It seems however that if I follow the masked cells consecutively, they correspond exactly to the numbering of the cells by cellprofiler. Hence it seems that I can run secondary analyses and match them with the cellprofiler results.

However this process I have described is awkward and requires some coding to produce matching numbers in the masks. As well, I am not 100% certain that the consecutive mask numbers will always correspond to the cell numbering system in cellprofiler. Could there be a better, more direct way to obtain numbered cell masks where the numbers correspond to those in the cellprofiler output?

Thanks very much,

Ernest