Problem with automatic saves in a macro.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with automatic saves in a macro.

Goldsmith, Noel
Hi,
I am (have) written a macro which selects part of an image and then analyzes
particles and then saves the data file, and then repeats on another part of
the image.
 The macro runs, but saves nothing. No file anywhere that I can find. Also
no errors.
I have worked around the problem for the job at hand by instituting a manual
save at the end of all the analyze particle operations by leaving out clear
in the set measurements dialog. Which in fact is better for my work anyway
but... It should work.

Here is a version that runs but saves nothing.

I am running 1.42g on an Intel Macpro running 10.5.5 or 10.5.6.
This is the macro, cut down to keep it simple.. And I changed the path to
the desktop, as was used in the examples.


xl=10;
wi=0;
yt=0;
for (i=0;i<11; i+=1) {
xl=10+i*34;
wi=34;
yt=0;
directory= "/Users/goldsmin/desktop/";
name="col" +toString(i)+".txt";
path="["+directory+name+"]";
makeRectangle(xl,yt,wi,2048);
run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
show=Nothing clear display include record");
saveAs("measurements", path);
}


If anyone can tell me what stupidity I  am committing I will be grateful.
Thank you.

PS the example macro "ArgumentPassingDemo

// This macro demonstrates how to use string concatenation to
// pass  variables  to commands called using the run() function.
// It creates an image, sets the scale to 150 pixels/mm, rotates
// 25 degrees, and saves in Analyze format. Note that the file
// path must be enclosed in brackets because of the space in
// the image name.

name = "Test Image";
directory = "/Users/wayne/Desktop/";
width = 400;
height = 300;
scale = 150; // 150 pixels/mm
unit = "mm";
angle = 25;
newImage(name, "8-bit ramp", width, height, 1);
run("Set Scale...", "distance="+scale+" known=1 pixel=1 unit="+unit);
run("Arbitrarily...", "interpolate  angle="+angle);
path = "["+ directory +name+"]";
run("Analyze Writer", "save="+path);

Will not finish, it objects about Analyze Writer. Which I couldn't find
anywhere.
I confess to being puzzled.




Noel Goldsmith
Air Vehicles Division
Defence Science and Technology Organisation
506 Lorimer Street Port Melbourne Vic 3207
Ph 03 96267527 Fax 03 96267089
Mobile 0428364003
[hidden email]



IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914.  If you have received this email in error, you are requested to contact the sender and delete the email.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with automatic saves in a macro.

Michael Schmid
Hi Noel,

the square brackets are too much, it should be simply

path=directory+name;
...
saveAs("measurements", path);

You need the square brackets only if the string is part of the  
arguments in a "run" command. There it is a delimiter of a string  
inside the arguments string.
e.g.
run("myPlugin", "size=17 file=[/tmp/file with blanks]");

---

ArgumentPassingDemo macro:

It seems that the "Analyze Writer" was an old plugin that is obsolete  
now.


Michael
________________________________________________________________

On 4 Feb 2009, at 23:02, Goldsmith, Noel wrote:

