separate_img-methods | R Documentation |
Takes in an image, gets the unique values, then creates a list of binary images for each one of those values.
separate_img(img, levels = NULL, drop_zero = TRUE) ## S4 method for signature 'nifti' separate_img(img, levels = NULL, drop_zero = TRUE) ## S4 method for signature 'array' separate_img(img, levels = NULL, drop_zero = TRUE) ## S4 method for signature 'ANY' separate_img(img, levels = NULL, drop_zero = TRUE) ## S4 method for signature 'factor' separate_img(img, levels = NULL, drop_zero = TRUE) ## S4 method for signature 'character' separate_img(img, levels = NULL, drop_zero = TRUE) ## S4 method for signature 'list' separate_img(img, levels = NULL, drop_zero = TRUE)
img |
character path of image or
an object of class |
levels |
if |
drop_zero |
Should zeroes be dropped from the labels? Zero usually denotes background or non-interesting voxels |
A nifti
object (or list of them) or class of
object passed in if not specified
Exact equalling is using ==
set.seed(5) dims = rep(10, 3) arr = array(rpois(prod(dims), lambda = 2), dim = dims) nim = oro.nifti::nifti(arr) simg = separate_img(nim) simg_arr = separate_img(arr) slist = lapply(simg, function(x) array(x, dim(x))) testthat::expect_equal(slist, simg_arr) rnifti = RNifti::asNifti(nim) timg = tempimg(nim) limg = list(factor(timg), factor(timg)) func = separate_img func(arr) func(nim) func(rnifti) func(timg) func(limg)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.