<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 26/02/14 17:53, Mark Hiner wrote:<br>
    </div>
    <blockquote
cite="mid:CA+B=mGpYhgm9b5cj+4D2MMsbiAqDHr-uY3cTb-v_c2NnhXURfQ@mail.gmail.com"
      type="cite">
      <div dir="ltr"><br>
        <div>But if you don't want to use the config, like I said, it is
          not required unless you find the default behavior to be
          insufficient. Just wanted to share my discoveries :)<br>
          <br>
        </div>
      </div>
    </blockquote>
    Hi Mark,<br>
    <br>
    thanks, good to know, also the importing tricks.<br>
    <br>
    <blockquote
cite="mid:CA+B=mGpYhgm9b5cj+4D2MMsbiAqDHr-uY3cTb-v_c2NnhXURfQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px
            solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Now
            it sort of works, but I still don't see the image. I get an
            icon with the Java guy on the launcher bar, with the image
            name and "(V) (3.1%)". If I click that, all other windows
            disappear and there a small stick-like artefact on the top
            of the screen, but nothing more.<br>
          </blockquote>
          <br>
        </div>
        <div>A good litmus test here would be to open your Fiji
          installation that you're harvesting your dependencies from,
          run Help > Switch to Modern Mode, and try using File >
          Open on your dataset. That should go through the same/very
          similar SCIFIO API you're testing in your jython script.<br>
        </div>
      </div>
    </blockquote>
    <br>
    I downloaded a fresh Fiji today. The image opens with File >
    Open, but all channels and slices end up in one time-series. With
    the LOCI Bio-Formats importer plugin the image opens correctly as a
    stack of four colors.<br>
    <br>
    Then I used the jars from the new Fiji and the script that works for
    you:<br>
    <br>
    hajaalin@biotek973:~/Software/fiji-20140226$ md5sum
    fiji-linux64.tar.gz <br>
    36e4373297a5a8c0919a7be094b70a30  fiji-linux64.tar.gz<br>
    hajaalin@biotek973:~/Software/fiji-20140226$ export CLASSPATH=`find
    /home/hajaalin/Software/fiji-20140226/Fiji.app/jars -name '*.jar'
    |sed ':a;N;$!ba;s/\n/:/g'`<br>
    <br>
    With the stack the script crashes:<br>
    hajaalin@biotek973:~/Software/fiji-20140226$ jython
    /home/hajaalin/Software/fiji-20140219/Fiji.app/macros/imglib1.py
    /home/hajaalin/Data/Misha/composite1.ome.tif<br>
    <br>
    First there is one error:<br>
    [ERROR] Cannot create plugin: class='io.scif.bf.BioFormatsFormat',
    priority=10000.0, enabled=true, pluginType=Format<br>
    java.lang.IllegalAccessError: tried to access field
    io.scif.AbstractFormat.suffixes from class
    io.scif.bf.BioFormatsFormat<br>
        at
    io.scif.bf.BioFormatsFormat.<init>(BioFormatsFormat.java:107)<br>
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
    Method)<br>
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)<br>
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)<br>
        at
    java.lang.reflect.Constructor.newInstance(Constructor.java:526)<br>
        at java.lang.Class.newInstance(Class.java:374)<br>
        at
    org.scijava.plugin.PluginInfo.createInstance(PluginInfo.java:308)<br>
        at
org.scijava.plugin.DefaultPluginService.createInstance(DefaultPluginService.java:236)<br>
        at
org.scijava.plugin.DefaultPluginService.createInstances(DefaultPluginService.java:225)<br>
        at
org.scijava.plugin.DefaultPluginService.createInstancesOfType(DefaultPluginService.java:216)<br>
        at
io.scif.services.DefaultFormatService.initializeSingletons(DefaultFormatService.java:369)<br>
        at
io.scif.services.DefaultFormatService.formats(DefaultFormatService.java:322)<br>
        at
