Results-table to macro

I have a 10 frames image. A result table contains frame number(1,4,9), xy coordinates(centroid of circle), size. I’d like to draw circles on the image at the 1st,4th and 9th frame using Macro and save all the circles to ROI.
I loaded the results-table to Macro. And I don’t know how to take each value from the data(xy coordinates and circle size is corresponding to the frame number) and apply to the image.
Could anyone help for that, please?

x = getNumber( "X", 13 );
y = getNumber( "Y", 12.284 );
d = getNumber( "Diameter", 3.713 ); 
for (i=0; i<nSlices; i++){
	run("Specify...", "width=[d] height=[d] x=[x] y=[y] oval centered");
	run("Next Slice [>]");

For extracting the data from the result table use the following command:

getResult("Column", row);

Assign it to a variable and then you would need to replace the String commands with your variables like so:

x = getResult("Column", row);
y = getResult("Column", row);
d = getResult("Column", row);

run("Specify...", "width=[" + d + "] height=[" + d + "] x=[" + x + "] y=[" + y + "] oval centered");

What one performs here is a string concatenation. Make sure that you preserve the spaces in the Fiji macro commands. Spaces are important to separate different commands.


Maybe you would like to use

a = getResult("Column", row);
makeOval(x, y, w, h);

All informations about these fonctions are on : ImageJ built-in macro functions


What should I do with this error?

Undefined variable in line 1
var; initializeSciJavaParameters (); getResult(“column”,);


you need to specify the column name instead of “column”.
It does not find the string “column” in you result table.


the second argument (13) it has to be the row number from where you want to extract the “X”.
could you please upload the results table here on the forum, so maybe someone could try directly with your results table?


Even though I specify the column name, it keeps complaining…
data.txt (86 Bytes)

macro "Import Results Table" {
     lineseparator = "\n";
     cellseparator = ",\t";

     // copies the whole RT to an array of lines
     lines=split(File.openAsString(""), lineseparator);

     // recreates the columns headers
     labels=split(lines[0], cellseparator);
     if (labels[0]==" ")
        k=1; // it is an ImageJ Results table, skip first column
        k=0; // it is not a Results table, load all columns
     for (j=k; j<labels.length; j++)

     // dispatches the data into the new RT
     run("Clear Results");
     for (i=1; i<lines.length; i++) {
        items=split(lines[i], cellseparator);
        for (j=k; j<items.length; j++)
 getResult("x", row);

data.txt (86 Bytes)

Yes, I don’t want to use ‘getNumber’.
Thank you.

When I import your result table and then run:

x = getResult("x", 0);

I get the value.
Make sure you select the right column (case sensitive) and row (index starts with 0).
Could you post the code that gives you the error. I am confused by the Import Results Table code now.

Thank you for your kind answers. I could draw the circle at the first frame.

f = getResult("frame", 0)
x = getResult("x", 0);
y = getResult("y", 0);
d = getResult("d", 0);

run("Specify...", "width=[" + d + "] height=[" + d + "] x=[" + x + "] y=[" + y + "] oval centered");

How can I make it automate drawing the circle at each frame(1st, 4th, and 9th in 10 frames image) ?

you would need to specify a loop. See how this is done here:
The nResults function will give you the number of rows.
Make sure you use semicolons after each line in the macro code.

Here is a working example:

numberOfRows = nResults;

for (row = 0; row < numberOfRows; row++) {

	frame = getResult("frame", row);
	x = getResult("x", row);
	y = getResult("y", row);
	diameter = getResult("d", row);
	run("Specify...", "width=[" + diameter + "] height=[" + diameter + "] x=[" + x + "] y=[" + y + "] oval centered");


Thank you so much. I appreciate the help!