 # 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.  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
run("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);
run("Measure");

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

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

wait(100);
}
}
``````

The result would then look like this: Cheers,
Robert

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,

This also gives you the opportunity to learn a bit more about ImageJ macro `profile = getProfile();`. This is a link explaining this trick and how to export to a file.