Error opening FSL NIfTI, but not SPM NIfTI

The default NIfTI reader (that operates when I simply use the Open… dialog) opens SPM-generated 4D NIfTI files fine. They load as a 4D object and look beautiful.

However when I attempt to open FSL or dcm2nii -generated 4D NIfTI files, I get the following error, below.

Please let me know if this functionality is currently being maintained, if not I can jump in and try to debug.

UPDATE: This is down to the .nii.gz format. When a nifti of any variety is first converted from .nii.gz to .nii, it opens fine. However, .nii.gz is the most common format, so it should probably be debugged.

Eric


(Fiji Is Just) ImageJ 2.0.0-rc-49/1.51e25; Java 1.8.0_66 [64-bit]; Linux 4.4.0-28-generic; 83MB of 20577MB (<1%)

java.lang.NullPointerException
    at loci.formats.in.NiftiReader.initFile(NiftiReader.java:234)
    at loci.formats.FormatReader.setId(FormatReader.java:1426)
    at loci.plugins.in.ImportProcess.initializeFile(ImportProcess.java:505)
    at loci.plugins.in.ImportProcess.execute(ImportProcess.java:143)
    at loci.plugins.in.Importer.showDialogs(Importer.java:140)
    at loci.plugins.in.Importer.run(Importer.java:76)
    at loci.plugins.LociImporter.run(LociImporter.java:78)
    at ij.IJ.runUserPlugIn(IJ.java:217)
    at ij.IJ.runPlugIn(IJ.java:181)
    at ij.IJ.runPlugIn(IJ.java:170)
    at HandleExtraFileTypes.openImage(HandleExtraFileTypes.java:499)
    at HandleExtraFileTypes.run(HandleExtraFileTypes.java:72)
    at ij.IJ.runUserPlugIn(IJ.java:217)
    at ij.IJ.runPlugIn(IJ.java:181)
    at ij.IJ.runPlugIn(IJ.java:170)
    at ij.io.Opener.openWithHandleExtraFileTypes(Opener.java:515)
    at ij.io.Opener.openImage(Opener.java:369)
    at ij.io.Opener.openImage(Opener.java:243)
    at ij.io.Opener.open(Opener.java:110)
    at ij.io.Opener.open(Opener.java:73)
    at ij.plugin.Commands.run(Commands.java:27)
    at ij.IJ.runPlugIn(IJ.java:187)
    at ij.Executer.runCommand(Executer.java:137)
    at ij.Executer.run(Executer.java:66)
    at java.lang.Thread.run(Thread.java:745)

If anyone involved with bio-formats/LOCI is interested to have this moved along:

The error points to this switch block. The switch block only handles the extensions .hdr and .nii . I propose also handling .nii.gz, by validating with the gzip handle class in bio-formats and using (unless bio-formats has a proprietary version) a Java 7 GZipInputStream .

This last line, then throws a null pointer exception for pixelFile which has not been properly handled when the suffix is not .hdr or .nii .
If the community is happy for me to do this I will fork the LOCI code, then submit a pull request.

1 Like

Update 2: Done! I forked the code and edited LOCI’s NIfTI reader to open .nii.gz files. It was tested by swapping out the snapshot jar for the old jar, and it opens .nii.gz now, as well as still opening .nii and .img / .hdr .

The pull request can be viewed below. Perhaps someone could advise whether I should also post a discussion thread over at OME, or whether posting here is good enough. If I don’t hear from anyone, I will post at OME sometime this week or next:

2 Likes

Thanks for your initiative, @ericbarnhill! Awesome to have your contribution.