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.
vol.read.file.with.affine(filepath)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).
character string, the path to an .mgz, .mgh, .nii or .nii.gz file.