Re: combine function of the ROI manager
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Aug 06, 2010; 2:51pm
URL: http://imagej.273.s1.nabble.com/combine-function-of-the-ROI-manager-tp3685239p3685240.html
On Aug 6, 2010, at 6:33 AM, Sebastien Tosi wrote:
> Hello,
>
> I am trying to use the "combine" function of the ROI manager within a macro.
> The idea is that I have various ROIs in the manager list and that I want to
> merge some of them and add them as new ROIs to the list. The manual way to
> do this task is to select the ROIs within the manager (by pressing "Control"
> for multi-selection) and to use "combine" followed by "add". I am unable to
> make this work in the macro... the "setkeydown" function apparently does not
> support the special key "control" and the behavior is not very clear. Any
> suggestions?
This is something that is easier to do in Java or a scripting language. Here is JavaScript that merges the 2nd and 4th ROI on the ROI Manager and adds the merged ROI to the ROI Manager.
manager = RoiManager.getInstance();
if (manager==null)
IJ.error("ROI Manager is not open");
rois = manager.getRoisAsArray();
roi1 = new ShapeRoi(rois[1]);
roi2 = new ShapeRoi(rois[3]);
combined = roi1.or(roi2);
manager.addRoi(combined);
-wayne