Macro recorded in image to stack

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

Macro recorded in image to stack

Adrián Villalba
Dear all,

I have recorded a macro that works fine for single images but when i do
File > Impor sequence and I apply the macro to the stack it gives me
different values than the recorded one used for each single image.

Do you know how can i modify the macro to use it for each image in a stack?
The main reason i want to use the macro in a stack is only to avoid running
the macro individually for each image rather than run the macro one for all
the different images i have.

If it helps, this is the macro:

title = getTitle();
  run("Split Channels");
  selectWindow(title+" (blue)");
  close();
  selectWindow(title+" (red)");
  close();
  selectWindow(title+" (green)");
  // process the green channel;
run("Gaussian Blur...", "sigma=5");


setThreshold(40, 255);

setOption("BlackBackground", false);


run("Convert to Mask");

run("Erode");
run("Analyze Particles...", "size=400-Infinity show=[Overlay Masks] display
exclude clear summarize in_situ");



Thank you in advance,


--

   - Adrián Villalba Felipe.
   https://es.linkedin.com/in/adrianvillalba

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

Re: Macro recorded in image to stack

Michael Schmid
Hi Adrián,

you ave two possibilities for analyzing many images:

(1) Process>Batch>Macro:
Paste your macro there and select the folder of the input files.
If you have many images, make sure that your macro closes all files
including the original one; otherwise you will end up with a large
number of open images; too many open windows can even crash ImageJ under
some operating systems.
To do this, you can add
   run("Close All");
at the end of the macro.

(2) Have all images in a stack (as you suggested); in this case "Split
Channels" will also create stacks. For further commands to process the
whole stack, not only the current slice, add 'stack to the second
argument of the 'run' commands, e.g.
   run("Gaussian Blur...", "sigma=5 stack");
   run("Analyze Particles...", "size=400-Infinity exclude clear
summarize stack");

'run' commands that do not have a second argument will usually process
the full stack if you add a second "stack" argument, e.g.
   run("Convert to Mask", "stack");

Michael
________________________________________________________________
On 12/04/2017 15:23, Adrián Villalba wrote:

> Dear all,
>
> I have recorded a macro that works fine for single images but when i do
> File > Impor sequence and I apply the macro to the stack it gives me
> different values than the recorded one used for each single image.
>
> Do you know how can i modify the macro to use it for each image in a stack?
> The main reason i want to use the macro in a stack is only to avoid running
> the macro individually for each image rather than run the macro one for all
> the different images i have.
>
> If it helps, this is the macro:
>
> title = getTitle();
>   run("Split Channels");
>   selectWindow(title+" (blue)");
>   close();
>   selectWindow(title+" (red)");
>   close();
>   selectWindow(title+" (green)");
>   // process the green channel;
> run("Gaussian Blur...", "sigma=5");
>
>
> setThreshold(40, 255);
>
> setOption("BlackBackground", false);
>
>
> run("Convert to Mask");
>
> run("Erode");
> run("Analyze Particles...", "size=400-Infinity show=[Overlay Masks] display
> exclude clear summarize in_situ");
>
>
>
> Thank you in advance,
>
>

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

Re: Macro recorded in image to stack

CARL Philippe (LBP)
In reply to this post by Adrián Villalba
Dear Adrián,
The following modification of your macro deals with slices features:

run("Organ of Corti (2.8M, 4D stack)");
run("RGB Color", "slices");
title = getTitle();
run("Split Channels");
selectWindow(title+" (blue)");
close();
selectWindow(title+" (red)");
close();
selectWindow(title+" (green)");
// process the green channel;
getDimensions(width, height, channels, slices, frames);
for(n = 1; n != slices + 1; n++)
{
        run("Make Substack...", "  slices=" + n);
        run("Gaussian Blur...", "sigma=5");
        setThreshold(40, 255);
        setOption("BlackBackground", false);
        run("Convert to Mask");
        run("Erode");
        run("Analyze Particles...", "size=400-Infinity show=[Overlay Masks] display exclude clear summarize in_situ");
        close();
}

My best regards,
Philippe

Philippe CARL
Laboratoire de Biophotonique et Pharmacologie
UMR 7213 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

-----Message d'origine-----
De : ImageJ Interest Group [mailto:[hidden email]] De la part de Adrián Villalba
Envoyé : mercredi 12 avril 2017 15:23
À : [hidden email]
Objet : Macro recorded in image to stack

Dear all,

I have recorded a macro that works fine for single images but when i do File > Impor sequence and I apply the macro to the stack it gives me different values than the recorded one used for each single image.

Do you know how can i modify the macro to use it for each image in a stack?
The main reason i want to use the macro in a stack is only to avoid running the macro individually for each image rather than run the macro one for all the different images i have.

If it helps, this is the macro:

title = getTitle();
  run("Split Channels");
  selectWindow(title+" (blue)");
  close();
  selectWindow(title+" (red)");
  close();
  selectWindow(title+" (green)");
  // process the green channel;
run("Gaussian Blur...", "sigma=5");


setThreshold(40, 255);

setOption("BlackBackground", false);


run("Convert to Mask");

run("Erode");
run("Analyze Particles...", "size=400-Infinity show=[Overlay Masks] display exclude clear summarize in_situ");



Thank you in advance,


--

   - Adrián Villalba Felipe.
   https://es.linkedin.com/in/adrianvillalba

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

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