Counting cells by colour

Hi, I am new to CellProfiler and I would like to use it to count sperm cells that are darkly stained with hematoxylin. The problem is that there are other (lightly stained) cells around the sperm cells that I would like to exclude. I have tried the Unmixcolors module, but it picks up all the cells. Is there a way that I can select the colour and use that to identify the cells I want counted?

I’ve attached one of my images. Thank you for any assistance you can give.


Brightfield/histological images are notoriously tough to segment, at least relative to fluorescent images. UnMixColors with Hematoxylin setting seems to work ok for my untrained eye. Please note that the output of this module is simply a grayscale image that you then subsequently are expected to segment using IdentifyPrimaryObjects to actually do the counting.

Does the attached pipeline come close? You can adjust the parameters in IdentifyPrimaryObjects to improve the segmentation. Note especially the Threshold Correction factor, and possibly the “declumping” settings toward the bottom, choosing your own declumping scales.

PIPE_DLogan.cp (3.57 KB)

[quote]Is there a way that I can select the colour and use that to identify the cells I want counted?

I forgot to say that you can choose a Custom Stain in UnMixColors, and then either choose the RGB absorbances yourself (hard) or use the “Estimate” button and input your Hema stain (easy). It is not easy to choose a single color mix for a single stain, since depending on illumination, exact staining technique, condition of the sample, etc., the ratios of the RGB absorbances can vary from sample to (otherwise similarly stained) sample.


Thanks, that works well with some of my images but not for the ones that are really crowded by sperm cells. I have tried adjusting a lower threshold correction factor and changing methods to distinguish clumped object, but I can’t make it work. I’m not sure which threshold method is best to use.

Attached is one of my more crowded images.

I agree, these bright field images are quite hard to generalize the CP settings for. I tried and have these suggestions (see the attached pipeline):
(1) Try a new version of CP, the 2.0 version (NOT 2.1) which we call “2_0_Bugfix”:
I am suggesting this upgrade because I had better results with the MCT thresholding method in IdentifyPrimaryObjects and it is only available in newer version than the release. You can keep your old installation as a backup and save this one along side it. Just make sure that you indicate the version number when you save pipelines with the new version, because they are forward- but not backward-compatible.
(2) The main pipeline is still the three modules (LoadImages, UnixColors, and IDPrimObjs) however I added a few modules in various attempts at pre-processing the images. They were not that substantially more successful than the simple pipeline but you can see what my thought process was.
(3) IdentifyPrimaryObjects:
(3a) Now uses MCT Global.
(3b) Distinguish clumped objects with “Shape” method, and as well, uses the Shape method to “draw dividing lines”.
(3c) Manually set the “Suppress local maxima” distance to 13. Increasing this from the auto distance which was smaller seems to help.

(4) There are still spurious objects identified. I also added a sample MeasureObjectSizeShape and FilterObjects module to show you how you might filter out some of these objects, depending on what measure you think would best exclude “bad” objects.

** However my preferred solution to improve segmentation is to add a fluorescent marker! Nuclear markers are nice since they tend to not overlap (e.g. DAPI). Once you have a decent segmentation, you can use other measures to distinguish sperm cells from other objects. Of course you need a fluorescence scope, markers, etc, so I understand if you cannot or prefer not to.

Good luck,
PIPE_DLogan3_CP_2_0_Bugfix.cp (7.06 KB)