Non reproducible bug on ImageJ

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

Non reproducible bug on ImageJ

CARL Philippe (LBP)
Dear all / Wayne,

I have got some trouble with an issue on both ImageJ and Fiji that on top of
this isn’t even reproducible which could make it very tricky to fix.

So let’s consider the following short macro code:

run("Blobs (25K)");

makeRectangle(83, 41, 94, 159);

run("Crop");

close();

run("Blobs (25K)");

run("Restore Selection");

So sometimes this code finishes with the Blobs picture open on which the
previously defined ROI (i.e. makeRectangle(83, 41, 94, 159)) is selected (as
expected).

But sometimes it finishes with all the picture being selected (i.e. similar
to run("Select All")), and this issue is connected to the fact that there is
a “run("Crop")” within the code.

This problem has now no consequences for the macro I was developing since I
finally use a getBoundingRect(x, y, width, height) to get the rectangular
ROI position and sizes and apply later on the copied values with a
makeRectangle (x, y, width, height) instead of a run("Restore Selection").

But it took me quite some time to figure out the origin of the issue and it
may as well be problematic for other users.

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: Non reproducible bug on ImageJ

Michael Schmid
Hi Philippe,

the "Restore Selection" command needs a previous selection that has been saved. The macro command "makeRectangle" does not save the selection it creates (it should not, maybe you want to restore the previous selection), so you can't restore the selection created by "makeRectangle". "Crop" does not save the selection either.

If there is no other open window, one could do the following:

  run("Blobs (25K)");
  makeRectangle(83, 41, 94, 159);
  run("Select None");        //saves the selection
  run("Restore Selection");
  run("Crop");
  close();
  run("Blobs (25K)");
  run("Restore Selection");

Unfortunately, this code does not work if there is another open window with a selection and that window comes to the foreground with close(). In that case, selecting that window saves its roi as the last one (WindowManager, line 42), and the roi of that other image will be transferred to the new image with the final "Restore Selection".

The conclusion: "Restore Selection" is not a safe way to transfer selections from one image to another - use the ROI Manager instead, or write Java/javascript code where you can access a roi.

Michael
________________________________________________________________
On Mar 18, 2015, at 14:20, Philippe CARL wrote:

> Dear all / Wayne,
>
> I have got some trouble with an issue on both ImageJ and Fiji that on top of
> this isn’t even reproducible which could make it very tricky to fix.
>
> So let’s consider the following short macro code:
>
> run("Blobs (25K)");
>
> makeRectangle(83, 41, 94, 159);
>
> run("Crop");
>
> close();
>
> run("Blobs (25K)");
>
> run("Restore Selection");
>
> So sometimes this code finishes with the Blobs picture open on which the
> previously defined ROI (i.e. makeRectangle(83, 41, 94, 159)) is selected (as
> expected).
>
> But sometimes it finishes with all the picture being selected (i.e. similar
> to run("Select All")), and this issue is connected to the fact that there is
> a “run("Crop")” within the code.
>
> This problem has now no consequences for the macro I was developing since I
> finally use a getBoundingRect(x, y, width, height) to get the rectangular
> ROI position and sizes and apply later on the copied values with a
> makeRectangle (x, y, width, height) instead of a run("Restore Selection").
>
> But it took me quite some time to figure out the origin of the issue and it
> may as well be problematic for other users.
>
> 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

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

Re: Non reproducible bug on ImageJ

Krs5
In reply to this post by CARL Philippe (LBP)
See the same behaviour but it does not depend on the run("Crop") as removing it from the code still gives the same result. When I remove close(); the restore selection works. After this the ROI is restored every time the macro runs but not as a result of the ROI created in the macro. If you change this code it has no effect on the restored ROI.

If I have a different ROI on an open image and run the macro this ROI is restored and not the ROI in the macro.

So it looks like the ROI created in the macro is not recognized.

Easy way around this is the use of the ROI manager.

Best wishes

Kees

Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Philippe CARL
Sent: 18 March 2015 13:20
To: [hidden email]
Subject: Non reproducible bug on ImageJ

Dear all / Wayne,

I have got some trouble with an issue on both ImageJ and Fiji that on top of this isn't even reproducible which could make it very tricky to fix.

So let's consider the following short macro code:

run("Blobs (25K)");

makeRectangle(83, 41, 94, 159);

run("Crop");

close();

run("Blobs (25K)");

run("Restore Selection");

So sometimes this code finishes with the Blobs picture open on which the previously defined ROI (i.e. makeRectangle(83, 41, 94, 159)) is selected (as expected).

But sometimes it finishes with all the picture being selected (i.e. similar to run("Select All")), and this issue is connected to the fact that there is a "run("Crop")" within the code.

This problem has now no consequences for the macro I was developing since I finally use a getBoundingRect(x, y, width, height) to get the rectangular ROI position and sizes and apply later on the copied values with a makeRectangle (x, y, width, height) instead of a run("Restore Selection").

But it took me quite some time to figure out the origin of the issue and it may as well be problematic for other users.

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

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

Re: Non reproducible bug on ImageJ

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by CARL Philippe (LBP)
> On Mar 18, 2015, at 9:20 AM, Philippe CARL <[hidden email]> wrote:
>
> Dear all / Wayne,
>
> I have got some trouble with an issue on both ImageJ and Fiji that on top of
> this isn't even reproducible which could make it very tricky to fix.
>
> So let's consider the following short macro code:
> run("Blobs (25K)");
> makeRectangle(83, 41, 94, 159);
> run("Crop");
> close();
> run("Blobs (25K)");
> run("Restore Selection");
>
> So sometimes this code finishes with the Blobs picture open on which the
> previously defined ROI (i.e. makeRectangle(83, 41, 94, 159)) is selected (as
> expected).
>
> But sometimes it finishes with all the picture being selected (i.e. similar
> to run("Select All")), and this issue is connected to the fact that there is
> a "run("Crop")" within the code.

Dear Philippe,

The latest ImageJ daily build (1.49q8) adds Roi.copy() and Roi.paste() functions to the macro language. They provide a more reliable way to copy selections from one image to another. Here is your macro code upgraded to use these new functions:

   run("Blobs (25K)");
   makeRectangle(83, 41, 94, 159);
   Roi.copy();
   run("Crop");
   close();
   run("Blobs (25K)");
   Roi.paste();

-wayne

> This problem has now no consequences for the macro I was developing since I
> finally use a getBoundingRect(x, y, width, height) to get the rectangular
> ROI position and sizes and apply later on the copied values with a
> makeRectangle (x, y, width, height) instead of a run("Restore Selection").
>
> But it took me quite some time to figure out the origin of the issue and it
> may as well be problematic for other users.
>
> My best regards,
>
> Philippe
>
>
>
> Philippe CARL

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

Re: Non reproducible bug on ImageJ

CARL Philippe (LBP)
Dear Wayne,
I thank you very much for your updates for the newly added Roi.copy() and
Roi.paste() methods.
Thus could you please test the following macro:
        run("Blobs (25K)");
        doWand(81, 176);
        Roi.copy();
        run("Crop");
        close();

        run("Blobs (25K)");
        Roi.paste();
        run("Crop");
        close();

        run("Blobs (25K)");
        Roi.paste();
As you will see, the shape of the ROI is correctly copied in the second
opened Blobs but not anymore its position.
I thank you very much in advance for your help.
Kindest regards,
Philippe

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

Re: Non reproducible bug on ImageJ

Rasband, Wayne (NIH/NIMH) [E]
> On Mar 23, 2015, at 10:38 AM, Philippe CARL <[hidden email]> wrote:
>
> Dear Wayne,
> I thank you very much for your updates for the newly added Roi.copy() and
> Roi.paste() methods.
> Thus could you please test the following macro:
> run("Blobs (25K)");
> doWand(81, 176);
> Roi.copy();
> run("Crop");
> close();
>
> run("Blobs (25K)");
> Roi.paste();
> run("Crop");
> close();
>
> run("Blobs (25K)");
> Roi.paste();
> As you will see, the shape of the ROI is correctly copied in the second
> opened Blobs but not anymore its position.

This bug is fixed in the latest ImageJ daily build (1.49q12).

-wayne

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