SparseNeuroVol-class: SparseNeuroVol Class

SparseNeuroVol-classR Documentation

SparseNeuroVol Class

Description

This class represents a three-dimensional brain image using a sparse data representation. It is particularly useful for large brain images with a high proportion of zero or missing values, offering efficient storage and processing.

Construct a SparseNeuroVol instance

Usage

SparseNeuroVol(data, space, indices = NULL, label = "")

Arguments

data

a numeric vector or ROIVol

space

an instance of class NeuroSpace

indices

a index vector indicating the 1-d coordinates of the data values

label

a character string

Details

The SparseNeuroVol class extends the NeuroVol class and implements the ArrayLike3D interface. It uses a sparseVector from the Matrix package to store the image data, which allows for memory-efficient representation of sparse 3D neuroimaging data.

Image data is backed by Matrix::sparseVector.

Value

SparseNeuroVol instance

Slots

data

A sparseVector object from the Matrix package, storing the image volume data in a sparse format.

References

Bates, D., & Maechler, M. (2019). Matrix: Sparse and Dense Matrix Classes and Methods. R package version 1.2-18. https://CRAN.R-project.org/package=Matrix

See Also

NeuroVol-class for the base volumetric image class. DenseNeuroVol-class for a dense representation of 3D brain images. sparseVector-class for details on the underlying sparse data structure.

Examples

## Not run: 
# Create a sparse 3D brain image
dim <- c(64L, 64L, 64L)
space <- NeuroSpace(dim = dim, origin = c(0, 0, 0), spacing = c(1, 1, 1))
sparse_data <- Matrix::sparseVector(x = c(1, 2, 3),
                                    i = c(100, 1000, 10000),
                                    length = prod(dim))
sparse_vol <- new("SparseNeuroVol", space = space, data = sparse_data)

## End(Not run)

data <- 1:10
indices <- seq(1,1000, length.out=10)
bspace <- NeuroSpace(c(64,64,64), spacing=c(1,1,1))
sparsevol <- SparseNeuroVol(data,bspace,indices=indices)
densevol <- NeuroVol(data,bspace,indices=indices)
sum(sparsevol) == sum(densevol)


bbuchsbaum/neuroim2 documentation built on Jan. 2, 2025, 3:38 p.m.