> Hi,
> I am (have) written a macro which selects part of an image and then  
> analyzes
> particles and then saves the data file, and then repeats on another  
> part of
> the image.
>  The macro runs, but saves nothing. No file anywhere that I can  
> find. Also
> no errors.
> I have worked around the problem for the job at hand by instituting  
> a manual
> save at the end of all the analyze particle operations by leaving  
> out clear
> in the set measurements dialog. Which in fact is better for my work  
> anyway
> but... It should work.
>
> Here is a version that runs but saves nothing.
>
> I am running 1.42g on an Intel Macpro running 10.5.5 or 10.5.6.
> This is the macro, cut down to keep it simple.. And I changed the  
> path to
> the desktop, as was used in the examples.
>
>
> xl=10;
> wi=0;
> yt=0;
> for (i=0;i<11; i+=1) {
> xl=10+i*34;
> wi=34;
> yt=0;
> directory= "/Users/goldsmin/desktop/";
> name="col" +toString(i)+".txt";
> path="["+directory+name+"]";
> makeRectangle(xl,yt,wi,2048);
> run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
> show=Nothing clear display include record");
> saveAs("measurements", path);
> }
>
>
> If anyone can tell me what stupidity I  am committing I will be  
> grateful.
> Thank you.
>
> PS the example macro "ArgumentPassingDemo
>
> // This macro demonstrates how to use string concatenation to
> // pass  variables  to commands called using the run() function.
> // It creates an image, sets the scale to 150 pixels/mm, rotates
> // 25 degrees, and saves in Analyze format. Note that the file
> // path must be enclosed in brackets because of the space in
> // the image name.
>
> name = "Test Image";
> directory = "/Users/wayne/Desktop/";
> width = 400;
> height = 300;
> scale = 150; // 150 pixels/mm
> unit = "mm";
> angle = 25;
> newImage(name, "8-bit ramp", width, height, 1);
> run("Set Scale...", "distance="+scale+" known=1 pixel=1 unit="+unit);
> run("Arbitrarily...", "interpolate  angle="+angle);
> path = "["+ directory +name+"]";
> run("Analyze Writer", "save="+path);
>
> Will not finish, it objects about Analyze Writer. Which I couldn't  
> find
> anywhere.
> I confess to being puzzled.
>
>
>
>
> Noel Goldsmith
> Air Vehicles Division
> Defence Science and Technology Organisation
> 506 Lorimer Street Port Melbourne Vic 3207
> Ph 03 96267527 Fax 03 96267089
> Mobile 0428364003
> [hidden email]
>
>
>
> IMPORTANT: This email remains the property of the Australian  
> Defence Organisation and is subject to the jurisdiction of section  
> 70 of the CRIMES ACT 1914.  If you have received this email in  
> error, you are requested to contact the sender and delete the email.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with automatic saves in a macro.

Gabriel Lapointe
In reply to this post by Goldsmith, Noel
Hi Noel,
you simply forgot the capital M. So, the line should read:

saveAs("Measurements", directory+name);

As said earlier there is no need for the brakets if it's not a string in
a string situation. Plus there is no need for the separate path string,
the 2 string can be concaneted directly inside the saveAs command.

Gabriel

Goldsmith, Noel wrote:

> Hi,
> I am (have) written a macro which selects part of an image and then analyzes
> particles and then saves the data file, and then repeats on another part of
> the image.
>  The macro runs, but saves nothing. No file anywhere that I can find. Also
> no errors.
> I have worked around the problem for the job at hand by instituting a manual
> save at the end of all the analyze particle operations by leaving out clear
> in the set measurements dialog. Which in fact is better for my work anyway
> but... It should work.
>
> Here is a version that runs but saves nothing.
>
> I am running 1.42g on an Intel Macpro running 10.5.5 or 10.5.6.
> This is the macro, cut down to keep it simple.. And I changed the path to
> the desktop, as was used in the examples.
>
>
> xl=10;
> wi=0;
> yt=0;
> for (i=0;i<11; i+=1) {
> xl=10+i*34;
> wi=34;
> yt=0;
> directory= "/Users/goldsmin/desktop/";
> name="col" +toString(i)+".txt";
> path="["+directory+name+"]";
> makeRectangle(xl,yt,wi,2048);
> run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
> show=Nothing clear display include record");
> saveAs("measurements", path);
> }
>
>
> If anyone can tell me what stupidity I  am committing I will be grateful.
> Thank you.
>
> PS the example macro "ArgumentPassingDemo
>
> // This macro demonstrates how to use string concatenation to
> // pass  variables  to commands called using the run() function.
> // It creates an image, sets the scale to 150 pixels/mm, rotates
> // 25 degrees, and saves in Analyze format. Note that the file
> // path must be enclosed in brackets because of the space in
> // the image name.
>
> name = "Test Image";
> directory = "/Users/wayne/Desktop/";
> width = 400;
> height = 300;
> scale = 150; // 150 pixels/mm
> unit = "mm";
> angle = 25;
> newImage(name, "8-bit ramp", width, height, 1);
> run("Set Scale...", "distance="+scale+" known=1 pixel=1 unit="+unit);
> run("Arbitrarily...", "interpolate  angle="+angle);
> path = "["+ directory +name+"]";
> run("Analyze Writer", "save="+path);
>
> Will not finish, it objects about Analyze Writer. Which I couldn't find
> anywhere.
> I confess to being puzzled.
>
>
>
>
> Noel Goldsmith
> Air Vehicles Division
> Defence Science and Technology Organisation
> 506 Lorimer Street Port Melbourne Vic 3207
> Ph 03 96267527 Fax 03 96267089
> Mobile 0428364003
> [hidden email]
>
>
>
> IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914.  If you have received this email in error, you are requested to contact the sender and delete the email.
>