Learn R Programming

neuroim (version 0.0.6)

as.sparse: Convert to from dense to sparse representation

Description

Convert to from dense to sparse representation

Usage

as.sparse(x, mask, ...)
"as.sparse"(x, mask)
"as.sparse"(x, mask)
"as.sparse"(x, mask)
"as.sparse"(x, mask)

Arguments

x
the object to make sparse, e.g. DenseBrainVolume or DenseBrainVector
mask
the elements to retain
...
additional arguments

Details

mask can be an integer vector of 1D indices or a mask volume of class LogicalBrainVolume

Examples

Run this code
bvol <- BrainVolume(array(runif(24*24*24), c(24,24,24)), BrainSpace(c(24,24,24), c(1,1,1)))
indmask <- sort(sample(1:(24*24*24), 100))
svol <- as.sparse(bvol, indmask)


mask <- LogicalBrainVolume(runif(length(indmask)), space=space(bvol), indices=indmask)
sum(mask) == 100

Run the code above in your browser using DataLab