Login  Register

Re: Using the BAR tool in a macro...writing

Posted by Tiago Ferreira-2 on Apr 17, 2015; 4:34am
URL: http://imagej.273.s1.nabble.com/Using-the-BAR-tool-in-a-macro-writing-tp5012501p5012511.html

Dear Ethan,

Cohen, Ethan D <Ethan.Cohen@...> writes:

> Using Fiji, I can run the BAR tool find Peaks tool from the macro recorder,
> and find 1-D peaks. This executes fine in ImageJ macro language..
>
> However, the macro recorder does not pick up pressing the "List" or "Save"
> buttons. So I cannot see the arguments passed.
>
> Q1: Could somebody provide an example of ImageJ macro code with BAR Find Peaks
> that some how accesses these SAVE/LIST buttons?
>
>
[Re-posting to the list: For whatever reason previous message went astray]

I just pushed an updated version that includes a "List values" option, that will
display the  Plot's table[1]. To save it programmatically, you can append the
following to your macro:

    selectWindow("Plot Values");
    saveAs("Results", "Path/to/Output/Directory/Plot Values.csv");
    run("Close");

In case you need to access tables from other Plot Windows:
The option to display the data table for _ALL_ IJ plots is set in 'Edit>Options>
Profile Plot Options' ("List values" checkbox). So, it can be set using the Macro
recorder. Here is an example:

// Set the "PlotWindow.listValues" option using Edit>Options>Profile Plot Options
run("Profile Plot Options...",
    "width=450 height=200 minimum=0 maximum=0 list interpolate");

// Generate your plot. The plot table will be displayed
run("Find Peaks",
    "min._peak_amplitude=20 min._peak_distance=0 min._value=NaN max._value=NaN");

// Save the plot's data table
selectWindow("Plot Values");
saveAs("Results", "/Path/to/Output/Directory/Plot Values.csv");

// Unset the "PlotWindow.listValues" option so it won't affect future plots.
// Note the omission of the keyword "list"
run("Profile Plot Options...",
    "width=450 height=200 minimum=0 maximum=0 interpolate");


Again, this should work for IJ generated plot.
-tiago

[1] https://github.com/tferr/Scripts/commit/ca5fe4a

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html