[Pkg-exppsy-pynifti] Possible bug in header get/set methods on RedHat Linux

Ryan Haynes rhaynes at mail.nih.gov
Sat Feb 27 16:54:34 UTC 2010


The problem was in SWIG and not pyNIFTI. I was using SWIG 1.3.29 which
is not compatible with Python 2.5. An upgrade to 1.3.33 worked. This
should probably be changed on the main website
(http://niftilib.sourceforge.net/pynifti/installation.html#installation)
b/c it says 1.3.29 will work which is true for Python 2.4 but at least
1.3.30 is needed for Python 2.5 and greater.

Ryan

On Wed, Feb 24, 2010 at 11:51 AM, Ryan Haynes <rhaynes at mail.nih.gov> wrote:
> I am trying to build pyNIFTI for use with pyMVPA on a Red Hat
> Enterprise 5. I've tried three different versions of pynifti on both
> Python 2.5 and 2.6. I'm running scipy-0.7.1 and numpy-1.4.0. The
> problem seems to relate to reading the header (in
> pynifti-0.20090303.1.tar.gz and pynifti-0.20090205.1) and writing the
> header (pynifti-0.20081017.1). The following are the stack traces for
> these two different (yet similar) errors:
>
> with pynifti-0.20090303.1.tar.gz and pynifti-0.20090205.1:
>
>  File "/s/data8/rhaynes/fmrianalyze-1.0/mvpa/Analysis/src/__init__.py",
> line 482, in CreateDatasetFromBetas
>    header = nim.asDict();
>  File "/opt/lib/python2.5/site-packages/nifti/format.py", line 270, in asDict
>    ret = nhdr2dict(nhdr, extensions=self.extensions)
>  File "/opt/lib/python2.5/site-packages/nifti/utils.py", line 254, in nhdr2dict
>    h['xyz_unit'] = ncl.xyzt2space(nhdr.xyzt_units)
> TypeError: in method 'xyzt2space', argument 1 of type 'char'
>
> ----------------------
>
> with pynifti-0.20081017.1:
>
>  File "/s/data8/rhaynes/fmrianalyze-1.0/mvpa/Analysis/src/__init__.py",
> line 496, in CreateDatasetFromBetas
>    nim = NiftiImage(dataset,header);
>  File "/opt/lib/python2.5/site-packages/nifti/niftiimage.py", line
> 57, in __init__
>    NiftiFormat.__init__(self, source, header)
>  File "/opt/lib/python2.5/site-packages/nifti/niftiformat.py", line
> 55, in __init__
>    self.__newFromArray(source, header)
>  File "/opt/lib/python2.5/site-packages/nifti/niftiformat.py", line
> 119, in __newFromArray
>    updateNiftiHeaderFromDict(nhdr, hdic)
>  File "/opt/lib/python2.5/site-packages/nifti/utils.py", line 259, in
> updateNiftiHeaderFromDict
>    nhdr.regular = hdrdict['regular']
>  File "/opt/lib/python2.5/site-packages/nifti/nifticlib.py", line 94,
> in <lambda>
>    __setattr__ = lambda self, name, value: _swig_setattr(self,
> nifti_1_header, name, value)
>  File "/opt/lib/python2.5/site-packages/nifti/nifticlib.py", line 33,
> in _swig_setattr
>    return _swig_setattr_nondynamic(self,class_type,name,value,0)
>  File "/opt/lib/python2.5/site-packages/nifti/nifticlib.py", line 26,
> in _swig_setattr_nondynamic
>    if method: return method(self,value)
> TypeError: in method 'nifti_1_header_regular_set', argument 2 of type 'char'
>
>
> As you can see, it appears to be a similar error with the 'char' type.
> In pynifti-0.20081017.1 the error results from assigning the character
> 'r' to the field 'regular' which should be a valid value for this
> field. I have also tried this exact code on my Windows XP system with
> Python 2.5 and pynifti-0.20081017.1.win32-py2.5.exe and it runs
> perfectly without errors. So, it appears that the error has to do with
> something peculiar to the pyNIFTI code. My guess is that it has
> something to do with the SWIG interface to the C++ libraries. I should
> also note that I'm using the shared object library built from the 3rd
> party folder in the pyNIFTI distributions and not the full version of
> nifticlibs though I also had errors with a full build of nifticlibs.
> Any suggestions would be greatly appreciated.
>
> Thanks,
> Ryan Haynes
>



More information about the Pkg-exppsy-pynifti mailing list