eachVolume {neuroim}R Documentation

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

Description

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

Usage

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

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)

[Package neuroim version 0.0.6 Index]