The 02_0_Load_and_Display_Dataset.py tutorial

@ctrueden - Hi Curtis, It’s me again. I’m sure you’ve missed me so I’m posting again. When I try to run the templates, tutorials, 02 - Load and Display Dataset by just clicking the run button, it opens a dialog box and if I choose a file, it gives an error message such as:

Traceback (most recent call last):
  File "/Users/avitalsteinberg/02_-_Load_and_Display_Dataset.py", line 6, in <module>
    dataset = ds.open(file.getAbsolutePath())
	at io.scif.services.DefaultDatasetIOService.open(DefaultDatasetIOService.java:136)
	at io.scif.services.DefaultDatasetIOService.open(DefaultDatasetIOService.java:111)
	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:497)

java.io.IOException: java.io.IOException: io.scif.img.ImgIOException: io.scif.FormatException: /Users/avitalsteinberg/01_-_Intro_to_ImageJ_API.groovy: No supported format found.

	at org.python.core.Py.JavaError(Py.java:546)
	at org.python.core.Py.JavaError(Py.java:537)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
	at org.python.core.PyObject.__call__(PyObject.java:478)
	at org.python.core.PyObject.__call__(PyObject.java:482)
	at org.python.core.PyMethod.__call__(PyMethod.java:141)
	at org.python.pycode._pyx3.f$0(/Users/avitalsteinberg/02_-_Load_and_Display_Dataset.py:9)
	at org.python.pycode._pyx3.call_function(/Users/avitalsteinberg/02_-_Load_and_Display_Dataset.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:167)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1386)
	at org.scijava.plugins.scripting.jython.JythonScriptEngine.eval(JythonScriptEngine.java:75)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:177)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:167)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
	at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: io.scif.img.ImgIOException: io.scif.FormatException: /Users/avitalsteinberg/01_-_Intro_to_ImageJ_API.groovy: No supported format found.
	at io.scif.services.DefaultDatasetIOService.open(DefaultDatasetIOService.java:136)
	at io.scif.services.DefaultDatasetIOService.open(DefaultDatasetIOService.java:111)
	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:497)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
	... 19 more
Caused by: io.scif.img.ImgIOException: io.scif.FormatException: /Users/avitalsteinberg/01_-_Intro_to_ImageJ_API.groovy: No supported format found.
	at io.scif.img.ImgOpener.createReader(ImgOpener.java:568)
	at io.scif.img.ImgOpener.openImgs(ImgOpener.java:145)
	at io.scif.services.DefaultDatasetIOService.open(DefaultDatasetIOService.java:126)
	... 25 more
Caused by: io.scif.FormatException: /Users/avitalsteinberg/01_-_Intro_to_ImageJ_API.groovy: No supported format found.
	at io.scif.services.DefaultFormatService.getFormatList(DefaultFormatService.java:351)
	at io.scif.services.DefaultFormatService.getFormat(DefaultFormatService.java:317)
	at io.scif.services.DefaultInitializeService.initializeReader(DefaultInitializeService.java:89)
	at io.scif.img.ImgOpener.createReader(ImgOpener.java:562)
	... 27 more

Was I expected to run it from a command line and pass the File file string as an argument?

Thanks,
Avital

Hi Avital,

for me the script works fine with common file formats (e.g. PNG, JPEG and TIFF). When I try to open a DM3 file the same error message is displayed. DatasetIOService.open() seams to work different than IJ.open(), as it cannot use all import plugins.

1 Like

Thanks, Michael - when I tried to open a .png file it did open it.

It should be the case that DatasetIOService.open() works with many more formats than IJ.open() can, because DatasetIOService uses all available SCIFIO plugins, including all of Bio-Formats—whereas IJ.open() supports only those formats hardcoded by ImageJ + HandleExtraFileTypes. In my tests, I was able to successfully use the “02 - Load and Display Dataset” script to open PNG, JPEG, TIFF, DICOM, OME-TIFF, SDT and Gatan DM3 file formats.

That error message suggests that when the file chooser popped up, you selected the file 01_-_Intro_to_ImageJ_API.groovy, which is a groovy script, not a DM3 file. Are you sure you clicked on the correct file? If so, that is a very strange bug indeed!

1 Like

Hi Curtis - I randomly selected a file (which was a .groovy script) that the Fiji gui can open because I didn’t know what types of files I should select, but then when I tried selecting a different file format (such as .png), the script did work. What I meant by “problem solved” was that the script does work if the user selects a file format which is one of the types that Michael mentioned.