init.nii: Initialize Empty NIfTI File

Description Usage Arguments Value Author(s) Examples

View source: R/init.nii.R

Description

This function is used to initialize an empty NIfTI file. It creates the file volume-by-volume rather than a bulk array write operation such that massive arrays do not need to be loaded into memory

Usage

1
2
3
4
5
6
7
init.nii(new.nii,
         ref.nii=NULL,
         dims,
         pixdim=NULL,
         orient=NULL,
         datatype=16,
         init.value=NA)

Arguments

new.nii

Full file path for the file to be written, must have .nii extension

ref.nii

Full file path for reference image to use same space

dims

a numeric vector specifying the image dimensions, e.g., c(X,Y,Z,T)

pixdim

An 8 element numeric vector specifying the pixel dimensions image to be created. Should be in the format (a,x,y,z,t,b,c,d), the output from info.nii("example_file.nii", "pixdim") is the correct format

orient

A named list with the following elements, qform_code [integer(1)], sform_code [integer(1)], quatern_b [numeric(1)], quatern_c [numeric(1)], quatern_d [numeric(1)], qoffset_x [numeric(1)], qoffset_y [numeric(1)], qoffset_z [numeric(1)], srow_x [numeric(3)], srow_y [numeric(3)], srow_z [numeric(3)]

datatype

a numeric value indicating the type of tdata to be used in the new NII file, default=16

init.value

value to use for all voxels to initialize NIfTI file, default=NA

Value

No return value

Author(s)

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

Examples

1
2
3
4
5
6
7
8
9
# get filename for example NII file included in nifti.io package
ref.nii <- system.file("extdata", "egBrain.nii", package="nifti.io")

# set new filename (using temporary directory for example)
tdir <- tempdir()
new.nii <- paste0(tdir, "/new.nii")

# initialize new NII file
init.nii(new.nii = new.nii, ref.nii = ref.nii)

nifti.io documentation built on June 8, 2021, 9:06 a.m.