How to update the display after using batchMode

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

How to update the display after using batchMode

Avital Steinberg
Hi,
I set batchMode equal to true in order to turn off the display. I would
like to display the final processed image. I tried using
img.updateAndDraw() to show the final image, but the image window didn't
open. I also tried setting batchMode back to false, but that didn't work
either.

How can I display the final image?

Thank you,
Avital

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

Re: How to update the display after using batchMode

Krs5
Dear Avital,

I assume you run a macro so according to http://imagej.nih.gov/ij/developer/macro/functions.html#S you can use either

setBatchMode("exit and display"):  Exits batch mode and displays all hidden images.

or

setBatchMode("show"): Displays the active hidden image, while batch mode remains in same state. Requires 1.48h.

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 Avital Steinberg
Sent: 22 November 2014 15:34
To: [hidden email]
Subject: How to update the display after using batchMode

Hi,
I set batchMode equal to true in order to turn off the display. I would like to display the final processed image. I tried using
img.updateAndDraw() to show the final image, but the image window didn't open. I also tried setting batchMode back to false, but that didn't work either.

How can I display the final image?

Thank you,
Avital

--
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: How to update the display after using batchMode

Avital Steinberg
Thanks for your answer - I'm trying to do it in Java. There is no
setBatchMode function in the Java ImageJ API. However, there is a Batchmode
variable. I understood that accessing a field variable directly (without
using a get or set method) is considered a bad coding practice. I saw
various methods in the java ImageJ API such as addBatchModeImage, but I'm
not sure what it does,

Avital

On Mon, Nov 24, 2014 at 6:59 PM, Straatman, Kees (Dr.) <[hidden email]
> wrote:

> Dear Avital,
>
> I assume you run a macro so according to
> http://imagej.nih.gov/ij/developer/macro/functions.html#S you can use
> either
>
> setBatchMode("exit and display"):  Exits batch mode and displays all
> hidden images.
>
> or
>
> setBatchMode("show"): Displays the active hidden image, while batch mode
> remains in same state. Requires 1.48h.
>
> 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
> Avital Steinberg
> Sent: 22 November 2014 15:34
> To: [hidden email]
> Subject: How to update the display after using batchMode
>
> Hi,
> I set batchMode equal to true in order to turn off the display. I would
> like to display the final processed image. I tried using
> img.updateAndDraw() to show the final image, but the image window didn't
> open. I also tried setting batchMode back to false, but that didn't work
> either.
>
> How can I display the final image?
>
> Thank you,
> Avital
>
> --
> 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
Reply | Threaded
Open this post in threaded view
|

Re: How to update the display after using batchMode

Michael Schmid
Hi Avital,

when programming in Java, for most of the functionality you have API calls that work on ImageProcessor level and do not display anything, in contrast to the simple IJ.run(...) method. So, if possible, try to avoid Batchmode in plugins.
Also, using BatchMode in a plugin is a bit dangerous, if you plugin casts an exception and does not exit Batchmode, you may run into trouble.

If avoiding BatchMode is too cumbersome:
If an image has no window yet (because it was created in BatchMode), simply use imp.show() on the ImagePlus. If the image has a roi, you might also need the following after show for the roi to be displayed correctly
        Roi roi = imp.getRoi();
        if (roi!=null) imp.setRoi(roi);

Here you can find the full code how to display any image after BatchMode (no matter whether the image was created in Batchmode or already has a window):
    https://github.com/imagej/imagej1/blob/master/ij/macro/Functions.java#l2812

Michael
________________________________________________________________
On Nov 25, 2014, at 10:23, Avital Steinberg wrote:

> Thanks for your answer - I'm trying to do it in Java. There is no
> setBatchMode function in the Java ImageJ API. However, there is a Batchmode
> variable. I understood that accessing a field variable directly (without
> using a get or set method) is considered a bad coding practice. I saw
> various methods in the java ImageJ API such as addBatchModeImage, but I'm
> not sure what it does,
>
> Avital
>
> On Mon, Nov 24, 2014 at 6:59 PM, Straatman, Kees (Dr.) <[hidden email]
>> wrote:
>
>> Dear Avital,
>>
>> I assume you run a macro so according to
>> http://imagej.nih.gov/ij/developer/macro/functions.html#S you can use
>> either
>>
>> setBatchMode("exit and display"):  Exits batch mode and displays all
>> hidden images.
>>
>> or
>>
>> setBatchMode("show"): Displays the active hidden image, while batch mode
>> remains in same state. Requires 1.48h.
>>
>> 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
>> Avital Steinberg
>> Sent: 22 November 2014 15:34
>> To: [hidden email]
>> Subject: How to update the display after using batchMode
>>
>> Hi,
>> I set batchMode equal to true in order to turn off the display. I would
>> like to display the final processed image. I tried using
>> img.updateAndDraw() to show the final image, but the image window didn't
>> open. I also tried setting batchMode back to false, but that didn't work
>> either.
>>
>> How can I display the final image?
>>
>> Thank you,
>> Avital
>>
>> --
>> 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

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

Re: How to update the display after using batchMode

lechristophe
In reply to this post by Avital Steinberg
Hi Avital,

You are trying to replicate macro functioning in a Java plugin, which is
not necessary. There is no batch mode in Java plugins. When shifting from
macro to Java or Javascript, keep in mind that everything can be done
without display by default: call directly the processing method on you
object, rather than using "run" to launch *real* commands with display. So
you can have as many images, results tables, plots etc. in memory,
manipulate them, and choose which one to display and at which point (these
classes have a "display" function). It can get a bit tricky when you are
working with selections for exemples (manipulating selections without
actually "selecting" stuff, to avoid display), but the batch mode does not
work reliably when used in a macro iterating through the ROI manager anyway.

Hope this helps,

Christophe

2014-11-25 10:23 GMT+01:00 Avital Steinberg <[hidden email]>:

> Thanks for your answer - I'm trying to do it in Java. There is no
> setBatchMode function in the Java ImageJ API. However, there is a Batchmode
> variable. I understood that accessing a field variable directly (without
> using a get or set method) is considered a bad coding practice. I saw
> various methods in the java ImageJ API such as addBatchModeImage, but I'm
> not sure what it does,
>
> Avital
>
> On Mon, Nov 24, 2014 at 6:59 PM, Straatman, Kees (Dr.) <
> [hidden email]
> > wrote:
>
> > Dear Avital,
> >
> > I assume you run a macro so according to
> > http://imagej.nih.gov/ij/developer/macro/functions.html#S you can use
> > either
> >
> > setBatchMode("exit and display"):  Exits batch mode and displays all
> > hidden images.
> >
> > or
> >
> > setBatchMode("show"): Displays the active hidden image, while batch mode
> > remains in same state. Requires 1.48h.
> >
> > 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
> > Avital Steinberg
> > Sent: 22 November 2014 15:34
> > To: [hidden email]
> > Subject: How to update the display after using batchMode
> >
> > Hi,
> > I set batchMode equal to true in order to turn off the display. I would
> > like to display the final processed image. I tried using
> > img.updateAndDraw() to show the final image, but the image window didn't
> > open. I also tried setting batchMode back to false, but that didn't work
> > either.
> >
> > How can I display the final image?
> >
> > Thank you,
> > Avital
> >
> > --
> > 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
>

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

Re: How to update the display after using batchMode

Avital Steinberg
In reply to this post by Michael Schmid
Thank you - Christophe and Michael. Your answers were very helpful and now
I'm happy with my plugin. It corrected a bug that existed when it worked it
batchMode, and now I'm using better coding practices.

Michael - I used the following idea that you gave me: (I wasn't using
batchMode, but it's a useful idea regardless of that)

"if an image has no window yet (because it was created in BatchMode),
simply use imp.show() on the ImagePlus." when I had to use the run methods,
which work on the ImagePlus rather than the ImageProcessor and require the
image to be open.

I appreciate your help,

Avital

On Tue, Nov 25, 2014 at 11:50 AM, Michael Schmid <[hidden email]>
wrote:

> Hi Avital,
>
> when programming in Java, for most of the functionality you have API calls
> that work on ImageProcessor level and do not display anything, in contrast
> to the simple IJ.run(...) method. So, if possible, try to avoid Batchmode
> in plugins.
> Also, using BatchMode in a plugin is a bit dangerous, if you plugin casts
> an exception and does not exit Batchmode, you may run into trouble.
>
> If avoiding BatchMode is too cumbersome:
> If an image has no window yet (because it was created in BatchMode),
> simply use imp.show() on the ImagePlus. If the image has a roi, you might
> also need the following after show for the roi to be displayed correctly
>         Roi roi = imp.getRoi();
>         if (roi!=null) imp.setRoi(roi);
>
> Here you can find the full code how to display any image after BatchMode
> (no matter whether the image was created in Batchmode or already has a
> window):
>
> https://github.com/imagej/imagej1/blob/master/ij/macro/Functions.java#l2812
>
> Michael
> ________________________________________________________________
> On Nov 25, 2014, at 10:23, Avital Steinberg wrote:
>
> > Thanks for your answer - I'm trying to do it in Java. There is no
> > setBatchMode function in the Java ImageJ API. However, there is a
> Batchmode
> > variable. I understood that accessing a field variable directly (without
> > using a get or set method) is considered a bad coding practice. I saw
> > various methods in the java ImageJ API such as addBatchModeImage, but I'm
> > not sure what it does,
> >
> > Avital
> >
> > On Mon, Nov 24, 2014 at 6:59 PM, Straatman, Kees (Dr.) <
> [hidden email]
> >> wrote:
> >
> >> Dear Avital,
> >>
> >> I assume you run a macro so according to
> >> http://imagej.nih.gov/ij/developer/macro/functions.html#S you can use
> >> either
> >>
> >> setBatchMode("exit and display"):  Exits batch mode and displays all
> >> hidden images.
> >>
> >> or
> >>
> >> setBatchMode("show"): Displays the active hidden image, while batch mode
> >> remains in same state. Requires 1.48h.
> >>
> >> 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
> >> Avital Steinberg
> >> Sent: 22 November 2014 15:34
> >> To: [hidden email]
> >> Subject: How to update the display after using batchMode
> >>
> >> Hi,
> >> I set batchMode equal to true in order to turn off the display. I would
> >> like to display the final processed image. I tried using
> >> img.updateAndDraw() to show the final image, but the image window didn't
> >> open. I also tried setting batchMode back to false, but that didn't work
> >> either.
> >>
> >> How can I display the final image?
> >>
> >> Thank you,
> >> Avital
> >>
> >> --
> >> 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
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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