Re: Problem with ROI Manager in BatchMode

Posted by Rasband, Wayne (NIH/NIMH) [E] on
URL: http://imagej.273.s1.nabble.com/Re-Problem-with-ROI-Manager-in-BatchMode-tp3682423p3682424.html

On Nov 28, 2011, at 8:15 AM, Winfried Wurm wrote:

> Hello,
> after a long Time I am now able to reproduce the error with a simple code. I create two Stacks  "A" & "B" with 3 Slices. Then I draw a diffrent object in each Slice of "A". At the next step I select each Object in "A" with doWand and add it to the roiManager. At last I select every ROI and draw it in "B". So Image "A" and "B" should be exact copys of each other.
>
> So far no Problem. But if I duplicate "A", make a selection in "A-1" and do something with it, like fill or enlarge, before I add the selections of "A" to the roiManager and then Enlarge the selections in the roi manager, the wrong Selections are drawn to "B".
> This error only occurs if I Enlarge the selections from the ROI Manager and do something with a selection in a third Image before. If I do just one of this two things, or the batchmode is turned off, nothing happens.

The 1.46b daily build fixes a batch mode macro bug that could cause run("Restore Selection") to fail. Your macro was failing because it uses the Enlarge command, which is implemented by a macro that uses run("Restore Selection").

-wayne

> Here the code:
>
> macro "batchmodetest"
> {
>     setBatchMode(true);                                        //The macro works fine if BatchMode is turned off
>     newImage("A", "8-bit Black", 400, 400, 3);
>     newImage("B", "8-bit Black", 400, 400, 3);
>     selectWindow("A");
>     makeRectangle(121, 132, 49, 43);
>     run("Fill", "slice");
>     setSlice(2);
>     run("Select All");
>     run("Fill", "slice");
>     setSlice(3);
>     makeOval(121, 132, 127, 113);
>     run("Fill", "slice");
>     run("Select None");
>    
>     run("Duplicate...", "title=A-1 duplicate range=1-3");
>     makeRectangle(5, 5, 49, 43);
>     run("Fill", "slice");                                //If this and Enlarge in Line 40 is called the Error occurs.
>                                                         //If one of them is turned off it works
>
>     roiManager("reset");
>     selectWindow("A");
>     setSlice(1);
>     doWand(121,132)
>     roiManager("Add");
>     setSlice(2);
>     doWand(121,132)
>     roiManager("Add");
>     setSlice(3);
>     doWand(121,132)
>     roiManager("Add");
>    
>     selectWindow("B");
>     m=(roiManager("count")-1);
>                                
>     for(r=0;r<=m;r++)
>     {                                
>         roiManager("deselect");
>         roiManager("select",r);
>
>         run("Enlarge...", "enlarge=10");                         // This is the enlarge that makes the error
>            
>         run("Fill", "slice");                                                            
>     }
>     setBatchMode("exit and display");
> }