as.sparse {neuroim2} | R Documentation |
Convert to from dense to sparse representation
Description
Convert to from dense to sparse representation
Usage
as.sparse(x, mask, ...)
Arguments
x |
the object to make sparse, e.g. |
mask |
the elements to retain |
... |
additional arguments |
Details
mask
can be an integer vector of 1D indices or a mask volume of class LogicalNeuroVol
Value
A sparse representation of the input object, containing only the elements specified by mask
.
Examples
bvol <- NeuroVol(array(runif(24*24*24), c(24,24,24)), NeuroSpace(c(24,24,24), c(1,1,1)))
indmask <- sort(sample(1:(24*24*24), 100))
svol <- as.sparse(bvol, indmask)
mask <- LogicalNeuroVol(runif(length(indmask)), space=space(bvol), indices=indmask)
sum(mask) == 100
[Package neuroim2 version 0.8.1 Index]