Custom Summary Results table macro


I’m trying to create a macro that performs an Image Analysis of 3D stack image. It should calculate some additional parameters, e.g. radius from the perimeter and more similar simple results. This I was able to do it. But what I’m struggling with is how to have a custom Summary Results table or just a new table where I can express e.g. the sum of all perimeters per slice, the sum of all radii per slice, average radii per slice etc. If someone can help me update the code to include e.g. the sum of all radii per slice, I would be very grateful, and hopefully, could continue with the rest of variables.

This is an example file which I’m using:
S1-Huang.rar (726.9 KB)

This is the working code which calculates the radius from perimeter for each particle, but does not creates summary of all radii per slice:


res=getNumber("Image Resolution [um]", 1);

run("Set Scale...", "distance=1 known=res unit=Micron global");
run("Auto Threshold", "method=Huang stack")
run("Set Measurements...", "area mean perimeter shape limit stack position redirect=None decimal=4");
run("Analyze Particles...", "add stack summarize display");

for (i = 0; i < nResults(); i++) {
    radius = getResult('Perim.', i)/(2*PI);
    setResult('Radius', i, radius);


saveAs("Results", + "RPerim.csv")

Thank you in advance. Regards,

Hi @Marko,

I am not able to open your .raw file. Here is how it opens for me:

In any case, you should be able to use Table functions:

… and get the specific column as array values using Table.getColumn(“Column name”).

Then you could use the Array functions:

or write your own function to calculate the sum of all perimeters or radii.



Dear Ved,

Sorry, I forgot to write the raw file description. It is a 8-bit file, unsigned, 300x300x300 in dimensions.

Now it should work.

Thank you for replaying. I will check the references.

Best regards,

Hi @Marko,

Have a look at the (Table section) This explains how to create a new table and fill it with results you calculate.

BTW: Analyze Particles is stated with a wrong parameter sequence

run("Analyze Particles...", "add stack summarize display");

does not display a summary table or makes problems in general because display needs to stand before summarize.

Here the recorded standard sequence of the activated checkboxes:

run("Analyze Particles...", "  show=Masks display exclude clear include summarize record add in_situ");

If you deviate from the sequence it will most likely not work as intended.