Cannot open BioFormats Image

Hi all,

hope, this is the right place to ask the following question.
I have a problem opening an microscope image (*.czi) from my plugin. Other images (e.g. *.tif) open fine.
I get an io.scif.FormatException. For me it looks like the BioFormats package was not included, so I think there might be an error in my pom.xml. I use pom-fiji (version 15.3.0) as parent. Can anyone help me with this issue?

Thanks,
cri

Exception:

io.scif.FormatException: Image53.czi: No supported format found.
    at io.scif.services.DefaultFormatService.getFormatList(DefaultFormatService.java:341)
    at io.scif.services.DefaultFormatService.getFormat(DefaultFormatService.java:310)
    at io.scif.services.DefaultDatasetIOService.canOpen(DefaultDatasetIOService.java:81)
    at io.scif.io.DatasetIOPlugin.supportsOpen(DatasetIOPlugin.java:65)
    at org.scijava.io.DefaultIOService.getOpener(DefaultIOService.java:66)
    at org.scijava.plugins.commands.io.OpenFile.run(OpenFile.java:84)
    at ImgOpenTest.main(ImgOpenTest.java:18)

Sample code (works with tiff images but fails with czi files):

public class ImgOpenTest {
	public static void main(String[] args){
		ImageJ ij2=net.imagej.Main.launch(args);
		OpenFile openfile=new OpenFile();
		openfile.setContext(ij2.getContext());
		openfile.setInputFile(new File("Image53.czi"));
		openfile.run();
		Dataset dataset=(Dataset)openfile.getData();
		ij2.ui().show(dataset);
	}
}

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>at.ac.oeaw.gmi</groupId>
  <artifactId>ImgOpenTest</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <parent>
  	<groupId>sc.fiji</groupId>
  	<artifactId>pom-fiji</artifactId>
  	<version>15.3.0</version>
  </parent>

	<repositories>
	  <!-- NB: for project parent -->
	  <repository>
	    <id>imagej.public</id>
	    <url>http://maven.imagej.net/content/groups/public</url>
	  </repository>
	</repositories>	

	<dependencies>
		<dependency>
			<groupId>net.imagej</groupId>
			<artifactId>imagej</artifactId>
		</dependency>
	</dependencies>
</project>
1 Like

I use pom-fiji (version 15.3.0) as parent

You’re very close. The problem is that the core ImageJ libraries do not depend on Bio-Formats due to their licensing.

All you should need is to add the scifio-bf-compat library as a dependency, as it includes a Bio-Formats plugin.

		<dependency>
			<groupId>io.scif</groupId>
			<artifactId>scifio-bf-compat</artifactId>
		</dependency>
2 Likes

Thanks, for your reply.

In fact I had to add two dependencies for the czi-images to open. Without “ome:bio-formats_plugins” I got lots of ClassNotFoundExceptions.

<dependency>
	<groupId>io.scif</groupId>
	<artifactId>scifio-bf-compat</artifactId>
</dependency>
<dependency>
	<groupId>ome</groupId>
	<artifactId>bio-formats_plugins</artifactId>
</dependency>

Thank you for testing and reporting back. That wasn’t the intent, so I opened an issue to investigate further.