I have created a macro that generates many different data points in the results window. For each image, a angle, lengths, etc. is generated. Is there a way I can format the column headers in the exported excel results file? For example, I have many different lengths generated in the macro, but they import into the excel file on individual rows with repeating image names. I would like each length in a different column corresponding to the same image name.
This is what I get: Label X Y Angle Length 1 IMG_1227.JPG 285 882 -48.406 714.025 2 IMG_1227.JPG 0 0 0 1003.544 3 IMG_1227.JPG 0 0 0 532 4 IMG_1227.JPG 0 0 0 5623 This is what I want: Label X Y Angle Length1 LengthN LengthTot LengthSeg 1 IMG_1227.JPG 285 882 -48.406 714.025 1003.544 532 5632 It would be ideal to modify the macro I have to do this. 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"); |
Dear Hannah,
On 16.09.2013 12:50 AM, hschn444 wrote: > I have created a macro that generates many different data points in the > results window. For each image, a angle, lengths, etc. is generated. Is > there a way I can format the column headers in the exported excel results > file? For example, I have many different lengths generated in the macro, but > they import into the excel file on individual rows with repeating image > names. I would like each length in a different column corresponding to the > same image name. You can add a column to the current line in the Results window like this: setResult("NameOfNewColumn", nResults-1, value); (see http://imagej.nih.gov/ij/developer/macro/functions.html#setResult ) However, I understand that you get a variable number of length measurements and therefore your number of needed columns would be variable for each line/image. This will be a little cumbersome to implement, and I'd suggest actually keep the measurements one per line. Provided you have unique image names (=Labels), you can group and analyze them much easier using e.g. Excel's PivotTable functions or any more powerful statistical software. If you only need the total length, you can add all your measurements within the macro and only add a "LengthTot" column. Hope that helps, Jan > > This is what I get: > > Label X Y Angle Length > 1 IMG_1227.JPG 285 882 -48.406 714.025 > 2 IMG_1227.JPG 0 0 0 1003.544 > 3 IMG_1227.JPG 0 0 0 532 > 4 IMG_1227.JPG 0 0 0 5623 > This is what I want: > > Label X Y Angle Length1 LengthN LengthTot > LengthSeg > 1 IMG_1227.JPG 285 882 -48.406 714.025 1003.544 532 5632 > > > It would be ideal to modify the macro I have to do this. > > 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"); > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Jan,
I am a little confused on how to use this line of code. Can I put it in after each measurement in the macro? i.e. function angle (input,filename){ open (input + filename); setTool("angle"); waitForUser("Select Angle Points"); run("Set Measurements...", " display redirect=None decimal=3"); run("Measure"); setResult("Angle", nResults-1, value); setTool("multipoint"); waitForUser("Count"); run("Set Measurements...", " display redirect=None decimal=3"); run("Measure"); setResult("Multipoint", nResults-1, value); How do you specify the value of that specific measurement? For each image, I will have 3 length measurements, one angle measurement, and 5 X,Y coordinates. |
Free forum by Nabble | Edit this page |