Include nrrd reader in project

Tags: #<Tag:0x00007fd543164890> #<Tag:0x00007fd5431646d8> #<Tag:0x00007fd5431644f8>



I am in the progress of trying to write a plugin that has to deal with nrrd-files. Last thing I heard, is that scifio does not support this format yet.
So I tried to include the stuff to my pom (that has pom-scijava as parent):


Buit when launching a ImageJ instance

ImageJ ij = new net.imagej.ImageJ();

… I cannot find File > Import > Nrrd in the menu
consequently the following code fails:

ImagePlus ref = new ImagePlus();, "Nrrd ...", path.getAbsolutePath());

What do I have to do to have the nrrd reader available in my project?


huh, weird…

File path = new File("path/to/my/file.nrrd");
ImagePlus ref =IJ.openImage(path.getAbsolutePath());;

kinda works
but throws io.scif.img.ImgIOException: io.scif.UnsupportedCompressionException: Unsupported encoding: gzip
	at net.imagej.legacy.DefaultLegacyHooks.interceptOpenImage(
	at ij.IJ.openImage(
	at SectionToVolumeRegistration.main(
Caused by: io.scif.img.ImgIOException: io.scif.UnsupportedCompressionException: Unsupported encoding: gzip
	at io.scif.img.ImgOpener.openImgs(
	at io.scif.img.ImgOpener.openImgs(
	at io.scif.img.ImgOpener.openImgs(
	... 7 more
Caused by: io.scif.UnsupportedCompressionException: Unsupported encoding: gzip
	at io.scif.formats.NRRDFormat$Reader.openPlane(
	at io.scif.formats.NRRDFormat$Reader.openPlane(
	at io.scif.AbstractReader.openPlane(
	at io.scif.filters.ChannelFiller.openPlane(
	at io.scif.filters.ChannelFiller.openPlane(
	at io.scif.filters.PlaneSeparator.openPlane(
	at io.scif.filters.PlaneSeparator.openPlane(
	at io.scif.filters.AbstractReaderFilter.openPlane(
	at io.scif.filters.AbstractReaderFilter.openPlane(
	at io.scif.img.ImgOpener.readPlanes(
	at io.scif.img.ImgOpener.openImgs(
	... 10 more


Hi @FelixM,

Do you have imagej-legacy on the classpath, i.e. is it a dependency of your project? NrrdReader and NrrdWriter are ImageJ1 plugins and will thus not be shown in the ImageJ2 user interface (which is the one that should be launched if you don’t have imagej-legacy on the classpath).

There is an NRRD implementation in SCIFIO which can’t handle gzipped image planes. This has nothing todo with the added dependency of sc.fiji:IO_ as far as I can tell.



Hey @stelfrich

thanks for your comments.

yes it has been in the class path.

which explains why

ImagePlus ref =IJ.openImage(path.getAbsolutePath());

… works
But I still cannot find the _Menu > File > Import > Nrrd in the menu though.

The error message I posted previously is consistant with that. Its the same when calling

Object obj =;

… whith the difference that the above ij2 command does not yield an image display, but the legacy code IJ.openImage(path.getAbsolutePath()); actually does open an image display despite the error message.

I can work with that. But it leaves me a bit confused.


Me too, but then I realized that those readers in IO_ are IJ1 plugins. Such plugins have to be located in a specific directory of an IJ1 installation (defined by the ij.dir property) since they are loaded from files and not discovered from the classpath (which is done for SciJava Commands :clap:). When executing from Eclipse/Netbeans/etc you’ll have to work around that “feature” by setting the ij.dir property. In practice, take a look at the explanation in the wiki (of course there is information on that… duh):


Thanks @stelfrich

in the following example the nrrd stuff is accessible during runtime and everything works as expected.

@Plugin(type = Command.class, menuPath = "Plugins > Test")
public class TestPlugin implements Command {

    public void run() {
        File path = new File("/path/to/file.nrrd");

        ImagePlus ref = new ImagePlus();, "Nrrd ...", "load=" + path.getAbsolutePath());;

    public static void main(String[] args) {"Test", "");

Calling the plugin like this takes a long time for ImageJ to start though.

However, is there a way that to get the class loader to include everything in the main() method?


Hmm. I have played around with the following project:

Startup time doesn’t seem to be an issue for me compared to the startup time of standalone Fiji. Maybe a second?

However, depending on the dependencies of your project, start up time might differ significantly. Remember that discovery of Commands and stuff like menu entries are created during runtime. So the complete classpath has to be scanned for potential candidates. What other dependencies do you have in your POM?


many :slight_smile:
clearvolume, bigdataviewer, and many more…