Learn R Programming

neurobase (version 1.32.4)

remake_img: Remake Image from Vector

Description

Wrapper function to take a vector of values and result in a nifti object

Usage

remake_img(vec, img, mask = NULL, warn = FALSE, ...)

Value

Object of class nifti

Arguments

vec

vector of values to be in resulting image

img

object of class nifti to put vector into

mask

binary array/ nifti object to denote where vector values are to be.

warn

Should a warning be issued if defaulting to FLOAT32?

...

additional arguments passed to datatyper

See Also

niftiarr

Examples

Run this code
set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
arr[,,10] = 0
nim = oro.nifti::nifti(arr)
remake_img(c(nim), nim)
mask = nim > 5
vals = nim[mask]
vals = sqrt(vals)
remake_img(vals, nim, mask = mask)

Run the code above in your browser using DataLab