Writing macros

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

Writing macros

sm2300
I got this handy macro from the listserve for overlaying plot profiles

// ---------- Start Macro --------------
// Three Color Overlay Plot of a Line
run("Fluorescent Cells (400K)");
run("Profile Plot Options...", "width=450 height=200 minimum=0
maximum=255 fixed interpolate draw");
makeLine(226, 166, 327, 464);
run("Plot Profile");
run("Invert");
rename("red");
selectWindow("FluorescentCells.tif");
setSlice(2);
run("Plot Profile");
run("Invert");
rename("green");
selectWindow("FluorescentCells.tif");
setSlice(3);
run("Plot Profile");
run("Invert");
rename("blue");
run("Merge Channels...", "red=red green=green blue=blue gray=*None*
create keep");
// ---------- End Macro --------------

But how do I write the macro so that I can do the same thing on multiple image files. So here its opening the sample image FluorescentCells. I know I can just create the macro to start after I've opened the image I want to work on but then what about the line 'selectWindow("FluorescentCells.tif")?

Thanks
Sonya
Reply | Threaded
Open this post in threaded view
|

Re: Writing macros

Nathaniel Ryckman
You are looking for the command:

File.open(path)

The selectWindow command does not open an image. The selectWindow command just brings an image into focus.

This page will be your friend:

http://rsbweb.nih.gov/ij/developer/macro/functions.html

I recommend writing a plugin if your project is going to be complicated at all. The macro language is slowly improving with each version but it still is quite buggy.

sm2300 wrote
I got this handy macro from the listserve for overlaying plot profiles

// ---------- Start Macro --------------
// Three Color Overlay Plot of a Line
run("Fluorescent Cells (400K)");
run("Profile Plot Options...", "width=450 height=200 minimum=0
maximum=255 fixed interpolate draw");
makeLine(226, 166, 327, 464);
run("Plot Profile");
run("Invert");
rename("red");
selectWindow("FluorescentCells.tif");
setSlice(2);
run("Plot Profile");
run("Invert");
rename("green");
selectWindow("FluorescentCells.tif");
setSlice(3);
run("Plot Profile");
run("Invert");
rename("blue");
run("Merge Channels...", "red=red green=green blue=blue gray=*None*
create keep");
// ---------- End Macro --------------

But how do I write the macro so that I can do the same thing on multiple image files. So here its opening the sample image FluorescentCells. I know I can just create the macro to start after I've opened the image I want to work on but then what about the line 'selectWindow("FluorescentCells.tif")?

Thanks
Sonya