Bug in ROI Manager?

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

Bug in ROI Manager?

Krs5
Dear list, dear Wayne,

Trying to merge different numbers of ROIs from a Z-stack  after a question from Jacqueline Ross earlier on the list I came across some strange behaviour in the ROI Manager.
Example code ImageJ macro that works:

run("Confocal Series (2.2MB)");
makeRectangle(153, 173, 33, 30);
roiManager("Add");
makeRectangle(192, 226, 40, 37);
roiManager("Add");
makeRectangle(132, 259, 39, 38);
roiManager("Add");
roiManager("Select", newArray(0,1,2));
roiManager("Combine");
roiManager("Add");
roiManager("Delete");
roiManager("Show All");

Now, if I don't know the number of ROIs and collect these separate in a variable I get:

run("Confocal Series (2.2MB)");
makeRectangle(153, 173, 33, 30);
roiManager("Add");
makeRectangle(192, 226, 40, 37);
roiManager("Add");
makeRectangle(132, 259, 39, 38);
roiManager("Add");
c= newArray(0,1,2);
roiManager("Select", newArray(c));
roiManager("Combine");
roiManager("Add");
roiManager("Delete");
roiManager("Show All");

However, this has now deleted all ROIs from the manager, not the once I had expected. Up to adding the combined ROI to the Manager everything is OK but after that the selection in the Manager is different and it does not recognize what is selected and deletes all ROIs. Adding  "roiManager("Select", newArray(c));" before trying to delete ROIs does not work. Adding " roiManager("Select", newArray(0,1,2));" however at this point works as expected. I assume this is a bug?

I run Fiji/ImageJ 2.0.0-rc-65/1.52b Java1.8.0-66 on a Windows 7 system 64bit

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
www.le.ac.uk/advanced-imaging-facility

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

Re: Bug in ROI Manager?

Bill Christens-Barry-2
Dear Kees,

If, in your second and nonworking macro, you replace the line:

  roiManager("Select", newArray(c));

with the line:

  roiManager("Select", c);

it appears to work correctly for me here on MacOS. This makes sense to me, given that you've already constructed the new array "c" in the previous line.

hth,

Bill Christens-Barry

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

Re: Bug in ROI Manager?

Wayne Rasband-2
In reply to this post by Krs5
> On May 16, 2018, at 1:38 PM, Straatman, Kees (Dr.) <[hidden email]> wrote:
>
> Dear list, dear Wayne,
>
> Trying to merge different numbers of ROIs from a Z-stack  after a question from Jacqueline Ross earlier on the list I came across some strange behaviour in the ROI Manager.

