NeuroSlice {neuroim2}R Documentation

NeuroSlice: 2D Neuroimaging Data Container

Description

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.

Usage

NeuroSlice(data, space, indices = NULL)

Arguments

data

A vector or matrix containing the slice data values.

space

An object of class NeuroSpace defining the spatial properties (dimensions, spacing, origin) of the slice.

indices

Optional integer vector. When data is provided as a 1D vector, indices specifies the linear indices where the data values should be placed in the 2D slice. Useful for creating sparse slices. Default is NULL.

Details

Two-Dimensional Neuroimaging Data Slice

Value

A new object of class NeuroSlice.

Input Validation

The function performs several validation checks:

Data Handling

The function supports two initialization modes:

See Also

NeuroSpace for defining spatial properties, NeuroVol for 3D volumetric data, plot for visualization methods

Examples

# 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)


[Package neuroim2 version 0.8.1 Index]