These functions extract the contents of a NIfTI-1 or ANALYZE-7.5 header, closely approximating how it is (or would be) stored on disk. Defaults will be used where information is missing, but no processing is performed on the metadata.
niftiHeader(image = list())
analyzeHeader(image = list())
# S3 method for niftiHeader
print(x, ...)
# S3 method for analyzeHeader
print(x, ...)
image | An image, in any acceptable form (see |
---|---|
x | A |
... | Ignored. |
For niftiHeader
, a list of class "niftiHeader"
, with
named components corresponding to the elements in a raw NIfTI-1 header.
For analyzeHeader
, the equivalent for ANALYZE-7.5.
The NIfTI-1 standard was originally formulated as a roughly backwards- compatible improvement on the ANALYZE format. Both formats use a binary header structure of 348 bytes, but the field names and their interpretation is often non-equivalent. These functions dump these fields, without regard to whether or not the result makes proper sense.
dumpNifti
is an alias of niftiHeader
, but the former is now
soft-deprecated.
Several medical image analysis packages, such as SPM and FSL, use the
ANALYZE originator
field to store a coordinate origin. This
interpretation is also returned, in the origin
field.
Both of these functions call asNifti
on their arguments to
coerce it to NIfTI, except in one specific circumstance: when
analyzeHeader
is called with a single-element character-mode
argument that is not an "internalImage"
object. In this case the
string is taken to be a path and the header is reported as stored on disk.
This is because otherwise the header may be changed by the process of
converting it to NIfTI and back.
The NIfTI-1 standard (https://www.nitrc.org/docman/view.php/26/64/nifti1.h).
Jon Clayden <code@clayden.org>
niftiHeader(system.file("extdata", "example.nii.gz", package="RNifti"))
#> NIfTI-1 header
#> sizeof_hdr: 348
#> dim_info: 0
#> dim: 3 96 96 60 1 1 1 1
#> intent_p1: 0
#> intent_p2: 0
#> intent_p3: 0
#> intent_code: 0 (Unknown)
#> datatype: 4 (INT16)
#> bitpix: 16
#> slice_start: 0
#> pixdim: -1.0 2.5 2.5 2.5 0.0 0.0 0.0 0.0
#> vox_offset: 352
#> scl_slope: 1
#> scl_inter: 0
#> slice_end: 0
#> slice_code: 0 (Unknown)
#> xyzt_units: 10
#> cal_max: 2503
#> cal_min: 0
#> slice_duration: 0
#> toffset: 0
#> descrip: TractoR NIfTI writer v3.0.0
#> aux_file:
#> qform_code: 2 (Aligned Anat)
#> sform_code: 2 (Aligned Anat)
#> quatern_b: 0
#> quatern_c: 1
#> quatern_d: 0
#> qoffset_x: 122.0339
#> qoffset_y: -95.18523
#> qoffset_z: -55.03814
#> srow_x: -2.5000 0.0000 0.0000 122.0339
#> srow_y: 0.00000 2.50000 0.00000 -95.18523
#> srow_z: 0.00000 0.00000 2.50000 -55.03814
#> intent_name:
#> magic: n+1
# Default header for a standard R array
niftiHeader(array(0L, dim=c(10,10)))
#> NIfTI-2 header
#> sizeof_hdr: 540
#> dim_info: 0
#> dim: 2 10 10 1 1 1 1 1
#> intent_p1: 0
#> intent_p2: 0
#> intent_p3: 0
#> intent_code: 0 (Unknown)
#> datatype: 8 (INT32)
#> bitpix: 32
#> slice_start: 0
#> pixdim: 0 1 1 0 0 0 0 0
#> vox_offset: 540
#> scl_slope: 0
#> scl_inter: 0
#> slice_end: 0
#> slice_code: 0 (Unknown)
#> xyzt_units: 0
#> cal_max: 0
#> cal_min: 0
#> slice_duration: 0
#> toffset: 0
#> descrip:
#> aux_file:
#> qform_code: 0 (Unknown)
#> sform_code: 0 (Unknown)
#> quatern_b: 0
#> quatern_c: 0
#> quatern_d: 0
#> qoffset_x: 0
#> qoffset_y: 0
#> qoffset_z: 0
#> srow_x: 0 0 0 0
#> srow_y: 0 0 0 0
#> srow_z: 0 0 0 0
#> intent_name:
#> magic: n+2