Skip to content
Snippets Groups Projects
Commit d3a75ad7 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

New Nifti methods to return xyzt unit codes - nibabel returns labels, but I

want the raw codes.
parent b5f7caa3
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment