splitFill {neuroim}R Documentation

Generic function to fill disjoint sets of values with the output of a function

Description

Generic function to fill disjoint sets of values with the output of a function

Usage

splitFill(x, fac, FUN)

## S4 method for signature 'BrainVolume,factor,'function''
splitFill(x, fac, FUN)

Arguments

x

the object to split

fac

the factor to split by

FUN

the function to summarize the the sets

Details

FUN can either return a scalar for each input vector or a vector equal to the length of the input vector. If it returns a scalar then every voxel in the set will be filled with that value in the output vector.

Value

a new object where the original values have been replaced by the function output

Examples


## summarize with mean -- FUN returns a scalar
x = BrainSpace(c(10,10,10), c(1,1,1))
vol <- BrainVolume(rnorm(10*10*10), x)
fac <- factor(rep(1:10, length.out=1000))
ovol.mean <- splitFill(vol, fac, mean)
identical(dim(ovol.mean), dim(vol))
length(unique(as.vector(ovol.mean))) == 10
## transform by reversing vector -- FUN returns a vector.
ovol2 <- splitFill(vol, fac, rev)

[Package neuroim version 0.0.6 Index]