[Neuroimaging] How to apply an affine transform estimated from ITK?
Matthew Brett
matthew.brett at gmail.com
Wed Jul 22 16:50:03 CEST 2015
Hi,
On Wed, Jul 22, 2015 at 2:55 PM, François Rousseau
<francois.rousseau at telecom-bretagne.eu> wrote:
>>
>> Not transparently, no. I'm afraid you have do something like:
>>
>> RAS2LPS = np.diag([-1, -1, 1, 1])
>> vox2itk_world = LPS2RAS.dot(img.affine)
>> lpi_world_pts = nib.affines.apply_affine(vox2itk_world, vox_pts)
>>
>> Is that what you mean?
>>
>
>
> Yes, exactly. This is what I’m doing right now. Thank you Matthew.
>
> However, I still do have another question.
>
> In ITK, the index coordinates (say for instance (0,0,0) ) correspond to the center of a voxel.
> It seems that in nibabel, it correspond to the corner of a voxel. Am I right? (I didn’t find that in the documentation)
>
> Such difference can introduce a shift of half a voxel in registration / interpolation / reconstruction algorithms.
You're right to worry about this, of course. The NIfTI standard says that:
"The (x,y,z) coordinates refer to the CENTER of a voxel"
http://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1.h
That is also the convention that nibabel uses, in general, but it's
true that isn't documented properly:
https://github.com/nipy/nibabel/issues/333
Cheers,
Matthew
More information about the Neuroimaging
mailing list