AFNI and NIfTI-1.1
AFNI now supports input and output of NIfTI-1.1 files. This addition is fairly recent (09 Apr 2005), so there may still be some bugs.
The conceptions of a volumetric dataset in AFNI and in NIfTI-1.1 are somewhat different. As a result, there are some NIfTI-1.1 datasets that AFNI has trouble dealing with, and there are some AFNI datasets that are not easily converted to the NIfTI-1.1 format. These issues are outlined below.
Reading:
If an input dataset filename ends in ".nii" or ".nii.gz" or ".hdr", all AFNI programs
will try to read the file using the NIfTI-1.1 C reference implementation
(available at SourceForge or in
the AFNI source code distribution).
There are some limitations to the kind of NIfTI-1.1 files that AFNI will read. These restrictions include:
- AFNI will only deal with a specific subset of NIfTI-1.1 data value types:
- AFNI can directly handle only the following data types: 8-bit unsigned byte (DT_UINT8),
16-bit signed short (DT_INT16), 32-bit float (DT_FLOAT32),
64-bit complex (DT_COMPLEX64), and 24-bit RGB (DT_RGB24).
- DT_UINT8 and DT_INT16 types that have a scale factor attached are converted to floats on input.
- The following other NIfTI-1.1 data types are converted to floats on input: 8-bit signed byte (DT_INT8), 16-bit unsigned short (DT_UINT16), 32-bit int (DT_INT32 and DT_UINT32), and 64-bit double (DT_FLOAT64).
- AFNI will not read the following NIfTI-1.1 types at all: 64-bit int (DT_INT64 and DT_UINT64), 128-bit long double (DT_FLOAT128), 128-bit double complex (DT_COMPLEX128), or 256-bit long double complex (DT_COMPLEX256).
- AFNI can directly handle only the following data types: 8-bit unsigned byte (DT_UINT8),
16-bit signed short (DT_INT16), 32-bit float (DT_FLOAT32),
64-bit complex (DT_COMPLEX64), and 24-bit RGB (DT_RGB24).
- AFNI can only deal with 2-4 dimensional datasets. A NIfTI-1.1 file can have either
dim[4]>1 or dim[5]>1, but not both if it
is to be read into AFNI.
- The former corresponds to an AFNI "3D+time" dataset and the latter to an AFNI "3D bucket" dataset.
- AFNI only "understands" the statistical codes 2-10 (NIFTI_INTENT_CORREL..NIFTI_INTENT_POISSON). Also, AFNI does not properly deal with datasets which have voxel-dependent statistical parameters (i.e., with dim[5]>1).
- AFNI does not use the intent_code field outside of the first few statistical distribution codes.
- AFNI does not deal with non-orthogonal coordinates as yet (i.e., as might be
specified in the sform fields).
- The AFNI program 3dWarp could be used to apply an arbitrary affine transform to a dataset, effectively warping the (i,j,k) axes to be orthogonal. (Note that in NIfTI-1.1, the (x,y,z) axes are always assumed to be orthogonal; it is the storage indexes (i,j,k) that may not be orthogonal in real space.)
Writing:
By default, AFNI programs output AFNI-formatted datasets
(described here).
However, if the user supplies an output filename "prefix" that ends in ".nii" or ".nii.gz", most AFNI programs will switch to writing a single-file NIfTI-1.1 dataset.
If the prefix ends in ".hdr", a dual-file (.hdr/.img) NIfTI-1.1 dataset will be written.
Not all AFNI dataset constructs can be mapped into a NIfTI-1.1 dataset. These issues are outlined below:
- AFNI allows the sub-bricks (different 3D volumes) in a 4D dataset to have different types (e.g., mixing a float volume with an RGB volume). NIfTI-1.1 does not allow this. AFNI will not be able to write such a mixed-type dataset to a .nii file.
- AFNI allows each sub-brick to have a different scaling factor. NIfTI-1.1 does not allow this, and AFNI will not write such a dataset out in the NIfTI-1.1 format.
- AFNI allows arbitrary slice timing patterns. NIfTI-1.1 does not (there wasn't room in the header), and if the slice timing pattern in an AFNI dataset being output to a .nii file doesn't fit into the NIfTI-1.1 schema, then the NIfTI-1.1 file won't have any slice timing indicated.
- The 'adwarp' program is not compatible with the NIfTI I/O library, and so can't be used to write a NIfTI-1.1 dataset. Sorry about that, Chief.
NIfTI-1.1 Extension used by AFNI:
AFNI datasets store some extra information that doesn't fit into the NIfTI-1.1 standard
header. AFNI uses the NIfTI-1.1 extension feature to store some of this extra metadata.
- The format of this AFNI extension (ecode=4) is described here.
- By default, all AFNI programs write this extension into .nii output files. To disable this feature, set the UNIX environment variable AFNI_NIFTI_NOEXT to YES.
- The nifti_tool program can also be used to strip extensions out of a NIfTI-1.1 dataset file.
Future Plans:
- Deal with the sform properly, when reading a NIfTI-1.1 file.
- Support the rest of the NIfTI-1.1 statistical codes.
- Support voxel-dependent statistical parameters.
- Think about how to support 5D datasets.