a class that stores a represents a 4-dimensional array as a set of basis functions (dictionary) and corresponding set of loadings (coefficients).
This function constructs a LatentNeuroVec object from a basis, associated loadings, a NeuroSpace instance, a mask, and an optional offset.
Arguments
- basis
A numeric n-by-k matrix containing the latent vectors forming the reduced space.
- loadings
A numeric p-by-k matrix of p loadings.
- space
A NeuroSpace instance defining the dimensions, spacing, origin, axes, and transformation of the neuroimaging space.
- mask
A 3D logical array, 1D logical vector, or an instance of LogicalNeuroVol class representing the brain mask.
- offset
An optional numeric 1-by-p offset vector. If not provided, it defaults to a zero vector.
Slots
basis
the matrix of bases, were each column is a basis vector.
loadings
the
sparseMatrix
of loadingsoffset
an offset vector
Usage
LatentNeuroVec(basis, loadings, space, mask, offset = NULL)
Examples
bspace <- NeuroSpace(c(2,2,2,10), c(1,1,1))
mask <- array(rnorm(2*2*2) > -100, c(2,2,2))
mat <- matrix(rnorm(sum(mask)), 10, sum(mask))
pres <- prcomp(mat)
svec <- LatentNeuroVec(pres$x, pres$rotation, bspace, mask, offset=colMeans(mat))
svec2 <- SparseNeuroVec(mat, bspace, mask)
length(indices(svec)) == sum(mask)
all.equal(svec2[1:prod(dim(mask))], svec[1:prod(dim(mask))])