Repeat command within a macro

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

Repeat command within a macro

Gareth Howell
Hi

I have recorded this bit of macro to measure the % of total area covered by pixels within a binary image. The image is part of a stack of 23 images that form part of a time series.
How can I modify this to perform the same step through the entire stack?
I realise its a basic question but my scripting is basic to say the least.  Thanks.
Gareth


selectWindow("Result shared pixels");
run("Set Measurements...", "area mean min area_fraction redirect=None decimal=3");
run("Measure");
run("Next Slice [>]");
Reply | Threaded
Open this post in threaded view
|

Re: Repeat command within a macro

Michael Doube
Gareth,

Enclosing your commands in a for loop is all you need to do


selectWindow("Result shared pixels");
run("Set Measurements...", "area mean min area_fraction redirect=None
decimal=3");
for (s = 1; s < nSlices(); s++){
        setSlice(s);
        run("Measure");
}

Check out the macro guide and list of macro commands:
http://rsbweb.nih.gov/ij/developer/index.html
http://rsbweb.nih.gov/ij/developer/macro/functions.html

Michael
Reply | Threaded
Open this post in threaded view
|

Re: Repeat command within a macro

Michael Doube
> for (s = 1; s<  nSlices(); s++){

Whoops - that should be s <= nSlices(), because slice numbers have the
"unique" quality of counting from 1, not 0, so this example would leave
out the last slice!