Label Image To RoiManager

Dear community,

While using CellProfiler (3.1.9) to analyze images with numerous cells, I stumbled on a label issue!

I need to continue the processing in FIJI, and thus I thought I will re-use @NicoKiaru’s code
But the CellProfiler’s output has multiple objects with the same label value (@CellProfilerTeam can something be done about it ?) thus I thought to use the particles analyzer to get different ROIs.

This script does the job, but the way we get rid of the “0” label (with RGB image) is a bit hacky/dummy and I was hoping for your help to come up with something better !

Here is a macro snippet to get a label image from blob


// macro to generate an image with labels

run("Blobs (25K)");

setAutoThreshold("Default");

setOption("BlackBackground", true);

run("Convert to Mask");

run("Analyze Particles...", " show=[Count Masks] exclude ");

You can download Here is a larger image from CellProfiler corresponding to the preview below.

Thank you in advance for your inputs,

Romain

1 Like

Hello! That is odd… Could you elaborate on what makes you think that CellProfiler produces multiple objects with the same label value?

I wonder if you are attempting to analyze one of the visual outputs of CellProfiler (meant for display) rather than the true label matrix of CellProfiler?

Hi @AnneCarpenter,

Thank you for your quick reply!

I use the module ConvertObjectsToImage(using my cell Objects, and I tried Color, uint16 and Grayscale) and then the module SaveImages. Is there an alternative way?

Yeah, I had this exact problem a while back where basically I wanted to output just count mask of all the objects and couldn’t work it out.

Eagerly awaiting a solution!

1 Like

Hi @romainGuiet,

To my understanding the uint16 mode of ConvertObjectsToImage should produce what you’re looking for. Provided you set the SaveImages tif bit depth to ‘16-bit integer’ you should get a greyscale image rather than the colour one you posted above, with individual labels for each object.

If you’ve tried this would you mind uploading the result?

Thanks

Yeah, I think this is the solution. I did a deep dive through my notes and this does seem to be what I found out eventually (but apparently forgot in the meantime!).

Here's the original image in what I think is the desired output test_Image.tiff (12.9 MB)

Hi @DStirling,

thank you for your suggestion!

That’s what I hoped but when selecting this option, and opening it in FIJI ( and photoshop :nauseated_face:), I only get an 8bit image with all pixel values at 0.
I thought that I might have more than 65535 objects ( the original image is much larger), so I tried with a smaller image ) and still get a zeros-only image.

Best,

Romain

Hi @romainGuiet,

Would you be able to send over a copy of the pipeline you’re using, perhaps with the actual output image that you obtained? It seems to work just fine in my hands.

Thanks

Hi @DStirling,

Please find here a gDrive folder, with the cproj and some input and output images.

Thank you for your help with this David,

Best,

Romain

Hi @romainGuiet,

In your SaveImages modules, you need to set the ‘Image Bit Depth’ to ‘16-bit integer’ in order to export uint16 images correctly. That seems to get it working on my end.

Note that these will appear black in most photo editors, but the data is present when opened in ImageJ.

Hope that helps!

2 Likes

If this is indeed the solution, does anybody have ideas on what we could do to make it more easy for people to figure out? Where in the documentation would you expect to find a description of how to do this?

1 Like

The best place might be a note in module help for ConvertObjectsToImage, since saving as 8-bit isn’t strictly wrong. I assume that SaveImages tries to scale down the 16-bit range to 8-bit. Typically segmentation labels don’t use the full range, so this placed all the labels in the 0-1 range and they got lost in this instance.

1 Like