Hi Alex, Josh et. al,<br><br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">I have used a similar approach to call ImageJ within OMERO scripts.
I had to overcome the Java headless problem (since my server does not
have an X environment and Java's AWT libraries on linux are tied to the X
server). This was easy enough for ImageJ with a few custom classes that
do not show graphical objects. I can then call ImageJ with a script to
do any processing I like on the exported TIFFs.<br></blockquote>
<br>Fiji employs similar hacks. It used to have a special JAR file that was prepended to the classpath before ij.jar, but now we opt to use Javassist with runtime patching instead, as it is less susceptible to problems when ij.jar changes. You can launch scripts and plugins headlessly using the --headless option of the Fiji launcher. See:<br>
<br> <a href="http://fiji.sc/wiki/index.php/Scripting_Help#Running_Scripts_in_Headless_Mode">http://fiji.sc/wiki/index.php/Scripting_Help#Running_Scripts_in_Headless_Mode</a><br><br>If you are going to try to integrate ImageJ1 with OMERO headlessly, I strongly suggest using Fiji rather than struggling with these issues yourself.<br>
<br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">java.lang.VerifyError: (class: loci/plugins/in/MainDialog, method:
rebuildDialog signature: (Lij/gui/GenericDialog;)V) Incompatible
argument to function<br></blockquote>
<br>We decided a while ago *not* to fix this in the Bio-Formats Importer plugin for ImageJ1. ImageJ2 is much more headless-friendly, including its file import mechanism (which is largely driven by Bio-Formats / SCIFIO).<br>
<br>I'm not sure what your use case is here, but is there way we can do it using ImageJ2 instead of ImageJ1?<br><br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
> Alternatively it may be that I should just recompile BioFormats
against my headless.jar. Then the Java linking should be OK.<br></blockquote><br>Unfortunately, I do not think this will work. You will need to change code in the Bio-Formats Importer that makes assumptions about the GenericDialog. One major issue is that the Importer attempts to rebuild a java.awt.Frame to add scroll bars, meaning it calls various AWT routines that have no hope of working headlessly.<br>
<br>-Curtis<br><br><br><div class="gmail_quote">On Wed, Feb 29, 2012 at 6:21 AM, Josh Moore <span dir="ltr"><<a href="mailto:josh@glencoesoftware.com">josh@glencoesoftware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Melissa, a few issues with headless exception of bioformats on the cluster which Alex recently brought up in a private message based on the forum post: <a href="https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=1051#p3834" target="_blank">https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=1051#p3834</a><br>
<br>
Also, if anyone else is doing something similar with their cluster and OMERO, let us know.<br>
<br>
~Josh.<br>
<br>
<br>
> Sent: Tue Feb 21, 2012 1:37 pm<br>
> by a.herbert<br>
><br>
> Hi Josh,<br>
><br>
> I can send you my code so you can have a look at it.<br>
<br>
Done. Thanks!<br>
<br>
> Basically I have an OMERO script that checks parameters and then calls a command-line script to do the work. This means I can test and develop the script without going through the OMERO scripts interface.<br>
><br>
> First I export the image as single plane tiffs. The only way I have managed to get it to work for my 16-bit multi-plane images is to convert them using numpy to 32-bit floats. These can be IO handled by PIL. PIL is not as advanced at reading and writing TIFFs as it could be.<br>
><br>
> The rest of the processing is done by submitting a bunch of jobs to a farm. The final script collates all the output images and uploads them using the Python API. This creates a new image using a numpy array generator that reads the TIFFs.<br>
><br>
> It is a bit of a mishmash but I got it to work. The reusable parts would probably be the process for getting the images out of OMERO and back in. The rest of the code is custom.<br>
><br>
> I have used a similar approach to call ImageJ within OMERO scripts. I had to overcome the Java headless problem (since my server does not have an X environment and Java's AWT libraries on linux are tied to the X server). This was easy enough for ImageJ with a few custom classes that do not show graphical objects. I can then call ImageJ with a script to do any processing I like on the exported TIFFs.<br>
><br>
> I could not use BioFormats in a headless environment. It has code tied to the X lib too. So instead of trying to recode this I just export my images to TIFFs and ImageJ can read them.<br>
<br>
See below for a follow-up on this.<br>
...<br>
> Alex<br>
<br>
<br>
<br>
<br>
> Sent: Tue Feb 28, 2012 4:41 pm<br>
> by a.herbert<br>
><br>
> I just checked the problem with BioFormats again. The issue is that to run in a headless environement you have to alter the GenericDialog so that it does not extend java.awt.Dialog. The java.awt.Dialog class throws a HeadlessException when GraphicsEnvironment.isHeadless() returns true.<br>
><br>
> Changing the signature causes BioFormats to error since the GenericDialog does not match the signature it is expecting:<br>
><br>
> Code: Select all<br>
> java.lang.VerifyError: (class: loci/plugins/in/MainDialog, method: rebuildDialog signature: (Lij/gui/GenericDialog;)V) Incompatible argument to function<br>
> at loci.plugins.in.ImporterPrompter.promptMain(ImporterPrompter.java:126)<br>
> at loci.plugins.in.ImporterPrompter.statusUpdated(ImporterPrompter.java:79)<br>
> at loci.plugins.in.ImportProcess.notifyListeners(ImportProcess.java:461)<br>
> at loci.plugins.in.ImportProcess.step(ImportProcess.java:757)<br>
> at loci.plugins.in.ImportProcess.execute(ImportProcess.java:142)<br>
> at loci.plugins.in.Importer.showDialogs(Importer.java:125)<br>
> at loci.plugins.in.Importer.run(Importer.java:77)<br>
> at loci.plugins.LociImporter.run(LociImporter.java:79)<br>
> at ij.IJ.runUserPlugIn(IJ.java:183)<br>
> at ij.IJ.runPlugIn(IJ.java:150)<br>
> at ij.Executer.runCommand(Executer.java:127)<br>
> at ij.Executer.run(Executer.java:64)<br>
> at ij.IJ.run(IJ.java:249)<br>
> at ij.macro.Functions.doRun(Functions.java:579)<br>
> at ij.macro.Functions.doFunction(Functions.java:82)<br>
> at ij.macro.Interpreter.doStatement(Interpreter.java:203)<br>
> at ij.macro.Interpreter.doStatements(Interpreter.java:191)<br>
> at ij.macro.Interpreter.run(Interpreter.java:102)<br>
> at ij.macro.Interpreter.run(Interpreter.java:72)<br>
> at ij.macro.Interpreter.run(Interpreter.java:83)<br>
> at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:102)<br>
> at ij.plugin.Macro_Runner.runMacroFile(Macro_Runner.java:87)<br>
> at ij.IJ.runMacroFile(IJ.java:117)<br>
> at ij.ImageJ.main(ImageJ.java:610)<br>
><br>
><br>
> Maybe I have not got my headless modifications correct. There may be a way around this I have not tried.<br>
><br>
> Alternatively it may be that I should just recompile BioFormats against my headless.jar. Then the Java linking should be OK.<br>
><br>
> I'll package up my cluster scripts and send them to you.<br>
><br>
> Alex<br>
_______________________________________________<br>
ome-devel mailing list<br>
<a href="mailto:ome-devel@lists.openmicroscopy.org.uk">ome-devel@lists.openmicroscopy.org.uk</a><br>
<a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel" target="_blank">http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel</a><br>
</blockquote></div><br>