This strange behavior is due to a bug in the macro interpreter. There is a syntax error in line 9 of the non-working macro that the interpreter does not detect. The latest ImageJ daily build (1.52c12) fixes this bug and displays this error message when you run the second macro:

   ‘[‘ expected in line 9

    roiManager ( “Select" , newArray (c <)> ) ;

-wayne


> Example code ImageJ macro that works:
>
> run("Confocal Series (2.2MB)");
> makeRectangle(153, 173, 33, 30);
> roiManager("Add");
> makeRectangle(192, 226, 40, 37);
> roiManager("Add");
> makeRectangle(132, 259, 39, 38);
> roiManager("Add");
> roiManager("Select", newArray(0,1,2));
> roiManager("Combine");
> roiManager("Add");
> roiManager("Delete");
> roiManager("Show All");
>
> Now, if I don't know the number of ROIs and collect these separate in a variable I get:
>
> run("Confocal Series (2.2MB)");
> makeRectangle(153, 173, 33, 30);
> roiManager("Add");
> makeRectangle(192, 226, 40, 37);
> roiManager("Add");
> makeRectangle(132, 259, 39, 38);
> roiManager("Add");
> c= newArray(0,1,2);
> roiManager("Select", newArray(c));
> roiManager("Combine");
> roiManager("Add");
> roiManager("Delete");
> roiManager("Show All");
>
> However, this has now deleted all ROIs from the manager, not the once I had expected. Up to adding the combined ROI to the Manager everything is OK but after that the selection in the Manager is different and it does not recognize what is selected and deletes all ROIs. Adding  "roiManager("Select", newArray(c));" before trying to delete ROIs does not work. Adding " roiManager("Select", newArray(0,1,2));" however at this point works as expected. I assume this is a bug?
>
> I run Fiji/ImageJ 2.0.0-rc-65/1.52b Java1.8.0-66 on a Windows 7 system 64bit
>
> Best wishes
>
> Kees
>
>
> Dr Ir K.R. Straatman
> Senior Experimental Officer
> Advanced Imaging Facility
> Centre for Core Biotechnology Services
> University of Leicester
> www.le.ac.uk/advanced-imaging-facility
>
> --
> 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: Bug in ROI Manager?

Krs5
In reply to this post by Bill Christens-Barry-2
Dear Bill,

Indeed, have stared too long at the code. Solved the problem.

Thanks

Kees

-----Original Message-----
From: Bill Christens-Barry [mailto:[hidden email]]
Sent: 16 May 2018 19:53
To: [hidden email]
Subject: Re: Bug in ROI Manager?

Dear Kees,

If, in your second and nonworking macro, you replace the line:

  roiManager("Select", newArray(c));

with the line:

  roiManager("Select", c);

it appears to work correctly for me here on MacOS. This makes sense to me, given that you've already constructed the new array "c" in the previous line.

hth,

Bill Christens-Barry

--
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: Bug in ROI Manager?

Krs5
In reply to this post by Wayne Rasband-2
Hi Wayne,

Thanks, I think that will be helpful to detect the error.

BW

Kees

-----Original Message-----
From: Wayne Rasband [mailto:[hidden email]]
Sent: 17 May 2018 02:24
To: [hidden email]
Subject: Re: Bug in ROI Manager?

> On May 16, 2018, at 1:38 PM, Straatman, Kees (Dr.) <[hidden email]> wrote:
>
> Dear list, dear Wayne,
>
> Trying to merge different numbers of ROIs from a Z-stack  after a question from Jacqueline Ross earlier on the list I came across some strange behaviour in the ROI Manager.

This strange behavior is due to a bug in the macro interpreter. There is a syntax error in line 9 of the non-working macro that the interpreter does not detect. The latest ImageJ daily build (1.52c12) fixes this bug and displays this error message when you run the second macro:

   ‘[‘ expected in line 9

    roiManager ( “Select" , newArray (c <)> ) ;

-wayne


> Example code ImageJ macro that works:
>
> run("Confocal Series (2.2MB)");
> makeRectangle(153, 173, 33, 30);
> roiManager("Add");
> makeRectangle(192, 226, 40, 37);
> roiManager("Add");
> makeRectangle(132, 259, 39, 38);
> roiManager("Add");
> roiManager("Select", newArray(0,1,2)); roiManager("Combine");
> roiManager("Add"); roiManager("Delete"); roiManager("Show All");
>
> Now, if I don't know the number of ROIs and collect these separate in a variable I get:
>
> run("Confocal Series (2.2MB)");
> makeRectangle(153, 173, 33, 30);
> roiManager("Add");
> makeRectangle(192, 226, 40, 37);
> roiManager("Add");
> makeRectangle(132, 259, 39, 38);
> roiManager("Add");
> c= newArray(0,1,2);
> roiManager("Select", newArray(c));
> roiManager("Combine");
> roiManager("Add");
> roiManager("Delete");
> roiManager("Show All");
>
> However, this has now deleted all ROIs from the manager, not the once I had expected. Up to adding the combined ROI to the Manager everything is OK but after that the selection in the Manager is different and it does not recognize what is selected and deletes all ROIs. Adding  "roiManager("Select", newArray(c));" before trying to delete ROIs does not work. Adding " roiManager("Select", newArray(0,1,2));" however at this point works as expected. I assume this is a bug?
>
> I run Fiji/ImageJ 2.0.0-rc-65/1.52b Java1.8.0-66 on a Windows 7 system
> 64bit
>
> Best wishes
>
> Kees
>
>
> Dr Ir K.R. Straatman
> Senior Experimental Officer
> Advanced Imaging Facility
> Centre for Core Biotechnology Services University of Leicester
> www.le.ac.uk/advanced-imaging-facility
>
> --
> 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