Login  Register

Re: question - analyze line graph macro

Posted by NabbleRay on Nov 28, 2011; 7:39pm
URL: http://imagej.273.s1.nabble.com/question-analyze-line-graph-macro-tp3682425p3682427.html

Wayne Rasband wrote
On May 25, 2007, at 3:07 PM, David Judd wrote:

> Hi,
>
> I'm trying to create a macro that will call Analyze Line Graph.  
> This works
> fine up to a point, but I can't figure out how to save the results.
> Specifically, run("Analyze Line Graph"); works fine, bringing up a  
> window
> with three buttons - List, Save, and Copy.  However, there doesn't  
> seem to
> be a macro command that will allow me to press any of those  
> buttons, or by
> any other method access the text data I've just taken from the image.
>
> Anybody have a fix?
>
> Thanks!
>
> -David

Here is a macro that runs Analyze>Tools>Analyze Line Graph and saves  
the results in the users home directory. The trick that makes it work  
is enabling the "Auto-close" and "List Values" options in the  
Edit>Options>Profile Plot Options.

   run("Profile Plot Options...",
     "width=450 height=200 auto-close list interpolate draw");
   run("Analyze Line Graph");
   selectWindow("Plot Values");
   values = getInfo();
   run("Close");
   f = File.open(getDirectory("home")+"results.txt");
   print(f, values);

-wayne
Sorry to dredge up such an old post, but I just had to deal with this problem myself and this solution came up on a Google search. I think there is a more direct solution, and I feel like it might benefit future Googlers:

run("Analyze Line Graph");
Plot.getValues(x,y);

This sticks the x and y values into the variables x and y... you can then do with them what you will.