Learn R Programming

fsbrain (version 1.0.0)

vol.read.file.with.affine: Load a volume file and return the data along with the affine transformation.

Description

Supports MGH/MGZ volumes (read with read.fs.mgh) and NIfTI v1 volumes, including oblique ones (read with read.fs.volume.nii, which requires the 'oro.nifti' package). The data array is returned in the storage order of the file, i.e., it is not reoriented, and the returned affine maps 0-based voxel indices (column, row, slice) to world coordinates. This is the convention used by the NIfTI sform and by mghheader.vox2ras.

Usage

vol.read.file.with.affine(filepath)

Value

named list with entries: 'data' (numeric array, 3D or 4D), 'affine' (4x4 numeric matrix), 'filepath' (character string), 'file_format' (character string, either 'mgh' or 'nifti'), and 'frames' (integer, the number of volumes in a 4D file).

Arguments

filepath

character string, the path to an .mgz, .mgh, .nii or .nii.gz file.