Ability to combine objects identified at different times



Hi all,
In talking to my labmates who want to do “semi-high throughput” analysis (ie maybe 100 images- enough that they’d like computational aid but not so many that they can’t sit there and oversee the output), one of their biggest complaints/barriers to hopping on the CellProfiler bandwagon has been that if, for example, Identify Primary Objects cuts a cell in half, they have to throw that object out and lose the data from it. Ideally, what they’d like would be something along the lines of

Identify Primary Objects- let the computer try to initially identify, say, nuclei
Edit Objects Manually- throw out the misidentified nuclei
OverlayOutlines- show the outlines of the edited nuclei on the original image
Identify Objects Manually- show the image with the overlaid outlines and then go through and circle/outline the nuclei you want to add

Ideally, these manually identified nuclei could then be combined with those from EditObjectsManually into a single class for use in whatever downstream steps (IdentifySecondaryObjects, etc).
Is there a way to do this? Thanks as always!


[quote=“bcimini”]Ideally, these manually identified nuclei could then be combined with those from EditObjectsManually into a single class for use in whatever downstream steps (IdentifySecondaryObjects, etc).
Is there a way to do this?[/quote]

Currently, there is no way to combine object sets in a straightforward manner. However, a workaround is the following:

  • Use ConvertObjectsToImage to convert the objects to a grayscale image. Do this for both the manually identified and edited object sets
  • Add these two images using ImageMath to combine the objects.
  • Re-identify the combined object image using IdentifyPrimaryObjects with manual thresholding, the threshold set to 0 (or a suitably small number), declumping using Intensity, no size exclusion nor hole filing, and the smoothing filter size set to 0 and the maxima suppression distance set to 2.

Note that this approach would only work if you can guarantee that the edited and manually identified objects are non-overlapping.



Thanks so much- I’m trying to implement this now but I’m having a problem where if, for example, the program identifies all the nuclei perfectly so the IdentifyObjectsManually image output is all black (but the EditObjectsManually image is not), the outcome after ImageMath is an all black image! Is there something obvious I’m missing? I can make sure to always put a little dot or something in the IdentifyObjectsManually image but it seems like I shouldn’t have to…


This is caused if there are no objects, so that the image returned by ConvertObjectsToImage contains all undefined values; adding this value to another image in ImageMath also returns an image of undefined values.

This is definitely a bug and will be fixed, but for now a workaround is to do the following:

  • In ConvertObjectstoImage, convert to uint16 rather than grayscale. This makes the image into a 16-bit image.
  • In ImageMath, uncheck the “Set values greater than 1…” setting.
  • Add RescaleIntensity, use the ImageMath image as input and use the default “Stretch each image…” as the rescaling method. This scales the image back to between 0 and 1.

The output of the RescaleIntensity module can be used as input into IdentifyPrimaryObjects.



Awesome, thanks so much- 2 other things I wanted to bring up

  1. Don’t know if there’s currently a plan in the works to address this, but EditObjectsManually just returns an error message if there aren’t any objects found by IdentifyPrimaryObjects- would it be possible to set it to just bypass that module instead?
  2. Any chance that in a future release it would be possible to have this all automatically happen in the background, say like adding a setting in IdentifyObjectsManually for ‘Add objects to a previously identified class?’, then a dropdown of current object classes if chosen?
    As always, appreciate the great/timely help!


Alright, while I’m just wishing for things like it’s Christmas or something… a brightness/intensity slider for EditObjectsManually and IdentifyObjectsManually images?


That’s certainly a bug. The fix will be included in the next release. Unfortunately, we can’t just skip the module but at least it won’t error.


Christmas is coming…https://github.com/CellProfiler/CellProfiler/pull/2151


Sorry for reviving old threads, but I’m one of those users who would have liked the ability to combine objects referenced in the following threads: (thread1, thread2, thread3.

Like others I found that re-identifying objects from a grayscale using identifyPrimaryObjects didn’t work. While it has been decided that this issue is no longer a priority I’ve noticed that in CP3.1.4 there is now a solution with a new module:

  1. convert 2 object classes to grayscale
  2. add them together then divide by 2
  3. use the new ConvertImageToObjects module to solve the issue that the IdentifyPrimaryObjects was having.

Thank you developers for adding that module!