Posted by
lechristophe on
Jul 29, 2008; 3:12pm
URL: http://imagej.273.s1.nabble.com/roi-select-two-rois-tp3695488p3695493.html
There is indeed a problem with selecting multiple ROIs in a macro. This is
more easily seen when trying to use the "Combine" command on two selected
ROIs in a macro. Below is a question I sent a few days ago and the response
of Wayne Rasband :
I would like to select two ROIs in the manager and combine them in a
> macro. What is wrong in the following code ?
>
> newImage("test", "8-bit Black", 128, 128, 1);
> makeRectangle(54, 35,10,10);
> roiManager("Add");
> makeRectangle(70, 70,10,10);
> roiManager("Add");
> roiManager("select",0);
> setKeyDown("alt");
> roiManager("select",1);
> roiManager("Combine");
>
> The composite macro is displayed, but I get the error : "More than one
> item must be selected, or none". Using shift as a modifier leads to
> the same error. Any ideas ?
>
Dear Christophe,
As far as I know, there is no way in a macro to select a subset of the ROIs
in the ROI Manager. There does appear to be a way to programatically select
multiple items in an java.awt.List.
-wayne
So basically it cannot be done... Too bad this java.awt.List seems a bit
limited (another gripe is that you cannot expand the ROI manager window to
see more ROIs or to see longer names, at least on OSX).
Christophe
On Tue, Jul 29, 2008 at 16:41, John Alexander <
[hidden email]> wrote:
> I think the confusion is that you are creating ONE roi - and not two. A
> ROI does not have to be contiguous. So, when using the shift key, you
> are still making ONE roi (in two parts). So, the macro is working just
> fine, it is measuring the content in that one roi.
>
> Since I am not sure what you want to do ...
>
> if you want a measure for each roi ...
>
> roiManager("Select", 0);
> roiManager("measure");
> roiManager("Select", 1);
> roiManager("measure");
>
>
>
> Thomas Boudier wrote:
> > Jan Eglinger a écrit :
> >> Hello Thomas,
> >>
> >>> I would like to write a macro that select several rois, but it seems
> >>> that the "Shift" key is not taking into account while selecting :
> >>>
> >>> roiManager("Select", 1);
> >>> setKeyDown("shift");
> >>> roiManager("Select", 2);
> >>>
> >>> this macro will select only roi2, while I would like roi1 and 2 to be
> >>> selected.
> >>>
> >>
> >> This code works fine for me (tried with v1.41c and v1.41i on WinXP),
> >> i.e. it selects the combination of the two ROIs.
> >> I tried only with rectangular ROIs, however.
> >
> > Hi,
> >
> > I'm running ImageJ 1.41i on linux with java1.6.0_06, what I would like
> > is to select specifically two rois (to perform some computation on
> > them), when I run this code :
> >
> > roiManager("Select", 0);
> > setKeyDown("shift");
> > roiManager("Select", 1);
> > roiManager("measure");
> >
> >
> > I only have one measure instead of two. Not sure if the shift key
> > applies to the list inside roiManager or to Rois in the image where they
> > are combined.
> >
> > Thomas
> >
> >>
> >> best,
> >> jan
> >>
> >
> >
>
> --
> John K. Alexander, Ph.D.
> Post-Doctoral Fellow
> William Green Laboratory
> University of Chicago
> Dept. Neurobiology, Pharmacology, and Physiology
> 947 East 58th Street
> Abott Hall 402
> Chicago, IL 60637
> (off) 773-702-9386
> (fax) 773-702-3774
>
[hidden email]
>