Batchmode questions

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

Batchmode questions

vischer
Hello List members,

below I include 4 macros to illustrate the following questions:

a) in macro [F1], I toggle batchMode to visualize the process ("Invert") only while loop==2. Here it works well; can I arbitrarily switch batchmode on and off? Doesn't this conflict with the suggestion that batchmode should be called only once in a macro?

b) When choosing macro [F2] (for preparation), then [F3] and [F4], speed differs by factor ~4,  although [F3] and [F4] both run in batch mode. What is the reason for this?

c) looking into the code of Interpreter.java, I find:
        static Vector imageTable; // images opened in batch mode
Is there somewhere more explanation about the meaning of this vector and how it is populated?

Norbert Vischer


output:
=======

-- macro F1:
loop= 1  time= 7
loop= 2  time= 3424
loop= 3  time= 5

-- macro F3:
time [sec] =  5.7

-- macro F4:
time [sec] =  1.5







var path = getDirectory("temp") + "myStack.tif";

macro "Alternate Batch Test [F1]"{
        run("Close All");
        print("\\Clear");
        print("-- macro 1:");
        run("Blobs (25K)");
        run("Blobs (25K)");
       
        for (loop = 1; loop <=3; loop++){
                setBatchMode(loop != 2);
                time = getTime;
                for (jj = 1; jj < 10; jj++){
                        selectImage(1);
                        run("Invert");
                        selectImage(2);
                        run("Invert");
                }
                time1 = getTime - time;
                print("loop=", loop, " time=", time1);
        }
        selectWindow("Log");
}

macro "Create and Save demo stack [F2]"{
        newImage("myStack.tif", "8-bit Black", 700, 70, 12);
        for (x = 1; x <= 12; x++){
                setSlice(x);
                makeOval(x*40, 20, 10, 10);
                run("Invert", "slice");
        }
        run("Select None");
        run("Gaussian Blur...", "sigma=3 stack");
        path = getDirectory("temp")+ "myStack.tif";
        saveAs("Tiff", path);
        wait(200);
        run("Close All");
}


macro "Slow [F3]"{
        print("-- macro 3:");
        run("TIFF Virtual Stack...", "open=" + path);
        setBatchMode(true);
        testMaxima();
}


macro "Fast [F4]"{
        print("-- macro 4:");
        setBatchMode(true);
        run("TIFF Virtual Stack...", "open=" + path);
        testMaxima();
}



function testMaxima(){
        time = getTime;
        for (count = 1; count < 500; count++){
                setSlice(count %12 + 1);
                run("Find Maxima...", "noise=10 output=[Point Selection]");
        }
        print("time [sec] = ", d2s((getTime - time)/1000, 1) );
        selectWindow("Log");
}
Reply | Threaded
Open this post in threaded view
|

Re: Batchmode questions

Michael Schmid
Hi Norbert,

maybe a partial answer to your questions:

(a) arbitrarily switching BatchMode on/off: If you switch BatchMode off,
images opened or created in BatchMode will be lost.

(b) Find Maxima faster on a virtual stack opened in BatchMode: This is
funny, indeed; I am pretty sure that the MaximumFinder is not responsible
but rather switching between slices of the Virtual Stack. I have had a
look at FileInfoVirtualStack.java, which opens the files of the virtual
stack, but found nothing obvious there.

(c) ImageTable in Interpreter.java: This list is supplements the table of
images in the WindowManager

Michael
__________________________________________________________________

On Fri, August 19, 2011 23:15, Norbert Vischer wrote:

> Hello List members,
>
> below I include 4 macros to illustrate the following questions:
>
> a) in macro [F1], I toggle batchMode to visualize the process ("Invert")
> only while loop==2. Here it works well; can I arbitrarily switch batchmode
> on and off? Doesn't this conflict with the suggestion that batchmode
> should be called only once in a macro?
>
> b) When choosing macro [F2] (for preparation), then [F3] and [F4], speed
> differs by factor ~4,  although [F3] and [F4] both run in batch mode. What
> is the reason for this?
>
> c) looking into the code of Interpreter.java, I find:
> static Vector imageTable; // images opened in batch mode
> Is there somewhere more explanation about the meaning of this vector and
> how it is populated?
>
> Norbert Vischer
>
>
> output:
> =======
>
> -- macro F1:
> loop= 1  time= 7
> loop= 2  time= 3424
> loop= 3  time= 5
>
> -- macro F3:
> time [sec] =  5.7
>
> -- macro F4:
> time [sec] =  1.5
>
>
>
>
>
>
>
> var path = getDirectory("temp") + "myStack.tif";
>
> macro "Alternate Batch Test [F1]"{
> run("Close All");
> print("\\Clear");
> print("-- macro 1:");
> run("Blobs (25K)");
> run("Blobs (25K)");
>
> for (loop = 1; loop <=3; loop++){
> setBatchMode(loop != 2);
> time = getTime;
> for (jj = 1; jj < 10; jj++){
> selectImage(1);
> run("Invert");
> selectImage(2);
> run("Invert");
> }
> time1 = getTime - time;
> print("loop=", loop, " time=", time1);
> }
> selectWindow("Log");
> }
>
> macro "Create and Save demo stack [F2]"{
> newImage("myStack.tif", "8-bit Black", 700, 70, 12);
> for (x = 1; x <= 12; x++){
> setSlice(x);
> makeOval(x*40, 20, 10, 10);
> run("Invert", "slice");
> }
> run("Select None");
> run("Gaussian Blur...", "sigma=3 stack");
> path = getDirectory("temp")+ "myStack.tif";
> saveAs("Tiff", path);
> wait(200);
> run("Close All");
> }
>
>
> macro "Slow [F3]"{
> print("-- macro 3:");
> run("TIFF Virtual Stack...", "open=" + path);
> setBatchMode(true);
> testMaxima();
> }
>
>
> macro "Fast [F4]"{
> print("-- macro 4:");
> setBatchMode(true);
> run("TIFF Virtual Stack...", "open=" + path);
> testMaxima();
> }
>
>
>
> function testMaxima(){
> time = getTime;
> for (count = 1; count < 500; count++){
> setSlice(count %12 + 1);
> run("Find Maxima...", "noise=10 output=[Point Selection]");
> }
> print("time [sec] = ", d2s((getTime - time)/1000, 1) );
> selectWindow("Log");
> }