Test Python plugins on OMERO

Hi everyone,

I am trying to implement a plugin to be used on omero. I will need to test it to debug it, so i don’t want it to be visible by the other users (yet).
After some research, i found this tutorial:https://docs.openmicroscopy.org/omero/5.6.1/developers/scripts/advanced.html

I followed the guideline, but after uploading, i can’t figure where the script is uploaded. Should it be on the server, or on the PC i am using to code?

In any case, i can’t access it with omero web, but when i click on the button “Display the available plugins” on OMERO.insight, i am getting this error:

java.lang.Exception: Abnormal termination due to an uncaught exception.
java.lang.StringIndexOutOfBoundsException: begin 1, end 0, length 0
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
at java.base/java.lang.String.substring(String.java:1874)
at org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.showAvailableScriptsMenu(ToolBar.java:1013)
at org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerWin.showMenu(TreeViewerWin.java:979)
at org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.setAvailableScripts(TreeViewerComponent.java:4303)
at org.openmicroscopy.shoola.agents.treeviewer.ScriptsLoader.handleResult(ScriptsLoader.java:118)
at org.openmicroscopy.shoola.env.data.events.DSCallAdapter.eventFired(DSCallAdapter.java:90)
at org.openmicroscopy.shoola.env.data.views.BatchCallMonitor$1.run(BatchCallMonitor.java:124)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Abnormal termination due to an uncaught exception.
java.lang.StringIndexOutOfBoundsException: begin 1, end 0, length 0
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
at java.base/java.lang.String.substring(String.java:1874)
at org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.showAvailableScriptsMenu(ToolBar.java:1013)
at org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerWin.showMenu(TreeViewerWin.java:979)
at org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.setAvailableScripts(TreeViewerComponent.java:4303)
at org.openmicroscopy.shoola.agents.treeviewer.ScriptsLoader.handleResult(ScriptsLoader.java:118)
at org.openmicroscopy.shoola.env.data.events.DSCallAdapter.eventFired(DSCallAdapter.java:90)
at org.openmicroscopy.shoola.env.data.views.BatchCallMonitor$1.run(BatchCallMonitor.java:124)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Exception in thread “AWT-EventQueue-0”

at org.openmicroscopy.shoola.env.ui.UserNotifierImpl.showErrorDialog(UserNotifierImpl.java:189)
at org.openmicroscopy.shoola.env.ui.UserNotifierImpl.notifyError(UserNotifierImpl.java:289)
at org.openmicroscopy.shoola.env.AbnormalExitHandler.doTermination(AbnormalExitHandler.java:147)
at org.openmicroscopy.shoola.env.AbnormalExitHandler.terminate(AbnormalExitHandler.java:85)
at org.openmicroscopy.shoola.env.RootThreadGroup.uncaughtException(RootThreadGroup.java:69)
at java.desktop/java.awt.EventDispatchThread.processException(EventDispatchThread.java:222)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:214)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

The error disappears after i delete the plugin with /opt/omero/server/venv3/bin/omero script delete number_of_script

Any clues? Thanks by advance, Marc.

Hi Marc,

I think you need to upload the scripts as admin user with --official flag. Then it should show up in Web and Insight. But the error in Insight is definitely not expected either way. I’ll open an issue for that.
And yes, scripts are uploaded and run on the server directly.

Regards,
Dominik

Hi Dominik,

Thanks for your answer, but after reading it and reading:

https://docs.openmicroscopy.org/omero/5.6.1/developers/scripts/user-guide.html
https://docs.openmicroscopy.org/omero/5.6.1/developers/scripts/advanced.html

It means the scripts (labeled as “official”) will be uploaded on the server, via a root account, and will be visible and potentially executable by other users.

It wasn’t my plan: my current objective was to use them “privately” from my client PC to test them only on my images, like it was mentioned in https://docs.openmicroscopy.org/omero/5.6.1/developers/scripts/advanced.html

So i assume the only way to test them is to upload them on the server and to let them potentially be executable by any user, is that correct?

Thanks by advance, Marc.

Yes, an ‘official’ script has to be uploaded as an OMERO user with the respective permissions (or the OMERO root user) and is executable by everyone. Tbh, I don’t know how/who can run a non-‘official’ script, as they are not listed in the clients, as you noticed.
But I’m not sure, if the OMERO.script workflow is actually what you want. Wouldn’t a local Python script using the https://docs.openmicroscopy.org/omero/5.6.1/developers/Python.html API do the job?
Kind Regards,
Dominik

Hi Dominik,

Thanks for the link. I looked the examples a bit, it may be useful. But it leads to another question:

How can i decide when is it relevant either to use the Python API locally, or to import the Python script on the server?

To give you an idea, the plugin i will try to implement should:

  • Be able to make a montage image of selected channels of a picture and the addition of the channels.
  • Be able to tune separately the brightness/contrast of each channel selected.
  • Be able to be used on any image format (shouldn’t be too problematic with the Bio-Formats library, however some 12 bits images coded in 16 bit depth might be problematic for their contrast range. The LIF/LIFEXT images might be challenging too), and take into account the stacks of images.
  • And be able to be used on a full dataset on images, with the same tunings.
  • Maybe be able to make Z-projects of the montages.

I also assume that my plugin should be able to create another dataset, filled with the montage images.

The main finality of this plugin is to create montages dedicated for publication. You will probably tell me to use OMERO.figure, and i concede it is a good tool for that, but the main point is to use the same tunings of contrast/brightness on a whole dataset, so it make me think that OMERO.figure is not the best solution for that.

I hope to have given you enough details. If you know fellows who had similar problems (and maybe have developed more relevant solutions, or met problems i haven’t foresought - after all, i’m still a beginner), feel free to let me know.

However, thanks for the advice, Marc.

A non-official script requires there to be a user-mode processor started to answer any requests by the server. This can be done with omero script serve. Another option would be to use omero script run locally without the need to upload the scripts either way.

@will-moore gave an introduction to scripting OMERO.figure during OME2020. That can be done either via the JS in the browser or also via a script. It might be interesting as a comparison. (Looking for a reference then I’ll add it here)

~Josh

Hi @mmongy

You can script the creation of OMERO.figure files in Python as described at https://omero-guides.readthedocs.io/en/latest/figure/docs/omero_figure_scripting.html#figure-creation-in-python

You can write a script that will create a figure with all the Images from a Dataset, applying your chosen rendering settings to them all.
Then you can open the figure in the OMERO.figure app (apply any other edits if needed) and export it to create a new Image in OMERO. This new Image will be in the same Dataset as the source Images, but it’s easy enough to move it to it’s own Dataset.

How would you like users of the script to choose rendering settings for the Images?
In OMERO.figure you can also select all the Images in the figure and apply the same rendering settings to them all.

How many Images do you typically have in your Datasets?

Will.