diff --git a/fsl/data/image.py b/fsl/data/image.py index 2b17dd65bd3405958a320e539fdb53ca04b732ba..934bde5ec3900a0dd5c9009e9cfb33adf7ed4e3e 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -42,7 +42,6 @@ import numpy as np import nibabel as nib import nibabel.fileslice as fileslice - import fsl.utils.transform as transform import fsl.utils.notifier as notifier import fsl.utils.memoize as memoize @@ -314,6 +313,29 @@ class Nifti(notifier.Notifier): return self.__intent + @property + def xyzUnits(self): + """Returns the NIFTI XYZ dimension unit code. """ + + # The nibabel get_xyzt_units returns labels, + # but we want the NIFTI codes. So we use + # the (undocumented) nifti1.unit_codes field + # to convert back to the raw codes. + xyzUnits = self.header.get_xyzt_units()[0] + xyzUnits = nib.nifti1.unit_codes[xyzUnits] + + return xyzUnits + + + def timeUnits(self): + """Returns the NIFTI time dimension unit code. """ + + # See xyzUnits + timeUnits = self.header.get_xyzt_units()[1] + timeUnits = nib.nifti1.unit_codes[timeUnits] + return timeUnits + + @property def worldToVoxMat(self): """Returns a ``numpy`` array of shape ``(4, 4)`` containing an