io.scif.services.DefaultFormatService.getFormatList(DefaultFormatService.java:287)<br>
        at
io.scif.services.DefaultFormatService.getFormat(DefaultFormatService.java:270)<br>
        at
io.scif.services.DefaultInitializeService.initializeReader(DefaultInitializeService.java:91)<br>
        at io.scif.img.ImgOpener.createReader(ImgOpener.java:377)<br>
        at io.scif.img.ImgOpener.openImg(ImgOpener.java:141)<br>
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br>
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>
        at java.lang.reflect.Method.invoke(Method.java:606)<br>
        at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:175)<br>
        at org.python.core.PyObject.__call__(PyObject.java:355)<br>
        at org.python.core.PyMethod.__call__(PyMethod.java:215)<br>
        at
    org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)<br>
        at org.python.core.PyMethod.__call__(PyMethod.java:206)<br>
        at org.python.core.PyObject.__call__(PyObject.java:414)<br>
        at org.python.core.PyObject.__call__(PyObject.java:418)<br>
        at
org.python.pycode._pyx0.f$0(/home/hajaalin/Software/fiji-20140219/Fiji.app/macros/imglib1.py:22)<br>
        at
org.python.pycode._pyx0.call_function(/home/hajaalin/Software/fiji-20140219/Fiji.app/macros/imglib1.py)<br>
        at org.python.core.PyTableCode.call(PyTableCode.java:165)<br>
        at org.python.core.PyCode.call(PyCode.java:18)<br>
        at org.python.core.Py.runCode(Py.java:1204)<br>
        at
    org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:200)<br>
        at org.python.util.jython.run(jython.java:246)<br>
        at org.python.util.jython.main(jython.java:129)<br>
    <br>
    <br>
    And the a problem in the script:<br>
    Traceback (most recent call last):<br>
      File
    "/home/hajaalin/Software/fiji-20140219/Fiji.app/macros/imglib1.py",
    line 20, in <module><br>
        img = opener.openImg( filename, config )<br>
        at
io.scif.ome.xml.meta.OMEXMLFormat$Checker.<init>(OMEXMLFormat.java:244)<br>
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
    Method)<br>
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)<br>
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)<br>
        at
    java.lang.reflect.Constructor.newInstance(Constructor.java:526)<br>
        at java.lang.Class.newInstance(Class.java:374)<br>
        at io.scif.AbstractFormat.createObject(AbstractFormat.java:209)<br>
        at
    io.scif.AbstractFormat.createContextualObject(AbstractFormat.java:170)<br>
        at io.scif.AbstractFormat.createChecker(AbstractFormat.java:118)<br>
        at
io.scif.services.DefaultFormatService.getFormatList(DefaultFormatService.java:288)<br>
        at
io.scif.services.DefaultFormatService.getFormat(DefaultFormatService.java:270)<br>
        at
io.scif.services.DefaultInitializeService.initializeReader(DefaultInitializeService.java:91)<br>
        at io.scif.img.ImgOpener.createReader(ImgOpener.java:377)<br>
        at io.scif.img.ImgOpener.openImg(ImgOpener.java:141)<br>
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br>
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>
        at java.lang.reflect.Method.invoke(Method.java:606)<br>
    <br>
    java.lang.NoSuchFieldError: java.lang.NoSuchFieldError:
    suffixNecessary<br>
    <br>
    <br>
    With a simple test image I get again the first error, but the script
    runs without problem.<br>
    <br>
    jython
    /home/hajaalin/Software/fiji-20140219/Fiji.app/macros/imglib1.py
    /home/hajaalin/Downloads/joo.jpg<br>
    <br>
    At this point there is the Java elf on the toolbar, but no image.<br>
    <br>
    <br>
    <br>
    <blockquote
