Posted by
GDC on
Nov 12, 2009; 12:30am
URL: http://imagej.273.s1.nabble.com/Confused-writing-a-macro-tp3690490p3690494.html
Thank you. I think I'm getting it now.
Greg
-----Original Message-----
From: Wayne Rasband <
[hidden email]>
To:
[hidden email]
Sent: Tue, Nov 10, 2009 7:14 pm
Subject: Re: Confused writing a macro
On Nov 10, 2009, at 2:18 PM, GDC wrote:
> Hi Michael
>
> Thanks for your help. I'm still not completely clear on the issue. > Are you saying I need to call another macro named PlotGetValuesDemo > from within the macro I'm trying to write? If so, I don't have this > macro on my machine and i can't find it on the ImageJ download > site. I get an invalid filename if I incorporate the text as you've > described into my macro. i am new to writing my own macros so > please bear with me if my questions are not very sophisticated.
>
> Thanks
> Greg
Here is a macro that adds three line profiles to the Result table and then saves the table as a tab-delimited text file. It is based on the GetProfileExample macro that is linked to from the description of the getProfile() macro function at <
http://rsbweb.nih.gov/ij/developer/macro/functions.html >.
makeLine(1, 90, 318, 90);
profile = getProfile;
record(profile, "y=90");
makeLine(1, 95, 318, 95);
profile = getProfile;
record(profile, "y=95");
makeLine(1, 100, 318, 100);
profile = getProfile;
record(profile, "y=100");
updateResults;
path = getDirectory("home")+"Results.xls";
saveAs("Measurements", path);
function record(profile, label) {
for (i=0; i<profile.length; i++)
setResult(label, i, profile[i]);
}
-wayne
>
>
>
>
>
> -----Original Message-----
> From: Michael Schmid-3 [via ImageJ] <
[hidden email]> >
> To: GDC <
[hidden email]>
> Sent: Tue, Nov 10, 2009 12:52 pm
> Subject: Re: Confused writing a macro
>
>
>
>
>
>
>
>
>
>
>
> Hi Greg,
>
>
> the error message is exact; you cannot use saveAs for saving the list
>
> of points of a Plot window. The PlotGetValuesDemo macro shows you how
>
> to get the values from a plot and print them into the 'Log' window:
>
>
> Plot.getValues(x, y);
>
> for (i=0; i<x.length; i++)
>
> print(x[i], y[i]);
>
>
> Then, you can save the contents of the 'Log' window and close it.
>
>
> Michael
>
> ________________________________________________________________
>
>
> On 10 Nov 2009, at 18:23, GDC wrote:
>
>
>
>> Hello
>
>>
>
>> I couldn't find my answer by using the search function on Nabble so
>
>> i am
>
>> asking here. I am trying to write a macro that will do multiple plot
>
>> profiles in an image. For example i need to get a profile from x=1
>
>> to x=319
>
>> at y=90, 95, 100, and 105 and save the plot in some ascii format.
>
>> When I
>
>> run the macro I have written, i get an error sayin that I need a
>
>> log window
>
>> in order to save txt files. I'm not sure what this means or how to
>
>> fix it.
>
>> Below is the macro I've written
>
>>
>
>> //setTool(4);
>
>> makeLine(1, 90, 318, 90);
>
>>
>
>> run("Plot Profile");
>
>> saveAs("Text", "C:\\Documents and Settings\\ Raw Files\\SC\\ 1b\>> \Row90
>
>> back.txt");
>
>> close();
>
>> makeLine(1, 95, 318, 95);
>
>> run("Plot Profile");
>
>> saveAs("Text", "C:\\Documents and Settings\\ Raw Files\\SC\\ 1b\>> \Row90
>
>> back.txt");
>
>> close();
>
>> makeLine(1, 100, 318, 100);
>
>> run("Plot Profile");
>
>> saveAs("Text", "C:\\Documents and Settings\\ Raw Files\\SC\\ 1b\>> \Row90
>
>> back.txt");
>
>> close();
>
>> :
>
>>
>
>> Any insight would be greatly appreciated.
>
>>
>
>> Thanks
>
>> Greg
>
>
>
>
>
>
>
>
>
>
> View message @
http://n2.nabble.com/Confused-writing-a-macro-tp3981266p3981437.html
>
>
> To unsubscribe from Confused writing a macro, click here.
>
>
>
>
>
>
>
>
>
> --> View this message in context:
http://n2.nabble.com/Confused-writing-a-macro-tp3981266p3982008.html
> Sent from the ImageJ mailing list archive at Nabble.com.