Reads the NIFTI image format .hdr header file into a
list.
Usage
f.read.nifti.header(file)
Arguments
Value
A list containing the information in the fields of the .hdr file.
file.namepath name of the .img file
swap1 or 0 variable indicating whether files are big (=native) or
little (=swapped) endian
sizeof.hdrMUST be 348
data.typechar[10]. UNUSED
db.namechar[18]. UNUSED
extentsUNUSED
session.errorUNUSED
regularUNUSED, but filled with 'r' as SPM does
dim.infoMRI slice ordering: This field encode which spatial
dimension (1=x, 2=y, or 3=z) corresponds to which acquisition dimension
for MRI data. In fact, it contains three informations: freq.dim,
phase.dim and slice.dim, all squished into the single byte field dim.info (2 bits each, since the values for each field are
limited to the range 0..3). The R function diminfo2fps can be used to extract these values from the dim.info byte.
dimvector (of length 8) of image dimensions. dim[1] specifies the
number of dimensions. In NIFTI-1 files, dim[2], dim[3], dim[4] are for
space, dim[5] is for time. The 5th dimension (dim[6]) of the dataset, if
present (i.e., dim[1]=5 and dim[6] > 1), contains multiple values (for
example a vector) to be stored at each spatiotemporal location. Uses of dim[7] and dim[8] are not specified in NIFTI-1 format.
intent.p11st intent parameter: first auxiliary parameter for a
possible statistical distribution specified in intent.code
intent.p22nd intent parameter: second auxiliary parameter for a
possible statistical distribution specified in intent.code
intent.p33rd intent parameter: third auxiliary parameter for a
possible statistical distribution specified in intent.code
intent.codeNIFTI INTENT code: if 0, this is a raw dataset; if in
range 2...24, this indicates that the numbers in the dataset should be interpreted
as being drawn from a given distribution. Most such distributions have
auxiliary parameters (given with intent.p?); if in range 1001...1011,
this is an other meaning. See file intent-code.txt in the niftidoc
directory of the source package. If the dataset DOES NOT have a 5th
dimension (dim[1]=4), then the auxiliary parameters are the same for
each voxel, and are given in header fields intent.p1, intent.p2, and
intent.p3. If the dataset DOES have a 5th dimension (dim[1]=5), then the auxiliary parameters are different for each voxel.
datatypeinteger indicator of data storage type for each
voxel. This could be 2 (unsigned char), 4 (signed short), 8 (signed
int), 16 (32 bit float), 32 (64 bit complex = two 32 bit floats), 64 (64
bit float = double), 128 (3 8 bit bytes), 256 (signed char), 512
(unsigned short), 768 (unsigned int), 1024 (signed long long), 1280 (unsigned long long),
1536 (128 bit float = long double), 1792 (128 bit complex = 2 64 bit
floats), 2048 (256 bit complex = 2 128 bit floats).
bitpixthe number of bits per voxel. This field MUST correspond with
the datatype field. The total number of bytes in the image data is
dim[2]* ... * dim[dim[1]+1] * bitpix / 8
slice.startIndicates the start of the slice acquisition pattern, when slice.code is nonzero. These values
are present to allow for the possible addition of
"padded" slices at either end of the volume, which
don't fit into the slice timing pattern. If there
are no padding slices, then slice.start=0 and
slice.end=dim[slice.dim+1]-1 are the correct values.
For these values to be meaningful, slice.start must
be non-negative and slice.end must be greater than
slice.start.
pixdimvector (of length 8). Grid spacings. When reading a
NIFTI-1 header, pixdim[1] stores qfac (which is either -1 or 1). If
pixdim[1]=0 (which should not occur), we take qfac=1. pixdim[2],
pixdim[3] and pixdim[4] give the voxel width along dimension x, y and
z respectively. pixdim[5] gives the time step (=Time Repetition=TR). The units of
pixdim can be specified with the xyzt.units field.
vox.offsetOffset into .nii file. Should be 352 for a .nii file,
0 for a nifti .hdr/.img pair.
scl.slopeData scaling: If the scl.slope field is nonzero, then
each voxel value in the dataset should be scaled as y = scl.slope*x +
scl.inter, where x = voxel value stored and y = "true" voxel value
scl.interData scaling: offset. Idem above.
slice.endIndicates the end of the slice acquisition pattern, when slice.code is nonzero. These values
are present to allow for the possible addition of
"padded" slices at either end of the volume, which
don't fit into the slice timing pattern. If there
are no padding slices, then slice.start=0 and
slice.end=dim[slice.dim+1]-1 are the correct values.
For these values to be meaningful, slice.start must
be non-negative and slice.end must be greater than
slice.start.
slice.codeSlice timing order. If this is nonzero, AND if slice.dim is nonzero, AND
if slice.duration is positive, indicates the timing
pattern of the slice acquisition. The following codes
are defined: 0 (NIFTI SLICE UNKNOWN), 1 (NIFTI SLICE
SEQ INC), 2 (NIFTI SLICE SEQ DEC), 3 (NIFTI SLICE ALT
INC), 4 (NIFTI SLICE ALT DEC)
xyzt.unitsUnits of pixdim[2:5]. Bits 1..3 of xyzt.units specify
the (same) space unit of pixdim[2:4]. Bits 4..6 of xyzt.units specify the
time unit of pixdim[5]. See xyzt-units.txt in the niftidoc directory of the
source package. The R function xyzt2st can be used to extract these values from the xyzt.units byte.
cal.maxMaximum display intensity (white) corresponds to dataset
value cal.max. Dataset values above cal.max should display as white. cal.min and cal.max only make sense when applied to scalar-valued
datasets (i.e., dim[1] < 5 or dim[6] = 1).
cal.minMinimum display intensity (black) corresponds to dataset
value cal.min. Dataset values below cal.min should display as black.
slice.durationTime for 1 slice. If this is positive, AND if slice.dim is nonzero, indicates the amount of time used to acquire 1 slice.
toffsetTime axis shift: The toffset field can be used to indicate a nonzero start point for
the time axis. That is, time point m is at t=toffset+m*pixdim[5] for
m=1, ..., dim[5]-1.
glmaxUNUSED
glminUNUSED
descripchar[80]. This field may contain any text you like
aux.filechar[24]. This field is used to store an auxiliary filename.
qform.codeNIFTI code (in 0, ... ,4). 0: Arbitrary
coordinates; 1: Scanner-based anatomical coordinates; 2:
Coordinates aligned to another file's, or to anatomical "truth" (coregistration); 3:
Coordinates aligned to Talairach-Tournoux Atlas; 4: MNI 152 normalized coordinates
sform.codeNIFTI code (in 0, ... ,4) with the same meaning as
qform codes. The basic idea behind having two coordinate systems is to allow the image to store information about (1) the scanner coordinate system used in the acquisition of the volume (in the qform) and (2) the relationship to a standard coordinate system - e.g. MNI coordinates (in the sform).
The qform allows orientation information to be kept for alignment
purposes without losing volumetric information, since the qform only
stores a rigid-body transformation (rotation and translation) which
preserves volume. On the other hand, the sform stores a general affine
transformation (shear, scale, rotation and translation) which can map the image coordinates into a standard coordinate system, like Talairach or MNI, without the need to resample the image.
By having both coordinate systems, it is possible to keep the original data (without resampling), along with information on how it was acquired (qform) and how it relates to other images via a standard space (sform). This ability is advantageous for many analysis pipelines, and has previously required storing additional files along with the image files. By using NIfTI-1 this extra information can be kept in the image files themselves.
Note: the qform and sform also store information on whether the coordinate system is left-handed or right-handed and so when both are set they must be consistent, otherwise the handedness of the coordinate system (often used to distinguish left-right order) is unknown and the results of applying operations to such an image are unspecified.
quatern.bQuaternion b param. These b,c,d quaternion parameters
encode a rotation matrix used when qform.code > 0 to
obtain a rigid transformation that maps voxel indices (i,j,k) to
spatial coordinates (x,y,z), typically anatomical coordinates assigned
by the scanner. This transformation ("Method 2" in the nifti1.h
documentation) is generated using also the voxel dimensions
(pixdim[1:4]) and a 3D shift, i.e. a translation, (qoffset.*)
quatern.cQuaternion c param
quatern.dQuaternion d param
qoffset.xQuaternion x shift. If the (0020,0032) DICOM attribute is extracted into (px,py,pz), then
qoffset.x = -px qoffset.y = -py qoffset.z = pz
is a reasonable setting when qform.code=NIFTI XFORM SCANNER ANAT.
qoffset.yQuaternion y shift
qoffset.zQuaternion z shift
srow.xvector of length 4. 1st row affine transform. These srow.*
parameters contain an affine (non-rigid) transformation ("Method 3" in the nifti1.h
documentation) that maps voxel indices (i,j,k) to spatial coordinates (x,y,z).
srow.yvector of length 4. 2nd row affine transform
srow.zvector of length 4. 3rd row affine transform
intent.namechar[16]. 'name' or meaning of data. If no data name is implied or needed, intent.name[1] should be set to 0.