Make macro run faster...

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

Make macro run faster...

Guilherme Barbosa
Hello all,

I wrote a macro to scan my image, and perform am FFT in every spot there is signal above a certain threshold. In every spot it is suppose to make several measurements and than analise the results table, do some math and get me angle data, finally it draws a line in a new image for every spot with that certain angle.

I can make that macro run on my opened image, but I can’t make it run in the batch mode to go faster (trying: setBatchMode(true) command). As I am very naive in the programing skills there must be many things that I poorly doing it.

Could someone try to help me make this macro be allowed to do its task in the batch mode without taking the time it takes to run with all the windows opened?

Thank you for your help,

Guilherme Oliveira Barbosa, Ph.D
Postdoctoral Research Scholar
UCSF, Kornberg Lab (Room 214)
555 Mission Bay Blvd. South,
San Francisco, CA, 94158 USA
Phone: 415-910-6919

dir = getDirectory("image");
title=getTitle();
print("z","r","p","value_a","mean_angle","orientation","SD_Angle");
getDisplayedArea(x, y, width, height);
sli=nSlices;
newImage("vector", "8-bit black", 1024, 1024, sli);
lateral=width/32;
vertical=height/32;
lat_min=width;
lower_lim=height;
for(z=1; z<=nSlices; z+=1){
selectWindow("vector");
setSlice(z);
selectWindow(title);
setSlice(z);
for(r=vertical/2; r<lower_lim; r+=vertical){
        for(p=lateral/2; p<lat_min; p+=lateral){
    selectWindow(title);    
        makeRectangle(p-10, r-10, 20, 20);
        getRawStatistics(nPixels, mean, min, max, std, histogram);
        if(max>30){
                for(i=1; i<(lateral*0.75); i+=1) {  
            selectWindow(title);
            run("Select None");        
                        makeRectangle(p-1, r-1, 2, 2);
                        run("Enlarge...", "enlarge=i pixel");
                        run("FFT");
                        rename("ftt");
                        getDisplayedArea(x, y, width, height);
                        a=width/2;
                        b=height/2;
                        //setTool("wand");
                        doWand(a-1, b-1, 50.0, "4-connected");
                        run("Fit Ellipse");
                        run("Measure");
                        close();
                }
                selectWindow("Results");
        total_feretang=0;
        mean=0;
        for(a=0; a<5; a+=1){
            total_feretang=total_feretang+getResult("FeretAngle", a);
        }
        for(b=5; b<nResults; b+=1){
            total_feretang=total_feretang+getResult("FeretAngle", b)-getResult("FeretAngle", b-5);
            mean=total_feretang/5;
            total_var=0;
        for(c=b-5; c<b; c+=1){
            total_var=total_var+((getResult("FeretAngle",c)-mean)*(getResult("FeretAngle",c)-mean));
            variance=total_var/4;
            SD_Angle=sqrt(variance);
            }
            value_a=b;
            mean_angle=mean;
            orientation=mean_angle-90;
        if(SD_Angle<15) {
            value_a=b;
            mean_angle=mean;
            orientation=mean_angle-90;
            run("Clear Results");
            continue;
            }
        }
        run("Clear Results");
        print(z,r,p,value_a,mean_angle,orientation,SD_Angle);
        selectWindow("vector");
        x1 = p;
        y1 = r;
        x2 = p+20*cos(orientation*PI/180);
        y2 = r-20*sin(orientation*PI/180);
        makeArrow(x1, y1, x2, y2, "Headless");
        run("Draw", "slice");  
        }
        }
}
}
selectWindow("Log");
saveAs("Text", dir+"Log_"+title+".txt");
selectWindow("vector");


       











--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Make macro run faster...

Mark Chopping
Hi Guilherme,

Why not just use setBatchMode(true); near the beginning and then
setBatchMode(false); before selectWindow("vector");  ?

That stops all the graphical output; even though the log/Results might
still update it's a lot faster and more convenient than using command-line
batch mode, unless you have a large number of jobs to process in the
background.

Mark

Mark Chopping, Ph.D.
Professor, Department of Earth and Environmental Studies
Director, Ph.D. Program in Environmental Management
Montclair State University, Montclair, NJ 07043
Tel. (973) 655-7384 Fax: (973) 655-4072
http://www.montclair.edu/csam/remote-sensing-lab/
<http://www.montclair.edu/csam/remote-sensing-lab/>[image: It's all here.
Montclair State University.] <http://montclair.edu/>
  <http://above.nasa.gov>
