You are correct, that is a bug in our code that we didn't notice, it will be fixed in the next release (for posterity, this bug affects 0.82 and earlier). I don't think we ever use -nifti-convert, which is about the only place that writes a nifti2 file that is broken that way (the code to write cifti files does not cause this problem). It might happen if you write a volume file with a dimension over 32767, I think that is the only other way to hit that bug.
Tim On Fri, Aug 2, 2013 at 3:45 PM, Matthew Brett <[email protected]>wrote: > Hi, > > I'm just finishing up a Nifti2 read / write module for nibabel: > http://nipy.org/nibabel > > To test it, I tried to read an image converted from Nifti1 using > Connectome Workbench. > > The original image is here: > > > https://github.com/nipy/nibabel/raw/master/nibabel/tests/data/example4d.nii.gz > > The converted image is here: > > https://www.dropbox.com/s/yj6pw7umpz26im5/example4d_ni2.nii.gz > > My reader fails when trying to read the Nifti extension from the > converted image. > > Looking at the nifti1 standard; > > http://www.nitrc.org/docman/view.php/26/64/nifti1.h > > I think that nifti1 extensions look like this: > > [348 bytes of header data] ending at 348 > [4 bytes of 'extension'] ending at 352, content [1, 0, 0, 0] if there > are extensions > [8 bytes of 2 ints, esize, ecode] ending at 360 for first extension > > Accordingly, here's a decimal hexdump of bytes 348 - 360 of the nifti1 > file: > > 00001 00000 00032 00000 00006 00000 30821 25460 > > So [1, 0, 0, 0], [32, 6] meaning: yes there are extensions, first > extension is length 32, type 6. > > By analogy, I think that a nifti2 header should have: > > [540 bytes of header data] ending at 540 > [4 bytes of 'extension'] ending at 544, content [1, 0, 0, 0] if there > are extensions > [8 bytes of 2 ints, esize, ecode] ending at 552 for first extension > > Here's a decimal hexdump of bytes 540 - 556 of the converted nifti2 file: > > 00002 00000 00001 00000 00032 00000 00006 00000 > > It looks like the [extension] and [esize, ecode] are offset by 4 > bytes, and start at 544. Is that right? Do you agree that they > should start at 540 instead? > > Thanks a lot, > > Matthew > _______________________________________________ > HCP-Users mailing list > [email protected] > http://lists.humanconnectome.org/mailman/listinfo/hcp-users > _______________________________________________ HCP-Users mailing list [email protected] http://lists.humanconnectome.org/mailman/listinfo/hcp-users
