splitFill-methods: Generic function to fill disjoint sets of values with the...

Description Usage Arguments Details Value Examples

Description

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

Usage

1
2
3
4
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

1
2
3
4
5
6
7
8
9
## 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)

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