Classifying ROIs in the RoiManager

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Classifying ROIs in the RoiManager

Avital Steinberg
Hi,
I would like to be able to choose ROIs belonging to a certain class from
the ROI manager in a macro. For example, I renamed the ROIs as triangle1,
triangle2, triangle3, circle1, circle2, rectangle1, rectangle2.

I would like to be able to add triangles and iterate over all the
triangles. I can sort the ROIs in the RoiManager, so that the ROIs of a
certain class will be in consecutive order.

However, in order to be able to choose only triangles, I would have to keep
track of how many triangles there are.

Is there an easier way to select (and iterate over) only ROIs of a certain
class (such as triangles or circles), without having to keep track of the
number of objects in each class and their order?

Thanks,
Avital

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

Re: Classifying ROIs in the RoiManager

Romain Guiet
Hi Avital,

maybe you could use the macro functions :
Roi.getType : Returns, as a string, the type of the current selection.
Roi.setName(name)
roiManager(cmd), with cmd = "Sort", to sort your ROIs

more on : http://imagej.nih.gov/ij/developer/macro/functions.html#Top

I hope it will help you,

Cheers,

Romain


---------------------------------------------------------------
Dr. Romain Guiet
Bioimaging and Optics Platform (PT-BIOP)
Ecole Polytechnique Fédérale de Lausanne (EPFL)
Faculty of Life Sciences
Station 19, AI 0140
CH-1015 Lausanne

Phone: [+4121 69] 39629
http://biop.epfl.ch/
---------------------------------------------------------------

________________________________________
De : ImageJ Interest Group [[hidden email]] de la part de Avital Steinberg [[hidden email]]
Envoyé : dimanche 19 avril 2015 21:09
À : [hidden email]
Objet : Classifying ROIs in the RoiManager

Hi,
I would like to be able to choose ROIs belonging to a certain class from
the ROI manager in a macro. For example, I renamed the ROIs as triangle1,
triangle2, triangle3, circle1, circle2, rectangle1, rectangle2.

I would like to be able to add triangles and iterate over all the
triangles. I can sort the ROIs in the RoiManager, so that the ROIs of a
certain class will be in consecutive order.

However, in order to be able to choose only triangles, I would have to keep
track of how many triangles there are.

Is there an easier way to select (and iterate over) only ROIs of a certain
class (such as triangles or circles), without having to keep track of the
number of objects in each class and their order?

Thanks,
Avital

--
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: Classifying ROIs in the RoiManager

Olivier Burri
Hello,

We had a similar need a while back, use this function

/*
 * Returns an array of indexes of ROIs that match
 * the given regular expression
 */
function findRoisWithName(roiName) {
        nR = roiManager("Count");
        roiIdx = newArray(nR);
        k=0;
        clippedIdx = newArray(0);
       
        for (i=0; i<nR; i++) {
                roiManager("Select", i);
                rName = Roi.getName();
                if (matches(rName, roiName)) {
                        roiIdx[k] = i;
                        k++;
                }
        }
        if (k>0) {
                clippedIdx = Array.trim(roiIdx,k);
        }
       
        return clippedIdx;
}


In your case, it would look something like this
Idx = findRoisWithName("triangle.*");

For (i=0; i< Idx.length; i++) {
        roiManager("Select", Idx[i]);
        // TO THINGS HERE
}

In case you want your ROIs sorted, then use roiManager("Sort"); before, as suggested by Romain

Best

Oli




> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Romain Guiet
> Sent: Monday, April 20, 2015 8:04
> To: [hidden email]
> Subject: Re: Classifying ROIs in the RoiManager
>
> Hi Avital,
>
> maybe you could use the macro functions :
> Roi.getType : Returns, as a string, the type of the current selection.
> Roi.setName(name)
> roiManager(cmd), with cmd = "Sort", to sort your ROIs
>
> more on : http://imagej.nih.gov/ij/developer/macro/functions.html#Top
>
> I hope it will help you,
>
> Cheers,
>
> Romain
>
>
> ---------------------------------------------------------------
> Dr. Romain Guiet
> Bioimaging and Optics Platform (PT-BIOP) Ecole Polytechnique Fédérale de
> Lausanne (EPFL) Faculty of Life Sciences Station 19, AI 0140
> CH-1015 Lausanne
>
> Phone: [+4121 69] 39629
> http://biop.epfl.ch/
> ---------------------------------------------------------------
>
> ________________________________________
> De : ImageJ Interest Group [[hidden email]] de la part de Avital
> Steinberg [[hidden email]] Envoyé : dimanche 19 avril 2015
> 21:09 À : [hidden email] Objet : Classifying ROIs in the RoiManager
>
> Hi,
> I would like to be able to choose ROIs belonging to a certain class from the
> ROI manager in a macro. For example, I renamed the ROIs as triangle1,
> triangle2, triangle3, circle1, circle2, rectangle1, rectangle2.
>
> I would like to be able to add triangles and iterate over all the triangles. I can
> sort the ROIs in the RoiManager, so that the ROIs of a certain class will be in
> consecutive order.
>
> However, in order to be able to choose only triangles, I would have to keep
> track of how many triangles there are.
>
> Is there an easier way to select (and iterate over) only ROIs of a certain class
> (such as triangles or circles), without having to keep track of the number of
> objects in each class and their order?
>
> Thanks,
> Avital
>
> --
> 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: Classifying ROIs in the RoiManager

Avital Steinberg
Thanks Romain and Oli for your help - now I can easily keep track of my
ROIs,

Avital

On Mon, Apr 20, 2015 at 10:12 AM, Burri Olivier <[hidden email]>
wrote:

> Hello,
>
> We had a similar need a while back, use this function
>
> /*
>  * Returns an array of indexes of ROIs that match
>  * the given regular expression
>  */
> function findRoisWithName(roiName) {
>         nR = roiManager("Count");
>         roiIdx = newArray(nR);
>         k=0;
>         clippedIdx = newArray(0);
>
>         for (i=0; i<nR; i++) {
>                 roiManager("Select", i);
>                 rName = Roi.getName();
>                 if (matches(rName, roiName)) {
>                         roiIdx[k] = i;
>                         k++;
>                 }
>         }
>         if (k>0) {
>                 clippedIdx = Array.trim(roiIdx,k);
>         }
>
>         return clippedIdx;
> }
>
>
> In your case, it would look something like this
> Idx = findRoisWithName("triangle.*");
>
> For (i=0; i< Idx.length; i++) {
>         roiManager("Select", Idx[i]);
>         // TO THINGS HERE
> }
>
> In case you want your ROIs sorted, then use roiManager("Sort"); before, as
> suggested by Romain
>
> Best
>
> Oli
>
>
>
>
> > -----Original Message-----
> > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> > Romain Guiet
> > Sent: Monday, April 20, 2015 8:04
> > To: [hidden email]
> > Subject: Re: Classifying ROIs in the RoiManager
> >
> > Hi Avital,
> >
> > maybe you could use the macro functions :
> > Roi.getType : Returns, as a string, the type of the current selection.
> > Roi.setName(name)
> > roiManager(cmd), with cmd = "Sort", to sort your ROIs
> >
> > more on : http://imagej.nih.gov/ij/developer/macro/functions.html#Top
> >
> > I hope it will help you,
> >
> > Cheers,
> >
> > Romain
> >
> >
> > ---------------------------------------------------------------
> > Dr. Romain Guiet
> > Bioimaging and Optics Platform (PT-BIOP) Ecole Polytechnique Fédérale de
> > Lausanne (EPFL) Faculty of Life Sciences Station 19, AI 0140
> > CH-1015 Lausanne
> >
> > Phone: [+4121 69] 39629
> > http://biop.epfl.ch/
> > ---------------------------------------------------------------
> >
> > ________________________________________
> > De : ImageJ Interest Group [[hidden email]] de la part de Avital
> > Steinberg [[hidden email]] Envoyé : dimanche 19 avril 2015
> > 21:09 À : [hidden email] Objet : Classifying ROIs in the RoiManager
> >
> > Hi,
> > I would like to be able to choose ROIs belonging to a certain class from
> the
> > ROI manager in a macro. For example, I renamed the ROIs as triangle1,
> > triangle2, triangle3, circle1, circle2, rectangle1, rectangle2.
> >
> > I would like to be able to add triangles and iterate over all the
> triangles. I can
> > sort the ROIs in the RoiManager, so that the ROIs of a certain class
> will be in
> > consecutive order.
> >
> > However, in order to be able to choose only triangles, I would have to
> keep
> > track of how many triangles there are.
> >
> > Is there an easier way to select (and iterate over) only ROIs of a
> certain class
> > (such as triangles or circles), without having to keep track of the
> number of
> > objects in each class and their order?
> >
> > Thanks,
> > Avital
> >
> > --
> > 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
>

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