Macro: Working with Results in Resultstable

Dear Forum,

I wrote a little code to measure structures within an image with the freehand line.
This is working fine.

My question is if there is a possibility to work with the measurements in the Resultstable. Instead of saving every single line in a separate csv file I’d like to combine the measurements in one larger Tabel (like excel).

Right now the procedure is like this:

  1. I draw the line
  2. I press a defined shortcut [1]
  3. I press a different shortcut (s) to save the data.

Is it possible to move/copy the data to a new resultstable with defined rows and collums instead of saving each measurement into a single file?

macro "Messen [1]" {                                        
    run("Add Selection...");
    run("Measure");
    call("ij.gui.ImageWindow.setNextLocation", 50, 50)
    updateResults;
script =                                                    
    "lw = WindowManager.getFrame('Results');\n"+
    "if (lw!=null) {\n"+
    "   lw.setLocation(800,850);\n"+                       
    "   lw.setSize(755, 310)\n"+                           
    "}\n";
  eval("script", script);  
    run("Remove Overlay");
    selectWindow(getTitle());
    wait(80);                                                
    makeLine(0, 0, 0, 0);                                    
}
macro "Schmelz [s]" {                                        
v=getDirectory("image");
x=getSliceNumber();
File.makeDirectory(v + "/Data");
w=v+"\\Data\\";
File.makeDirectory(w + "/01_Schmelz");
z=w+"\\01_Schmelz\\";
path=z;
saveAs("Results", path+"Schmelz_"+x+".txt");
run("Clear Results");
selectWindow(getTitle());
}

I know ImageJ is not meant for that, but maybe its possible :slightly_smiling:.

Thank you and best regards

Tobias

A post was split to a new topic: Setting window location dependent on screen size

Using a scripting language other than ImageJ1 macros, you can create a new ResultsTable instance and populate it with values using its incrementCounter() and addValue() methods. See also these tips on the ImageJ wiki.

2 Likes

Hi Tobias @TMC ,

You could combine List.setMeasurements and creating a table-type window to achieve what you need. see two example macros linked below.

List.setMeasurements example
http://imagej.net/macros/DrawEllipse.txt

List to a custom table
http://imagej.net/macros/DisplayJavaProperties.txt

Cheers,
Kota

2 Likes

Thank you @Kota,

I’ll look into this. It looks promising :slightly_smiling:

Best

Tobias

1 Like