Nuclei Counting using Grids in CellProfiler

CellCount.tif (2.8 MB) CellCount.cppipe (8.9 KB) ### Sample image and/or code

Hello all. I have attached a pipeline where the goal is to quantify the number of nuclei within individual grid squares.

The attached image is of a mouse spinal cord with the nuclei stained. The basic pipeline I have written crops this image to a region I am interested in and then superimposes a grid on this image.

What I an having trouble with is identifying the primary objects correctly since they are of different intensities and also how to set up the export function so that I get the number of nuclei within each grid.

All help or input appreciated. Thanks in advance.

Hi @Iwan,

For your question regarding counting objects within a grid using DefineGrid and IdentifyObjectsInGrid, a few thoughts:

  • The “Natural Shape and Location” setting that you selected in your example pipeline will combine all of the objects within a grid square into one new object that has the shape of the combined objects. For example, compare these two overlays. The left shows multiple nuclei detected and the right shows how those nuclei have been combined into two different objects.
    CellCount_Overlay_Nuclei crop CellCount_Overlay_GridNuclei crop

  • You can then use the RelateObjects module to relate parent objects (the output of IdentifyObjectsInGrid) to child objects (the output of your IdentifyPrimaryObjects module). The ExportToSpreadsheet module will then export a Children_Nuclei_Count column that represents the number of nuclei that overlap with the combined object you created within each grid square

  • Note that any objects whose centers are close to the edge of the grid rectangle are excluded from new object created by IdentifyObjectsInGrid.
    – For this reason, your count will represent only nuclei that are fully contained within a grid square.
    – If you’d rather count any object that overlaps with a grid rectangle, you can instead select the “Rectangle Forced Location” option under “Select object shapes and locations”. This setting will create rectangular objects dictated solely by the grid parameters. If you go this route, nuclei that overlap with multiple grid rectangles will be counted in the rectangle where they have the most overlap.

Regarding identifying the primary objects correctly:

  • One thing I noticed when running your pipeline is that the crop area affects the thresholding and thus the identification of primary objects. You may consider running an initial pipeline to make and save your image crops that you then analyze in a second pipeline.
  • You may find it helpful to set “Automatically calculate minimum allowed distance between local maxima” to the average size of a small nucleus if you’re finding a lot of oversegmentation of nuclei
  • Changing the “Fill holes in identified objects?” setting is often useful
  • Keep in mind the the IdentifyPrimaryObjects is looking for objects with high intensity centers and low intensity edges. You can use additional pre-processing steps like background subtraction and filtering to help make the objects in your images fit this description. If that doesn’t work, then using pixel-based classification with https://www.ilastik.org/ followed by primary object identification in CellProfiler may work. We have a tutorial on our GitHub page and a video tutorial on the Center for Open Bioimage Analysis YouTube page.

Hope this helps!
Pearl

1 Like

Hello @pearl-ryder,

Many thanks for the reply and the input. I will give these suggestions a try and see how it works out.

Thanks also for the link to the ilastik website. I didn’t know about this before.

Iwan.