Masking different cell types with different markers and shape in a tissue




I am trying to use Cell Profiler on staining of human tissue sections. The tissue has multiple different cell types with different shapes in close proximity, and each cell type has a separate surface marker. In addition to analysis of individual cell types, I would like to create a mask for the entire tissue that accurately separates cell borders (hopefully remaining faithful to different cell shapes), but I was having trouble.

One thing I have been trying is to create multiple different “sub-masks” and merging them, with the following process:

  • I start with primary objects for the whole image, as all the nuclear staining is the same.
  • I then identify and mask secondary objects from each different surface marker.
  • I would then filter each mask for positivity of that given marker to create a subset of the mask. (For example, I would mask secondary objects based on marker A and then filter out only the cells positive for marker A, giving a “sub-mask” of only cell type A).
  • Finally, I merge these different submasks in a different software – haven’t figured out how to do this within CellProfiler yet. (If it can be done in CellProfiler, please let me know!)

While this method seemed promising, I have run into a lot of issues with faithful segmentation since the different cell types are in close proximity to one another. For example, when I identify secondary objects using marker A, the program is not “aware” of any other membrane markers (say, marker B). Therefore, when identifying these secondary objects, it may extend the membrane to include a region with marker B, and I will now get a false double-positive cell.

Please let me know if there is a good method to get faithful segmentation and masking of differing cell types with different markers that are in close proximity within a tissue.

Thanks for your help!


Hi Zavi,

If I understood your question correctly you have different type of tissue cells and each type has a specific marker and you want to identify them and measure its properties. I suggest you first identify nuclei + cells following thresholding of different markers. Use Mask Objects module to mask cells if they are positive or negative for given marker in the thresholded image. for e.g if the cells positive for marker A. Then you take all remaining cells negative for marker A and mask with thresholded marker B and so on. You can collect the information of each cell types their counts and properties. Let me know if this help?


Hi Habbasi,

That is similar to what we have been doing, but I am somewhat unsure of how to do this effectively without having overlap between the masks with the “double-positive” cells.

Because cells are defined by different membrane markers and shapes, I use the Identify Secondary Objects module multiple different times on each of the different markers. For example, I identify my nuclei using Identify Primary Objects, and then I would have two separate Secondary Object images, one based on marker A and one based on marker B. Next, I filter each set of secondary objects based on presence of the appropriate marker. However, the issue is that the secondary objects based on marker A are not “aware” of the existence of marker B, so it may extend some membranes to include an area with marker B in it, or vice versa, giving a double positive cell when I do analysis. Does this make sense?

I noticed you mentioned that I could take all the remaining cells negative for marker A and mask with thresholded marker B. What is the best way to do this (i.e. take all remaining cells negative for marker A)?

As another idea, is there a way to filter out nuclei (i.e. primary objects) that are already used by the filtered set of objects positive for marker A, and then only use the remaining nuclei for any subsequent masks?

Again, thank you for your help, and let me know if any of this is unclear.



Hi Zach,

A better solution might be to sum all your non-DAPI markers in ImageMath, use IdentifySecondaryObjects once and only once on the total image to better define ALL cells simultaneously (making it impossible to have overlaps), then using Threshold + MaskObjects or MeasureObjectIntensity+FilterObjects to filter into your MarkerA positive, Marker B positive, etc. Does that make sense?


Thank you. We have tried summing all our membrane markers into one for the secondary objects. The main issue is that the cells of different type are very closely associated with one another. See image below for a rough drawing of how this may be an issue when all the membrane markers are summed together, as the borders drawn become somewhat random and can include multiple cell types.