Re: Help with macro iterating slices of a stack

Posted by CARL Philippe (LBP) on
URL: http://imagej.273.s1.nabble.com/Help-with-macro-iterating-slices-of-a-stack-tp5023279p5023286.html

Dear Pedro,
As I already pointed out, there is either the easy way:
        run("Bat Cochlea Volume");
        setOption("BlackBackground", true);
        run("Set Measurements...", "area display redirect=None decimal=2");
        run("Analyze Particles...", "display clear include summarize add stack");
or the hard way [Quentin Tarantino even said: “There are two ways: my way and the highway.”]
        run("Bat Cochlea Volume");
        setOption("BlackBackground", true);
        run("Set Measurements...", "area display redirect=None decimal=2");
        run("Analyze Particles...", "clear include add stack");
// roiManager("Show None");
        for(i = 0; i != roiManager("count"); i++)
        {
                roiManager("Select", i);
                roiManager("Measure");
        }
Both will give you exactly the same results!
Now if "the rest of the macro will" or needs to "generate a text file for each slice" you can of course add a "call("ij.plugin.frame.RoiManager.getName", index)" inside of the "hard way" "for" loop and work it out from there.
I would alternatively rather use the "easy way" version of the code and then "generate a text file for each slice" by using the getResultString("Column", row) and/or getResult("Column", row) methods of the obtained results table.
From my point of view, this solution is way easier, shorter, gracefuler, cooler,... but in the same time all is relative...
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

----- Le 4 Mai 20, à 1:38, Pedro J Camello [hidden email] a écrit :

Dear Philippe,

You are right that a simpler way is to apply the Analyze particles command to the stack, but at the moment I prefer to get separated ROIs and Results for each slice (the rest of the macro will generate a text file for each slice).

Thanks for your help

Pedro

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

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