Density counting of neurons

I’ve just started using ilastik instead of ImageJ/CellProfiler to count neurons and have so far been pretty impressed! My current workflow is to use pixel classification then object classification but I’m having trouble segmenting clumps of neurons into individual objects (even when using the Hysteresis threshold option). I recently looked into the cell density option (instead of pixel/object classification) and I think this would work well for my purposes. For the next step in my analysis, I need the x and y coordinates of counted objects, is this something that can be determined from the density maps in Python? I have a lot of experience in R but very limited experience in Python. I have hundreds of huge images so I don’t necessarily want to draw a box the size of each of image and export one by one from the GUI. Thanks for your help!
Julie S.
Image 1: Example image with pixel classification prediction map
Image 2: Example image with object classification (large clumps where neurons overlap/are crowded and missing some cells that have a lower threshold than specified but the lower threshold to include those introduce too much noise in the rest of the image)
Image 3: Binary image with object classification

Dear Julie,

Could you upload an image file so we can have a go, please?



Please see attached (embedded?). troubleshooting.tif (4.7 MB) Thanks for your help.

Hi @sadinoj,

welcome to the community!

That’s quite the challenging data. I can totally see how you end up with lot’s of cells crammed into a single object.

The cell density counting workflow works under the assumption that cells are round and partly overlapping. In order to come up with actual locations you’d have to basically do the same as in object classification (come up with some sort threshold…). So I basically think that you’d end up at the exact same conundrum. :confused:

Maybe there is a good #startist network that could do the job.

If you wouldn’t have to localize the nuclei I would say that you can even get some good counts with object classification by adding the appropriate classes for 2, 3, 4, 5, 6… object clusters to identify those. If size of your cells is fairly constant you could also estimate it by counting object pixels and dividing by this size.

Thanks for the quick response. Yes, this data is certainly challenging to analyze in a high throughput, automated way. To clarify your final suggestion, for clumps of neurons one possible way to at least get counts (but not x/y) would be to add label classes at the “Object Classification” stag for 2, 3, 4, n clumps of neurons then divide that pixel area by an average cell size? Luckily the neurons seem to be pretty uniform in size so that could be possible. I’ll have to try that out and see if there’s maybe a consistent factor of underestimating clumped cells, thanks for the suggestion.

Hi @sadinoj,

I’d suggest to do either or. So either you use object classification to only get rid of background objects vs foreground objects, and then go by approximate size to determine the number of neurons per “object”, or you train those additional classes and multiply the numbers in the result table accordingly to get the counts.