Plot number of particles vs distance

Hello All,
I am trying to quantify RNAscope signal by counting the number of particles. The counting works pretty well but what I want to do now is to plot the number of particles vs the distance. Something similar to dropping a line on an image and Analyze>plot profile and I get the Gray Value vs Distance (see below), but instead of the Gray Value I need the number of particles.

200 100

I guess it will be about dividing the whole image into areas, count the particles in each area and plot them versus the distance.
Does anybody know a way to do this?
Thank you very much!

Hi @caldarellip,

can you share how you count the dots? I quickly tried with Find Maxima... and I’m not so convinced. However, I can show you how to count the dots in tiles, for exmple with a macro:

// convert the image from RGB to 8-bit
// generate a binary image with the dots in white
run("Find Maxima...", "prominence=10 output=[Single Points]");

// make a copy; just in case
run("Duplicate...", " ");

// define tile size
tileWidth = 20;
tileHeight = 20;

// get image size
getDimensions(width, height, channels, slices, frames);

// we want to measure the mean intensity in a binary image
run("Set Measurements...", "mean redirect=None decimal=3");

// go through all tiles
for (x = 0; x < width; x += tileWidth) {
	for (y = 0; y < height; y += tileHeight) {
		// outline a tile and measure mean intensity
		makeRectangle(x, y, tileWidth, tileHeight);

		// calculate number of points from mean intensity
		count = getResult("Mean", nResults() - 1) * tileWidth * tileHeight / 255;

		// draw the result
		drawRect(x, y, tileWidth, tileHeight);
		drawString("" + count, x, y);


The result would then look like this:
Is this something helpful?


1 Like

Hello Robert,

Thank you very much for your answer. I count the dots in the way that the company of RNAscope suggests: threshold the image, play with it a little bit and then Analyze>Analyze particles. This method is very rough and indeed I think the Find Maxima is much more accurate than Analyze Particles.
Do you know of any other way to accurately count the dots? I am uploading the original file here.
good.tif (516.6 KB)

I am trying the macro you sent me and I really like it. For example, I am dividing the image into strips and plot the number of dots vs the distance (based on the size of the tile).

The problem I have is that I have to add the number of dots in an Excel file by hand. It would be nice to get in the Results the number of dots instead of the mean so I can then export it directly in an Excel file. I am not very handy with that, do you think we can add it to the macro?

Thank you very much for your help. I heard many people having problems with quantifying RNAscope, this thread can be useful for them as well.

1 Like

Hi @caldarellip,

glad that it helped.

Sure, you can write a csv file, which can then be opened in Excel. You learn how to do this in this PPT on slide 22:

This also gives you the opportunity to learn a bit more about ImageJ macro :wink:


If you reduce each particle to 1 pixel with a value of 1 (threshold, divide by 255), you can set the width of the line, then do the profile plot, each pixel adds 1 to the grey value. Five pixels on a row, perpendicular to your example yellow line, will give a grey value of 5 for the center pixel.You can ‘get’ the values using
profile = getProfile();. This is a link explaining this trick and how to export to a file.