Saving cell detection locations and loading them in another image

Hi there, great software proving very useful for my experiments. I am working with RGB marking to label tumour lineages. I am trying to create a pipeline for identifying and counting cells of each identifiable label, that is:

Red + Green = Yellow
Red + Blue = Purple
Green + Blue = Cyan

Red + Blue + Green = White

Have tried to paste an image below.


Currently I can quantify differently coloured cells by performing cell analysis for each channel then extract the nuclear mean pixel intensity for each channel for each detected cell. However with this method I get repeats i.e when counting purple cells I detect these with cell analysis in the red and blue channel but they do not always return the same values.

What I am trying to do is to turn the images initially into a 8-bit grey scale image on Imagej and then do a cell analysis on this image to detect all cells irrespective of channel. I would then like to load these detection’s into the mutli-channel image and measure the mean cytoplasm pixel intensity inside the detection’s to avoid having repeated detection’s of the same cells. Would this be possible?

PLeas let me know if any of that was unclear adn I look forward to figuring this out!

It sounds like you want to use the ImageJ macro runner, and then, potentially, convert that into a macro in a script.
Working with ImageJ
Post about ImageJ scripts:

A couple of other scripts that might be useful:
Short example of inserting a variable from the groovy script into the ImageJ macro.
A much more complicated example where a variety of variables are used within an ImageJ script to generate a fluorescent tissue annotation. See here for the original intended use.

Also, another user was creating a script where they ran a cell detection in multiple channels and then eliminated overlapping cells.

Side note, due to the shape, I think you will have some trouble filtering out the cells in a single image. What happens when a red+green cell overlaps with a blue cell, etc? And those dendritic (neurons?) cells are not going to play nicely with their cell borders!

Just out of curiosity, what types of images/cells are these? The signal looks relatively weak, which makes me think live cell, and maybe downstream FP markers. And maybe confocal/2P.

Hi There,

Thanks for the reply. These are living U87 cells imaged on an inverted zeiss lsm 710 through a plastic culture dish. I infected them with 3 different lentivirus’ each carrying a different fluorophore resulting in differential expression of each fluorophore in the cells.

I want to be able to identify the fluorophores expressed in each cell and the level of fluorescence for each. Cells showing the same fluorophore combinations and similar expression levels are likely to be related to one-another.

Here is an example of a cryo-sectioned three-dimensional culture containing cells infected in a similar fashion.

1 Like

To add a little clarity to what I had asked earlier . . . here are some snapshots one of the original image and one of the same image converted to greyscale and with cell detection performed.

I was hoping to transfer the detection’s to the original multi-channel image and then get a readout of the pixal intensities for each of the detection regions.

Is that a little clearer??

1 Like

Yep, that is going to be fairly difficult to segment. I realize it isn’t helpful now, but it is actually far easier to use a nuclear marker (TOPRO markers are apparently a favorite for many lightsheet analyses due to greater penetration of far red vs Hoechst). With the nuclear markers you don’t need to segment the whole cell, you only need to find the nuclei, pop a (small) doughnut around them, and then poll that area right next to the nucleus for the three different colors. At that point you can use something like the multiplex classifier script to classify all of your cells based on three thresholds. The smaller area also reduces the chance of overlap between two cells causing a false dual/triple positive area.

Something to consider for the future.

That is also the sort of thing that the Pixel Classifier in 0.2.0m4 should be good for… once it is finished :slight_smile:

You might also try creating tiles, turning them into cells, and running subcellular detections on them… though that might be unnecessarily complex if you can do a cell detection in each channel and get cells relatively accurately. The previous script where they were removing overlaps between two detection channels might work well for your purposes if expanded to 3 channels. Not sure if that would be easier or harder than getting the ImageJ script to work.

If you simply want to transfer the detections, and the two images are the exact same (it is a little worrying that I see a jpg in there and not a CZI!) you can just move the .qpdata file between the two images. Go to the project folder and find the qpdata file with a lot of data, and copy it into the other data folder.

  • another option is to export the detections and import them again using a pair of scripts here. You will need to both adjust the scripts to find detections instead of annotations and split it into two scripts.

Thanks a lot for the feedback. That is really helpful, I am still working on the best way to process the cells for subsequent analysis. I can setup a nuclear stain and try out what you suggested relatively easily.

I have tried what you suggested transferring the datafile, but when I look at the detection measurements it just has the same measurements as were recorded from the original greyscale file. Would it be possible to update the detection measurements for the image they have been transferred too?

Unfortunately you do see a .jpg I have been using theses. What is the advantage of using .CZI? I know .jpg file deteriorate over time?

Well, not so much over time, but the conversion to jpg does degrade it and the data is no longer accurate as it is blurred into little 8x8 pixel boxes. If you zoom in enough you will see them. JPG are generally not encouraged in science, see section 6.8.

CZI will still have the metadata, which frequently makes further analysis easier, as everything will be in um rather than in pixels. Plus the scale bar will be accurate by default! Conversion to JPG also generally turns the data into 8bit, so if you collected at higher bit depth you will face some compression there.

Measurements: You will need to generate new ones using Add Intensity Features, see more about adding measurements here.

Yeah I had heard that about .jpg, Either way I shall be sure to use my original .czi files from now on!

Thanks a lot for the rapid assistance, I have got plenty to work away at now. Cheers!

May be back to pester for more assistance at some point!!

1 Like

Hi again,

I have been trying to compute new intensity features for the transferred detection’s. The parameters I am using are below. Then when I run the process I selected “cells” in the process feature box.

Unfortunately, when I run the process it returns and error and does not update the detection measurements

Seems to be an issue with the ‘colorOD’ which I cant find anywhere. Any suggestions?


Not 100% sure without more information, but I have a feeling you aren’t treating your image as a fluorescent image. Check the image type in the Image tab.

I did verify that the Compute intensity features should work in 0.2.0m4 in a fluorescent image, though I was using a “real” multichannel image and not a jpg. So there might be some sort of problem with how it calculates things considering the jpg aspect, versus multichannel. If you want to share one of the original images (jpg, since you are working with that now) I could take a look.

Nix that, that is a bug in 0.2.0m4 due to the colorOD channel being inserted second in Fluorescent JPG images. I will create an issue ticket and update here.

Somewhat unrelated, but this function should work if you load your images into 0.1.2 or 0.1.3. The joys of using Milestone test versions :slight_smile:

Thanks, this should be resolved with in the next milestone:

In the meantime, you can temporarily set the image type to Brightfield as a workaround when calculating intensity features in RGB images (assuming you use measurements that don’t involve color deconvolution).

1 Like

But you might already see the problem disappear if you can use the original file format (not JPEG), since the issue should be restricted to 8-bit RGB images.

(If the original is 8-bit RGB then that won’t help…)

Yeah, ImageJ macro runner + downsample should work as well as the compressed JPG I would hope.