replaceEmptyImageDimensions-methods: Replace 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
replaceEmptyImageDimensions(
  img,
  inds,
  target_dim,
  value = 0,
  reorient = FALSE,
  ...
)

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

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

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

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

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

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

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

replace_empty_dim(img, ...)

Arguments

img

image, nifti object, or array

inds

indices of subset from getEmptyImageDimensions or dropEmptyImageDimensions.

target_dim

Original dimension from which the data was subset, the final dimension of the output

value

value to replace in the image where outside the indices

reorient

Should image be reoriented if a filename?

...

not used

Value

Object of class nifti or array if nifti is not supplied

Note

replace_empty_dim is a shorthand for replaceEmptyImageDimensions 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
31
32
33
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
arr[,,10] = 0
nim = oro.nifti::nifti(arr)
rnifti = RNifti::asNifti(nim)
timg = tempimg(nim)
limg = list(factor(timg, timg))
inds = getEmptyImageDimensions(nim)
inds_arr = getEmptyImageDimensions(arr)
testthat::expect_equal(inds, inds_arr)

out = applyEmptyImageDimensions(nim, inds = inds)
result = replaceEmptyImageDimensions(out, inds = inds,
target_dim = dim(nim))
testthat::expect_equal(array(result, dim = dim(result)), 
array(nim, dim = dim(nim)))
replace_empty_dim(out, inds = inds,
target_dim = dim(nim))

target_dim = dim(nim)

arr = array(out, dim = dim(out))
nim = oro.nifti::nifti(arr)
rnifti = RNifti::asNifti(nim)
timg = tempimg(nim)
limg = list(factor(timg), factor(timg))
func = function(...) replaceEmptyImageDimensions(..., 
target_dim = target_dim, inds = inds)
func(arr)
func(nim)
func(rnifti)
func(timg)
func(limg)

neuroconductor-devel-releases/neurobase documentation built on May 6, 2020, 4:25 p.m.