Login  Register

Re: Batch Mode/Active Image Ambiguity

Posted by Gabriel Landini on Mar 12, 2009; 12:39pm
URL: http://imagej.273.s1.nabble.com/Batch-Mode-Active-Image-Ambiguity-tp3693320p3693323.html

> When running the included script with batch mode not set, I get
> "4: active image is  test2" from  the final print statement. This jibes
> with my intuition about what the active image should be at
> this point. But, if I use "setBatchMode(true)", I get
> "4: active image is  test1". Why does using the batch mode cause
> a shift in the active image? Is this correct? This caused me some
> problems until I discovered what was going on and started using
> selectImage() rather than depending on the default active image.

You haven't selected any image inside the batchmode, so it is not using any
and returns the original.

If not using batchmode, I think that IJ must be assigning the active (by
default) to test2 (perhaps by order in the list of windows?).

see:
http://rsb.info.nih.gov/ij/developer/macro/functions.html#S
setBatchMode(arg)
If arg is true, the interpreter enters batch mode and images are not
displayed, allowing the macro to run up to 20 times faster. If arg is false,
exits batch mode and displays the active image in a window. ImageJ exits batch
mode when the macro terminates if there is no setBatchMode(false) call. Note
that a macro should not call setBatchMode(true) more than once.

Apply a SelectImage( string or id); and that will be displayed at the end of
batchmode.
You have to be explicit about which images you are processing using
SelectImage(), otherwise some commands create new results windows that might
get autoselected instead.

Cheers,
G.