FreeSurfer and NIfTI-1.1
FreeSurfer now supports import and export of NIfTI-1 volumes. While many FreeSurfer programs will read and write NIfTI-1 volumes, the preferred usage is to convert data to .mgh/.mgz format once when importing data, working with .mgh/.mgz during analysis, and converting to NIfTI-1 when exporting data. .mgh/.mgz volumes preserve information not present in NIfTI-1 volumes, and FreeSurfer does not currently support any NIfTI-1 extensions.
mri_convert may be used to convert between formats. mri_convert will automatically determine the format of the input data and will determine the output format by the filename extension or by a command-line flag, if given. Output volumes with the extension .img are written as ANALYZE volumes, so to write a two-file NIfTI-1 volume, it is necessary to explicitly specify the output format on the mri_convert command line. Other FreeSurfer programs that support writing arbitrary formats only look at the output filename extension, so writing two-file NIfTI-1 volumes is only possible using mri_convert.
Running "mri_convert --help" will give usage information for mri_convert.
FreeSurfer will accept the following data types when voxel values are unscaled (scl_slope = 0):
- DT_UNSIGNED_CHAR
- DT_SIGNED_SHORT
- DT_SIGNED_INT
- DT_FLOAT
and represent the data internally in the type given. For scaled data, FreeSurfer accepts:
- DT_UNSIGNED_CHAR
- DT_SIGNED_SHORT
- DT_SIGNED_INT
- DT_FLOAT
- DT_DOUBLE
- DT_INT8
- DT_UINT16
- DT_UINT32
and represents the data internally as floating point numbers. FreeSurfer will always write volumes in the data type used internally and will never write scaled voxel values (so scl_slope = 0 always).
FreeSurfer only supports single-valued 3D volumes and 3D volumes with multiple time points. Vector-valued datasets are unsupported and may be handled incorrectly. Intent codes are ignored on read and intent_code is always set to NIFTI_INTENT_NONE on write.
NIfTI-1 extensions are unsupported; any extensions are ignored on read and none are written.
FreeSurfer volumes internally support a single voxel to world transformation. This transformation is always written to both qform and sform. When reading, the source of the orientation is checked as follows:
- if qform = 0, the origin is taken as the center of the volume, and orientation is taken as i: L -> R, j: P -> A, k: I -> S;
- if sform <= 0, qform is used,
- otherwise sform is used.
Non-trivial slice timing patterns are unsupported.
Two-file NIfTI-1 volumes are written uncompressed, and are expected to be uncompressed when reading. Single-file volumes are similarly uncompressed when the extension .nii is used, and compressed when the extension .nii.gz is used.