[Neuroimaging] reg. load nifti image

Raghav Mehta raghav.mehta at research.iiit.ac.in
Thu Jan 21 04:11:36 EST 2016


Pre-defined thresold is -6.6e-14, while value of w2 for my data is -6.401211e-07. So when I change the thresold is works perfectly?? Can you please explain how this may effect processing of data. as I had to multiply quaternion thresold with 1e9 to get proper thresold value

Raghav Mehta

----- Original Message -----
From: "Matthew Brett" <matthew.brett at gmail.com>
To: "neuroimaging" <neuroimaging at python.org>
Sent: Thursday, January 21, 2016 2:21:41 PM
Subject: Re: [Neuroimaging] reg. load nifti image


On Wed, Jan 20, 2016 at 7:36 PM, Raghav Mehta
<raghav.mehta at research.iiit.ac.in> wrote:
> Hi,
> I am trying to read Nifti images using Nibabel, but when I am using nib.load to load the file from perticlar dataset I am getting following error:
> Traceback (most recent call last):
>   File "<input>", line 1, in <module>
>   File "/usr/local/lib/python2.7/dist-packages/nibabel/loadsave.py", line 44, in load
>     return guessed_image_type(filename).from_filename(filename, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/nibabel/keywordonly.py", line 16, in wrapper
>     return func(*args, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/nibabel/analyze.py", line 986, in from_filename
>     return klass.from_file_map(file_map, mmap=mmap)
>   File "/usr/local/lib/python2.7/dist-packages/nibabel/keywordonly.py", line 16, in wrapper
>     return func(*args, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/nibabel/analyze.py", line 956, in from_file_map
>     img._affine = header.get_best_affine()
>   File "/usr/local/lib/python2.7/dist-packages/nibabel/nifti1.py", line 642, in get_best_affine
>     return self.get_qform()
>   File "/usr/local/lib/python2.7/dist-packages/nibabel/nifti1.py", line 822, in get_qform
>     quat = self.get_qform_quaternion()
>   File "/usr/local/lib/python2.7/dist-packages/nibabel/nifti1.py", line 797, in get_qform_quaternion
>     return fillpositive(bcd, self.quaternion_threshold)
>   File "/usr/local/lib/python2.7/dist-packages/nibabel/quaternions.py", line 99, in fillpositive
>     raise ValueError('w2 should be positive, but is %e' % w2)
> ValueError: w2 should be positive, but is -6.401211e-07
> I know this due to fill option in quaternions.py file. My question is how can I disable that option and read these files.
> This issue is only for this perticular dataset. I am able to read other files normally from other dataset. Can anyone help me in solving this issue??

It looks like our threshold is too strict here.

Does this work?

>>> import numpy as np
>>> import nibabel as nib
>>> nib.Nifti1Header.quaternion_threshold = np.finfo(np.float32).eps * 10
>>> img = nib.load('bad_image.nii')



Neuroimaging mailing list
Neuroimaging at python.org

More information about the Neuroimaging mailing list