"3D" pseudocolor for ratiometric images (FRET)

Tags: #<Tag:0x00007fd542daabf0> #<Tag:0x00007fd542daaa38>


Hi, I am lost in color-space. Maybe someone can point me in the right direction. I want to generate ratiometric (Yellow/Cyan) images that resemble the image below, a HSL image where the hue illustrates the ratio and the fluorescence level the intensity (saturation is set to 100% in this example, which is generated in Igor Pro, btw). And if anyone knows if anyone made a similar calibration cube for ImageJ (color top-bottom, intensity left-right), that would be great! If anyone wants to play with this you can use the example images at the bottom of this post.

Any advice is appreciated, thanks.

How to make the heatmap of fluorescent intensity ratio using ImageJ like the example?

please do not use JPG to store/share your image data, since it uses lossy compression and is hence not suited for analysis. Could you upload the raw image data instead?

You could try the following:

  • open both images via Plugins > Bio-Formats > Bio-Formats Importer. Take care to open the original raw data that you got from the microscope. If both channels are stored in the same image you can tick “split channels” in the Bio-Formats Importer.

  • use process -> image calculator to create the ratiometric image by dividing yellow/cyan

  • then you can change the LUT (lookup table) for better visualization via Image -> lookup Tables -> Rainbow RGB (for example)

  • you can add a scale bar via Analyze > Tools > Scale Bar

  • you can also add a scale bar for the intensity using Analyze > Tools > Calibration Bar


Hi Kai, thanks for your reply. I don’t use JPG to store or share my data :wink: I drag/dropped .png files (500 kB) from file explorer in ubuntu to this forum on chrome, for some reason it converted to .jpg, is this working as intended @imagejan? I will update my post. EDIT: Even using the Upload button in the forum GUI they convert .png to .jpeg, weird. I included an imgur link in stead. Not that it really matters for this post.

@CellKai, I know how to split channels and make ratiometric images, thats what I’m already doing, maybe that wasn’t clear. I wan’t an output where the color indicates the ratio and the intensity the fluorescence of the FRET-pair fluorescent proteins.

Yes, I know, but my question was is there a combined scale bar, and a scale bar that indicates both intensity and ratio, please see the screenshot in my post.




Thanks for the heads up, @Sverre.
I did some quick search and found that in newer version of Discourse (the forum backend), “large” images are auto-converted to .jpg:

This might be useful for forums where users upload a lot of stuff from mobile devices (e.g. raw captured photographs), but for the ImageJ forum, compression might not be desired as you guys pointed out (and I wouldn’t consider any of you as “Bad Users” ;-)).

I therefore looked for this option in the settings and disabled compression by setting quality to 100:

(I hope @ctrueden you’re ok with that.)

@Sverre I would still prefer having the files embedded in the forum instead of linking to an external site (and after my changes, it should work as intended). Do you want to try yourself by editing your post once more? :slight_smile:

You should be able to generate the image using the image calculator and filling the Hue and Brightness of an HSB Stack accordingly, right?

I don’t know if anyone did this already, but I think it should be straightforward by generating a small image, filling it with gradients (vertical hue, horizontal brightness), and using this as an overlay on your RGB image generated from the raw data.


Hi Jan,

I edited and can confirm that both drag/drop and gui facilitated upload no longer converts to jpg, thanks :slight_smile:

So this is what I tried, but it left me more confused. I was hoping to get an output where the hue channel was the ratio (0 to ~2…) and the brightness channel the… brightness (of either the yellow or cyan channel, probably cyan). I tried the following and got strange results, which I suspect seem strange because I don’t understand them, maybe it makes sense to you!

Image calc. Divide yellow/cyan (32-bit float) -> Ratiometric image
Merge channels: Ch 1 = Ratiometric image, Ch 2 = Cyan raw. (Tried both composite and… not composite)
Type >> RGB to HSB
Image >> Color >> Stack to RGB

Type >> 32-bit
LUT >> Rainbow RGB

and the raw ratiometric image:

However, the values in the Hue and Brightness channels of this HSB stack do not seem to correspond at all to the original ratiometric values, or the brightness values from the cyan channel. Any thoughts?

I wasn’t able to find it. Before i delve into this, would I need to develop an ad hoc java plugin, or could this be scripted efficiently (I’m a python guy)? I supose I could just use the same small image and then add the appropriate text in a scripted action.


There’s two problems with your approach:

  • You first merge the channels and then change the color space to HSB. Instead, you should first create an empty HSB stack, then paste your image data into the appropriate slices, and finally convert back to RGB.
  • ImageJ (at least the ImageJ 1.x commands we’re using here) handles both RGB and HSB images with 8 bit per channel only. If you have a ratiometric image as 32-bit float, you’ll have to scale it correctly to 8-bit (e.g. set min and max from 0.0 to 2.0, then change to 8-bit) before transferring it to the HSB stack.

Here’s a macro that illustrates how to create a 2D gradient image with horizontal brightness and vertical hue gradient:

// Create gradient image
newImage("Gradient", "8-bit ramp", 256, 256, 1);
run("Select All");

// Create empty result image
newImage("Result", "RGB black", 256, 256, 1);
run("HSB Stack");

// Paste left-right gradient into B channel

// Rotate and scale gradient
run("Rotate 90 Degrees Right");
run("Multiply...", "value=0.66");
run("Select All");

// Paste top-bottom scaled gradient into H channel

// Set saturation (S) channel to all white
setForegroundColor(255, 255, 255);
run("Select All");
run("Fill", "slice");

// Convert HSB to RGB
run("RGB Color");

(I scaled the Hue gradient by 0.66 to approximately match your example image’s hue from red to blue, without taking the full turn back to red.)

Hope that gets you started.


Hi Jan, this is exactly what I needed, thank you!

This is what I wanted to do, create a “custom” HSB stack, I’m glad it wasn’t more difficult than a simple copy/paste step… And thanks for the gradient macro!

I will update with the results,




Yes, as cool as the autoconvert-to-JPEG feature is in general, for this forum, I think we want to always leave raw images alone. Thanks for tracking that down.


Hi, Sverre, I also want to get the ratiometric of membrane distribution. Accoding to Jan’s gradient macro, I can’t find the “Multiply…”, could you please tell me the button? Really appreciate!


Hi @sxl123084, you can always use the Command Finder (type L) to search for commands. The “Multiply” command is in Process > Math > Multiply…


Thanks so much. I just start using ImageJ and it seems a little difficult for me.


Hi Jan, I can’t find setForegroundColor using command finder in my ImageJ. Whether I should install other plugins?


I believe what you are looking for can be found under Edit > Options > Colors…

The command would be Colors...

Using setForegroundColor would be another, more specific, way to achieve the same effect as using run("Colors...", "foreground=choice") as you can specify the Red, Green and Blue pixel values.

*where choice is your desired color…

Someone please correct me if I am mistaken!


Great. Really appreciate!


Image/Color/Color picker
Thanks for your supplement.


I should have read through the thread more before jumping in :wink:


Hi camlloyd, the last question, where is the command ‘slice’?


Could you please post an example of what you would like to do with the slice? :slight_smile:


I want to obtain the ratiometric of my interested membrane protein in neuron following Jan’s macro. I am not familiar with ImageJ and can find the command.


Image > Stacks > Set Slice…

where slice refers to a layer in your stack of images.

You can use the < and > arrow keys to navigate between your H, S, and B channels manually.

To display a specific layer in your image stack, you can use setSlice(n)

Please see https://imagej.net/developer/macro/functions.html#setSlice for more information :slight_smile: