Cell Counter for CellProfiler

Hello everyone,

I have put together a pipeline that counts cells in an image and counts the number of green fluorescent punctae as well. I am currently having issues getting CellProfiler to accurately count the number of cells in each image. I first use the “EnhanceorSuppressFeatures” before I apply the “IdentifyPrimaryObjects” and where it says “feature size” I entered 150 (my largest cell is roughly about 150 pixels in diameter). I have used 80 in the past and that seemed to have worked a little bit better however the “?” help button does say “enter the diameter of the largest speckle” so I’m a little bit confused on how I could optimize this value.

CellCounter.cpproj (79.6 KB)

These are the Images I am analyzing
20210122_FITC_07.tif (8.0 MB) 20210122_FITC_08.tif (8.0 MB)

Please let me know if you think I should be using a different thresholding method. I thought Robust would work better but Imnot sure if it’s the best one for counting cells. Thank you so much in advance!

This is what I currently get, There should about 44 cells in this image. Thank you

Hi @namaya13,

Regarding your cell segmentation, I would recommend the following:

  • Rather than performing an enhancement prior to detecting your cells, I think you can get quite a good segmentation using the original image. To simplify things, I would switch your input image for IdentifyPrimaryObjects to the original image
  • RobustBackground is probably not the best thresholding option for your images, since it works best on very sparsely dispersed bright objects against a mostly dark background (like your speckles). I tried out Otsu two-class thresholding w/ the option to log transform prior to thresholding and it worked well
  • The borders between your cells are distinguished mostly by intensity dropping at the edges, so I would switch to the “Intensity” method for distinguishing clumped objects and drawing dividing lines between clumped objects
  • Finally, I found that switching to an object size of 60 - 300 reduced the amount of oversegmentation (splitting of one cell into two cells)

Example results:

Ways to troubleshoot:

  • If you think the edges of the cells don’t accurately distinguish between foreground / background, you can try out Otsu 3-class thresholding, turning off the log transform prior to thresholding, or the MCE thresholding method
  • Alternatively, you can add a correction factor to your threshold. For example, if you think that too much background is included at the edge of your cells, see what happens if you change the correction factor (try out several options: 1.1, 1.5, 0.5, 0.9. In doing so, you’ll get a sense of how that affects your segmentation).

I think your speckle detection part of your pipeline looks reasonable. Let us know if you have more questions related to that!

Best,
Pearl

1 Like

Hi Pearl,

Thank you so much, this is very helpful! With respect to my punctae count, I am enhancing the images and using a feature size of 8 pixels. Is this, in your opinion, the best way to quantify these fluorescent punctae/particles? I am currently running an analysis on about 230 images with varying punctae count and I feel like it may under count the total number of punctae in each image. For example for image 20210122_FITC_07.tif it says there is 51 punctae;however, it can be seen that there is way more than 51 punctae in that particular image. Do you have any suggestions on how to optimize this part of my pipeline? Thank you so much in advance!

@namaya13 to evaluate the speckles, here’s what I would look at:

  • your speckle enhancement using EnhanceOrSuppressFeatures. If you compare the original image to the enhanced image, are the right features being enhanced? Are all speckles brightened? Your current settings of Speckle Feature size of 8 look reasonable to me, but you may want to adjust this to see if you prefer the results
  • Next I’d evaluate your thresholding. Are small speckles missed? You may need to lower your size cutoff range (try 3-8 or even 2-8). Are some speckles detected but their borders are wrong? You may need to change your thresholding by adjusting the # of deviations that are added to your average to compute the threshold (try 1 for less stringency or 3 for more stringency).
  • In general, for this type of image (bright spots on dark background), I think you’ve already selected the best method for thresholding (RobustBackground)

By my eye, I thought that dropping your size threshold to 2-8 pixels improved the speckle detection, but you know better than I do what should be considered a speckle. Good luck!

1 Like

Pearl,

Great! Thank you so much for your time!

Hi Pearl,

I have a question, I am currently analyzing 230 images and noticed that the otsu thresholding method worked very well for some of the images but not all. I’d possibly like to analyze all of my images using the same thresholding method. What do you think would be best to account for the variability from image to image? Thank you

Hi @namaya13,

The problem you’ve described is very common and a challenge for most imaging sets. A great resource for thinking about optimizing image analysis workflows is this article: When To Say ‘Good Enough’ | Carpenter Lab

Here are a couple thoughts regarding thresholding errors and how I would approach the threshold method working well for some images but not others:

  • Inspect images where the thresholding method works well. What intensity value is selected as the threshold? Similarly, for images where the thresholding isn’t working well, what intensity value is selected? Is it too low or too high?
  • Ultimately, your goal is to try to identify why the thresholding method is failing. These methods are trying to separate the pixels in your image into foreground vs background based on the distribution of intensity values for your entire image (often visualized with a histogram; for any image in CellProfiler, right-click on the image and select “Show image histogram” to view the distribution of pixel intensities for that image:

Here is the pixel intensity histogram from the CellProfiler example pipeline for the OrigBlue image on the left

.

  • The images where the method is not performing well must have a different shape to the distribution of intensity values. Once you’ve identified how your images that don’t perform well are different, then you might be able to add a manipulation to help correct for that (such as an EnhanceOrSuppressFeatures module or reducing background using CorrectIlluminationCalculate and CorrectIlluminationApply).

Here is an excellent resource to understand thresholding and object detection (start at minute ~ 16:30):

I hope these ideas help. Good luck!

1 Like

I will look at these resources! Thank you so much again!