Macro question

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

Macro question

Christophe CHAMOT
Hello listers,

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.

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");
                        }
                }
        }


--
CHAMOT Christophe
---------------------------------------------------------------------
Plate-Forme de Recherche IFR117
"Imageries des Processus Dynamiques
en Biologie Cellulaire et Biologie du Développement "
Institut Jacques Monod, CNRS, Universités Paris 6 et 7
2, place Jussieu - Tour 43
75251 Paris cedex 05
Tel: 01 44 27 57 84
http://www.ijm.jussieu.fr/
---------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Macro question

Wayne Rasband
> 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");
>                         }
>                 }
>         }
Reply | Threaded
Open this post in threaded view
|

record starts and doWand

Martin du Saire
Hi,

The following macro generates different composite ROI depending on
whether the Particle Analyzer displays Nothing, Masks or Outlines,
even though the XStart, YStart values are the same.   Displaying
Nothing and Masks seems to be equivalent.  Has anyone else encountered this?

Thanks.

Martin

run("Set Measurements...", "redirect=None decimal=3");
run("Analyze Particles...", "minimum=200 maximum=307201 bins=20
show=Outlines display record clear");

for (i=0; i<nResults; i++) {
      x = getResult('XStart', i);
      y = getResult('YStart', i);
      if (i>0) setKeyDown("shift");
      doWand(x,y);
   }