cite="mid:CA+B=mGpYhgm9b5cj+4D2MMsbiAqDHr-uY3cTb-v_c2NnhXURfQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <br>
        </div>
        <div>Also, feel free to <a moz-do-not-send="true"
            href="http://fiji.sc/Upload_Sample_Image">upload your
            dataset</a>. I can then take a closer look at what's going
          on, and see if I can reproduce the display error you saw.<br>
          <br>
        </div>
      </div>
    </blockquote>
    I will send the test images and the screenshot.<br>
    <br>
    Harri<br>
    <br>
    <br>
    <blockquote
cite="mid:CA+B=mGpYhgm9b5cj+4D2MMsbiAqDHr-uY3cTb-v_c2NnhXURfQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>- Mark<br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Wed, Feb 26, 2014 at 9:19 AM, Harri
          Jäälinoja <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:harri.jaalinoja@helsinki.fi" target="_blank">harri.jaalinoja@helsinki.fi</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>Hi Mark, <br>
                <br>
                thanks a lot, setting CLASSPATH did the trick, after I
                removed the unnecessary lines. I didn't understand them
                anyway, I was just parroting <a moz-do-not-send="true"
                  href="http://fiji.sc/ImgLib2_Examples" target="_blank">http://fiji.sc/ImgLib2_Examples</a>.<br>
                <br>
                Now it sort of works, but I still don't see the image. I
                get an icon with the Java guy on the launcher bar, with
                the image name and "(V) (3.1%)". If I click that, all
                other windows disappear and there a small stick-like
                artefact on the top of the screen, but nothing more.<br>
                <br>
                Good progress anyway, more tomorrow.<span class="HOEnZb"><font
                    color="#888888"><br>
                    <br>
                    Harri</font></span>
                <div>
                  <div class="h5"><br>
                    <br>
                    On 26/02/14 16:41, Mark Hiner wrote:<br>
                  </div>
                </div>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div class="gmail_extra">Hi Harri,<br>
                        <br>
                        <blockquote style="margin:0px 0px 0px
                          0.8ex;border-left:1px solid
                          rgb(204,204,204);padding-left:1ex"
                          class="gmail_quote">java.lang.
                          <div>IllegalArgumentException:
                            java.lang.IllegalArgumentException: No
                            compatible service: io.scif.SCIFIOService<br>
                          </div>
                          hajaalin@biotek973:~/Software/
                          <div>mvn-IJ2$ jar tvf
                            target/dependency/scifio-0.9.2.jar |grep
                            SCIFIOService<br>
                               150 Fri Feb 14 16:24:24 EET 2014
                            io/scif/SCIFIOService.class</div>
                        </blockquote>
                        <br>
                      </div>
                      <div class="gmail_extra">So this exception may be
                        slightly misleading. SCIFIOService is a marker
                        interface for all the services that are part of
                        SCIFIO. When an org.scijava.Context is
                        initialized as it is here, it's typically given
                        a set of base service interfaces and then loads
                        all implementations of that service. So it seems
                        like the Context knows about the SCIFIOService
                        interface, but didn't discover any
                        implementations (things like
                        DefaultFormatService, DefaultImgUtilityService).<br>
                        <br>
                         So this brings me to my next point: I think
                        there is either a) a bug in jython where
                        annotations are not preserved or b) a bug with
                        the class loading logic used by Fiji/IJ2. I am
                        leaning towards a) right now.<br>
                        <br>
                      </div>
                      <div class="gmail_extra"> I am using an Ubuntu
                        12.04 64-bit VM. I installed Jython 2.5.3, but I
                        suspect you can get this working with 2.5.1.<br>
                        <br>
                      </div>
                      <div class="gmail_extra"> Anyway, I went back to
                        OSX and tested jython with the -Dpython.path
                        option, and got the same missing service
                        exception. But! If I set $CLASSPATH (java
                        automatically picks up the $CLASSPATH
                        environment variable) and run the equivalent of:<br>
                        <br>
                      </div>
                      <div class="gmail_extra">jython macros/imglib0.py
                        /home/hajaalin/Data/Misha/composite1.ome.tif<br>
                        <br>
                      </div>
                      <div class="gmail_extra">it works! Thus I believe
                        that python.path has a bug and although jython
                        supports discovery of classes on python.path, it
                        does not preserve their annotations (or some
                        similar metadata is being lost).<br>
                        <br>
                      </div>
                      <div class="gmail_extra">So instead of setting CP
                        and passing it via -Dpython.path, just use:<br>
                        <br>
                      </div>
                      <div class="gmail_extra">export CLASSPATH=`find
                        /home/hajaalin/Software/fiji-20140219/Fiji.app/jars
                        -name '*.jar' |sed ':a;N;$!ba;s/\n/:/g'`<br>
                        <br>
                      </div>
                      <div class="gmail_extra">A simple rule of thumb
                        is, try running a random SCIFIO class like "java
                        io.scif.SCIFIOService" from the command line. If
                        you get a NoClassDef error, your CLASSPATH is
                        not configured correctly. If you get a
                        "NoSuchMethodError: main", your CLASSPATH is
                        correct and your jython will pick up all the
                        desired classes.<br>
                      </div>
                      <div class="gmail_extra"><br>
                      </div>
                      <div class="gmail_extra">Moving on...<br>
                      </div>
                      <div class="gmail_extra"><br>
                        jython macros/imglib0.py
                        /home/hajaalin/Data/Misha/composite1.ome.tif<br>
                        <br>
                      </div>
                      <div class="gmail_extra"> ^ That then works a bit
                        better with my CLASSPATH set, except I get a
                        different runtime error about how ImgMode.CELL
                        can't be coerced to ImgMode. (same error I get
                        when running using Fiji).<br>
                        <br>
                      </div>
                      <div class="gmail_extra"> I notice that you aren't
                        actually using the SCIFIOConfig you construct,
                        so if you delete those lines and I'm finally
                        able to open an image. The SCIFIOConfig isn't
                        strictly necessary either - SCIFIO will open it
                        as a CellImg automatically if it needs to. I
                        will try to investigate further as to how to get
                        the types working for a nested enum in jython..<br>
                        <br>
                      </div>
                      <div class="gmail_extra">You may see yet another
                        error message about io.scif.bf.BioFormatsFormat
                        failing. This is because some jars in Fiji are
                        out of date, but that shouldn't cause
                        catastrophic failure (it just means that some
                        proprietary formats won't be supported right
                        now). These jars should be updated this week.<br>
                        <br>
                      </div>
                      <div class="gmail_extra">I hope this helps. Let me
                        know if you can't get this working on your end.<br>
                        <br>
                      </div>
                      <div class="gmail_extra">- Mark<br>
                      </div>
                    </div>
                  </blockquote>
                  <br>
                  <br>
                </div>
              </div>
              <div class="">
                <pre cols="72">-- 
__________________________________________________
Harri Jäälinoja
Light Microscopy Unit
Institute of Biotechnology, University of Helsinki
<a moz-do-not-send="true" href="http://www.biocenter.helsinki.fi/bi/lmu/" target="_blank">http://www.biocenter.helsinki.fi/bi/lmu/</a>
<a moz-do-not-send="true" href="tel:%2B358%209%20191%2059370" value="+358919159370" target="_blank">+358 9 191 59370</a> fax <a moz-do-not-send="true" href="tel:%2B358%209%20191%2059366" value="+358919159366" target="_blank">+358 9 191 59366</a>

</pre>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
__________________________________________________
Harri Jäälinoja
Light Microscopy Unit
Institute of Biotechnology, University of Helsinki
<a class="moz-txt-link-freetext" href="http://www.biocenter.helsinki.fi/bi/lmu/">http://www.biocenter.helsinki.fi/bi/lmu/</a>
+358 9 191 59370 fax +358 9 191 59366

</pre>
  </body>
</html>