Getting a list of indexes of selected ROIs

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting a list of indexes of selected ROIs

Straub, Volko A. (Dr.)
I am trying to get a list of the indexes if multiple ROIs are selected in the ROI manager to use in a macro. The function roiManager("index") returns the index of the first selected ROI, but is there a way to obtain the number and indexes of multiple selected ROIs? I noticed that the RoiManager class has a getIndexes() function. Is there a way to use that function in a macro? I thought there was, but searching the documentation, I don't seem to be able to find the right information.

Any advice/pointers would be very welcome.

Thanks,

Volko

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of indexes of selected ROIs

Avital Steinberg
Hi Volko,
I don't understand: aren't you the one writing the macro? In which case,
you are the one who determines which ROIs are selected. The command
roiManager("index") selects the ROI that has the index "index" - it doesn't
return anything. Similarly, the command: roiManager("select", indexes)
*s*elects
multiple ROIs. In this case, indexes is an array of indices,

Avital


On Mon, Jul 27, 2015 at 6:27 PM, Straub, Volko A. (Dr.) <
[hidden email]> wrote:

> I am trying to get a list of the indexes if multiple ROIs are selected in
> the ROI manager to use in a macro. The function roiManager("index") returns
> the index of the first selected ROI, but is there a way to obtain the
> number and indexes of multiple selected ROIs? I noticed that the RoiManager
> class has a getIndexes() function. Is there a way to use that function in a
> macro? I thought there was, but searching the documentation, I don't seem
> to be able to find the right information.
>
> Any advice/pointers would be very welcome.
>
> Thanks,
>
> Volko
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of indexes of selected ROIs

Straub, Volko A. (Dr.)
Sorry, if the original description of my problem wasn't clear. I am trying to write a macro that allows the user to manually select a number of ROIs from the ROI manager that contains a large number of ROIs. The macro will then only analyse the selected ROIs. In order to achieve this, I would like to get a list/array of the indexes of the selected ROIs. So, I am looking for an equivalent to the roiManager("index") function that returns not just the index of the first, but all selected ROIs.
Any suggestions?
Thanks,
Volko

On July 27, 2015 5:27:37 PM GMT+01:00, Avital Steinberg <[hidden email]> wrote:

>Hi Volko,
>I don't understand: aren't you the one writing the macro? In which
>case,
>you are the one who determines which ROIs are selected. The command
>roiManager("index") selects the ROI that has the index "index" - it
>doesn't
>return anything. Similarly, the command: roiManager("select", indexes)
>*s*elects
>multiple ROIs. In this case, indexes is an array of indices,
>
>Avital
>
>
>On Mon, Jul 27, 2015 at 6:27 PM, Straub, Volko A. (Dr.) <
>[hidden email]> wrote:
>
>> I am trying to get a list of the indexes if multiple ROIs are
>selected in
>> the ROI manager to use in a macro. The function roiManager("index")
>returns
>> the index of the first selected ROI, but is there a way to obtain the
>> number and indexes of multiple selected ROIs? I noticed that the
>RoiManager
>> class has a getIndexes() function. Is there a way to use that
>function in a
>> macro? I thought there was, but searching the documentation, I don't
>seem
>> to be able to find the right information.
>>
>> Any advice/pointers would be very welcome.
>>
>> Thanks,
>>
>> Volko
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
>--
>ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of indexes of selected ROIs

Avital Steinberg
Hi Volko,
I don't know how to get this type of information from the ROI manager.

If the user clicks inside the ROI (on the image), there's an Imagej macro
tool that can be installed. This way, you would know the coordinates of the
click:

http://rsb.info.nih.gov/ij/macros/tools/CoordinatePickerTool.txt

Then, you can check if a ROI contains this point:

*Roi.contains(x, y)*
Returns "1" if the point *x,y* is inside the current selection or "0" if it
is not. Aborts the macro if there is no selection. Requires 1.49h. See
also: selectionContains
<http://rsb.info.nih.gov/ij/developer/macro/functions.html#selectionContains>.


I haven't done it yet (but it sounds very useful), so if someone has
written code that does something similar, it would be nice to know,

Avital


On Tue, Jul 28, 2015 at 12:22 AM, vs64 <[hidden email]> wrote:

