Problem with RelateObjects?


I’ve noticed occasional strange behavior of RelateObjects, where the Child Objects are occasionally assigned to the wrong Parent Object. It doesn’t happen all the time, but often enough to wonder what is going on.

Attached are two images of the output from RelateObjects, one that exhibits the behavior that I’d expect, and one that seems just plain wrong. In the one that behaves correctly, each Golgi is appropriately assigned to the Cell that it is contained within. In the example that seems wrong, the yellow Cell contains the red Golgi, etc.

I’ve also attached the CP pipeline that generated the Bad outcome (and many Good outcomes as well), and an example set of images that generated the Bad outcome.

Have I done something wrong? Or might you be able to fix it?

Any help you can provide would be greatly appreciated.


p.s., I’m using CellProfiler 2.0 r11710 on MacOSX 10.6.8, 64 bit with 12GB RAM, in case that matters (2.61 MB)
MX GFP Streamlined Golgi not so good.cp (19.3 KB)

Hi Seth,

What you are observing is a problem in the display of the results, rather than the results themselves. In the attached images, the object number of the cells and the parent number of the golgi are shown. These values should be the same, and color-coded accordingly in the module figure window for RelateObjects. As you can see, the former is true even though the latter is not, as you noticed.

This display issue is a bug that seems to occur when the secondary objects touching the image edge are discarded, so it will be fixed for the next release.



Hi Mark,

I think there may still be a problem with RelateObjects, or maybe I’m doing something wrong.

I’ve noticed that in the spreadsheet that is written out, that sometimes the Golgi is associated with the wrong cell. However, the output from DisplayDataOnImage (showing the Golgi’s Parent cell) does not agree with the output to the spreadsheet (indicating the Golgi’s parent cell). The associated measurements within the spreadsheet definitely indicate that the Golgi is associated with the wrong cell.

I’ve attached an example.

In the Image, for each cell the Cytoplasm is outlined in white, the Golgi (red) is outlined in yellow. Also, for each cell (“FilteredCell”) the object number is shown in yellow, the parent of the Golgi is shown in white, and the parent of the nucleus is shown in red. In the image, everything appears to be correct.

However, in the data that is exported to the spreadsheet, many of the FilteredCells are associated with the wrong Golgi (but the correct nucleus). For example for FilteredCell #13 the Golgi contained within has a parent FilteredCell of 12. Likewise for FilteredCell #14, the Golgi contained within has a parent FilteredCell of 13. The measured Golgi areas also are switched.

Attached is the input data file, the pipeline used to generate the data, and the output CVS file that shows that problem.

I guess I see that my use of CalculateMath to force the child Golgi measurements into the parent cell spreadsheet is probably the source of the problem. Is there another way to have all of the measurements for each cell end up in the same spreadsheet (since there is one Golgi and one nucleus per cell, it would be great to have the measurements show up together for each cell)?

If there is a better way to deal with it, I’d appreciate any suggestions.


CP 2.0 r11710, Mac OSX 10.6.8
DefaultOUT_FilteredCells.csv (1.76 KB)
SJF Golgi calcs relate problem.cp (31.5 KB)
images (2.11 MB)

1 Like


I think I see that the issue is. You seem to be assuming that the Object_Numbers for all 3 objects in question (FIlteredGolgi, FilteredCells, and FilteredFilteredNuclei) should all match because the Golgi have been unified by Cell and related back to the FIlteredCells; a similar thought process applies to the FilteredFilteredNuclei. In fact, this is not the case, and does not need to be the case.

The way to see this is to plot FilteredGolgi_Number_ObjectNumber, instead of FilteredCells_Number_ObjectNumber. In that case, you will see that they no longer match your picture, but they do match what is in the FilteredGolgi spreadsheet (had you exported it). Since the FilteredGolgi and FilteredCells ordering is not guaranteed to match, using CalculateMath to add them and write the result to the spreadsheet will not work.

The reason for this is that the object number is assigned strictly by the (x,y) centroid location of the object, from top to bottom. The cells and the nuclei centroids are close enough in proximity such that the numbering is the same. The same cannot be said for the Golgi, however, since theire locations are substantially different with respect to each other.


Hi Mark -

I’m having the same problem here, and completely understand how CellProfiler deals with numbering the objects. I’ve kicking myself in the head thinking that I might have done something wrong for 2 days - until I found this post. Perhaps some kind of a new feature/module (or an updated version of ‘Relate Objects’) might be very useful to many of us where we are trying to relate a lot of objects together… especially when those objects are not originally identified in a conventional way - like FilteredGolgi and FilteredCells.

Thank you,

Perhaps some kind of a new feature/module (or an updated version of ‘Relate Objects’) might be very useful to many of us where we are trying to relate a lot of objects together… especially when those objects are not originally identified in a conventional way - like FilteredGolgi and FilteredCells.

I’m not totally sure I understand what you’re asking for- the ability to change the numbering of the objects so that they all match a given parent object that they’ve been related to? It’s theoretically possible I suppose, but it’d only be applicable when you’d only expect either zero or one child object, otherwise you could potentially give multiple children the same ObjectNumber (and that would break a lot of things). Or am I not correctly understanding your request?

Pearl, does the module Reassign Object Numbers help you?

1 Like

Hi -

Yes, I would like to relate multiple children to the same parents… and I think RelateObjects is supposed to do that. But occasionally we identify parent objects in many different ways; for my case, I identify nuclei from DNA images, and I have my own masks for the cell boundary which I drawned manually and imported into cell profiler… so those 2 objects have undergone filtering and relating… and for some reason when I would like to relate another structure that I also manually identifed and imported into cellprofiler, the relateObject didn’t do it correctly similar to what the previous person mentioned. I am just wondering if there’s a way to renumber all those children object accordingly.

Hi Anne -

Yes, actually the reassign object number helps with the re-numbering (I just tried that), but I’m afraid I lose the ability to calculate ‘per-parent means for all child measurements’ and ‘child-parent distance’ between the correct children and their parents. Is there a way to do so afterward?

Thank you,

You could relate the reassigned objects again to the parents; your workflow would be something like this

Identify[Primary,Secondary,Tertiary]Objects -> Parent
IdentifyObjects -> PrelimChild
RelateObjects-> PrelimChild to Parent
ReassignObjectNumber -> Turn PrelimChild into Child
Measure[Shape,Intensity] ->Child
RelateObjects ->Child to Parent

1 Like