Counting and Tracking Cells in a tight Z-Stack

Hi! I am looking for some advice on pipeline selection/execution for a z-stack of neurons that are tightly packed. I want a count of the number of neurons in a stack of 15-20 steps. I have multiple channels for my z-stack including one for nuclei (DAPI) and one for neurons.

I am attaching a pipeline I have been using but it has been giving me imprecise numbers of objects. I also have a link to an example .oib that I work with.

NeuN_TestProject.cpproj (1.4 MB)


Can you explain a bit more what you mean by an “imprecise number of objects”? And are you looking at the TrackObjectLabel (which is the object number after the tracking) or the ObjectNumber when you are determining your count?

Hi! What I mean is when I look at the outline being tracked, it isn’t really dividing the cell bodies into what by eye I would consider the cells’ boundaries (ie sometimes there is a divide where there shouldn’t be one and sometimes it groups multiple cells into one object). This is to the point where I believe I am getting significant under or over estimation.

I have been looking at the Object Number when counting

Where cell boundaries are drawn is going to be largely a function of where the nuclei are segmented in IDPrimary, since those provide the seeds for cellular segmentation. I think you could stand to make changes in several of the settings there- 5-20 doesn’t seem to be the right window for picking up your nuclei (see below, pink= things that are being thrown out for being the wrong size). Try something like 10-40 and playing with your declumping settings (a smoothing filter of 10 looked pretty nice to me).

Once your IDPrimary settings are reasonable, you can use small tweaks in IDSecondary (I got much better segmentation switching to a global rather than a per-object IDSecondary in my hands) to get the exact cell boundaries, but the total number of cells is going to be based on the number of nuclei found at the beginning.

Finally, my standard CP caveat- when you’re doing automated segmentation, you are going to always have to trade a small amount of your accuracy for speed and the ability to do measurements. I think you can make a few quick tweaks to vastly improve the accuracy in this case, but it’s impossible to get 100% accuracy on 100% of the images.

Thanks for the tips! I will give this a try right away. I have one other question, and that is my main goal is to count my NeuN stain, which I currently have for a secondary object. Should I change my settings so that CellProfiler is counting the NeuN objects as primary objects?

If your question is “would just segmenting NeuN be more accurate”, we generally find that using nuclei as the seed and then segmenting cell bodies is more accurate overall, but your nuclei and cell bodies here are so close together you may not find much difference between trying to use IDPrimary on nuclei vs on your NeuN objects. You’d have to play around with it.

If your question is “is there a difference in how CellProfiler treats Primary vs Secondary objects”, outside of one or two rare cases where there’s a bug they should be 100% identical.

Hello! I wanted to ask a further question about the spreadsheet interpretation for this pipeline. I have made the alterations above and have used it to try to track objects through a stack (in an effort to track the same objects through a 3D space rather than time). In this pipeline, I use “overlap” as my TrackObjects setting.

My question, however, is how to interpret the count output from these tracked objects in the spreadsheet (In this case, I generated an Image spreadsheet). That is, for every group of images (where an image is a step in the z-shack, and the group is the image file) how can I interpret the “Count” output in the spreadsheet? Is the highest number seen the total number of objects tracked in the group (or the total number of cells in the image file), or should I add all of the numbers in the group together to get the total number of cells in the image file? I am attaching a sample excel file to better illustrate my question. NeuN_Count_DNxVehImage.csv (275.0 KB)


How can I interpret the “Count” output in the spreadsheet?

The count listed in each image is the number of objects detected in that single plane, irresepective of how they’re going to be stitched later in TrackObjects

Is the highest number seen the total number of objects tracked in the group (or the total number of cells in the image file), or should I add all of the numbers in the group together to get the total number of cells in the image file?

This gets a bit complicated, and depends on the details of what your images look like (do you have a single layer of cells, or many layers on top of each other?). If it’s a single layer, and you know for sure that the middle plane (or whatever plane has the highest number of identified cells) has every single cell represented, you could take the highest value of ‘Count’ across the planes and use that as the surrogate for your count for that image set. Alternately, if you go to the Object spreadsheet, you could look at the highest value of TrackObjects_Label for each image set- that will be the maximum number of objects found after stitching everything back together. If you have multiple layers of cells, that’s likely to be the more reliable number.

My recommendation is to take a handful of images, count them manually, then compare both of those approaches to see if one or the other is consistently accurate for your purposes.

Thank you for the explanation - this helps clarify the file a little more. I was making a few comparisons in columns and wanted to verify something I noticed, which hopefully will help future readers as well. My Object spreadsheet is very large (each image is a z-stack of up to 15 stacks with 20 images, and I essentially have a 49,000 row excel file) and so looking through the TrackObjects_Label for the highest number is a bit confusing and I am likely to make an error. However, I noticed in the Image spreadsheet that summing the 15 rows under ‘TrackObjects_NewObjectCount’ representing one of my image is what I found to be equal to the highest value in the TrackObjects_Label for that image. Would that make sense then to get the total objects and thus the total cell count?

Again, thank you for all of your help so far!

1 Like

I hadn’t thought of that, but of course you’re correct- the sum of all the ‘NewObjects’ created for the image would be the number of objects in the image :smile: . Sorry I didn’t think of that sooner!

1 Like

Great! I just wanted to check that they corresponded. Glad there are multiple ways to find the info, of course!