Re: Plot profile macro through multiple slices
Posted by Jubok on May 20, 2016; 11:47am
URL: http://imagej.273.s1.nabble.com/Plot-profile-macro-through-multiple-slices-tp5016475p5016476.html
I have a working solution but I think it's not the most elegant one :
dir = getDirectory("Choose a directory :");
counter=1;
for (i=1; i <= nSlices(); i++) {
setSlice(i);
run("Plot Profile");
Plot.getValues(x,y);
run("Clear Results");
for (j=0; j<x.length; j++) {
setResult("x", j, x[j]);
setResult("y", j, y[j]);
}
setOption("ShowRowNumbers", false);
updateResults;
saveAs("txt", dir+"slice_"+counter+".txt");
counter+=1;
run("Close");
run("Close");
}
It needs to close the Plot and Results windows so I had to put "run("Close")" two times, it didn't work with "close()"
If you have suggestion to improve the code don't hesitate ! :)