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

Nifti intent codes added to fsl.data.constants. Nifti1 instances have an

'intent' attribute.
parent f39e5927
No related branches found
No related tags found
No related merge requests found
......@@ -79,3 +79,61 @@ NIFTI_XFORM_TALAIRACH = 3
NIFTI_XFORM_MNI_152 = 4
"""MNI 152 normalized coordinates."""
# NIFTI file intent codes
NIFTI_INTENT_NONE = 0
NIFTI_INTENT_CORREL = 2
NIFTI_INTENT_TTEST = 3
NIFTI_INTENT_FTEST = 4
NIFTI_INTENT_ZSCORE = 5
NIFTI_INTENT_CHISQ = 6
NIFTI_INTENT_BETA = 7
NIFTI_INTENT_BINOM = 8
NIFTI_INTENT_GAMMA = 9
NIFTI_INTENT_POISSON = 10
NIFTI_INTENT_NORMAL = 11
NIFTI_INTENT_FTEST_NONC = 12
NIFTI_INTENT_CHISQ_NONC = 13
NIFTI_INTENT_LOGISTIC = 14
NIFTI_INTENT_LAPLACE = 15
NIFTI_INTENT_UNIFORM = 16
NIFTI_INTENT_TTEST_NONC = 17
NIFTI_INTENT_WEIBULL = 18
NIFTI_INTENT_CHI = 19
NIFTI_INTENT_INVGAUSS = 20
NIFTI_INTENT_EXTVAL = 21
NIFTI_INTENT_PVAL = 22
NIFTI_INTENT_LOGPVAL = 23
NIFTI_INTENT_LOG10PVAL = 24
NIFTI_FIRST_STATCODE = 2
NIFTI_LAST_STATCODE = 24
NIFTI_INTENT_ESTIMATE = 1001
NIFTI_INTENT_LABEL = 1002
NIFTI_INTENT_NEURONAME = 1003
NIFTI_INTENT_GENMATRIX = 1004
NIFTI_INTENT_SYMMATRIX = 1005
NIFTI_INTENT_DISPVECT = 1006
NIFTI_INTENT_VECTOR = 1007
NIFTI_INTENT_POINTSET = 1008
NIFTI_INTENT_TRIANGLE = 1009
NIFTI_INTENT_QUATERNION = 1010
NIFTI_INTENT_DIMLESS = 1011
NIFTI_INTENT_TIME_SERIES = 2001
NIFTI_INTENT_NODE_INDEX = 2002
NIFTI_INTENT_RGB_VECTOR = 2003
NIFTI_INTENT_RGBA_VECTOR = 2004
NIFTI_INTENT_SHAPE = 2005
# FSL-specific intent codes
# FNIRT
FSL_FNIRT_DISPLACEMENT_FIELD = 2006
FSL_CUBIC_SPLINE_COEFFICIENTS = 2007
FSL_DCT_COEFFICIENTS = 2008
FSL_QUADRATIC_SPLINE_COEFFICIENTS = 2009
# TOPUP
FSL_TOPUP_CUBIC_SPLINE_COEFFICIENTS = 2016
FSL_TOPUP_QUADRATIC_SPLINE_COEFFICIENTS = 2017
FSL_TOPUP_FIELD = 2018
......@@ -73,6 +73,7 @@ class Nifti1(object):
``worldToVoxMat`` A 4*4 array specifying the affine transformation
for transforming real world coordinates into voxel
coordinates.
``intent`` The NIFTI intent code specified in the header.
================= ====================================================
......@@ -100,6 +101,8 @@ class Nifti1(object):
self.header = header
self.shape = shape
self.intent = header.get('intent_code',
constants.NIFTI_INTENT_NONE)
self.__origShape = origShape
self.pixdim = pixdim
self.voxToWorldMat = voxToWorldMat
......@@ -115,11 +118,12 @@ class Nifti1(object):
# We have to treat FSL/FNIRT images
# specially, as FNIRT clobbers the
# sform section of the NIFTI header
# to store other data. The hard coded
# numbers here are the intent codes
# output by FNIRT.
# to store other data.
intent = header.get('intent_code', -1)
if intent in (2006, 2007, 2008, 2009):
if intent in (constants.FSL_FNIRT_DISPLACEMENT_FIELD,
constants.FSL_CUBIC_SPLINE_COEFFICIENTS,
constants.FSL_DCT_COEFFICIENTS,
constants.FSL_QUADRATIC_SPLINE_COEFFICIENTS):
log.debug('FNIRT output image detected - using qform matrix')
voxToWorldMat = np.array(header.get_qform())
......
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