All opinion expressed here is my own and does not represent the views or
policies of Montclair State University, NASA, NJ DEP, NACP, USDA, or AGU.



On Mon, Nov 20, 2017 at 1:48 PM, Guilherme Barbosa <[hidden email]>
wrote:

> Hello all,
>
> I wrote a macro to scan my image, and perform am FFT in every spot there
> is signal above a certain threshold. In every spot it is suppose to make
> several measurements and than analise the results table, do some math and
> get me angle data, finally it draws a line in a new image for every spot
> with that certain angle.
>
> I can make that macro run on my opened image, but I can’t make it run in
> the batch mode to go faster (trying: setBatchMode(true) command). As I am
> very naive in the programing skills there must be many things that I poorly
> doing it.
>
> Could someone try to help me make this macro be allowed to do its task in
> the batch mode without taking the time it takes to run with all the windows
> opened?
>
> Thank you for your help,
>
> Guilherme Oliveira Barbosa, Ph.D
> Postdoctoral Research Scholar
> UCSF, Kornberg Lab (Room 214)
> 555 Mission Bay Blvd. South,
> San Francisco, CA, 94158 USA
> Phone: 415-910-6919
>
> dir = getDirectory("image");
> title=getTitle();
> print("z","r","p","value_a","mean_angle","orientation","SD_Angle");
> getDisplayedArea(x, y, width, height);
> sli=nSlices;
> newImage("vector", "8-bit black", 1024, 1024, sli);
> lateral=width/32;
> vertical=height/32;
> lat_min=width;
> lower_lim=height;
> for(z=1; z<=nSlices; z+=1){
> selectWindow("vector");
> setSlice(z);
> selectWindow(title);
> setSlice(z);
> for(r=vertical/2; r<lower_lim; r+=vertical){
>         for(p=lateral/2; p<lat_min; p+=lateral){
>     selectWindow(title);
>         makeRectangle(p-10, r-10, 20, 20);
>         getRawStatistics(nPixels, mean, min, max, std, histogram);
>         if(max>30){
>                 for(i=1; i<(lateral*0.75); i+=1) {
>             selectWindow(title);
>             run("Select None");
>                         makeRectangle(p-1, r-1, 2, 2);
>                         run("Enlarge...", "enlarge=i pixel");
>                         run("FFT");
>                         rename("ftt");
>                         getDisplayedArea(x, y, width, height);
>                         a=width/2;
>                         b=height/2;
>                         //setTool("wand");
>                         doWand(a-1, b-1, 50.0, "4-connected");
>                         run("Fit Ellipse");
>                         run("Measure");
>                         close();
>                 }
>                 selectWindow("Results");
>         total_feretang=0;
>         mean=0;
>         for(a=0; a<5; a+=1){
>             total_feretang=total_feretang+getResult("FeretAngle", a);
>         }
>         for(b=5; b<nResults; b+=1){
>             total_feretang=total_feretang+getResult("FeretAngle",
> b)-getResult("FeretAngle", b-5);
>             mean=total_feretang/5;
>             total_var=0;
>         for(c=b-5; c<b; c+=1){
>             total_var=total_var+((getResult("FeretAngle",c)-
> mean)*(getResult("FeretAngle",c)-mean));
>             variance=total_var/4;
>             SD_Angle=sqrt(variance);
>             }
>             value_a=b;
>             mean_angle=mean;
>             orientation=mean_angle-90;
>         if(SD_Angle<15) {
>             value_a=b;
>             mean_angle=mean;
>             orientation=mean_angle-90;
>             run("Clear Results");
>             continue;
>             }
>         }
>         run("Clear Results");
>         print(z,r,p,value_a,mean_angle,orientation,SD_Angle);
>         selectWindow("vector");
>         x1 = p;
>         y1 = r;
>         x2 = p+20*cos(orientation*PI/180);
>         y2 = r-20*sin(orientation*PI/180);
>         makeArrow(x1, y1, x2, y2, "Headless");
>         run("Draw", "slice");
>         }
>         }
> }
> }
> selectWindow("Log");
> saveAs("Text", dir+"Log_"+title+".txt");
> selectWindow("vector");
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Make macro run faster...

Guilherme Barbosa
Hi Mark,

If I do that, I will get a message saying that ImageJ needs a selection to fit ellipse. So I am guessing that in batch mode the program does not execute some of the tasks prior to run(“Fit Ellipse”) in this block.

                for(i=1; i<(lateral*0.75); i+=1) {  
            selectWindow(title);
            run("Select None");        
                        makeRectangle(p-1, r-1, 2, 2);
                        run("Enlarge...", "enlarge=i pixel");
                        run("FFT");
                        rename("ftt");
                        getDisplayedArea(x, y, width, height);
                        a=width/2;
                        b=height/2;
                        //setTool("wand");
                        doWand(a-1, b-1, 50.0, "4-connected");
                        run("Fit Ellipse");
                        run("Measure");
                        close();
                }




> On Nov 20, 2017, at 1:35 PM, Mark Chopping <[hidden email]> wrote:
>
> setBatchMode(true)


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Make macro run faster...

Cardone, Giovanni
In reply to this post by Guilherme Barbosa
Hi Guilherme,

you definitely need to run the script in background, as Mark suggested, but first you need to do an important change:
- replace every getDisplayedArea  with the two functions getWidth and getHeight, because in background mode supposedly nothing is displayed;
In addition to it, here other comments:
- the line
    run("Enlarge...", "enlarge=i pixel");
should be either
    run("Enlarge...", "enlarge=&i pixel");
or
    run("Enlarge...", "enlarge="+i+" pixel");
I am surprised that it works in the way you wrote it.
- at the beginning of the script add a line to set the measurements you are interested to, e.g. in your case it could be
   run("Set Measurements...", "area mean standard min feret's kurtosis redirect=None decimal=3");
otherwise it could not run properly on any Fiji installation.

At this point you are ready to run your script in background:
- at the beginning of the script, hide the image under analysis with
  setBatchMode("hide");
- after that, hide all the next images generated during the process with
  setBatchMode(true);
- at the end of the script, show all the remaining images with
setBatchMode("exit and display");

IHTH,
Giovanni


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Guilherme Barbosa
Sent: Montag, 20. November 2017 19:49
To: [hidden email]
Subject: Make macro run faster...

Hello all,

I wrote a macro to scan my image, and perform am FFT in every spot there is signal above a certain threshold. In every spot it is suppose to make several measurements and than analise the results table, do some math and get me angle data, finally it draws a line in a new image for every spot with that certain angle.

I can make that macro run on my opened image, but I can’t make it run in the batch mode to go faster (trying: setBatchMode(true) command). As I am very naive in the programing skills there must be many things that I poorly doing it.

Could someone try to help me make this macro be allowed to do its task in the batch mode without taking the time it takes to run with all the windows opened?

Thank you for your help,

Guilherme Oliveira Barbosa, Ph.D
Postdoctoral Research Scholar
UCSF, Kornberg Lab (Room 214)
555 Mission Bay Blvd. South,
San Francisco, CA, 94158 USA
Phone: 415-910-6919

dir = getDirectory("image");
title=getTitle();
print("z","r","p","value_a","mean_angle","orientation","SD_Angle");
getDisplayedArea(x, y, width, height);
sli=nSlices;
newImage("vector", "8-bit black", 1024, 1024, sli); lateral=width/32; vertical=height/32; lat_min=width; lower_lim=height; for(z=1; z<=nSlices; z+=1){ selectWindow("vector"); setSlice(z); selectWindow(title); setSlice(z); for(r=vertical/2; r<lower_lim; r+=vertical){
        for(p=lateral/2; p<lat_min; p+=lateral){
    selectWindow(title);    
        makeRectangle(p-10, r-10, 20, 20);
        getRawStatistics(nPixels, mean, min, max, std, histogram);
        if(max>30){
                for(i=1; i<(lateral*0.75); i+=1) {  
            selectWindow(title);
            run("Select None");        
                        makeRectangle(p-1, r-1, 2, 2);
                        run("Enlarge...", "enlarge=i pixel");
                        run("FFT");
                        rename("ftt");
                        getDisplayedArea(x, y, width, height);
                        a=width/2;
                        b=height/2;
                        //setTool("wand");
                        doWand(a-1, b-1, 50.0, "4-connected");
                        run("Fit Ellipse");
                        run("Measure");
                        close();
                }
                selectWindow("Results");
        total_feretang=0;
        mean=0;
        for(a=0; a<5; a+=1){
            total_feretang=total_feretang+getResult("FeretAngle", a);
        }
        for(b=5; b<nResults; b+=1){
            total_feretang=total_feretang+getResult("FeretAngle", b)-getResult("FeretAngle", b-5);
            mean=total_feretang/5;
            total_var=0;
        for(c=b-5; c<b; c+=1){
            total_var=total_var+((getResult("FeretAngle",c)-mean)*(getResult("FeretAngle",c)-mean));
            variance=total_var/4;
            SD_Angle=sqrt(variance);
            }
            value_a=b;
            mean_angle=mean;
            orientation=mean_angle-90;
        if(SD_Angle<15) {
            value_a=b;
            mean_angle=mean;
            orientation=mean_angle-90;
            run("Clear Results");
            continue;
            }
        }
        run("Clear Results");
        print(z,r,p,value_a,mean_angle,orientation,SD_Angle);
        selectWindow("vector");
        x1 = p;
        y1 = r;
        x2 = p+20*cos(orientation*PI/180);
        y2 = r-20*sin(orientation*PI/180);
        makeArrow(x1, y1, x2, y2, "Headless");
        run("Draw", "slice");  
        }
        }
}
}
selectWindow("Log");
saveAs("Text", dir+"Log_"+title+".txt"); selectWindow("vector");


       











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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Make macro run faster...

Guilherme Barbosa
WOWW Giovanni,

Thank you very much, I am running the script and it is looking promising. It was a lesson going though this. In order to go batch mode I should not rely on displayed images (makes a lot of sense). I still get the results window and the log window on display getting updated. I guess there is no way to run away from that. But things seems to e running faster already.

Once again thank you very much, Giovanni and Mark

Guilherme

 

> On Nov 21, 2017, at 2:31 AM, Cardone, Giovanni <[hidden email]> wrote:
>
> Hi Guilherme,
>
> you definitely need to run the script in background, as Mark suggested, but first you need to do an important change:
> - replace every getDisplayedArea  with the two functions getWidth and getHeight, because in background mode supposedly nothing is displayed;
> In addition to it, here other comments:
> - the line
>    run("Enlarge...", "enlarge=i pixel");
> should be either
>    run("Enlarge...", "enlarge=&i pixel");
> or
>    run("Enlarge...", "enlarge="+i+" pixel");
> I am surprised that it works in the way you wrote it.
> - at the beginning of the script add a line to set the measurements you are interested to, e.g. in your case it could be
>   run("Set Measurements...", "area mean standard min feret's kurtosis redirect=None decimal=3");
> otherwise it could not run properly on any Fiji installation.
>
> At this point you are ready to run your script in background:
> - at the beginning of the script, hide the image under analysis with
>  setBatchMode("hide");
> - after that, hide all the next images generated during the process with
>  setBatchMode(true);
> - at the end of the script, show all the remaining images with
> setBatchMode("exit and display");
>
> IHTH,
> Giovanni
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Guilherme Barbosa
> Sent: Montag, 20. November 2017 19:49
> To: [hidden email]
> Subject: Make macro run faster...
>
> Hello all,
>
> I wrote a macro to scan my image, and perform am FFT in every spot there is signal above a certain threshold. In every spot it is suppose to make several measurements and than analise the results table, do some math and get me angle data, finally it draws a line in a new image for every spot with that certain angle.
>
> I can make that macro run on my opened image, but I can’t make it run in the batch mode to go faster (trying: setBatchMode(true) command). As I am very naive in the programing skills there must be many things that I poorly doing it.
>
> Could someone try to help me make this macro be allowed to do its task in the batch mode without taking the time it takes to run with all the windows opened?
>
> Thank you for your help,
>
> Guilherme Oliveira Barbosa, Ph.D
> Postdoctoral Research Scholar
> UCSF, Kornberg Lab (Room 214)
> 555 Mission Bay Blvd. South,
> San Francisco, CA, 94158 USA
> Phone: 415-910-6919
>
> dir = getDirectory("image");
> title=getTitle();
> print("z","r","p","value_a","mean_angle","orientation","SD_Angle");
> getDisplayedArea(x, y, width, height);
> sli=nSlices;
> newImage("vector", "8-bit black", 1024, 1024, sli); lateral=width/32; vertical=height/32; lat_min=width; lower_lim=height; for(z=1; z<=nSlices; z+=1){ selectWindow("vector"); setSlice(z); selectWindow(title); setSlice(z); for(r=vertical/2; r<lower_lim; r+=vertical){
> for(p=lateral/2; p<lat_min; p+=lateral){
>    selectWindow(title);    
> makeRectangle(p-10, r-10, 20, 20);
> getRawStatistics(nPixels, mean, min, max, std, histogram);
> if(max>30){
> for(i=1; i<(lateral*0.75); i+=1) {  
>            selectWindow(title);
>            run("Select None");        
> makeRectangle(p-1, r-1, 2, 2);
> run("Enlarge...", "enlarge=i pixel");
> run("FFT");
> rename("ftt");
> getDisplayedArea(x, y, width, height);
> a=width/2;
> b=height/2;
> //setTool("wand");
> doWand(a-1, b-1, 50.0, "4-connected");
> run("Fit Ellipse");
> run("Measure");
> close();
> }
> selectWindow("Results");
>        total_feretang=0;
>        mean=0;
>        for(a=0; a<5; a+=1){
>            total_feretang=total_feretang+getResult("FeretAngle", a);
>        }
>        for(b=5; b<nResults; b+=1){
>            total_feretang=total_feretang+getResult("FeretAngle", b)-getResult("FeretAngle", b-5);
>            mean=total_feretang/5;
>            total_var=0;
>        for(c=b-5; c<b; c+=1){
>            total_var=total_var+((getResult("FeretAngle",c)-mean)*(getResult("FeretAngle",c)-mean));
>            variance=total_var/4;
>            SD_Angle=sqrt(variance);
>            }
>            value_a=b;
>            mean_angle=mean;
>            orientation=mean_angle-90;
>        if(SD_Angle<15) {
>            value_a=b;
>            mean_angle=mean;
>            orientation=mean_angle-90;
>            run("Clear Results");
>            continue;
>            }
>        }
>        run("Clear Results");
>        print(z,r,p,value_a,mean_angle,orientation,SD_Angle);
>        selectWindow("vector");
>        x1 = p;
>        y1 = r;
>        x2 = p+20*cos(orientation*PI/180);
>        y2 = r-20*sin(orientation*PI/180);
>        makeArrow(x1, y1, x2, y2, "Headless");
>        run("Draw", "slice");  
> }
> }
> }
> }
> selectWindow("Log");
> saveAs("Text", dir+"Log_"+title+".txt"); selectWindow("vector");
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Make macro run faster...

Cardone, Giovanni
Hi Guilherme,

