A problem with Roi.setProperty

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

A problem with Roi.setProperty

Avital Steinberg
Hi,
I'm having trouble with Roi.setProperty (or Roi.getProperty). The following
code requires an image to be open and requires one ROI to be added to the
ROI manager:

roiManager("select", 0);
Roi.setProperty("narrow",1);
print(Roi.getProperty("narrow"));

print("Property before re-select=" + Roi.getProperty("narrow"));

roiManager("select", 0);
print("Property after re-select=" + Roi.getProperty("narrow"));

When I run these lines of code, I get the following output:

1
Property before re-select=1
Property after re-select=

Why can't I select the ROI from the ROI manager again and get the property?

Thank you,
Avital

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

Re: A problem with Roi.setProperty

Rasband, Wayne (NIH/NIMH) [E]
> On Apr 27, 2015, at 11:32 AM, Avital Steinberg <[hidden email]> wrote:
>
> Hi,
> I'm having trouble with Roi.setProperty (or Roi.getProperty). The following
> code requires an image to be open and requires one ROI to be added to the
> ROI manager:
>
> roiManager("select", 0);
> Roi.setProperty("narrow",1);
> print(Roi.getProperty("narrow"));
>
> print("Property before re-select=" + Roi.getProperty("narrow"));
>
> roiManager("select", 0);
> print("Property after re-select=" + Roi.getProperty("narrow"));
>
> When I run these lines of code, I get the following output:
>
> 1
> Property before re-select=1
> Property after re-select=
>
> Why can't I select the ROI from the ROI manager again and get the property?

You need to update the version of the ROI in the ROI Manager after making changes. This version of your macro

  roiManager("select", 0);
  Roi.setProperty("narrow",1);
  roiManager("update");
  print("Property before re-select=" + Roi.getProperty("narrow"));
  roiManager("select", 0);
  print("Property after re-select=" + Roi.getProperty("narrow"));

outputs

  Property before re-select=1
  Property after re-select=1

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

Re: A problem with Roi.setProperty

Avital Steinberg
Hi Wayne,
Thank you for your answer - now I can use this feature to classify my ROIs,

Avital

On Tue, Apr 28, 2015 at 6:21 AM, Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]> wrote:

> > On Apr 27, 2015, at 11:32 AM, Avital Steinberg <
> [hidden email]> wrote:
> >
> > Hi,
> > I'm having trouble with Roi.setProperty (or Roi.getProperty). The
> following
> > code requires an image to be open and requires one ROI to be added to the
> > ROI manager:
> >
> > roiManager("select", 0);
> > Roi.setProperty("narrow",1);
> > print(Roi.getProperty("narrow"));
> >
> > print("Property before re-select=" + Roi.getProperty("narrow"));
> >
> > roiManager("select", 0);
> > print("Property after re-select=" + Roi.getProperty("narrow"));
> >
> > When I run these lines of code, I get the following output:
> >
> > 1
> > Property before re-select=1
> > Property after re-select=
> >
> > Why can't I select the ROI from the ROI manager again and get the
> property?
>
> You need to update the version of the ROI in the ROI Manager after making
> changes. This version of your macro
>
>   roiManager("select", 0);
>   Roi.setProperty("narrow",1);
>   roiManager("update");
>   print("Property before re-select=" + Roi.getProperty("narrow"));
>   roiManager("select", 0);
>   print("Property after re-select=" + Roi.getProperty("narrow"));
>
> outputs
>
>   Property before re-select=1
>   Property after re-select=1
>
> -wayne
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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