macro help

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

macro help

Anil Bagri
hi all,
I have a quick (or perhaps not so quick) question for you.  I am trying
to process (count objects in ) a large batch of jpg files that are all
in the same directory using the following macro:

setAutoThreshold();
//run("Threshold...");
setThreshold(132, 255);
run("Threshold", "thresholded remaining black");
run("Analyze Particles...", "minimum=10 maximum=999999 bins=20
show=Nothing summarize");


but I dont want to run the macro individually on each file in the
directory.  Is there a way to make the macro automatically run on every
file in the folder and put the values in an excel file?  will I have to
write another macro to make that happen.  can anyone help me with this
- it is clearly beyond my coding abilities.
thanks in advance
Anil
Reply | Threaded
Open this post in threaded view
|

Re: macro help

Huang, Judy C
Anil,

This is how I did it except for writing the result to an excel file which I
believe you can use the Excel Plug-In module mentioned in a few of earlier
e-mail.   -Judy



dir = getDirectory("Choose a Directory ");
list = getFileList(dir);
requires("1.34m");
totalFile=list.length;
setBatchMode(true);
for (i=1; i<=totalFile; i++)
{
    open(dir+list[i-1]);
    run("8-bit");
    run("Set Scale...", "distance=236.000 known=20 pixel=1 unit=mm global");
    setThreshold(67, 255);
    makeRectangle(280, 120, 116, 1562);
    fileName =substring(list[i-1],0,lengthOf(list[i-1])-4);
    run("Analyze Particles...", "minimum=100 maximum=999999 bins=20
show=Nothing display summarize");
    save("C:\\ImageJ\\Results\\" + fileName +"R"+i + ".txt");
    setThreshold(67, 133);
    makeRectangle(396, 128, 116, 1562);
   run("Analyze Particles...", "minimum=100 maximum=999999 bins=20
show=Nothing display summarize");
   save("C:\\ImageJ\\Results\\" +fileName+"L"+i + ".txt");
   close();
}
exit();


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Anil
Bagri
Sent: Thursday, September 08, 2005 9:06 PM
To: [hidden email]
Subject: macro help


hi all,
I have a quick (or perhaps not so quick) question for you.  I am trying
to process (count objects in ) a large batch of jpg files that are all
in the same directory using the following macro:

setAutoThreshold();
//run("Threshold...");
setThreshold(132, 255);
run("Threshold", "thresholded remaining black");
run("Analyze Particles...", "minimum=10 maximum=999999 bins=20
show=Nothing summarize");


but I dont want to run the macro individually on each file in the
directory.  Is there a way to make the macro automatically run on every
file in the folder and put the values in an excel file?  will I have to
write another macro to make that happen.  can anyone help me with this
- it is clearly beyond my coding abilities.
thanks in advance
Anil





------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system.
------------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: macro help

Anil Bagri
In reply to this post by Anil Bagri
Hi all,
thanks for the great suggestions.
  I have now gotten the macro to automatically open and count objects
from all images.  I use this macro:

    requires("1.33n");
    dir = getDirectory("Choose a Directory ");
    list = getFileList(dir);
    start = getTime();
    setBatchMode(true); // runs up to 6 times faster
    for (i=0; i<list.length; i++) {
         path = dir+list[i];
         //print(i+"  "+path);
         showProgress(i, list.length);
         open(path);
         setAutoThreshold();
        //run("Threshold...");
        setThreshold(132, 255);
        run("Threshold", "thresholded remaining black");
        run("Analyze Particles...", "minimum=10 maximum=999999 bins=20
        show=Nothing summarize");
         close();
   }
   //print((getTime()-start)/1000);

My question is how do I get it to put the results in an excel file.
I  looked at quite a few macros, but cant identify the commands that
would allow me to do this.
thanks again for all your help.
anil
Reply | Threaded
Open this post in threaded view
|

Re: macro help

Huang, Judy C
In reply to this post by Anil Bagri
Anil,
    This is what I got from one of early discussion regarding to Excel:


path="C:\\....\\.....\\.....\\";
name="file_name";
selectWindow("Results");
run("Excel...", "select...=["+path+name+".xls]");

Or you can look into this:

http://rsb.info.nih.gov/ij/plugins/excel-writer.html

-Judy

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Anil
Bagri
Sent: Friday, September 09, 2005 11:48 AM
To: [hidden email]
Subject: Re: macro help


Hi all,
thanks for the great suggestions.
  I have now gotten the macro to automatically open and count objects
from all images.  I use this macro:

    requires("1.33n");
    dir = getDirectory("Choose a Directory ");
    list = getFileList(dir);
    start = getTime();
    setBatchMode(true); // runs up to 6 times faster
    for (i=0; i<list.length; i++) {
         path = dir+list[i];
         //print(i+"  "+path);
         showProgress(i, list.length);
         open(path);
         setAutoThreshold();
        //run("Threshold...");
        setThreshold(132, 255);
        run("Threshold", "thresholded remaining black");
        run("Analyze Particles...", "minimum=10 maximum=999999 bins=20
        show=Nothing summarize");
         close();
   }
   //print((getTime()-start)/1000);

My question is how do I get it to put the results in an excel file.
I  looked at quite a few macros, but cant identify the commands that
would allow me to do this.
thanks again for all your help.
anil





------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system.
------------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: macro help

Bill Mohler
In reply to this post by Anil Bagri
Dear Anil and others:

Just trying this batch approach myself, and having no luck on a Mac
with v1.34s installed.  Is there and issue with Macros being platform
specific?  I get to point of identifying the folder, but then don't
see any action.

Thanks,
Bill

>Hi all,
>thanks for the great suggestions.
>  I have now gotten the macro to automatically open and count objects
>from all images.  I use this macro:
>
>    requires("1.33n");
>    dir = getDirectory("Choose a Directory ");
>    list = getFileList(dir);
>    start = getTime();
>    setBatchMode(true); // runs up to 6 times faster
>    for (i=0; i<list.length; i++) {
>         path = dir+list[i];
>         //print(i+"  "+path);
>         showProgress(i, list.length);
>         open(path);
>         setAutoThreshold();
> //run("Threshold...");
> setThreshold(132, 255);
> run("Threshold", "thresholded remaining black");
> run("Analyze Particles...", "minimum=10 maximum=999999
>bins=20 show=Nothing summarize");
>         close();
>   }
>   //print((getTime()-start)/1000);
>
>My question is how do I get it to put the results in an excel file.
>I  looked at quite a few macros, but cant identify the commands that
>would allow me to do this.
>thanks again for all your help.
>anil


--
-----------------
William A. Mohler
Assistant Professor
Dept. of Genetics and Developmental Biology
University of Connecticut Health Center
MC-3301
263 Farmington Ave.
Farmington, CT   06030-3301

[hidden email]
Office: (860) 679-1833, room E2056
Mobile: (860) 985-2719
Lab: (860) 679-1834, room E2052
Fax: (860) 760-6140
G&DB dept. ofc.: (860) 679-8350
G&DB dept. fax : (860) 679-8345
http://genetics.uchc.edu/Faculty/Mohler/Mohler.html
Reply | Threaded
Open this post in threaded view
|

Re: macro help

Dutton,Jeff
In reply to this post by Anil Bagri
Hello,

I saw your note on the ImageJ listserver.  

Is this problem on FSBill???

The only thing I think might be a problem is if you have the plain JRE
on the computer and not the JDK.  Maybe the function call (or any
function calls) depend upon the JDK to compile and run.

Maybe???

Jeff

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Mohler,William
Sent: Tuesday, September 20, 2005 12:01 PM
To: [hidden email]
Subject: Re: macro help

Dear Anil and others:

Just trying this batch approach myself, and having no luck on a Mac
with v1.34s installed.  Is there and issue with Macros being platform
specific?  I get to point of identifying the folder, but then don't
see any action.

Thanks,
Bill

>Hi all,
>thanks for the great suggestions.
>  I have now gotten the macro to automatically open and count objects
>from all images.  I use this macro:
>
>    requires("1.33n");
>    dir = getDirectory("Choose a Directory ");
>    list = getFileList(dir);
>    start = getTime();
>    setBatchMode(true); // runs up to 6 times faster
>    for (i=0; i<list.length; i++) {
>         path = dir+list[i];
>         //print(i+"  "+path);
>         showProgress(i, list.length);
>         open(path);
>         setAutoThreshold();
> //run("Threshold...");
> setThreshold(132, 255);
> run("Threshold", "thresholded remaining black");
> run("Analyze Particles...", "minimum=10 maximum=999999
>bins=20 show=Nothing summarize");
>         close();
>   }
>   //print((getTime()-start)/1000);
>
>My question is how do I get it to put the results in an excel file.
>I  looked at quite a few macros, but cant identify the commands that
>would allow me to do this.
>thanks again for all your help.
>anil


--
-----------------
William A. Mohler
Assistant Professor
Dept. of Genetics and Developmental Biology
University of Connecticut Health Center
MC-3301
263 Farmington Ave.
Farmington, CT   06030-3301

[hidden email]
Office: (860) 679-1833, room E2056
Mobile: (860) 985-2719
Lab: (860) 679-1834, room E2052
Fax: (860) 760-6140
G&DB dept. ofc.: (860) 679-8350
G&DB dept. fax : (860) 679-8345
http://genetics.uchc.edu/Faculty/Mohler/Mohler.html
Reply | Threaded
Open this post in threaded view
|

Re: macro help

Bill Mohler
In reply to this post by Anil Bagri
Thanks Jeff-
I think it just turned out to be gremlin characters...

-----Original Message-----

From:  "Dutton,Jeff" <[hidden email]>
Subj:  Re: macro help
Date:  Tue Sep 20, 2005 1:45 pm
Size:  2K
To:  [hidden email]

Hello,

I saw your note on the ImageJ listserver.  

Is this problem on FSBill???

The only thing I think might be a problem is if you have the plain JRE
on the computer and not the JDK.  Maybe the function call (or any
function calls) depend upon the JDK to compile and run.

Maybe???

Jeff

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Mohler,William
Sent: Tuesday, September 20, 2005 12:01 PM
To: [hidden email]
Subject: Re: macro help

Dear Anil and others:

Just trying this batch approach myself, and having no luck on a Mac
with v1.34s installed.  Is there and issue with Macros being platform
specific?  I get to point of identifying the folder, but then don't
see any action.

Thanks,
Bill

>Hi all,
>thanks for the great suggestions.
>  I have now gotten the macro to automatically open and count objects
>from all images.  I use this macro:
>
>    requires("1.33n");
>    dir = getDirectory("Choose a Directory ");
>    list = getFileList(dir);
>    start = getTime();
>    setBatchMode(true); // runs up to 6 times faster
>    for (i=0; i<list.length; i++) {
>         path = dir+list[i];
>         //print(i+"  "+path);
>         showProgress(i, list.length);
>         open(path);
>         setAutoThreshold();
> //run("Threshold...");
> setThreshold(132, 255);
> run("Threshold", "thresholded remaining black");
> run("Analyze Particles...", "minimum=10 maximum=999999
>bins=20 show=Nothing summarize");
>         close();
>   }
>   //print((getTime()-start)/1000);
>
>My question is how do I get it to put the results in an excel file.
>I  looked at quite a few macros, but cant identify the commands that
>would allow me to do this.
>thanks again for all your help.
>anil


--
-----------------
William A. Mohler
Assistant Professor
Dept. of Genetics and Developmental Biology
University of Connecticut Health Center
MC-3301
263 Farmington Ave.
Farmington, CT   06030-3301

[hidden email]
Office: (860) 679-1833, room E2056
Mobile: (860) 985-2719
Lab: (860) 679-1834, room E2052
Fax: (860) 760-6140
G&DB dept. ofc.: (860) 679-8350
G&DB dept. fax : (860) 679-8345
http://genetics.uchc.edu/Faculty/Mohler/Mohler.html


William A. Mohler
Assistant Professor
Dept. of Genetics & Developmental Biology
UConn Health Center
860-679-1833