Learn R Programming

neurobase (version 1.32.4)

finite_img-methods: Finite Image

Description

Simple wrapper for setting non-finite values to zero

Usage

finite_img(img, replace = 0)

# S4 method for nifti finite_img(img, replace = 0)

# S4 method for array finite_img(img, replace = 0)

# S4 method for ANY finite_img(img, replace = 0)

# S4 method for character finite_img(img, replace = 0)

# S4 method for list finite_img(img, replace = 0)

Value

nifti object

Arguments

img

character path of image or an object of class nifti, or list of images

replace

Value to replace non-finite values to

Author

John Muschelli muschellij2@gmail.com

Examples

Run this code
set.seed(5)
dims = rep(10, 3)
arr = array(rpois(prod(dims), lambda = 2), dim = dims)
arr[c(5, 6, 7, 8)] = c(NA, NaN, Inf, -Inf)
nim = nifti(arr)
finite_img(nim)
finite_img(arr)
tfile = tempimg(nim)
checkimg(c(tfile, tfile))
checkimg(list(tfile, tfile))
finite_img(list(tfile, tfile))
finite_img(c(tfile, tfile))
img = RNifti::readNifti(tfile)
checkimg(img)
img[c(5, 6, 7, 8)] = c(NA, NaN, Inf, -Inf)
stopifnot(!any(c(is.na(c(finite_img(img))))))

Run the code above in your browser using DataLab