> Sorry, if the original description of my problem wasn't clear. I am trying
> to write a macro that allows the user to manually select a number of ROIs
> from the ROI manager that contains a large number of ROIs. The macro will
> then only analyse the selected ROIs. In order to achieve this, I would like
> to get a list/array of the indexes of the selected ROIs. So, I am looking
> for an equivalent to the roiManager("index") function that returns not just
> the index of the first, but all selected ROIs.
> Any suggestions?
> Thanks,
> Volko
>
> On July 27, 2015 5:27:37 PM GMT+01:00, Avital Steinberg <
> [hidden email]> wrote:
> >Hi Volko,
> >I don't understand: aren't you the one writing the macro? In which
> >case,
> >you are the one who determines which ROIs are selected. The command
> >roiManager("index") selects the ROI that has the index "index" - it
> >doesn't
> >return anything. Similarly, the command: roiManager("select", indexes)
> >*s*elects
> >multiple ROIs. In this case, indexes is an array of indices,
> >
> >Avital
> >
> >
> >On Mon, Jul 27, 2015 at 6:27 PM, Straub, Volko A. (Dr.) <
> >[hidden email]> wrote:
> >
> >> I am trying to get a list of the indexes if multiple ROIs are
> >selected in
> >> the ROI manager to use in a macro. The function roiManager("index")
> >returns
> >> the index of the first selected ROI, but is there a way to obtain the
> >> number and indexes of multiple selected ROIs? I noticed that the
> >RoiManager
> >> class has a getIndexes() function. Is there a way to use that
> >function in a
> >> macro? I thought there was, but searching the documentation, I don't
> >seem
> >> to be able to find the right information.
> >>
> >> Any advice/pointers would be very welcome.
> >>
> >> Thanks,
> >>
> >> Volko
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >
> >--
> >ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of indexes of selected ROIs

Straatman, Kees (Dr.)
In reply to this post by Straub, Volko A. (Dr.)
Hi Volko,

I don't know how to get the indexes from the ROI manager when more than one ROI is selected but the code below collects the ROI indexes when they are selected one by one (directly in the ROI manager or on the image). It will add an extra selection to the ROI manager which you select when ready. At the end this is deleted again

----------------------- Code --------------------------------------
// Maximum number of selected ROIs
n=newArray(roiManager("count"));
c= roiManager("count");
// Fill array with -1 otherwise they will have the value 0
for (i=0;i<roiManager("count");i++)
 n[i] = -1;
// add extra selection to ROI manager to stop selection
makeRectangle(0, 0, 1, 1);
roiManager("Add");
roiManager("Deselect");
// Select the ROIs of interest
waitForUser("Select your first ROI, click \"OK\" and continue to select ROIs.\nWhen ready select the last ROI in the ROI manager");
for (i=0; i<=roiManager("count");i++){
 if(roiManager("index")<c){
 
  n[i] = roiManager("index");
 
  do{
   wait(500);
   new = roiManager("index");
  }while((n[i]==new)||(new==-1))
 }
 else i=roiManager("count")+1;
 
}
Array.print(n);

// Delete extra added ROI
roiManager("select", roiManager("count")-1);
roiManager("Delete");

--------------------------------Code ---------------------------------

Best wishes

Kees
________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Straub, Volko A. (Dr.) [[hidden email]]
Sent: 27 July 2015 16:27
To: [hidden email]
Subject: Getting a list of indexes of selected ROIs

I am trying to get a list of the indexes if multiple ROIs are selected in the ROI manager to use in a macro. The function roiManager("index") returns the index of the first selected ROI, but is there a way to obtain the number and indexes of multiple selected ROIs? I noticed that the RoiManager class has a getIndexes() function. Is there a way to use that function in a macro? I thought there was, but searching the documentation, I don't seem to be able to find the right information.

Any advice/pointers would be very welcome.

Thanks,

Volko

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of indexes of selected ROIs

Straub, Volko A. (Dr.)
Thanks Avital and Kees for your comments and suggestions. As a workaround, I was thinking along similar lines to Kees' suggestion to write a function to select a series of ROIs - thanks to the code you have posted I won't have to write it myself.
Thanks,
Volko

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Straatman, Kees (Dr.) [[hidden email]]
Sent: 28 July 2015 12:42
To: [hidden email]
Subject: Re: Getting a list of indexes of selected ROIs

