Learn R Programming

freesurferformats (version 1.1.0)

write.nifti2: Write header and data to a file in NIFTI v2 format.

Description

Write header and data to a file in NIFTI v2 format.

Usage

write.nifti2(filepath, niidata, niiheader = NULL, extensions = NULL)

Arguments

filepath

the file to write. The extension should be '.nii' or '.nii.gz'.

niidata

array of numeric or integer data, with up to 7 dimensions. Will be written to the file with the datatype and bitpix specified in the 'niiheader' argument.

niiheader

an optional NIFTI v2 header that is suitable for the passed 'niidata'. If not given, one will be generated with ni2header.for.data.

extensions

optional list of NIFTI v2 header extensions to write between the header and the data, each created with nifti2.extension. If left at NULL and the 'niiheader' has a field named 'extensions', that field is used, so that a header read with read.nifti2.header can be written back to a new file without losing its extensions. The 'vox_offset' field of the header is adapted if it is too small to fit the extensions, and the data is written directly after them.

See Also

read.nifti2.header, nifti2.get.extension

Other nifti2 writers: write.fs.morph.ni2()