sub_vector-methods: Generic function to extract a sub-vector from a 'NeuroVec'...

sub_vectorR Documentation

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

Description

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

Extract Sub-vector from FileBackedNeuroVec

Usage

sub_vector(x, i, ...)

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

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

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

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

Arguments

x

A FileBackedNeuroVec object.

i

A numeric vector specifying the indices to extract.

...

additional arguments

Details

This method reads the specified volumes from the file-backed data and returns them as a DenseNeuroVec object.

Value

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

A DenseNeuroVec object containing the extracted sub-vector.

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])

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

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])

bbuchsbaum/neuroim2 documentation built on Nov. 3, 2024, 9:31 a.m.