Dialog waiting broken in macros

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

Dialog waiting broken in macros

Olivier Burri
Dear ImageJ List,

It would seem that since the last update or even before that, ImageJ has a bit of trouble with user actions during macro execution.

As an example, I have a macro that prompts the user to make sure everything is OK before proceeding. This usually involves the user rotating the image to make sure it's aligned properly. This worked just fine till the last update.

Now what happens is that if the user makes a rotation while the "waitForUser" dialog it active, this dialog disappears and the macro hangs, apparently still waiting for the user to click OK.

I tried replicating the mistake with a simple waitForUser("") followed by user actions, but that simple one seems to work, so I am annexing the culprit macro.

It's simple, the macro prompts you for a file to open, it should have at least two channels. Makes a rotation on the first channel.

At some point a "Make sure the channels and selection \n are correct and press OK" message pops up. If you run a rotate there (or other commands), the macro stalls and the waitForUser dialog disappears.

It would be great if someone could give me a hand with that.

Best

Oli


macro "Open ZVI Maia" {

                run("Set Measurements...", "  fit limit redirect=None decimal=3");

                open();
                getDimensions(x,y,c,z,t);

                //
                // Blue Green Red Phase

                for(i=1; i<=c; i++) {
                               Stack.setChannel(i);
                               if(i==1) {run("Blue"); }
                               if(i==2) {run("Green"); }
                               if(i==3) {run("Red"); }
                               if(i==4) {run("Grays"); }

                               run("Enhance Contrast", "saturated=0.25");

                }
                run("Make Composite");
                run("Duplicate...", " duplicate channels=1");
                setAutoThreshold("Yen dark");
                run("Convert to Mask");
                name = getTitle();
                run("Options...", "iterations=60 count=3 black edm=Overwrite do=Close");
                run("Fill Holes");
                run("Points from Mask");
                run("Convex Hull");
                run("Measure");
                angle = getResult("Angle",nResults-1);
                close();
                run("Rotate... ", "angle="+(angle)+" grid=1 interpolation=Bilinear enlarge");
                go = getBoolean("Rotate Image 180 degrees?");
                if (go)  {
                               run("Rotate... ", "angle=180 grid=1 interpolation=Bilinear enlarge");
                }
                n= roiManager("count");

                if(n>0) roiManager("Select",0);

                run("Brightness/Contrast...");
                Stack.setDisplayMode("color");
                waitForUser("Make sure the channels and selection \n are correct and press OK");
                Stack.setDisplayMode("composite");
                name = getTitle();
                run("Duplicate...", " duplicate channels");
                name2 = getTitle();
                // Make RGB
                run("Stack to RGB");
                rgbName = getTitle();

                //Split the other images
                selectImage(name2);
                run("Split Channels");

                //Make each an RGB image
                for (i=1;i<=c; i++) {
                               selectImage("C"+i+"-"+name2);

                               run("RGB Color");
                               run("Copy");
                               selectImage(rgbName);
                               run("Add Slice");
                               run("Paste");

                }

                // Assemble the stack for
                run("Make Montage...", "columns="+(c+1)+" rows=1 scale=1.0 border=3 font=12");

                //Set the scale
                run("Scale Bar...", "width=50 height=15 font=18 color=White background=None location=[Lower Left] bold hide");

                rename(name+" Montage");
                run("Tiff...");
                showMessage("Saved!");
                run("Close All");





Olivier Burri
Engineer - Image Processing
& Software Development
EPFL - SV - PTECH - PTBIOP


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html