[ome-users] [bug] Opening Nifty (.nii) files fails on large images
Christian Niedworok
Christian.Niedworok at crick.ac.uk
Wed Apr 13 12:06:16 BST 2016
Dear OME Team,
I have stumbled across an issue when attempting to open the Nifty (.nii) file format.
When opening .nii files above a certain size (see below) using the Bio-Formats importer (5.1.8, build date 12. February 2016) on Fiji, it will crash with the following stack trace:
(Fiji Is Just) ImageJ 2.0.0-rc-43/1.50i; Java 1.6.0_24 [64-bit]; Linux 3.16.0-4-amd64; 3193MB of 140327MB (2%)
java.lang.IllegalArgumentException: Negative position
at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:600)
at loci.common.NIOByteBufferProvider.allocateDirect(NIOByteBufferProvider.java:127)
at loci.common.NIOByteBufferProvider.allocate(NIOByteBufferProvider.java:112)
at loci.common.NIOFileHandle.buffer(NIOFileHandle.java:602)
at loci.common.NIOFileHandle.seek(NIOFileHandle.java:293)
at loci.common.RandomAccessInputStream.seek(RandomAccessInputStream.java:174)
at loci.formats.in.NiftiReader.openBytes(NiftiReader.java:151)
at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:156)
at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:225)
at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:349)
at loci.formats.DimensionSwapper.openBytes(DimensionSwapper.java:249)
at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:349)
at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:269)
at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:260)
at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:335)
at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:335)
at loci.plugins.util.ImageProcessorReader.openProcessors(ImageProcessorReader.java:186)
at loci.plugins.in.ImagePlusReader.readProcessors(ImagePlusReader.java:416)
at loci.plugins.in.ImagePlusReader.readPlanes(ImagePlusReader.java:380)
at loci.plugins.in.ImagePlusReader.readImage(ImagePlusReader.java:277)
at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:238)
at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:216)
at loci.plugins.in.ImagePlusReader.openImagePlus(ImagePlusReader.java:111)
at loci.plugins.in.Importer.readPixels(Importer.java:149)
at loci.plugins.in.Importer.run(Importer.java:86)
at loci.plugins.LociImporter.run(LociImporter.java:78)
at ij.IJ.runUserPlugIn(IJ.java:216)
at ij.IJ.runPlugIn(IJ.java:180)
at ij.IJ.runPlugIn(IJ.java:169)
at HandleExtraFileTypes.openImage(HandleExtraFileTypes.java:499)
at HandleExtraFileTypes.run(HandleExtraFileTypes.java:72)
at ij.IJ.runUserPlugIn(IJ.java:216)
at ij.IJ.runPlugIn(IJ.java:180)
at ij.IJ.runPlugIn(IJ.java:169)
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.openAndAddToRecent(Opener.java:292)
at ij.plugin.DragAndDrop.openFile(DragAndDrop.java:192)
at ij.plugin.DragAndDrop.run(DragAndDrop.java:159)
at java.lang.Thread.run(Thread.java:662)
The behaviour is size-dependent and can be reproduced by e.g. generating .nii files with the matlab nifty toolbox (http://uk.mathworks.com/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image), but also happens with .nii files from different programs.
The command for generating my examples is in matlab is
save_nii(make_nii(rand(x1, x2, x3), [1 1 1]), 'test.nii')
with x1, x2 and x3 being the dimensions. If the image is "too large" it crashes, however thus far I could not find the pattern or exact size that causes this behaviour. Here is what I tried:
#voxels x1 x2 x3
270108000 1080*1220*205 crash
268790400 1080*1220*204 no crash
268460031 8193*1*32767 crash (despite having fewer voxels than the no crash example above)
268427264 8192*1*32767 no crash
268492798 4096*2*32767 crash
268427264 4096*2*32767 no crash
I am happy to upload test files of any dimensions if that would help.
Best
Christian
The Francis Crick Institute Limited is a registered charity in England and Wales no. 1140062 and a company registered in England and Wales no. 06885462, with its registered office at 215 Euston Road, London NW1 2BE.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-users/attachments/20160413/abacd778/attachment.html>
More information about the ome-users
mailing list