Login  Register

Re: Batch Mode/Active Image Ambiguity

Posted by Wayne Rasband on Mar 12, 2009; 2:34pm
URL: http://imagej.273.s1.nabble.com/Batch-Mode-Active-Image-Ambiguity-tp3693320p3693321.html

On Mar 11, 2009, at 4:27 PM, David William Webster wrote:

> 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.

Switch to batch mode before opening any images and the macro will work
as expected. In batch mode there are separate lists for images that are
displayed and images that are not displayed and the list of displayed
images has priority.

    setBatchMode(true);
    newImage("test1", "32-bit", 101, 101, 1);
    print("1: active image is ", getTitle());
    run("Duplicate...","title=test2");
    print("2: active image is ", getTitle());
    run("Duplicate...","title=test3");
    print("3: active image is ", getTitle());
    close();
    print("4: active image is ", getTitle());

-wayne


> macro batchtest3 {
>
> newImage("test1", "32-bit", 101, 101, 1);
> //setBatchMode(true);
> print("1: active image is ",getTitle());
> img2="test2"; run("Duplicate...","title="+img2);
> print("2: active image is ",getTitle());
> img3="test3"; run("Duplicate...","title="+img3);
> print("3: active image is ",getTitle());
> selectImage(img3); close();
> print("4: active image is ",getTitle());
>
> } //End macro main
>
> David Webster
>
>
>