maskEmptyImageDimensions-methods: Apply Masking from Empty Image Dimensions

maskEmptyImageDimensions-methodsR Documentation

Apply Masking from Empty Image Dimensions

Description

Simple wrapper for replacing indices with a value

Usage

maskEmptyImageDimensions(img, inds, reorient = FALSE, mask.value = 0, ...)

## S4 method for signature 'nifti'
maskEmptyImageDimensions(img, inds, reorient = FALSE, mask.value = 0, ...)

## S4 method for signature 'character'
maskEmptyImageDimensions(img, inds, reorient = FALSE, mask.value = 0, ...)

## S4 method for signature 'factor'
maskEmptyImageDimensions(img, inds, reorient = FALSE, mask.value = 0, ...)

## S4 method for signature 'list'
maskEmptyImageDimensions(img, inds, reorient = FALSE, mask.value = 0, ...)

## S4 method for signature 'array'
maskEmptyImageDimensions(img, inds, reorient = FALSE, mask.value = 0, ...)

## S4 method for signature 'anlz'
maskEmptyImageDimensions(img, inds, reorient = FALSE, mask.value = 0, ...)

## S4 method for signature 'ANY'
maskEmptyImageDimensions(img, inds, reorient = FALSE, mask.value = 0, ...)

mask_empty_dim(img, ...)

Arguments

img

image, nifti object, or array

inds

indices of subset from getEmptyImageDimensions or dropEmptyImageDimensions.

reorient

Should image be reoriented if a filename?

mask.value

Value to replace voxels outside the mask.

...

not used

Value

Object of class nifti or array if nifti is not supplied

Note

mask_empty_dim is a shorthand for maskEmptyImageDimensions with all the same arguments.

See Also

getEmptyImageDimensions, dropEmptyImageDimensions

Examples

set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
arr[,,10] = 0
nim = oro.nifti::nifti(arr)
inds = getEmptyImageDimensions(nim)
inds_arr = getEmptyImageDimensions(arr)
res = maskEmptyImageDimensions(nim, inds = inds, mask.value = NA)
res2 = maskEmptyImageDimensions(arr, inds = inds_arr, mask.value = NA)
testthat::expect_equal(array(res, dim = dim(res)), 
array(res2, dim = dim(res2)))

set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
arr[,,10] = 0
nim = oro.nifti::nifti(arr)
inds = getEmptyImageDimensions(nim)
rnifti = RNifti::asNifti(nim)
timg = tempimg(nim)
limg = list(factor(timg), factor(timg))
mask_empty_dim(nim, inds = inds)
func = function(...) maskEmptyImageDimensions(..., inds = inds)
func(arr)
func(nim)
func(rnifti)
func(timg)
func(limg)


neurobase documentation built on May 29, 2024, 2:17 a.m.