write.nii.volume: Write NIfTI-1 Volume

Description Usage Arguments Details Value Author(s) Examples

View source: R/write.nii.volume.R

Description

Write values to a specific volume in a NIfTI-1 file.

Usage

1
  write.nii.volume(nii.file, vol.num, values)

Arguments

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

Details

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.

Value

Output directly to NIFTI file.

Author(s)

Timothy R. Koscik <timothy-koscik@uiowa.edu>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
reference.image = "~/reference_image.nii"
pixdim = info.nii(nii.file = reference.image, field="pixdim")
orientation = info.nii(nii.file = reference.image, field="orientation")
init.nii(file.name = "~/example_image.nii",
         dims = c(100,100,100),
         pixdim = pixdim,
         orient = orientation)
new.values <- rnorm(prod(c(100,100,100)))
write.nii.volume(nii.file = "~/example_image.nii",
                 vol.num = 1,
                 values = new.values)

## End(Not run)

TKoscik/tk.nifti documentation built on June 6, 2021, 2:30 a.m.