RF: Preserve pixdims
Make sure pixdim values are preserved, as floating point imprecision can be introduced when they are generated from the affine. Previously, if we have an image with these properties:
In [5]: img.pixdim
Out[5]: (1.0, 1.0, 1.0)
In [6]: img.getAffine('voxel', 'world')
Out[6]:
array([[-9.92611945e-01, 0.00000000e+00, -1.21332847e-01, 9.82672577e+01],
[ 4.10042368e-02, 9.41164672e-01, -3.35451543e-01, -8.12412491e+01],
[-1.14194185e-01, 3.37948352e-01, 9.34211254e-01, -1.15231804e+02],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])
Creating a copy of it would result in the same affine, but slightly different pixdims:
In [7]: copy = fi.Image(img.data, xform=img.voxToWorldMat, header=img.header)
In [8]: copy.pixdim
Out[8]: (1.0000001, 1.0, 1.0)
In [9]: copy.getAffine('voxel', 'world')
Out[9]:
array([[-9.92611945e-01, 0.00000000e+00, -1.21332847e-01, 9.82672577e+01],
[ 4.10042368e-02, 9.41164672e-01, -3.35451543e-01, -8.12412491e+01],
[-1.14194185e-01, 3.37948352e-01, 9.34211254e-01, -1.15231804e+02],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])