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
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: