<div dir="ltr"><div>Hi Graeme,</div><div><br></div><div>Sorry for the delay in reply. Writing to a public mailing list is better. I am CCing imagej-devel and ome-devel since your questions are very technical, and related to those two projects.</div>
<div><br></div><div>> I thought I would Email you directly because the ImageJ-devel</div><div>> mailing list seems to be intended for core project development.</div><div><br></div><div>From <a href="http://developer.imagej.net/mailing-lists">http://developer.imagej.net/mailing-lists</a>:</div>
<div><div>> ImageJ: For general user and developer discussion about ImageJ. This</div><div>> list is the best place to go for help with your specific use case.</div><div>></div><div>> ImageJ-devel: For technical and developer discussion of the ImageJ2</div>
<div>> project. This list is for programmers contributing code to ImageJ2, or</div><div>> interested in technical discussions surrounding such development.</div></div><div><br></div><div>Both are public mailing lists intended for use by the community, not just for core project development. The wording of ImageJ-devel is phrased that way because ImageJ2 is still in beta and if you are using it for your projects, you are an early adopter who is almost certainly "interested in technical discussions" surrounding core development.</div>
<div><br></div><div><div>> 1. I was looking for example plugins (& example minimal plugin</div><div>> project), but get 404's when I try to look at the HelloWorld and</div><div>> GradientImage examples here:-</div>
<div>> <a href="http://developer.imagej.net/writing-imagej2-plugins">http://developer.imagej.net/writing-imagej2-plugins</a></div><div>> (I found the github repo & Fiji wiki ImgLib2 examples)</div></div><div><br>
</div><div>All links on that page should be working again.</div><div><br></div><div><div>> 2. I see an example of calling IJ2 from a legacy plugin, but am also</div><div>> interested in doing the reverse, and unsure what the limitations are.</div>
</div><div><br></div><div>The limitations are evolving. Legacy support is very challenging to get right. That said, it should work to call ImageJ1 data structures from an ImageJ2 style command. There is a LegacyService for converting between IJ1 and IJ2 data structures, although the API still needs work.</div>
<div><br></div><div>Note that at the moment, ImageJ2 commands are only discovered and exposed in the modern ImageJ2 UI. We are exploring ways of blending things in additional ways, such as allowing the ImageJ1/Fiji legacy UI to discover and allow execution of IJ2 commands.</div>
<div><br></div><div>What is your goal? You want to write a plugin that is available from both IJ1 and IJ2? If so, structuring it as a legacy IJ1 plugin (which may or may not leverage certain IJ2 API internally as demonstrated in calling-modern-from-legacy) is the way to go for now.</div>
<div><br></div><div><div>> 3. What are the constraints / requirements for running plugins</div><div>> (including legacy wrapped in IJ2?) headless, with a view to running</div><div>> from OMERO in future?</div></div>
<div><br></div><div>In IJ2 terms, the ImgLib2 library is fully usable headless. If your IJ2 command does not depend on ij-ui you probably will be able to run it headlessly. The requirements, in general, are the same as running any Java code headless: do not use AWT or Swing or other UI, especially Windows/Frames/Dialogs.<br>
</div><div><br></div><div>Unfortunately, you cannot just take a legacy IJ1 plugin and "wrap in IJ2." The problem is that fundamentally, IJ1 is filled with java.awt references including some core classes extending java.awt.Dialog and java.awt.Frame, which are illegal to even instantiate headlessly.</div>
<div><br></div><div>We have some crazy hacks in Fiji to allow limited execution of IJ2 code headless even when it would normally use those AWT window classes. It works by using bytecode manipulation (javassist library) to rewrite parts of IJ1 at runtime to avoid references to those classes. However, in some cases things will still blow up. It should go without saying that any time an IJ1 plugin asks the user for input (e.g., the WaitForUserInput dialog), it will fail when trying to run headless.</div>
<div><br></div><div>All of that said, we may be able to support calling many IJ1 plugins headlessly from OMERO in the same way we support it headlessly in general: using by install Xvfb on the server side. This gets around the limitations of java.awt.headless=true, in favor of actually giving Java a virtual/offscreen UI. See: <a href="http://fiji.sc/Headless">http://fiji.sc/Headless</a></div>
<div><br></div><div>As of this writing, I have not yet tried to get legacy IJ1 plugins working from OMERO. The reason is that I know it will be a lot of effort, for something that would only be transitional. We are writing IJ2 precisely to avoid the sorts of problems incurred by IJ1's heavy use of AWT in core classes. IJ2 maintains a strict separation of concerns, and its commands have typed inputs and outputs, which are a natural match to other paradigms such as OMERO scripts, CellProfiler modules, and KNIME nodes. Mapping IJ1 plugins to those paradigms is difficult not only due to headless issues but also because in general there is no easy way to know the actual inputs and outputs of the plugin, since IJ1 plugins do not declare that metadata.</div>
<div><br></div><div>So in conclusion, while I sympathize with the desire to execute ImageJ1 plugins from OMERO, ultimately a better direction is to rewrite plugins of interest as ImageJ2 commands so we truly get a "write once, run anywhere" effect with the whole software ecosystem interoperating with ImageJ2.</div>
<div><br></div><div><div>> Apologies if I missed some documentation, or a more appropriate</div><div>> community forum to ask these questions, and me know if I am jumping</div><div>> the gun and would be better waiting a few months.</div>
</div><div><br></div><div>Not at all; these are good questions and not well explained online. I added a couple of short entries to the online FAQ:</div><div><br></div><div><a href="http://developer.imagej.net/can-i-call-imagej2-api-imagej1-plugin">http://developer.imagej.net/can-i-call-imagej2-api-imagej1-plugin</a><br>
</div><div><div><a href="http://developer.imagej.net/can-i-call-imagej1-api-imagej2-command">http://developer.imagej.net/can-i-call-imagej1-api-imagej2-command</a><br></div><div><br></div></div><div>Please let me know if there are other topics you would like to see covered on the website.</div>
<div><br></div><div>Regards,</div><div>Curtis</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 26, 2013 at 6:39 PM, Graeme Ball <span dir="ltr"><<a href="mailto:graemeball@googlemail.com" target="_blank">graemeball@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Curtis, </div><div><br></div><div>I have a few questions about writing plugins for ImageJ2, </div>
<div>and I thought I would Email you directly because the </div>
<div>ImageJ-devel mailing list seems to be intended for core </div><div>project development. </div><div><br></div><div>1. I was looking for example plugins (& example minimal </div>
<div> plugin project), but get 404's when I try to look at </div><div> the HelloWorld and GradientImage examples here:- </div><div> <a href="http://developer.imagej.net/writing-imagej2-plugins" target="_blank">http://developer.imagej.net/writing-imagej2-plugins</a> </div>
<div> (I found the github repo & Fiji wiki ImgLib2 examples) </div><div><br></div><div>2. I see an example of calling IJ2 from a legacy plugin, </div><div> but am also interested in doing the reverse, and </div>
<div> unsure what the limitations are. </div><div><br></div><div>3. What are the constraints / requirements for running </div><div> plugins (including legacy wrapped in IJ2?) headless, </div>
<div> with a view to running from OMERO in future? </div><div><br></div><div>Apologies if I missed some documentation, or a more </div><div>appropriate community forum to ask these questions, and </div>
<div>let me know if I am jumping the gun and would be better </div><div>off waiting a few months. </div><div><br></div><div>Thanks & Best Regards, </div>
<div><br></div><div>Graeme</div><div><br></div><div><div>-- </div><div>--------------------------- </div><div>Dr. Graeme Ball </div><div>Department of Biochemistry </div>
<div>University of Oxford </div><div>South Parks Road </div><div>Oxford OX1 3QU </div><div>Phone <a href="tel:%2B44-1865-613-359" value="+441865613359" target="_blank">+44-1865-613-359</a> </div>
<div>---------------------------</div>
</div></div>
</blockquote></div><br></div>