Measuring Nuclei Neighbours


I am working on a pipeline to analyze the spatial distribution of nuclei and astrocytes in cryosections. I would like to use MeasureObjectNeighbors to identify the number of astrocytes (and their coordinates) within a radius of each nuclei. Based on the output of the module, I am not sure if there is a way to get these results - specifically, the coordinates of each neighbour or the object number of each neighbour. Suggestions? Maybe there is a better module to use? I’m using the latest version of Cell Profiler.

Hi @Samir_Gouin,

Unfortunately there is not a way right now for MeasureObjectNeighbors to export more than the closest two neighbors for any given objects. I’ve created a feature request to the CellProfiler GitHub to add this option: Allow MeasureObjectNeighbors to export the ObjectNumbers of the closest n neighbors · Issue #4334 · CellProfiler/CellProfiler · GitHub

In the meantime, I think that an alternative approach that may work in your case would be as follows:

  • Use ExpandOrShrinkObjects to expand your nuclei by the radius that you’re interested in
  • Followed by RelateObjects to relate the astrocytes to the expanded nuclei. You can measure distances between these objects (if you use minimum distance btwn the two objects, keep in mind that you should adjust the distance by the radius that you expanded your nuclei)
  • When you export your data, your astrocytes table should have a column with the Parent_ExpandedNuclei Object Number, if it is within the radius of that nucleus. You’ll then also have the x, y coordinate of the astrocyte and the distance to the nucleus

I hope that helps! Good luck!

A caveat w/ the approach I just provided: the RelateObjects module will only allow a “child” object to have one parent, so you will only find out the closest expanded nucleus for a given astrocyte. If one astrocyte is within the radius of two nuclei, you will only get the identity of the closest nucleus to that astrocyte. Depending on the ratio of nuclei to astrocytes and your goals in measuring the neighbors, this approach may or may not work for you.

Hi Pearl,

Thanks for the detailed response and adding the request. I’ll try that approach and compare the results with MeasureObjectNeighbors

Hi Pearl,
Was just wondering if it would be possible to include the coordinates of the parent nuclei in the astrocyte file instead of just the object number? This way I could avoid having to search for the object numbers in the nuclei file to add the coordinates.

Hi @Samir_Gouin,

I don’t know of a way to get CellProfiler to combine these data into a single spreadsheet for export. However, you should be able to join the two tables using a merge operation on the nuclei ObjectNumber (the Parent_ExpandedNuclei_ObjectNumber in your astrocyte table matches with the ObjectNumber in your ExpandedNuclei table). You can search the internet for “merging data tables” and whatever software you’re using to analyze your data (Excel, Prism, R, Python, etc.) and you should be able to find resources for how to combine data from two different sources.

Hope this helps!

1 Like