Exporting H and E stained cells as colored objects instead of grayscale objects

I am trying to work a pipeline used for identifying blood smear cells to identifying and classifying immune cells from BALF fluid. I would ideally like for the cell images to be in color since the color of cell staining can be an important distinguished between otherwise similar looking cells- the first picture is what I’d like it to look like only with H and E staining instead of fluorescence. However because I’m using identifyprimaryobject and identifysecondaryobject to identify the cells they are exporting them as black and white images- see second picture. I’ve tried a number of ways to try and get around this such as using split greyscale instead of combined greyscale, running the identify modules on one channel, converting the objects into images and using greytocolorscale and finally converting them back to objects, but I get an error that there were too many objects for object to image to work. Would anyone have any other ideas?

You should be able to choose the display colour for each stain, either in the .properties file before opening CPA, or by using the menus at the top of the screen when running the classifier.

If you still have trouble, it might help if you could upload a copy of the properties file.

Thanks so much for responding (I uploaded the properties file here)- I changed the color channels in the properties file to red, green, blue instead of grey but this time the images show up as just red. It seems like it would want one color per channel but I’m not sure how to specify each channel.DefaultDB_MyExpt.properties (6.9 KB)

Hi @momonotmorg,

Your properties file only has one image that it’s looking for (lines 51 and 52):

image_path_cols = Image_PathName_DNA
image_file_cols = Image_FileName_DNA

That is why your image now appears red. As the comment in the properties file says:

“Individual image files are expected to be monochromatic and represent a single channel. However, any number of images may be combined by adding a new channel path and filename column to the per-image table of your database and then adding those column names here.”

Let us know if my suggestion on your post here helps: Exporting color image for Cell Profiler Analyst

Good luck! Pearl

Thank you so much Pearl for your comments- I definitely understand more now how to define different layers to adjust their colors in Cell Profiler analyst. The only question I’d have left is whether I could somehow preserve the original colors of the H and E stain when RBG splitting, as the pipeline treats all cells the same in a layer in order to identify them but in order to tell apart certain cells (especially neutrophils and eosinophils) we need to see whether their cytosol was stained more pink or blue.

Here’s what works for me. Essentially, you can use the UnmixColors module to create an image that you do object detection and measurement with. Separately, take your original image and split it into its RGB components in order to save those individual channels for visualization in CellProfiler Analyst.

  • Split your original H&E image to three channels using RGB type with ColorToGray

  • Save each RGB channel separately. Choose “Yes” for “Record the file and path information to the saved image?”

  • After you export to database and create your .properties file, edit the properties file so that the default colors are none for all images except the OrigRed, OrigGreen, and OrigBlue images that you created with ColorToGray. Set those colors to the corresponding color:

This method works for me to show appropriate H&E staining in CPA. Let us know how it goes for you!

That worked! I can’t thank you enough Pearl :slight_smile:

2 Likes