Skip to contents

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

Usage

sub_vector(x, i, ...)

# S4 method for FileBackedNeuroVec,numeric
sub_vector(x, i)

# S4 method for NeuroVec,numeric
sub_vector(x, i)

# S4 method for NeuroVecSeq,numeric
sub_vector(x, i)

# S4 method for SparseNeuroVec,numeric
sub_vector(x, i)

Arguments

x

four-dimensional image

i

the indices of the volume(s) to extract

...

additional arguments

Value

a NeuroVec object that is a sub-sequence of the supplied object.

Examples

bvec <- NeuroVec(array(rnorm(24*24*24*24), c(24,24,24,24)), NeuroSpace(c(24,24,24,24), c(1,1,1)))
vec <- sub_vector(bvec,1:2)
all.equal(2, dim(vec)[4])
#> [1] TRUE

vec <- sub_vector(bvec, c(1,3,5,7))
all.equal(4, dim(vec)[4])
#> [1] TRUE

mask <- LogicalNeuroVol(rep(TRUE, 24*24*24), NeuroSpace(c(24,24,24), c(1,1,1)))
svec <- SparseNeuroVec(array(rnorm(24*24*24*24), c(24,24,24,24)),
NeuroSpace(c(24,24,24,24), c(1,1,1)), mask)
vec <- sub_vector(svec, c(1,3,5))
all.equal(3, dim(vec)[4])
#> [1] TRUE