View source: R/write_fs_volume.R
| write.fs.volume | R Documentation |
Write brain volume data to a file. The format is determined from the file extension of filepath.
write.fs.volume(filepath, fs_vol)
filepath |
string. Full path to the output file. The file extension determines the format: '.mgh' or '.mgz' for FreeSurfer MGH/MGZ format, '.nii' or '.nii.gz' for NIFTI v1 format, and '.hdr', '.img', '.hdr.gz' or '.img.gz' for a NIFTI v1 pair, i.e. a header file with a separate data file. A pair is written instead of a plain ANALYZE 7.5 file because ANALYZE cannot store the geometry of the volume, see |
fs_vol |
an |
When writing NIFTI files, this function uses nii1header.for.mgh to compute a NIFTI v1 header from the MGH header information.
A file name that is one of the standard CIFTI-2 names (e.g. .dscalar.nii) is an
error: such a file has to contain the CIFTI XML metadata, so a NIFTI file with that
name is refused by this package and misread by other software. Use
write.cifti for CIFTI-2 files.
## Not run:
mgh_file <- system.file("extdata", "brain.mgz",
package = "freesurferformats",
mustWork = TRUE
)
fs_vol <- read.fs.volume(mgh_file, with_header = TRUE)
write.fs.volume(tempfile(fileext = ".mgz"), fs_vol)
write.fs.volume(tempfile(fileext = ".nii.gz"), fs_vol)
write.fs.volume(tempfile(fileext = ".hdr"), fs_vol)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.