Learn R Programming

neurobase (version 1.32.4)

applyEmptyImageDimensions-methods: Apply Subsetting from Empty Image Dimensions

Description

Simple wrapper for subsetting an image with indices, dropping empty dimensions.

Usage

applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)

# S4 method for nifti applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)

# S4 method for character applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)

# S4 method for factor applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)

# S4 method for list applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)

# S4 method for array applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)

# S4 method for anlz applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)

# S4 method for ANY applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)

apply_empty_dim(img, ...)

Value

Object of class nifti or array if nifti

is not supplied

Arguments

img

image, nifti object, or array

inds

indices of subset from getEmptyImageDimensions or dropEmptyImageDimensions.

reorient

Should image be reoriented if a filename?

...

not used

See Also

getEmptyImageDimensions, dropEmptyImageDimensions

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)
inds = getEmptyImageDimensions(nim)
inds_arr = getEmptyImageDimensions(arr)
testthat::expect_equal(inds, inds_arr)

out = applyEmptyImageDimensions(nim, inds = inds)
out_arr = applyEmptyImageDimensions(arr, inds = inds)
testthat::expect_equal(out_arr, array(out, dim = dim(out)))
out = apply_empty_dim(nim, inds = inds)

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))
apply_empty_dim(nim, inds = inds)
func = function(...) applyEmptyImageDimensions(..., inds = inds)
func(arr)
func(nim)
func(rnifti)
func(timg)
func(limg)



Run the code above in your browser using DataLab