Login  Register

get current image filename/directory for macros

Posted by Dan Siegal-Gaskins-2 on Aug 05, 2008; 10:08pm
URL: http://imagej.273.s1.nabble.com/get-current-image-filename-directory-for-macros-tp3695447.html

Hello all,

After a couple of years of playing with ImageJ, I'm only now starting to
write macros.  What I have is a stack of 9 images, and I'd like to:

1. run the Image CorrelationJ plugin on the first slice
2. save the output to a text file
3. skip to the next slice
4. run the Image CorrelationJ plugin
5. go back to step 2 and loop through until the end of the stack

Using the macro recorder, the command for running Image CorrelationJ is:

--------------
run("Image CorrelationJ 1o", "target=filename.tif source=filename.tif
correlation=[Fix slide (Source)] statistic=Average markers=Circle local=1
decimal=2");
--------------

So my first question is, how do I replace filename.tif with the a variable
name of the current active image?  I'm assuming there is some 'get filename'
command that I could run, and then I could assign the result to a variable
that I could use in the above statement.  After that I need to save the
data.  The macro recorder shows this as:

--------------
saveAs("Text", "active directory/foo.bar");
--------------

Similar to my first question, how do I use a variable for the directory
which I can assign the directory to be the current working directory?

Thanks,
Dan