From e2fa21fc8e3ec255d5c5e150df933cc8e5404d54 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Wed, 13 Sep 2017 15:37:58 +0100 Subject: [PATCH] Renamed voxelsToScaledVoxels to voxToScaledVoxMat, and made it a property. Also added scaledVoxToVoxMat --- fsl/data/image.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/fsl/data/image.py b/fsl/data/image.py index 8a2465d29..c61d8dc28 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -460,7 +460,7 @@ class Nifti(notifier.Notifier): @deprecation.deprecated(deprecated_in='1.1.0', - removed_in='1.2.0', + removed_in='2.0.0', details='Use ndims instead') def is4DImage(self): """Returns ``True`` if this image is 4D, ``False`` otherwise. """ @@ -554,7 +554,16 @@ class Nifti(notifier.Notifier): @memoize.Instanceify(memoize.memoize) + @deprecation.deprecated(deprecated_in='1.1.0', + removed_in='2.0.0', + details='Use voxToScaledVoxMat instead') def voxelsToScaledVoxels(self): + """See :meth:`voxToScaledVoxMat`.""" + return self.voxToScaledVoxMat + + + @property + def voxToScaledVoxMat(self): """Returns a transformation matrix which transforms from voxel coordinates into scaled voxel coordinates, with a left-right flip if the image appears to be stored in neurological order. @@ -563,6 +572,12 @@ class Nifti(notifier.Notifier): _format_of_the_matrix_used_by_FLIRT.2C_and_how_does_it_relate_to\ _the_transformation_parameters.3F """ + return self.__voxToScaledVoxMat() + + + @memoize.Instanceify(memoize.memoize) + def __voxToScaledVoxMat(self): + """See :meth:`voxToScaledVoxMat`. """ shape = list(self.shape[ :3]) pixdim = list(self.pixdim[:3]) @@ -576,6 +591,20 @@ class Nifti(notifier.Notifier): return voxToPixdimMat + @property + def scaledVoxToVoxMat(self): + """Returns a transformation matrix which transforms from scaled voxels + into voxels, the inverse of the :meth:`voxToScaledVoxMat` transform. + """ + return self.__scaledVoxToVoxMat() + + + @memoize.Instanceify(memoize.memoize) + def __scaledVoxToVoxMat(self): + """See :meth:`scaledVoxToVoxMat`. """ + return transform.invert(self.voxToScaledVoxMat) + + def sameSpace(self, other): """Returns ``True`` if the ``other`` image (assumed to be a :class:`Nifti` instance) has the same dimensions and is in the -- GitLab