Not so easy ROI Manager macro

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

Not so easy ROI Manager macro

CARL Philippe (LBP)
Dear all,

I have a whole bunch of ROIs saved within the ROI Manager for which I would
like to create a macro that creates me a file (or alternatively a results
window) containing the x, y positions (2 first columns) of all the pixels
within the different ROIs together with a tag (3rd column) referring to the
given ROI ID within the ROI Manager (= ROI Name within the ROI Manager).

You ideas on the best strategies for writing such a macro are more than
welcome.

Also the link:

http://rsbweb.nih.gov/ij/docs/macros/Roi_Properties_Test.txt

that is given as example for the getProperty(), setProperty() and
getProperties() methods additions of Jérôme on the 1.48h 30 November 2013
update seems to be broken.

I thank you very much in advance.

My best regards,

Philippe

 

Philippe CARL

Laboratoire de Biophotonique et Pharmacologie

UMR 7213 CNRS - Université de Strasbourg

Faculté de Pharmacie

74 route du Rhin

67401 ILLKIRCH

Tel : +33(0)3 68 85 41 84

 


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

Re: Not so easy ROI Manager macro

CARL Philippe (LBP)
Dear all,
I was finally able to write the macro I requested some help for and the
result is the following:

        run("Clear Results");
        for(k = 0; k != roiManager("count"); k++)
        {
                roiManager("select", k);
                Roi.getBounds(x, y, width, height);
                for(i = x; i <= x + width; i++)
                        for(j = y; j <= y + height; j++)
                                if(selectionContains(i, j))
                                {
                                        nbPixels = nResults;
                                        setResult("x"    , nbPixels, i);
                                        setResult("Y"    , nbPixels, j);
                                        setResult("index", nbPixels, k);
                                }
        }

My problem about developing this macro is that I wasn't aware about the
"selectionContains(x, y)" function that I was looking for within the "ROI
Functions".
My best regards,
Philippe

On Sep 1, 2014, at 9:23 AM, Philippe CARL wrote:

> Dear all,
>
> I have a whole bunch of ROIs saved within the ROI Manager for which I
> would like to create a macro that creates me a file (or alternatively
> a results
> window) containing the x, y positions (2 first columns) of all the
> pixels within the different ROIs together with a tag (3rd column)
> referring to the given ROI ID within the ROI Manager (= ROI Name
> within
 the ROI Manager).

>
> You ideas on the best strategies for writing such a macro are more
> than welcome.
>
> Also the link:
>
> http://rsbweb.nih.gov/ij/docs/macros/Roi_Properties_Test.txt
>
> that is given as example for the getProperty(), setProperty() and
> getProperties() methods additions of Jérôme on the 1.48h 30 November
> 2013 update seems to be broken.
>
> I thank you very much in advance.
>
> My best regards,
>
> Philippe
>
>
>
> Philippe CARL
>
> Laboratoire de Biophotonique et Pharmacologie
>
> UMR 7213 CNRS - Université de Strasbourg
>
> Faculté de Pharmacie
>
> 74 route du Rhin
>
> 67401 ILLKIRCH
>
> Tel : +33(0)3 68 85 41 84

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

Re: Not so easy ROI Manager macro

Jerome Mutterer-3
In reply to this post by CARL Philippe (LBP)
Hi,

maybe the selectionContains could be aliased in the doRoi() function in
ij/macro/Functions.java using  something like:

} else if (name.equals("contains")) {
double contains = selectionContains();
return new Double(contains).toString();
}

Sincerely,
Jerome.


On 5 September 2014 09:08, Philippe CARL <[hidden email]> wrote:

>
> Dear all,
> I was finally able to write the macro I requested some help for and the
> result is the following:
>
>         run("Clear Results");
>         for(k = 0; k != roiManager("count"); k++)
>         {
>                 roiManager("select", k);
>                 Roi.getBounds(x, y, width, height);
>                 for(i = x; i <= x + width; i++)
>                         for(j = y; j <= y + height; j++)
>                                 if(selectionContains(i, j))
>                                 {
>                                         nbPixels = nResults;
>                                         setResult("x"    , nbPixels, i);
>                                         setResult("Y"    , nbPixels, j);
>                                         setResult("index", nbPixels, k);
>                                 }
>         }
>
> My problem about developing this macro is that I wasn't aware about the
> "selectionContains(x, y)" function that I was looking for within the "ROI
> Functions".
> My best regards,
> Philippe
>
> On Sep 1, 2014, at 9:23 AM, Philippe CARL wrote:
>
> > Dear all,
> >
> > I have a whole bunch of ROIs saved within the ROI Manager for which I
> > would like to create a macro that creates me a file (or alternatively
> > a results
> > window) containing the x, y positions (2 first columns) of all the
> > pixels within the different ROIs together with a tag (3rd column)
> > referring to the given ROI ID within the ROI Manager (= ROI Name
> > within
>  the ROI Manager).
> >
> > You ideas on the best strategies for writing such a macro are more
> > than welcome.
> >
> > Also the link:
> >
> > http://rsbweb.nih.gov/ij/docs/macros/Roi_Properties_Test.txt
> >
> > that is given as example for the getProperty(), setProperty() and
> > getProperties() methods additions of Jérôme on the 1.48h 30 November
> > 2013 update seems to be broken.
> >
> > I thank you very much in advance.
> >
> > My best regards,
> >
> > Philippe
> >
> >
> >
> > Philippe CARL
> >
> > Laboratoire de Biophotonique et Pharmacologie
> >
> > UMR 7213 CNRS - Université de Strasbourg
> >
> > Faculté de Pharmacie
> >
> > 74 route du Rhin
> >
> > 67401 ILLKIRCH
> >
> > Tel : +33(0)3 68 85 41 84
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html




