NeuroSlice | R Documentation |
Creates a NeuroSlice
object representing a two-dimensional slice of neuroimaging data
with associated spatial information. This class is particularly useful for working with
individual slices from volumetric neuroimaging data or for visualizing 2D cross-sections.
NeuroSlice(data, space, indices = NULL)
data |
A vector or matrix containing the slice data values. |
space |
An object of class |
indices |
Optional integer vector. When |
Two-Dimensional Neuroimaging Data Slice
A new object of class NeuroSlice
.
The function performs several validation checks:
Verifies that space
is 2-dimensional
Ensures data dimensions are compatible with space
Validates indices
when provided for sparse initialization
The function supports two initialization modes:
Dense mode (indices = NULL):
Data is reshaped if necessary to match space dimensions
Dimensions must match exactly after reshaping
Sparse mode (indices provided):
Creates a zero-initialized matrix matching space dimensions
Places data values at specified indices
NeuroSpace
for defining spatial properties
NeuroVol
for 3D volumetric data
plot.NeuroSlice
for visualization methods
# Create a 64x64 slice space
slice_space <- NeuroSpace(c(64, 64), spacing = c(2, 2))
# Example 1: Dense slice from matrix
slice_data <- matrix(rnorm(64*64), 64, 64)
dense_slice <- NeuroSlice(slice_data, slice_space)
# Example 2: Dense slice from vector
vec_data <- rnorm(64*64)
vec_slice <- NeuroSlice(vec_data, slice_space)
# Example 3: Sparse slice with specific values
n_points <- 100
sparse_data <- rnorm(n_points)
sparse_indices <- sample(1:(64*64), n_points)
sparse_slice <- NeuroSlice(sparse_data, slice_space, indices = sparse_indices)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.