actually you could get rid of the Results window completely by using the functions List.setMeasurements and List.getValue(key) (https://imagej.nih.gov/ij/developer/macro/functions.html#List) , which do the same as run("Measure") and getResult("Column", row), but without opening/updating any window. However, in your case you would need to change the logic of the code, since currently it relies on the order results are stored in the Results window: for example you could store measures in arrays, and work with them later.

Giovanni


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Guilherme Barbosa
Sent: Dienstag, 21. November 2017 19:40
To: [hidden email]
Subject: Re: Make macro run faster...

WOWW Giovanni,

Thank you very much, I am running the script and it is looking promising. It was a lesson going though this. In order to go batch mode I should not rely on displayed images (makes a lot of sense). I still get the results window and the log window on display getting updated. I guess there is no way to run away from that. But things seems to e running faster already.

Once again thank you very much, Giovanni and Mark

Guilherme

 

> On Nov 21, 2017, at 2:31 AM, Cardone, Giovanni <[hidden email]> wrote:
>
> Hi Guilherme,
>
> you definitely need to run the script in background, as Mark suggested, but first you need to do an important change:
> - replace every getDisplayedArea  with the two functions getWidth and
> getHeight, because in background mode supposedly nothing is displayed; In addition to it, here other comments:
> - the line
>    run("Enlarge...", "enlarge=i pixel"); should be either
>    run("Enlarge...", "enlarge=&i pixel"); or
>    run("Enlarge...", "enlarge="+i+" pixel"); I am surprised that it
> works in the way you wrote it.
> - at the beginning of the script add a line to set the measurements you are interested to, e.g. in your case it could be
>   run("Set Measurements...", "area mean standard min feret's kurtosis
> redirect=None decimal=3"); otherwise it could not run properly on any Fiji installation.
>
> At this point you are ready to run your script in background:
> - at the beginning of the script, hide the image under analysis with  
> setBatchMode("hide");
> - after that, hide all the next images generated during the process
> with  setBatchMode(true);
> - at the end of the script, show all the remaining images with
> setBatchMode("exit and display");
>
> IHTH,
> Giovanni
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Guilherme Barbosa
> Sent: Montag, 20. November 2017 19:49
> To: [hidden email]
> Subject: Make macro run faster...
>
> Hello all,
>
> I wrote a macro to scan my image, and perform am FFT in every spot there is signal above a certain threshold. In every spot it is suppose to make several measurements and than analise the results table, do some math and get me angle data, finally it draws a line in a new image for every spot with that certain angle.
>
> I can make that macro run on my opened image, but I can’t make it run in the batch mode to go faster (trying: setBatchMode(true) command). As I am very naive in the programing skills there must be many things that I poorly doing it.
>
> Could someone try to help me make this macro be allowed to do its task in the batch mode without taking the time it takes to run with all the windows opened?
>
> Thank you for your help,
>
> Guilherme Oliveira Barbosa, Ph.D
> Postdoctoral Research Scholar
> UCSF, Kornberg Lab (Room 214)
> 555 Mission Bay Blvd. South,
> San Francisco, CA, 94158 USA
> Phone: 415-910-6919
>
> dir = getDirectory("image");
> title=getTitle();
> print("z","r","p","value_a","mean_angle","orientation","SD_Angle");
> getDisplayedArea(x, y, width, height); sli=nSlices; newImage("vector",
> "8-bit black", 1024, 1024, sli); lateral=width/32; vertical=height/32; lat_min=width; lower_lim=height; for(z=1; z<=nSlices; z+=1){ selectWindow("vector"); setSlice(z); selectWindow(title); setSlice(z); for(r=vertical/2; r<lower_lim; r+=vertical){
> for(p=lateral/2; p<lat_min; p+=lateral){
>    selectWindow(title);    
> makeRectangle(p-10, r-10, 20, 20);
> getRawStatistics(nPixels, mean, min, max, std, histogram);
> if(max>30){
> for(i=1; i<(lateral*0.75); i+=1) {  
>            selectWindow(title);
>            run("Select None");        
> makeRectangle(p-1, r-1, 2, 2);
> run("Enlarge...", "enlarge=i pixel");
> run("FFT");
> rename("ftt");
> getDisplayedArea(x, y, width, height);
> a=width/2;
> b=height/2;
> //setTool("wand");
> doWand(a-1, b-1, 50.0, "4-connected");
> run("Fit Ellipse");
> run("Measure");
> close();
> }
> selectWindow("Results");
>        total_feretang=0;
>        mean=0;
>        for(a=0; a<5; a+=1){
>            total_feretang=total_feretang+getResult("FeretAngle", a);
>        }
>        for(b=5; b<nResults; b+=1){
>            total_feretang=total_feretang+getResult("FeretAngle", b)-getResult("FeretAngle", b-5);
>            mean=total_feretang/5;
>            total_var=0;
>        for(c=b-5; c<b; c+=1){
>            total_var=total_var+((getResult("FeretAngle",c)-mean)*(getResult("FeretAngle",c)-mean));
>            variance=total_var/4;
>            SD_Angle=sqrt(variance);
>            }
>            value_a=b;
>            mean_angle=mean;
>            orientation=mean_angle-90;
>        if(SD_Angle<15) {
>            value_a=b;
>            mean_angle=mean;
>            orientation=mean_angle-90;
>            run("Clear Results");
>            continue;
>            }
>        }
>        run("Clear Results");
>        print(z,r,p,value_a,mean_angle,orientation,SD_Angle);
>        selectWindow("vector");
>        x1 = p;
>        y1 = r;
>        x2 = p+20*cos(orientation*PI/180);
>        y2 = r-20*sin(orientation*PI/180);
>        makeArrow(x1, y1, x2, y2, "Headless");
>        run("Draw", "slice");  
> }
> }
> }
> }
> selectWindow("Log");
> saveAs("Text", dir+"Log_"+title+".txt"); selectWindow("vector");
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

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