eachVolume-methods: Generic function to apply a function to each volume of a...

Description Usage Arguments Value Examples

Description

Generic function to apply a function to each volume of a four-dimensional image

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
eachVolume(x, FUN, withIndex, mask, ...)

## S4 method for signature 'SparseBrainVector,'function',logical,missing'
eachVolume(x, FUN,
  withIndex = FALSE, mask, ...)

## S4 method for signature 'SparseBrainVector,'function',missing,missing'
eachVolume(x, FUN,
  withIndex, mask, ...)


  ## S4 method for signature 
## 'SparseBrainVector,‘function',missing,LogicalBrainVolume’
eachVolume(x,
  FUN, withIndex, mask, ...)

## S4 method for signature 'BrainVector,'function',missing,missing'
eachVolume(x, FUN, withIndex,
  mask, ...)

## S4 method for signature 'BrainVector,'function',missing,BrainVolume'
eachVolume(x, FUN,
  withIndex, mask, ...)

## S4 method for signature 'BrainVector,'function',missing,missing'
eachVolume(x, FUN, withIndex,
  mask, ...)

## S4 method for signature 'BrainBucket,'function',missing,missing'
eachVolume(x, FUN, withIndex,
  mask, ...)

## S4 method for signature 'BrainBucket,'function',logical,ANY'
eachVolume(x, FUN, withIndex,
  mask, ...)

## S4 method for signature 'BrainVector,'function',logical,ANY'
eachVolume(x, FUN, withIndex,
  mask, ...)

Arguments

x

four-dimensional image, e.g. of class BrainVector

FUN

a function taking one or two arguments (depending on the value of withIndex)

withIndex

whether the index of the volume supplied as the second argument to the function

mask

an image mask indicating subset of volume elements to apply function over

...

additional arguments

Value

a list of results of apply FUN to each volume.

Examples

1
2
3
4
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1)))
res <- eachVolume(bvec, mean)

res <- eachVolume(bvec, function(x,i) median(x), withIndex=TRUE)

neuroim documentation built on May 2, 2019, 1:04 p.m.