Read the header of an ANALYZE 7.5 file, i.e. of a file in the two-file format that stores the voxel
data in a separate .img file.
Arguments
- filepath
character string, the path to the
.hdrfile. The base name without the extension is accepted as well, seeanalyze.pair.files.
Value
named list with the ANALYZE 7.5 header fields, in the field naming of the format specification. See
analyzeheader.template for a description of all of them. In addition to the fields of the
specification, the following entries are present:
endiancharacter string, the endianness of the file,
'little'or'big'. It is detected from thesizeof_hdrfield.magiccharacter string, the 4 bytes at offset 344 (which are the
sminfield of the ANALYZE specification), interpreted as a string. It is empty for ANALYZE files, seeis.analyze.file.header_formatcharacter string, always
'analyze'here. The other variant of the two-file format is reported as'nifti1_pair', seeread.fs.volume.analyze.spm_origininteger vector of length 3, the interpretation that SPM gives to the
originatorfield: the voxel coordinates of the image origin, as stored in the first 6 bytes of the field. It isNULLif all of them are zero, which means that the field does not store an origin.originator_bytesraw vector of length 10, the unmodified content of the
originatorfield. Theoriginatorentry is the same content with the zero bytes removed and interpreted as a string, which loses information for the files in which SPM stores the image origin there.filepath_header,filepath_imagecharacter strings, the paths of the two files of the pair.
Note
ANALYZE 7.5 does not define the meaning of the world coordinate system of an image: the header stores the
voxel sizes but neither the direction of the voxel axes nor the position of the image in space. This function
therefore reports the fields as they are stored and does not derive a transformation matrix. See
read.fs.volume.analyze for the ways to get a matrix anyway, and for what is known and unknown
about them.
Examples
hdrfile <- system.file("extdata", "analyze", "tiny_u8.hdr",
package = "freesurferformats", mustWork = TRUE
)
analyzeheader <- read.analyze.header(hdrfile)
analyzeheader$datatype
#> [1] 2
analyzeheader$pix_dim
#> [1] 1 1 2 3 1 1 1 1