Posted by
Michael Schmid on
May 29, 2007; 5:24pm
URL: http://imagej.273.s1.nabble.com/IMAGE-SUBSTRACTION-WITH-IMAGE-J-tp3699286p3699289.html
Hi Aryeh,
to find the options for a 'run' command in a macro, the Macro
Recorder is clearly the best choice. You can easily change
the values after recording.
Numeric and string arguments of a dialog box are recorded as
"name=value", where 'name' usually is the first word of the
text left of an input field. For string values (=texts), square
brackets around the value should be used and are essential if
the string contains spaces.
For checkboxes, add their name (without any "=") to put them into
the on (checked) state, and simply don't mention them to put them
into the off (unchecked) state. Again, the name is usually the
first word left of the checkbox (the Macro Recorder will show
you the name).
In your example,
run("Duplicate...", "title=[Substack (5,6)-1] duplicate");
the "Duplicate Entire Stack" checkbox is on, because you have
the word "duplicate" in the options string.
To duplicate only the current slice, use
run("Duplicate...", "title=[Substack (5,6)-1]");
There is one exception: Many ImageJ commands show a dialog
"Process all nnn slices? There is no undo when you select yes"
In these cases, as the Macro Recorder will easily show, add the
word "stack" to the options to run the command on a stack.
Names of input fields and checkboxes should be always converted
to lowercase.
---
Copy and Paste works on single images only, not on stacks.
Either use
run("Duplicate...", "title=[newname] duplicate");
or write a short macro looping over the slices, e.g. to transfer
the contents of the selection from one stack to another stack.
See setSlice() and related methods:
http://rsb.info.nih.gov/ij/developer/macro/functions.html#setSliceMichael
________________________________________________________________
On 28 May 2007, at 21:25, Aryeh Weiss wrote:
> I see from the examples how to pass arguments to ImageJ commands
> which are run from within a macro (as in the ArgumentPassingDemo
> macro). However, I do not know how to find the names of the
> arguments, when they are not recorded by the macro recorder. Fro
> example, the macro recorder records:
> run("Duplicate...", "title=[Substack (5,6)-1] duplicate");
> when I duplicate a stack. However, this is the same regardless of
> whether I select the "duplicate entire stack" checkbox, so I dont
> know how to tell it to duplicate the entire stack in a macro,
> unless I run it interactively.
> Is there a general way to know the argument names for a given command?
>
> In a related question, I want to copy an entire stack and paste it
> somewhere. However, the copy command (Run("Copy")) only copies a
> single slice, while I want the entire stack. Is there an an option
> to Copy which will do this?