Jython scripting to close a notification or warning window

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

Jython scripting to close a notification or warning window

John-2
I have a jython script which uses TrakEM2 to register a large series of images. If it encounters a situation where it cannot find matching features, it interrupts the script with a notification. I cannot find a way around this.

First, is there a way to run a script with warnings or notifications completely disabled?

Second, is there a way to dismiss them in the script? Here is a more general example:

If I run the following without an image open, the IJ.getImage() will display a “No Image” error notification, after I manually dismiss it, it will move on to the “except”. I cannot find a way to get either the window manager or the “Close All”  to dismiss the notification. I’ve shuffled them around and no matter where I put them, I still have to manual close the “No Image” error window.

try:
                imp = IJ.getImage()

                IJ.run("Close All") # I've tried this

                w = WindowManager # And I've tried this
                win = w.getWindow("No Image")
                win.removeNotify()
except:
                print "except"

Thanks,
John

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

Re: Jython scripting to close a notification or warning window

Michael Schmid-3
Hi John,

since ImageJ handles the error condition of having no image by
displaying a notification box, the python try/except does not catch it.

Simply check at the beginning whether at least one image is there, e.g. with
   WindowManager.getImageCount()
An alternative is
   WindowManager.getCurrentImage()
which returns null if there is no image.

Michael
________________________________________________________________


On 05.09.19 21:46, John wrote:

> I have a jython script which uses TrakEM2 to register a large series of images. If it encounters a situation where it cannot find matching features, it interrupts the script with a notification. I cannot find a way around this.
>
> First, is there a way to run a script with warnings or notifications completely disabled?
>
> Second, is there a way to dismiss them in the script? Here is a more general example:
>
> If I run the following without an image open, the IJ.getImage() will display a “No Image” error notification, after I manually dismiss it, it will move on to the “except”. I cannot find a way to get either the window manager or the “Close All”  to dismiss the notification. I’ve shuffled them around and no matter where I put them, I still have to manual close the “No Image” error window.
>
> try:
>                  imp = IJ.getImage()
>
>                  IJ.run("Close All") # I've tried this
>
>                  w = WindowManager # And I've tried this
>                  win = w.getWindow("No Image")
>                  win.removeNotify()
> except:
>                  print "except"
>
> Thanks,
> John

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

Re: Jython scripting to close a notification or warning window

John-2
In reply to this post by John-2
Thank you, Michael, that solves the particular case I listed!

Unfortunately, I still have an additional issue in the script which require programmatically dismissing or suppressing other notifications:

When running Register_Virtual_Stack_MT.exec() to register images, if no matching features are found, it pauses the script to display a notification.

I've been looking through the documentation and cannot find a way to make this not happen. Any ideas?

Thanks,
John

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

Re: Jython scripting to close a notification or warning window

Albert Cardona-2
Hi John,
There is an underlying API for feature extraction, transformation
model finding and application that you could use directly.
See https://github.com/axtimwalde/mpicbg/ and also
https://github.com/trakem2/TrakEM2/tree/master/src/main/java/mpicbg/trakem2
Best,
Albert

Missatge de John Hensel <[hidden email]> del dia ds., 7
de set. 2019 a les 20:47:

>
> Thank you, Michael, that solves the particular case I listed!
>
> Unfortunately, I still have an additional issue in the script which require programmatically dismissing or suppressing other notifications:
>
> When running Register_Virtual_Stack_MT.exec() to register images, if no matching features are found, it pauses the script to display a notification.
>
> I've been looking through the documentation and cannot find a way to make this not happen. Any ideas?
>
> Thanks,
> John
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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