Given a NeuroVol object (or similar), this function
builds a basic NIfTI-1 header structure, populating essential fields such as
dim, pixdim, datatype, the affine transform, and the
quaternion parameters.
as_nifti_header(
vol,
file_name,
oneFile = TRUE,
data_type = "FLOAT",
extensions = NULL
)A list representing the NIfTI-1 header fields, containing
elements like dimensions, pixdim, datatype, qform,
quaternion, qfac, extensions, etc. This can be passed to
other functions that write or manipulate the header.
A NeuroVol (or 3D array-like) specifying
dimensions, spacing, and affine transform.
A character string for the file name (used within the header but not necessarily to write data).
Logical; if TRUE, sets the NIfTI magic to "n+1",
implying a single-file format (.nii). If FALSE, uses
"ni1" (header+image).
Character specifying the data representation, e.g. "FLOAT",
"DOUBLE". The internal code picks an integer NIfTI code.
Optional NiftiExtensionList-class object or list
of NiftiExtension-class objects to include in the header.
This is a convenience function that calls createNIfTIHeader
first, then updates the fields (dimensions, pixdim, orientation, etc.)
based on the vol argument. The voxel offset is set to 352 bytes (or
larger if extensions are provided), and the quaternion is derived from the
transform matrix via matrixToQuatern.
Note: This function primarily sets up a minimal header suitable for writing standard single-file NIfTI-1. If you need a more comprehensive or advanced usage, consider manually editing the returned list.
createNIfTIHeader for the base constructor of an empty NIfTI header.
NiftiExtension for creating extensions.