[Pkg-exppsy-pynifti] Issue putting packed binary data into extension

Brendan Moloney moloney at ohsu.edu
Fri Feb 26 01:08:56 UTC 2010


Hello,

I am trying to put binary data into an extension. I use the python module 'struct' to pack the data into a string, but pyNifti seems to not like control characters in the string. Here is a simple example:

>>import nifti, struct

>>nim = nifti.NiftiImage('/path/to/nifti/file')

>>packedData = struct.pack('I', 12345)   # That's an uppercase i

>>packedData
'90\x00\x00'

>>len(packedData)
4

>>nim.extensions += (0, packedData)

>>nim.extensions[-1]
'90'

>>len(nim.extensions[-1])
2


Any idea if this issue is caused by pyNifti or the underlying C library? I looked through the source code briefly but I didn't see an obvious fix.

Thanks,
Brendan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pynifti/attachments/20100225/05017ef5/attachment.htm>


More information about the Pkg-exppsy-pynifti mailing list