Problem with Li plot using coloc2



Hi everyone,

I am having a problem using the plugin Coloc2. I run the plugin using my two images and select a ROI that is drawn on one of the images. When I obtain the results I am able to see the Li plots and the ICQ, Pearson… coeficients. However, I can’t get the data from the Li plots to make the representation by my own.

Previously I’ve been using JACoP, that indeed gives me the “Li data”, but now I want to select ROIs, and JACOP doesn’t allow me to do so.

Do you know how I can get the data from the Li plots?

Thank you in advance

Coloc2, multiple ROIs
How to write automatize macro for Coloc2?


There is an example Groovy script that will allow you access to the Li plot data as ArrayImgs. To access/run the script, just go to Templates > Examples > Colocalisation (Groovy).

This is the ‘easiest’ way to access those datasets - you’ll have to adapt the code to do exactly what you want - but that’s the foundation.

eta :slight_smile:


Dear eta

First of all thank you for your help.
When I run the script I obtain de colocalization coeficients and also the Li graphs are shown. My problem is that I can’t save those images or get the data to represent those graphs by my own.
Specifically, this is what I get:


My purpose is to represent the Li plots to show the colocalization pattern of my two signals.

Thank you in advance



If you run this code:

// @ImagePlus imp1
// @ImagePlus imp2
// @UIService ui

// Colocalisation.groovy
// This script demonstrates programmatic usage of Fiji's Coloc 2 plugin,
// including how to extract quantitative measurements after execution.

import sc.fiji.coloc.Coloc_2
import net.imglib2.*
coloc2 = new Coloc_2()

indexMask = 0
indexRegr = 0
autoSavePdf = false
displayImages = false
displayShuffledCostes = false
useLiCh1 = true
useLiCh2 = true
useLiICQ = true
useSpearmanRank = true
useManders = true
useKendallTau = true
useScatterplot = true
useCostes = true
psf = 3
nrCostesRandomisations = 10


img1 = coloc2.img1
img2 = coloc2.img2
box = coloc2.masks[0].roi
mask = coloc2.masks[0].mask

// NB: Passing a different bounding box and/or mask here
// may work, but is (as of this writing) UNTESTED.
results = coloc2.colocalise(img1, img2, box, mask, null)
for (v in results.values()) {
  println( + " = " + (v.isNumber ? v.number : v.value))
println("I also have histograms:")
for (image in results.images()) {
	name = image.toString()
	histoPlot = image.getObject(), histoPlot)

Now you will get individual images with your plots… should be the data you need. Many thanks to @ctrueden on that one!

eta :slight_smile:

How to write automatize macro for Coloc2?
Coloc2 results to table
Colocalization Threshold Macro
Using colocalisation threshold in Java

Thank you so much for your help @etarena (and @ctrueden too)!

The code worked great and now I can copy the plot images to use them!.

I would really appreciate if you could help me with another little detail. With JACOP I get the coordinates of every dots of the Li plot, like this:

Do you know if there is a way to extract the plot values from the Coloc.2 plugin? ( I can’t use JACOP because doesn’t allow me to select ROIs)

Thank you again for your help and your time, I really appreciate it.



Just add this loop to your code…

for (img in results.images()) {
	println("Name of Image: " + img.toString())
	c = img.getObject().localizingCursor()
	while (c.hasNext()) {
		x = c.getDoublePosition(0)
		y = c.getDoublePosition(1)
		//if (c.get().getRealDouble() > 2) 
		println("\t" + x + "\t" + y + "\t" + c.get())

you will have to copy/paste the results… but at least you’ll get the numbers you need.

eta :slight_smile:



I’m also trying to export graphs (Li’s ICA) out of coloc2. I tried some different approaches and I have some questions about them.

Based on this previous post, I’m also trying to use the groovy code (thanks for sharing this code!). If I understand the code correctly, it is not applying any ROI/mask in the coloc2 analysis. Could someone get me started to change the code to implement the possibility to use a ROI in the analysis? (It is the first time to use groovy).

Besides the groovy code I also tried to replot the scatterplot using the export ‘list’ function in coloc2. To plot the values I used matlab but for some reason the values in this list give an inverted y-axis. To plot I used : h=scatter(x,y,,z, ‘filled’, ‘square’) after copying the values to a x, y, and z vector. After I flip the y vector up down (flipud), the scatterplot looks the same. Has someone a clue why this axis is fliped in the list?

My last question is concerning the axis values. The list gives very large values for the x and y-axis while in the article of Li the values are in the range of -0.4 to 0.4. I think this is because in the article they normalize the intensity values. Is there a reason why this is not done in coloc2?

Thank you in advance for any help!