Imglib2 - Opening LIF images throws java.lang.UnsupportedOperationException

Hello everyone,

I am discovering Imglib2 through the excellent Jupyter tutorial, but I’m doing it the Jython way. I wanted to try to apply one of the script of the tutorial (the “copy image” script) on some datas of mine. Problem : some would not even open.
Here is how I would very basically open them :

from io.scif.img import IO
from net.imglib2.img.display.imagej import ImageJFunctions

path = "C:\Users\julien.dumont\Desktop\imagetest.tif"

img = IO.open(path)

ImageJFunctions.show(img)

I have three sample image. The first one is a small TIFF stack I created myself in Imagej. It opens and shows without any problem. The second one is a stack at LIF format, at the same location than the first one. here is the output :

Traceback (most recent call last):
  File "C:\Users\julien.dumont\Desktop\Bidouille\openimage.py", line 6, in <module>
    img = IO.open(path)
	at io.scif.io.VirtualHandle.read(VirtualHandle.java:82)
	at io.scif.io.RandomAccessInputStream.read(RandomAccessInputStream.java:436)
	at io.scif.formats.KontronFormat$Checker.isFormat(KontronFormat.java:153)
	at io.scif.AbstractChecker.isFormat(AbstractChecker.java:92)
	at io.scif.services.DefaultFormatService.getFormatList(DefaultFormatService.java:341)
	at io.scif.services.DefaultFormatService.getFormat(DefaultFormatService.java:316)
	at io.scif.services.DefaultInitializeService.initializeReader(DefaultInitializeService.java:88)
	at io.scif.img.ImgOpener.createReader(ImgOpener.java:419)
	at io.scif.img.ImgOpener.openImgs(ImgOpener.java:145)
	at io.scif.img.ImgOpener.openImgs(ImgOpener.java:113)
	at io.scif.img.IO.openImgs(IO.java:80)
	at io.scif.img.IO.open(IO.java:397)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.UnsupportedOperationException: java.lang.UnsupportedOperationException: Attempting to read or write from a io.scif.io.VirtualHandle. There is no source to operate on.

	at org.python.core.Py.JavaError(Py.java:552)
	at org.python.core.Py.JavaError(Py.java:543)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:206)
	at org.python.core.PyObject.__call__(PyObject.java:480)
	at org.python.core.PyObject.__call__(PyObject.java:484)
	at org.python.pycode._pyx23.f$0(C:/Users/julien.dumont/Desktop/Bidouille/openimage.py:8)
	at org.python.pycode._pyx23.call_function(C:/Users/julien.dumont/Desktop/Bidouille/openimage.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:171)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1614)
	at org.python.core.__builtin__.eval(__builtin__.java:497)
	at org.python.core.__builtin__.eval(__builtin__.java:501)
	at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259)
	at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:57)
	at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsupportedOperationException: Attempting to read or write from a io.scif.io.VirtualHandle. There is no source to operate on.
	at io.scif.io.VirtualHandle.read(VirtualHandle.java:82)
	at io.scif.io.RandomAccessInputStream.read(RandomAccessInputStream.java:436)
	at io.scif.formats.KontronFormat$Checker.isFormat(KontronFormat.java:153)
	at io.scif.AbstractChecker.isFormat(AbstractChecker.java:92)
	at io.scif.services.DefaultFormatService.getFormatList(DefaultFormatService.java:341)
	at io.scif.services.DefaultFormatService.getFormat(DefaultFormatService.java:316)
	at io.scif.services.DefaultInitializeService.initializeReader(DefaultInitializeService.java:88)
	at io.scif.img.ImgOpener.createReader(ImgOpener.java:419)
	at io.scif.img.ImgOpener.openImgs(ImgOpener.java:145)
	at io.scif.img.ImgOpener.openImgs(ImgOpener.java:113)
	at io.scif.img.IO.openImgs(IO.java:80)
	at io.scif.img.IO.open(IO.java:397)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
	... 23 more


I thought it was related to the LIF format. I then converted it to TIF format, and the result is exactly the same…
I know it is a very basic problem, but I’m completely stuck with this. I tried several opening options via Ops, ImgOpener, etc. All images are equally opened in Fiji.
If a good soul could take me out of this pity, I would be very grateful !

Have a good day !

Julien

I forgot to mention that both images could not be open with :

from ij import IJ


path = "C:\Users\julien.dumont\Desktop\Bidouille\16stack.tif"
img = IJ.openImage(path)
img.show()

As they are considered as NoneType.
And I can reproduce the issue with other images format.