Hi Volko,

I don't know how to get the indexes from the ROI manager when more than one ROI is selected but the code below collects the ROI indexes when they are selected one by one (directly in the ROI manager or on the image). It will add an extra selection to the ROI manager which you select when ready. At the end this is deleted again

----------------------- Code --------------------------------------
// Maximum number of selected ROIs
n=newArray(roiManager("count"));
c= roiManager("count");
// Fill array with -1 otherwise they will have the value 0
for (i=0;i<roiManager("count");i++)
 n[i] = -1;
// add extra selection to ROI manager to stop selection
makeRectangle(0, 0, 1, 1);
roiManager("Add");
roiManager("Deselect");
// Select the ROIs of interest
waitForUser("Select your first ROI, click \"OK\" and continue to select ROIs.\nWhen ready select the last ROI in the ROI manager");
for (i=0; i<=roiManager("count");i++){
 if(roiManager("index")<c){

  n[i] = roiManager("index");

  do{
   wait(500);
   new = roiManager("index");
  }while((n[i]==new)||(new==-1))
 }
 else i=roiManager("count")+1;

}
Array.print(n);

// Delete extra added ROI
roiManager("select", roiManager("count")-1);
roiManager("Delete");

--------------------------------Code ---------------------------------

Best wishes

Kees
________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Straub, Volko A. (Dr.) [[hidden email]]
Sent: 27 July 2015 16:27
To: [hidden email]
Subject: Getting a list of indexes of selected ROIs

I am trying to get a list of the indexes if multiple ROIs are selected in the ROI manager to use in a macro. The function roiManager("index") returns the index of the first selected ROI, but is there a way to obtain the number and indexes of multiple selected ROIs? I noticed that the RoiManager class has a getIndexes() function. Is there a way to use that function in a macro? I thought there was, but searching the documentation, I don't seem to be able to find the right information.

Any advice/pointers would be very welcome.

Thanks,

Volko

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of indexes of selected ROIs

Emanuele Martini
In reply to this post by Straub, Volko A. (Dr.)
Hi Volko,
I don't know in imagej macro language...but I use roim.getSelectedIndices() in jython script and it returns the indices of all selected rois.
roim is the roimanager instance.

But I really don't know how it works in macro language, since I don't use it very often.
Hoping to have been helpful,
have a nice day
Emanuele Martini
Image Analyst @Ifom-IEO research campus -MI-
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of indexes of selected ROIs

Carmine Pagliaro
Hi all
which is the best way to load a nifti image, create landmark and try a
registration?
thank

2015-08-03 11:20 GMT+02:00 Emanuele Martini <[hidden email]>:

> Hi Volko,
> I don't know in imagej macro language...but I use roim.getSelectedIndices()
> in jython script and it returns the indices of all selected rois.
> roim is the roimanager instance.
>
> But I really don't know how it works in macro language, since I don't use
> it
> very often.
> Hoping to have been helpful,
> have a nice day
> Emanuele Martini
>
>
>
> -----
> Image Analyst @Ifom-IEO research campus -MI-
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Getting-a-list-of-indexes-of-selected-ROIs-tp5013762p5013856.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
Carmine Pagliaro
*Life is for sharing.*

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of indexes of selected ROIs

Straub, Volko A. (Dr.)
In reply to this post by Emanuele Martini
Thanks Emanuele,
With the help of some previous comments I have some working macro script that enables me to create a list of selected ROIs. I had noticed the getSelectedIndices() function in the documentation, but I can't find a way to get it working in a macro. I probably should start using plugins or jython.
Volko



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Emanuele Martini
Sent: 03 August 2015 10:21
To: [hidden email]
Subject: Re: Getting a list of indexes of selected ROIs

Hi Volko,
I don't know in imagej macro language...but I use roim.getSelectedIndices() in jython script and it returns the indices of all selected rois.
roim is the roimanager instance.

But I really don't know how it works in macro language, since I don't use it very often.
Hoping to have been helpful,
have a nice day
Emanuele Martini



-----
Image Analyst @Ifom-IEO research campus -MI-
--
View this message in context: http://imagej.1557.x6.nabble.com/Getting-a-list-of-indexes-of-selected-ROIs-tp5013762p5013856.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html