Saving log and results files in one excel document with macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Saving log and results files in one excel document with macro

hschn444
This post was updated on .
Hello,

I am new to imagej. I have created a macro that generates results both in the log and results pages.  I need a macro that saves both the results and log files into one big excel file and is organized by image name.

    input=getDirectory("Choose Source Directory ");

list = getFileList(input);
for (i = 0; i < list.length; i++)
        rootangle(input, list[i]);

function angle (input,filename){
    open (input + filename);
setTool("angle");
for (i = 0; i < 5; i++){
waitForUser("Select Angle Points");
run("Set Measurements...", "  display redirect=None decimal=3");
//run("Measure");
}

setTool("multipoint");
waitForUser("Count");
run("Set Measurements...", "  display redirect=None decimal=3");
run("Measure");
}

setTool("line");
waitForUser("Measure");
run("Set Measurements...", "  display redirect=None decimal=3");
run("Measure");
}

setTool("freehand");
waitForUser("Distance");
run("Set Measurements...", "  display redirect=None decimal=3");
run("Measure");
}


setTool("polyline");
waitForUser("Draw");
    run("Fit Spline", "straighten");
    getSelectionCoordinates(x, y);
     for (i=0; i<x.length; i++)
         print(i+" "+x[i]+" "+y[i]);
}

   dir=getDirectory("image");
   name = "Results";
   index = lastIndexOf(name, "\\");
   if (index!=-1) name = substring(name, 0, index);
   name = name + ".xls"; ///can change xls to csv, txt, etc.
   saveAs("Measurements", dir+name);

close();
}
run("Clear Results");

In this macro the polyline generates many many x,y coordinates for each image that may be bulky for the excel file. These coordinates can be listed on one line in the results excel file.

In addition, the angle macro function measures five different angles on each image. Is there a way I can label the data points generated 1-5 in the excel file and have this count start over for each image? Currently, the count is continuous between images.