nifti: Nifti

View source: R/nifti.R

niftiR Documentation

Nifti

Description

nifti: create a nifti object from input\n as.nifti: converts input to become a nifti object\n is.nifti: checks if input is a nifti object

Usage

    nifti(x, header=NULL, dim=NULL)
    as.nifti(x, header=NULL)
    is.nifti(x)

Arguments

x

a vector, matrix, or array for nifti; can also be a nifti, big.nifti4d, niftiXd for as.nifti

header

a list with the header attributes

dim

dimensions of input x

Details

A nifti object is an array with an additional header slot.

When the header argument is missing or NULL, a list is created with all supported header attributes set to NULL except for dim which is set to the dim of x.

Value

nifti object for nifti and as.nifti\n TRUE or FALSE for is.nifti

Author(s)

Zarrar Shehzad

See Also

as.nifti-methods

Examples

    nim <- nifti(0, list(dim=c(10,10,10)))  # creates a 10x10x10 nifti object with values 0

    tmp <- read.nifti(file.path(system.file("data", package="niftir"), "test.nii.gz"))
    x <- array(0, c(10,10,10))
    nim <- nifti(x, header(tmp))    # OR even better
    nim <- as.nifti(x, header(tmp)) # both create a 10x10x10 nifti object with header from tmp
    is.nifti(nim)   # should be TRUE

czarrar/niftir documentation built on April 19, 2022, 3:35 a.m.