--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes
12, rue du Général Zimmer
67084 Strasbourg Cedex
T 0367155339
www.ibmp.cnrs.fr

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

Re: Not so easy ROI Manager macro

CARL Philippe (LBP)
Hi Jerome,
How are you doing?
Actually I'm already in the middle of a discussion with Wayne about the fact
to add a "Roi.contains(x,y)" function within the ROI Functions of the
Built-in Macro Functions.
And the issue is indeed that the Roi.* functions are only returning strings
and not a boolean.
Nevertheless if it is finally decided not to create such a Roi.contains(x,y)
function because of this casting issue I think a comment should be added on
the top of the "ROI Functions" paragraph in order to link the users to the
existence of a selectionContains(x, y) function with a "See also:" section
similarly to what is done for example for the "Overlay Functions".
Have a nice day and week-end,
Philippe

-----Message d'origine-----
De : ImageJ Interest Group [mailto:[hidden email]] De la part de Jerome
Mutterer
Envoyé : vendredi 5 septembre 2014 09:39
À : [hidden email]
Objet : Re: Not so easy ROI Manager macro

Hi,

maybe the selectionContains could be aliased in the doRoi() function in
ij/macro/Functions.java using  something like:

} else if (name.equals("contains")) {
double contains = selectionContains();
return new Double(contains).toString();
}

Sincerely,
Jerome.


On 5 September 2014 09:08, Philippe CARL <[hidden email]> wrote:

>
> Dear all,
> I was finally able to write the macro I requested some help for and
> the result is the following:
>
>         run("Clear Results");
>         for(k = 0; k != roiManager("count"); k++)
>         {
>                 roiManager("select", k);
>                 Roi.getBounds(x, y, width, height);
>                 for(i = x; i <= x + width; i++)
>                         for(j = y; j <= y + height; j++)
>                                 if(selectionContains(i, j))
>                                 {
>                                         nbPixels = nResults;
>                                         setResult("x"    , nbPixels, i);
>                                         setResult("Y"    , nbPixels, j);
>                                         setResult("index", nbPixels, k);
>                                 }
>         }
>
> My problem about developing this macro is that I wasn't aware about
> the "selectionContains(x, y)" function that I was looking for within
> the "ROI Functions".
> My best regards,
> Philippe
>
> On Sep 1, 2014, at 9:23 AM, Philippe CARL wrote:
>
> > Dear all,
> >
> > I have a whole bunch of ROIs saved within the ROI Manager for which
> > I would like to create a macro that creates me a file (or
> > alternatively a results
> > window) containing the x, y positions (2 first columns) of all the
> > pixels within the different ROIs together with a tag (3rd column)
> > referring to the given ROI ID within the ROI Manager (= ROI Name
> > within
>  the ROI Manager).
> >
> > You ideas on the best strategies for writing such a macro are more
> > than welcome.
> >
> > Also the link:
> >
> > http://rsbweb.nih.gov/ij/docs/macros/Roi_Properties_Test.txt
> >
> > that is given as example for the getProperty(), setProperty() and
> > getProperties() methods additions of Jérôme on the 1.48h 30 November
> > 2013 update seems to be broken.
> >
> > I thank you very much in advance.
> >
> > My best regards,
> >
> > Philippe
> >
> >
> >
> > Philippe CARL
> >
> > Laboratoire de Biophotonique et Pharmacologie
> >
> > UMR 7213 CNRS - Université de Strasbourg
> >
> > Faculté de Pharmacie
> >
> > 74 route du Rhin
> >
> > 67401 ILLKIRCH
> >
> > Tel : +33(0)3 68 85 41 84
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html




--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes 12, rue du Général
Zimmer
67084 Strasbourg Cedex
T 0367155339
www.ibmp.cnrs.fr

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

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