<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Dear OME Team,<br>
<br>
I have stumbled across an issue when attempting to open the Nifty (.nii) file format.<br>
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:<br>
<br>
(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%)<br>
<br>
java.lang.IllegalArgumentException: Negative position<br>
at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:600)<br>
at loci.common.NIOByteBufferProvider.allocateDirect(NIOByteBufferProvider.java:127)<br>
at loci.common.NIOByteBufferProvider.allocate(NIOByteBufferProvider.java:112)<br>
at loci.common.NIOFileHandle.buffer(NIOFileHandle.java:602)<br>
at loci.common.NIOFileHandle.seek(NIOFileHandle.java:293)<br>
at loci.common.RandomAccessInputStream.seek(RandomAccessInputStream.java:174)<br>
at loci.formats.in.NiftiReader.openBytes(NiftiReader.java:151)<br>
at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:156)<br>
at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:225)<br>
at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:349)<br>
at loci.formats.DimensionSwapper.openBytes(DimensionSwapper.java:249)<br>
at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:349)<br>
at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:269)<br>
at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:260)<br>
at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:335)<br>
at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:335)<br>
at loci.plugins.util.ImageProcessorReader.openProcessors(ImageProcessorReader.java:186)<br>
at loci.plugins.in.ImagePlusReader.readProcessors(ImagePlusReader.java:416)<br>
at loci.plugins.in.ImagePlusReader.readPlanes(ImagePlusReader.java:380)<br>
at loci.plugins.in.ImagePlusReader.readImage(ImagePlusReader.java:277)<br>
at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:238)<br>
at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:216)<br>
at loci.plugins.in.ImagePlusReader.openImagePlus(ImagePlusReader.java:111)<br>
at loci.plugins.in.Importer.readPixels(Importer.java:149)<br>
at loci.plugins.in.Importer.run(Importer.java:86)<br>
at loci.plugins.LociImporter.run(LociImporter.java:78)<br>
at ij.IJ.runUserPlugIn(IJ.java:216)<br>
at ij.IJ.runPlugIn(IJ.java:180)<br>
at ij.IJ.runPlugIn(IJ.java:169)<br>
at HandleExtraFileTypes.openImage(HandleExtraFileTypes.java:499)<br>
at HandleExtraFileTypes.run(HandleExtraFileTypes.java:72)<br>
at ij.IJ.runUserPlugIn(IJ.java:216)<br>
at ij.IJ.runPlugIn(IJ.java:180)<br>
at ij.IJ.runPlugIn(IJ.java:169)<br>
at ij.io.Opener.openWithHandleExtraFileTypes(Opener.java:515)<br>
at ij.io.Opener.openImage(Opener.java:369)<br>
at ij.io.Opener.openImage(Opener.java:243)<br>
at ij.io.Opener.open(Opener.java:110)<br>
at ij.io.Opener.openAndAddToRecent(Opener.java:292)<br>
at ij.plugin.DragAndDrop.openFile(DragAndDrop.java:192)<br>
at ij.plugin.DragAndDrop.run(DragAndDrop.java:159)<br>
at java.lang.Thread.run(Thread.java:662)<br>
<br>
<br>
The behaviour is size-dependent and can be reproduced by e.g. generating .nii files with the matlab nifty toolbox (<a class="moz-txt-link-freetext" href="http://uk.mathworks.com/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image">http://uk.mathworks.com/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image</a>),
but also happens with .nii files from different programs.<br>
<br>
The command for generating my examples is in matlab is<br>
save_nii(make_nii(rand(x1, x2, x3), [1 1 1]), 'test.nii')<br>
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:<br>
<br>
#voxels x1 x2 x3<br>
270108000 1080*1220*205 crash<br>
268790400 1080*1220*204 no crash<br>
<br>
268460031 8193*1*32767 crash (despite having fewer voxels than the no crash example above)<br>
268427264 8192*1*32767 no crash<br>
<br>
268492798 4096*2*32767 crash<br>
268427264 4096*2*32767 no crash<br>
<br>
I am happy to upload test files of any dimensions if that would help.<br>
<br>
<br>
Best<br>
Christian<br>
<br>
<p style="color:rgb(112,113,115);font-family: 'Trebuchet MS', 'Lucida Grande'; font-style: italic; font-size: 10pt;">
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.
</p>
</body>
</html>