Login  Register

Re: Help needed: Macro to save plot profile data as text

Posted by Peterbauer Thomas on Apr 26, 2015; 7:05pm
URL: http://imagej.273.s1.nabble.com/Help-needed-Macro-to-save-plot-profile-data-as-text-tp5012614p5012615.html

On 2015-04-26 18:21, Silas Kraus wrote:

> I am using ImageJ to make linescans over Nanoparticles. As I have a lot
> of images, I wanted to create a macro that automates the process a bit.
> After manually drawing a line, I want the macro to create a plot profile
> and save the data as text in a file. So far, I have:
>
> run("Plot Profile");
> saveAs("Text", "/path/to/file/Values.txt");
>
> The plot profile is created, but then I get an error message stating
> that a TextWindow is needed. I searched the manual and the web for
> several hours, but found nothing. Someone else on this mailing list also
> had this problem, but never got an answer.
> http://imagej.1557.x6.nabble.com/macro-script-to-save-radial-profile-plot-data-td5000012.html

You are trying to save the plot, not the values. You have to get the
values into a results table:

run("Clear Results");
profile = getProfile();
for (i=0; i<profile.length; i++) {
    setResult("Value", i, profile[i]);
}
updateResults;
saveAs("results","/path/to/file");

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