Login  Register

Re: RoiManager "Combine"

Posted by Ben.BigHair on Aug 21, 2006; 4:11pm
URL: http://imagej.273.s1.nabble.com/RoiManager-Combine-tp3701796p3701800.html

Wayne Rasband wrote:

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

Hello again,

I used the above quite successfully to combine ROIs ... until now.  I am
using ImageJ 1.37p on Max OSX.  The setDownKey("shift") doesn't appear
to work as only the last selected ROI is selected.

I have appended the macro I adapted from the example macro
"RoiManagerAddParticles.txt"   Here is the relevant loop where I use the
setKeyDown("shift") command. This doesn't appear to select all of the
ROIs - but see that "blobs.gif" shows all of the outlines.  Anyway, a
call to roiManager("combine") causes an error with the message "More
than one item must be selected, or none."

   roiManager("select",0);      
   for (i=1; i<roiManager("count"); i++){
    setKeyDown("shift");
            roiManager("select", i);
            setKeyDown("none");
   }



I have also tried it with the setKeyDown() calls are on the outside of
the loop, as shown below, but with similar results, *except* that in
"blobs.gif" only the last item is outlined.

     //select all of the Rois
   roiManager("select",0);      
   setKeyDown("shift");
   for (i=1; i<roiManager("count"); i++){
                roiManager("select", i);
   }
   setKeyDown("none");


Could this be a bug in the setKeyDown() or roiManager("combine")
commands?  Or do I have something out of proper sequence?

Thanks!
BEn


****BEGIN

// ImageJ Macro
// RoiManagerAddParticles
// 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);
   roiManager("reset");
   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");
   }

   //select all of the Rois
   roiManager("select",0);      
   for (i=1; i<roiManager("count"); i++){
    setKeyDown("shift");
            roiManager("select", i);
            setKeyDown("none");
   }
   showMessage("All should be selected in ROI Manager now - but they
aren't (except in 'blobs.gif'!)");
   //  roiManager("combine");
  //  roiManager("add");

   roiManager("deselect");
     //select all of the Rois
   roiManager("select",0);      
   setKeyDown("shift");
   for (i=1; i<roiManager("count"); i++){
            roiManager("select", i);
   }
   setKeyDown("none");
   showMessage("All should be selected in ROI Manager now - but they
aren't (even in 'blobs.gif'!)");
   //  roiManager("combine");
   //  roiManager("add");




****END