Saving statistics from 3D object counter


#1

Hello,

I am trying to write a macro that runs 3D object counter on a stack of images and save the statistics. However, when I do the saveAs function, it saves the image instead, which I do not need.
Here is my code:
macro “batch_3dobjectcounter”
{
file1 = getDirectory(“Choose a Directory”);
list1 = getFileList(file1);
n1 = lengthOf(list1);

file2 = getDirectory("Choose a Directory");

for (i = 0; i < n1; i++)
{
name = list1[i];
open(file1 + list1[i]);
setBatchMode(true);
run(“8-bit”);

 run("3D Objects Counter", "threshold=1 slice=1" +
	" min.=0 max.=65024" + 
	" statistics");
 saveAs(file2+name+"_stats");
     setBatchMode(false);
 close()
}

}
Any thoughts?


#2

i updated the code to the following:
macro “batch_3dobjectcounter”
{
file1 = getDirectory(“Choose a Directory”);
list1 = getFileList(file1);
n1 = lengthOf(list1);

file2 = getDirectory("Choose a Directory");

for (i = 0; i < n1; i++)
{
name = list1[i];
open(file1 + list1[i]);
setBatchMode(true);
run(“8-bit”);

 run("3D Objects Counter", "threshold=1 slice=1" +
	" min.=0 max.=65024" + 
	" statistics");
 selectWindow("Statistics for " + name);
 saveAs(file2+name+"_stats");
     setBatchMode(false);
 close();
}

}

But it still doesn’t work


#3

@jjame

I think (and you have to test this!) that you need to specify what you are saving like this:

saveAs("Results", file2+name+"_stats");```

Test it to be sure.  

eta :)