Learn R Programming

neuroim (version 0.0.6)

subVector: Generic function to extract a sub-vector from a BrainVector object.

Description

Generic function to extract a sub-vector from a BrainVector object.

Usage

subVector(x, i, ...)
"subVector"(x, i)
"subVector"(x, i)

Arguments

x
four-dimensional image
i
the indices of the volume(s) to extract
...
additional arguments

Value

a BrainVector object that is a sub-vector of the supplied object.

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)))
vec <- subVector(bvec,1:2)
all.equal(2, dim(vec)[4])

vec <- subVector(bvec, c(1,3,5,7))
all.equal(4, dim(vec)[4])

mask <- LogicalBrainVolume(rep(TRUE, 24*24*24), BrainSpace(c(24,24,24), c(1,1,1)))
svec <- SparseBrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), 
BrainSpace(c(24,24,24,24), c(1,1,1)), mask)
vec <- subVector(svec, c(1,3,5))
all.equal(3, dim(vec)[4])

Run the code above in your browser using DataLab