Login  Register

Re: RoiManager "Combine"

Posted by Wayne Rasband on Aug 08, 2006; 2:50pm
URL: http://imagej.273.s1.nabble.com/RoiManager-Combine-tp3701796p3701799.html

The roiManager("select", index) function selects one ROI at a time. As
a workaround, use setKeyDown("shift") to combine the ROIs:

   // combine the first two ROIs and measure
   requires("1.37i");
   roiManager("select", 0);
   setKeyDown("shift");
   roiManager("select", 1);
   setKeyDown("none");
   run("Measure");

Note that there is a bug in the ROI Manager "Combine" function that
causes it to combine all the ROIs when only one is selection. This is
fixed in ImageJ 1.37m.

-wayne


> Ah!  Thanks.  I folled myself into thinking that "Combine" would
> replace the two automatically and "Add" - but that would be too
> destructive.
>
> Within a macro I can get the two to combine and be added, I can delete
> the original two, but when I select the last element to measure it
> selects all of the ROIs.  This is different than if I manually combine
> add and measure the two.
>
> Here is the example I am using...
>
> // RoiManagerAddParticles2
> // This macro demonstrates how to add particle analyzer
> // outlines to the ROI Manager. Note that doWand() may
> // not work reliably unless the objects being traced
> // have been highlighted in red using setThreshold().
> //Nothing clear record
>   requires("1.33f");
>   run("Blobs (25K)");
>   setThreshold(125, 248);
>   run("Analyze Particles...", "minimum=1 maximum=999999 bins=20 show
> =Nothing display clear record");
>   for (i=0; i<nResults; i++) {
>       x = getResult('XStart', i);
>       y = getResult('YStart', i);
>       doWand(x,y);
>       roiManager("add");
>   }
>
>
> run("Record...");
>
> print("Count after Analyze: " + roiManager("Count"));
>
> // select 1 and 2 to combine - add them as a new ROI
>
> roiManager("Deselect");
> roiManager("Select", 1);
> roiManager("Select", 2);
> roiManager("Combine");
> roiManager("Add");
> print("Count after Combine and Add: " + roiManager("Count"));
>
> // now remove 1 and 2  (in reverse order)
>
> roiManager("Deselect");
> roiManager("Select", 2);
> roiManager("delete");
> print("Count after first deletion: " + roiManager("Count"));
> roiManager("Select",1);
> roiManager("delete");
> print("Count after first deletion: " + roiManager("Count"));
>
> // finally, select the last element and measure that
>
> roiManager("Deselect");
> n = roiManager("count");
> print("Count at end: " + n);
> lastIndex = n-1;
> print("Index to select and measure: " + lastIndex);
> roiManager("Select",lastIndex);
> run("Measure");
>