Learn R Programming

neuroim (version 0.0.6)

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

Run this code
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)

Run the code above in your browser using DataLab