Hi, can someone help me find a bug in my code. I have a macro that is working in GUI but when I try to run it via command line, I get an issue with getting my second results where the same value is present for all images. Basically, I open an image do Process 1 and get some results (Mean) then further process and get results (%Area). I can get the results for process one per Image and they match what I expect from GUI results but in process 2, I get the same value for all of my test Images which is not expected. I have added a print line so I can see that the loop is working and not stuck on one Image. I suspect the line of code with and issue (Larger example below) is… var2=getResult("%Area",nResults-1);
but as it is giving me a result just not changing with image nor matching the GUI I do not know what the problem is. One thing I considered trying but that I do not know how to do would be to clear the results from process one after I extracted my measurements but as the results in command line are held in some hidden place I’m not sure how to do that.
File.saveString("File,Mean\n",dir[1]+"fibrosis.csv");
for (f=0; f<list.length; f++)
{
path = dir[0]+list[f];
if (!endsWith(path,"/")) open(path);
t=getTitle();
//Process 1 commands
run("Measure");
var1=getResult("Mean",nResults-1);
print(var1);
File.append(t+","+var1,dir[1]+"fibrosis.csv");
// Process2 commands
run("Measure");
updateResults();
var2=getResult("%Area",nResults-1);
print("Fibroris Value" +t+var2);
File.append(t+"Fib"+","+var2,dir[1]+"fibrosis.csv");
}