Problem Macro Recording

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

Problem Macro Recording

Adrián Villalba
Dear all,

I am very new to imageJ,
I tried to record a Macro like that:

run("Split Channels");
close();
selectWindow("IC_5.jpg (red)");
close();
selectWindow("IC_5.jpg (green)");
setAutoThreshold("Moments dark");
//run("Threshold...");
setAutoThreshold("Moments dark");
//setThreshold(82, 255);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Close");
run("Erode");
run("Analyze Particles...", "size=200-Infinity show=[Overlay Masks] display
exclude clear summarize in_situ");


But when i try to re-use again, it does not work with other pictures
because of IC_5.jpg error name. I know this is a very basic question. Could
anyone help me? 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
|  
Report Content as Inappropriate

Re: Problem Macro Recording

Philippe CARL
Dear Adrián,
Your code applies only to the specific picture named "IC_5.jpg" (i.e. the one open while you were using the recorder).
Thus in order to generalize your code, just add a:
pictureName = getTitle();
to get the opened picture name and then later use:
selectWindow(pictureName + " (green)");
selectWindow(pictureName + " (red)");
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é : mardi 11 avril 2017 15:54
À : [hidden email]
Objet : Problem Macro Recording

Dear all,

I am very new to imageJ,
I tried to record a Macro like that:

run("Split Channels");
close();
selectWindow("IC_5.jpg (red)");
close();
selectWindow("IC_5.jpg (green)");
setAutoThreshold("Moments dark");
//run("Threshold...");
setAutoThreshold("Moments dark");
//setThreshold(82, 255);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Close");
run("Erode");
run("Analyze Particles...", "size=200-Infinity show=[Overlay Masks] display exclude clear summarize in_situ");


But when i try to re-use again, it does not work with other pictures because of IC_5.jpg error name. I know this is a very basic question. Could anyone help me? 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem Macro Recording

Michael Schmid-3
In reply to this post by Adrián Villalba
Hi Adrián,

you can use something like the following:

   title = getTitle();
   run("Split Channels");
   selectWindow(title+" (blue)");
   close();
   selectWindow(title+" (red)");
   close();
   selectWindow(title+" (green)");
   // process the green channel

Note that '+' serves as string concatenation operator in the macro
language (as it does in Java and Javascript).

For more info on macro programming, see
   https://imagej.nih.gov/ij/developer/index.html
   https://imagej.nih.gov/ij/developer/macro/functions.html

Michael
________________________________________________________________
On 11/04/2017 15:53, Adrián Villalba wrote:

> Dear all,
>
> I am very new to imageJ,
> I tried to record a Macro like that:
>
> run("Split Channels");
> close();
> selectWindow("IC_5.jpg (red)");
> close();
> selectWindow("IC_5.jpg (green)");
> setAutoThreshold("Moments dark");
> //run("Threshold...");
> setAutoThreshold("Moments dark");
> //setThreshold(82, 255);
> setOption("BlackBackground", false);
> run("Convert to Mask");
> run("Close");
> run("Erode");
> run("Analyze Particles...", "size=200-Infinity show=[Overlay Masks] display
> exclude clear summarize in_situ");
>
>
> But when i try to re-use again, it does not work with other pictures
> because of IC_5.jpg error name. I know this is a very basic question. Could
> anyone help me? Thank you in advance!
>

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