Description Usage Arguments Details Value Author(s) Examples
View source: R/write.nii.volume.R
Write values to a specific volume in a NIfTI-1 file.
1 | write.nii.volume(nii.file, vol.num, values)
|
nii.file |
Full directory listing to a NIfTI file. File must not be gzipped. |
vol.num |
An integer indicating which volume to read. |
values |
an array or vector of values to be written |
NIfTI files need to be unzipped before using this function or any other portions of the nifti.io package. This is necessary given the inconsistent way in which gzipped files are indexed.
Output directly to NIFTI file.
Timothy R. Koscik <timothy-koscik@uiowa.edu>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # get filename for example NII file included in nifti.io package
ref.nii <- system.file("extdata", "egBrain.nii", package="nifti.io")
# create a temporary file to write into
tdir <- tempdir()
new.nii <- paste0(tdir, "/new.nii")
init.nii(new.nii = new.nii, ref.nii = ref.nii)
# generate an array of random values the same size as the image volume
xyz.dims <- info.nii(ref.nii, "xyz")
new.values <- array(rnorm(prod(xyz.dims)), dim=xyz.dims)
# write out volume all at once
write.nii.volume(nii.file = new.nii, vol.num = 1, values = new.values)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.