[Pkg-exppsy-pynifti] nifti extensions bug?

Kanterakis, Efstathios Efstathios.Kanterakis at uphs.upenn.edu
Mon Feb 23 20:04:38 UTC 2009


Dear all,
I've been using pynifti for quite a while and it has made a big
difference in our lab. Thanks for continuing to develop and support it.
Recently I've been playing around with Nifti header extensions and
discovered a potential bug.
Seems that extensions which are N*16+8 characters (bytes) in length get
saved with junk characters appended at the end.

To re-create the problem, I attach a simple script that creates a blank
image, adds extensions of a variety of sizes, saves the image and then
retrieves the extensions back.

For lengths 8 and 24, with this text as input:
12345678
123456789012345678901234

I get the following text back:
12345678`Z~\x17'
123456789012345678901234!

When I use Afni's nifti_tool to display header extensions I get:
> nifti_tool -disp_exts -infiles bug_report.nii
header file 'bug_report.nii', num_ext = 18
    ext #0 : ecode = 0, esize = 16, edata = (unknown data type)
    ext #1 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #2 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #3 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #4 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #5 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #6 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #7 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #8 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #9 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #10 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #11 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #12 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #13 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #14 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #15 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #16 : ecode = 0, esize = 32, edata = (unknown data type)
    ext #17 : ecode = 0, esize = 48, edata = (unknown data type)

So pynifti in most cases saves the extensions correctly, as per nifti
specifications ("esize must be a positive integral multiple of 16"
http://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1field
s_pages/extension.html)
except for the case explained above.

I attach the nifti file that was created by this script for your
convenience.

Looking forward to the next release!

Thank you very much for your help and efforts
Regards,
Stathis Kanterakis




The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: extensions_bug.py
Type: application/octet-stream
Size: 1239 bytes
Desc: extensions_bug.py
Url : http://lists.alioth.debian.org/pipermail/pkg-exppsy-pynifti/attachments/20090223/de236138/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.nii
Type: application/octet-stream
Size: 1928 bytes
Desc: test.nii
Url : http://lists.alioth.debian.org/pipermail/pkg-exppsy-pynifti/attachments/20090223/de236138/attachment-0001.obj 


More information about the Pkg-exppsy-pynifti mailing list