Login  Register

Re: A problem with Roi.setProperty

Posted by Rasband, Wayne (NIH/NIMH) [E] on Apr 28, 2015; 3:21am
URL: http://imagej.273.s1.nabble.com/A-problem-with-Roi-setProperty-tp5012625p5012630.html

> 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