Ratiometric images?

934 views
Skip to first unread message

Vince Luczak

unread,
Aug 1, 2014, 8:14:27 PM8/1/14
to icy-so...@googlegroups.com
Hi everyone!

I have 5D images (x, y, z, t, 2 channel) and I would like to know if it is possible to make a composite image that will be color coded to display the ratio between the two channels, perhaps over time.

I've figured out how to do this in Fiji and I've made a macro to save time, however the most useful option would be to make a plugin. The problem of course is that I don't know how to code and I'm not sure if I have the time to learn. (*hint*hint* I have lot's of respect for you coders, lol) ;-D

I was curious if I could find similar functions in ICY to get a result like I do with Fiji and use the "Protocols Editor" to make a pseud-ICY-plugin (Alexandre?) to simplify the speed the process. I've been trying this already, but I guess the order of my operations are eating up all the memory so I usually give up.

I attached my Fiji macro and a picture of the operations so you can have a look at the details, but I can describe the process here:

- Extract each channel (ch0 and ch1)
- Max or Average Z Projection on each channel (However, it would be better to calculate the ratio as a stack so I can make projections of specific slices at the end. This will be more useful for images with more dense fluorescence throughout the slice.)
- Make a binary mask (0's and 1's) for each channel (e.g. threshold) to subtract background. [To make the mask in Fiji, first duplicate the image; apply a threshold that generates "accurate" morphology; Subtract 254 from the image (because Fiji 'binary' is 0 and 255)]
- Multiply the Projection and the Mask with image calculator (i.e. ch0 by mask0; ch1 by mask1)
- Divide with image calculator (masked 0 / masked 1)
- Second Mask. At this point, there are usually some pixels with an "infinity" value (white pixels), so I make another mask and subtract those pixels too.

The result is a 2D ratio image that changes with time. From here I just pull out the specific slices that highlight the relevant parts in the experiment (i.e. t20= 'baseline'; t40= 'first stimulation'; t58= 'second stimulation'). I have a separate Macro to do this since it varies for each experiment, but I will not include it for now.

As I mentioned, if I try to set up these similar operations in ICY, the program uses all the memory (>10GB) and freezes. I'm sure there's a better way, but I haven't found it yet.

As always, any help is greatly appreciated, and sorry for the lengthy description (I got a little carried away).

-Vince

20140801_AKAR_Fiji_Macro.txt
20140801_AKAR_macroOperationsPicture.png

Stephane

unread,
Aug 7, 2014, 4:57:45 AM8/7/14
to icy-so...@googlegroups.com
Hi Vince,

Thanks for your interest in Icy :)
I think you can indeed reproduce your Fiji macro with the Protocol editor as it seems you use basic operations only.
About the memory problem, what is the size of the original sequence ? > 10 GB of used memory seems a lot !
Also, do you still have the protocol you tried to build ? I'm not familiar with ImageJ macro and that would be helpful.

- Stephane

Vince Luczak

unread,
Aug 7, 2014, 8:01:10 PM8/7/14
to icy-so...@googlegroups.com
Hi Stephane,

Thanks for getting back to me. In advance, very sorry this turned into a monster email. I tried to keep things neat, but please let me know if you have questions. Feel free to answer things in small blocks. We can sort out the rest later.

The original TIFF file is 2.03 GB

I tried performing some of the same Fiji operations outside and inside the protocol editor and found a few problems, but I have a couple other things to point out.

1) The Protocols Editor does not contain the "z projection" plugin.

2) Ideally, I would make the ratiometric image on the whole stack and later select different slices to project, but the protocol could not get past the "operation binary" step for the first channel (step 3) if I do not start with a z projection.

3) I therefore usually need to extract all channels and z project (max or mean) outside of protocol editor. Is it possible to add these functions to the protocol so I can just call the file and run the steps? That's basically what I'm trying to do, but I don't know how to get the first steps into the protocol.

4) If I z project first (outside of protocol editor) and then use protocol editor to call the projected images, the protocol will run to the end. But there is a problem with the duplication>threshold>multiply functions in steps 9-15. After applying the "manual threshold" to the ratio image, the mask is inverted, meaning the background has a 1 value (white pixel) and the cell's signal has a value of 0 (black pixel) which is opposite of what I want. I tried running "simple operations" to invert the mask, but it is requiring input from two channels and it throws an error if I select "no sequence" for value 2.

5) I have also tried using HK-Means to apply a threshold (for steps 2 and 5) instead of using the "thresholder" function, but it seems to work with variable accuracy when moving through the other time points in the image. Meaning a mask for time=1 may look good, but time=4 may look bad. Perhaps you can comment on why the threshold is so different from one time point to another?

I've attached the protocol and screenshot that I have been working on. I also attached a screen shot of the comparable steps of the protocol performed separately outside of the protocol editor which allows me to invert the ratio mask and create a ratiometric color coded image.

Regarding the final ratiometric image, I'm having trouble with two things, the LUT and measuring the ratio within an ROI.

For the LUT: I would like to adjust the LUT to exaggerate the different ratios. It looks like the ratio mostly ranges from ~1-3 so it would be best to have the greatest color change over this pixel range. I've tried adjusting the contrast but I can't seem to reproduce a color change as dramatic as I have seen in ImageJ/Fiji.

For the ratio measurement: I drew a few ROIs and tried using "ROI intensity evolution", "intensity profile, and "roi statistics" to measure the average ratio in the ROI, but for some reason none of the plugins are calculating the mean pixel value. Strange...

Thank so much for helping out with this!

-Vince
Ratiometric image 2.protocol_screenshot.png
Ratiometric image 2.protocol
20140807_ICY_RatiometricAndROI_Screenshot.pdf

Alexandre Dufour

unread,
Aug 11, 2014, 6:14:54 AM8/11/14
to icy-so...@googlegroups.com
Hi Vince,

That *is* a long email indeed, so it’ll be hard to answer all of it at once. I’m gonna answer a few points which are a bit more relevant to what I do/did, and perhaps give some hints for the other points.


On 08 Aug 2014, at 01:01, Vince Luczak <vglu...@gmail.com> wrote:

1) The Protocols Editor does not contain the "z projection" plugin.

2) Ideally, I would make the ratiometric image on the whole stack and later select different slices to project, but the protocol could not get past the "operation binary" step for the first channel (step 3) if I do not start with a z projection.

3) I therefore usually need to extract all channels and z project (max or mean) outside of protocol editor. Is it possible to add these functions to the protocol so I can just call the file and run the steps? That's basically what I'm trying to do, but I don't know how to get the first steps into the protocol.

In fact there are 2 “Projection” plugins in Icy: one called “Projection” (which you have used and doesn’t have a Protocols counterpart), and another one called “Intensity Projection” that does have all these options (the latter is technically supposed to supersede the former). This should pretty much get you started in your protocol.

4) If I z project first (outside of protocol editor) and then use protocol editor to call the projected images, the protocol will run to the end. But there is a problem with the duplication>threshold>multiply functions in steps 9-15. After applying the "manual threshold" to the ratio image, the mask is inverted, meaning the background has a 1 value (white pixel) and the cell's signal has a value of 0 (black pixel) which is opposite of what I want. I tried running "simple operations" to invert the mask, but it is requiring input from two channels and it throws an error if I select "no sequence" for value 2.

This is probably due to the fact that after the division step, you are dividing some values by 0, and this doesn’t result with a NaN, but rather, a positive infinity. Therefore, if you then manually threshold this, you’ll end up selecting only these problematic pixels.

5) I have also tried using HK-Means to apply a threshold (for steps 2 and 5) instead of using the "thresholder" function, but it seems to work with variable accuracy when moving through the other time points in the image. Meaning a mask for time=1 may look good, but time=4 may look bad. Perhaps you can comment on why the threshold is so different from one time point to another?

Automated threshold methods are essentially dependent on the input histogram. Although all images seem to look the same, their histogram never really does, therefore the calculated thresholds may vary from image to image. In any case, I don’t think the HK-Means would be of help here, since it’s designed to extract objects of given size, and it seems you don’t really know the size of your structures in advance. I recommend you try (outside Protocols) to use the classic Thresholder plugin with automated (KMeans) threshold calculation, and see whether the “time independent” option has any effect (that indicates whether the histogram of each image should be considered, or the histogram of the entire sequence)

Regarding the final ratiometric image, I'm having trouble with two things, the LUT and measuring the ratio within an ROI.

For the LUT: I would like to adjust the LUT to exaggerate the different ratios. It looks like the ratio mostly ranges from ~1-3 so it would be best to have the greatest color change over this pixel range. I've tried adjusting the contrast but I can't seem to reproduce a color change as dramatic as I have seen in ImageJ/Fiji.

Which LUT were you using in ImageJ? Have you tried all of the available LUTs in addition to adjusting the contrast?

For the ratio measurement: I drew a few ROIs and tried using "ROI intensity evolution", "intensity profile, and "roi statistics" to measure the average ratio in the ROI, but for some reason none of the plugins are calculating the mean pixel value. Strange…

Again this might have to do with the division step where values become pretty much out of hand. I think the Math operations block should have an extra option to allow divisions by 0 to be replaced by 0 in the final image, which might solve some of your problems (probably not all though). I don’t know who’s maintaing this plugin nowadays however, but this could be easily patched.

Alexandre


Sen S

unread,
Dec 29, 2016, 5:05:18 PM12/29/16
to Icy imaging
I stumbled upon this as I was searching some answers to a similar question. Not sure if you have settled on an answer yet. I used "sequence comparator" after splitting the image in to two channels. This plug-in gives the option to measure and compare differences


maximum pixelwise difference, L1/L2 distance etc. You can then project the absolute difference on to a 3D map and visualize it. The issue I am trying to get around is to get the plug-in to make the background transparent so that I can visualize the difference map in 3D.

as a novice user, I am still probing and learning Icy, but love it so far for its capabilities. Excellent work Developers!

All the best!
Sen
Reply all
Reply to author
Forward
0 new messages