Skip to content

CSA slice normal can be not quite orthogonal #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
moloney opened this issue Jul 13, 2012 · 1 comment
Closed

CSA slice normal can be not quite orthogonal #137

moloney opened this issue Jul 13, 2012 · 1 comment

Comments

@moloney
Copy link
Contributor

moloney commented Jul 13, 2012

I have a data set where the slice normal in the Siemens CSA header is not quite orthogonal to the directions in the "ImageOrientationPatient". This causes the assertion on line 165 in nibabel.nicom.dicomwrappers to fail.

>>> from nibabel.nicom.dicomwrappers import wrapper_from_data
>>> dcm_wrp = wrapper_from_data(dcm)
>>> dcm_wrp.rotation_matrix
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
/home/moloney/<ipython-input-13-3a0219ff8c80> in <module>()
----> 1 dcm_wrp.rotation_matrix

/usr/global/lib/python2.7/site-packages/nibabel-1.2.0-py2.7.egg/nibabel/onetime.pyc in __get__(self, obj, type)
     41            return self.getter
     42 
---> 43        val = self.getter(obj)
     44        #print "** setattr_on_read - loading '%s'" % self.name  # dbg

     45        setattr(obj, self.name, val)

/usr/global/lib/python2.7/site-packages/nibabel-1.2.0-py2.7.egg/nibabel/nicom/dicomwrappers.pyc in rotation_matrix(self)
    163         assert np.allclose(np.eye(3),
    164                            np.dot(R, R.T),
--> 165                            atol=1e-6)
    166         return R
    167 

AssertionError: 

>>> dcm_wrp.slice_normal
array([ 0.        ,  0.43994078,  0.89802679])
>>> iop = dcm_wrp.image_orient_patient
>>> iop = np.array([float(x) for col in iop for x in col]).reshape(iop.shape)
>>>  np.cross(*iop.T[:]) - dcm_wrp.slice_normal
array([  4.39939181e-17,  -1.59949810e-06,   7.80545210e-07])
moloney added a commit to moloney/nibabel that referenced this issue Jul 13, 2012
If the CSA slice normal is in the opposite direction then negate the
cross product. Fixes issue nipy#137.
@matthew-brett
Copy link
Member

Closed by the pull request above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants