Login  Register

Re: Macro question

Posted by Wayne Rasband on Sep 22, 2005; 6:58pm
URL: http://imagej.273.s1.nabble.com/Macro-question-tp3704801p3704802.html

> I've a question about macro. I made a macro to count the
> integrated density of fluorescence in green stack based on a
> binary threshold of an other color. I thought I'll be able
> to catch the different regions with a wand on the binary
> image. And it works !!! On a single image. But if I put this
> macro in a "for" loop to process stacks, it's nonsense !
>
> Just a clue, if I comment the "doWand" command, all the
> slices are processed. (I work on linux, ImageJ 1.35b, java
> 1.6.0-ea but I tried with older versions -1.33- under win
> XP).Any idea is welcome. Thanks.

With ImageJ 1.35d and later you can do this without a macro by enabling
redirected sampling.

   1. Set the green stack as the "Redirect To" image in Analyze>Set
Measurements.
   2. Select the binary stack.
   3. Run the particle analyzer and click "Yes" in the "Process Stack?"
dialog.

-wayne

> here's the code :
>
>
> selectWindow("bleu.tif-copy");
> run("Fill Holes", "stack");
> for (i=1; i<=nSlices; i++){
>         selectWindow("bleu.tif-copy");
>         setSlice(i);
>         nResAvant=nResults;
>         run("Analyze Particles...", "minimum=25 maximum=999999 bins=2
> show=Nothing display exclude slice");
>         nResApres=nResults;
>         nRes=nResApres-nResAvant;
>         if (nRes != 0){
>                 for (j=0; j<nRes; j++){
>                         indice=nResAvant+j;
>                         centX=getResult("X", indice);
>                         centY=getResult("Y", indice);
>                         setTool(8);
>                         doWand(centX, centY);
>                         selectWindow("vert.tif");
>                         setSlice(i);
>                         run("Restore Selection");
>                         run("Measure");
>                         }
>                 }
>         }