Does anyone help me with the use of setResults function in a macro?

call4help
macro
imagej
measure
Tags: #<Tag:0x00007fd5439851a0> #<Tag:0x00007fd543984fe8> #<Tag:0x00007fd543984ea8> #<Tag:0x00007fd543984d68>

#1

Hi,

I want to measure in each image of an animation the area of diferent things with the wand tool, and I want to put the results in diferent columns in the results window. Does anyone help me with the use of setResults function in my macro?

this is my macro:

run("Set Measurements...", "area redirect=None decimal=3");

for(i = 1; i <= nSlices; i++){
setSlice(i);
//setTool("wand");
doWand(92, 242, 30.0, "Legacy");
run("Measure");
}

for(i = 1; i <= nSlices; i++){
setSlice(i);
//setTool("wand");
doWand(143, 196, 30.0, "Legacy");
run("Measure");
}

Thanks a lot.


#2

Dear @juandemedellin,

you can’t use run("Measure") in your case because that will write into the results table that you are trying to create. You can use List.setMeasurements to measure the currently active selection and List.getValue("Area") to get the area of that selection. You can replace "Area" with any column header from the results table that would be generated by the call run("Measure"):

run("Set Measurements...", "area redirect=None decimal=3");

for(i = 1; i <= nSlices; i++){
setSlice(i);
//setTool("wand");
doWand(92, 242, 30.0, "Legacy");
List.setMeasurements;
area1 = List.getValue("Area");
setResult("Area 1", i, area1);
}

for(i = 1; i <= nSlices; i++){
setSlice(i);
//setTool("wand");
doWand(143, 196, 30.0, "Legacy");
List.setMeasurements;
area2 = List.getValue("Area");
setResult("Area 2", i, area2);
}

Best,
Stefan


#3

Dear Stefan Helfrich

When I run the macro I get this error:


#4

Dear Stefan Helfrich,

my friends and I resolved it in this way:

Thanks a lot.