applyEmptyImageDimensions-methods: Apply Subsetting from Empty Image Dimensions

Description Usage Arguments Value Note See Also Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)

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

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

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

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

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

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

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

apply_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?

...

not used

Value

Object of class nifti or array if nifti is not supplied

Note

apply_empty_dim is a shorthand for applyEmptyImageDimensions with all the same arguments.

See Also

getEmptyImageDimensions, dropEmptyImageDimensions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)

neuroconductor-devel/neurobase documentation built on May 6, 2021, 1:48 p.m.