NeuroVec-class: NeuroVec Class

NeuroVec-classR Documentation

NeuroVec Class

Description

This S4 class represents a four-dimensional brain image, which is used to store and process time series neuroimaging data such as fMRI or 4D functional connectivity maps. The class extends the basic functionality of NeuroObj.

This function constructs a NeuroVec object, which represents a four-dimensional brain image. It can create either a DenseNeuroVec or SparseNeuroVec object depending on the input parameters.

Usage

NeuroVec(data, space = NULL, mask = NULL, label = "")

Arguments

data

The image data. This can be:

  • A matrix (voxels x time points)

  • A 4D array

  • A list of NeuroVol objects

If a list of NeuroVol objects is provided, the geometric space (NeuroSpace) will be inferred from the constituent volumes, which must all be identical.

space

An optional NeuroSpace object defining the spatial properties of the image. Not required if data is a list of NeuroVol objects.

mask

An optional logical array specifying which voxels to include. If provided, a SparseNeuroVec object will be created.

label

A character string providing a label for the NeuroVec object. Default is an empty string.

Details

NeuroVec objects are designed to handle 4D neuroimaging data, where the first three dimensions represent spatial coordinates, and the fourth dimension typically represents time or another series dimension. This structure is particularly useful for storing and analyzing functional MRI data, time series of brain states, or multiple 3D volumes in a single object.

The function performs several operations:

  • If data is a list of NeuroVol objects, it combines them into a single 4D array.

  • It checks that the dimensions of data match the provided space.

  • Depending on whether a mask is provided, it creates either a DenseNeuroVec or a SparseNeuroVec object.

Value

A concrete instance of the NeuroVec class:

  • If mask is provided: a SparseNeuroVec object

  • Otherwise: a DenseNeuroVec object

Slots

This class inherits all slots from NeuroObj.

Methods

Methods specific to NeuroVec objects may include operations for time series analysis, 4D data manipulation, and extraction of 3D volumes or time courses.

Usage

To create a NeuroVec object, use the constructor function NeuroVec(). This function should handle the appropriate initialization of the 4D data structure and associated spatial information.

See Also

NeuroObj-class for the parent class. DenseNeuroVec-class and SparseNeuroVec-class for specific implementations.

DenseNeuroVec-class, SparseNeuroVec-class for the specific NeuroVec types. NeuroVol-class for 3D volumetric data. NeuroSpace-class for details on spatial properties.

Examples

## Not run: 
# Load an example 4D brain image
example_4d_image <- read_vec(system.file("extdata", "example_4d.nii", package = "neuroim2"))

# Create a NeuroVec object
neuro_vec <- NeuroVec(data = array(rnorm(64*64*32*100), dim = c(64, 64, 32, 100)),
                      space = NeuroSpace(dim = c(64, 64, 32),
                                        origin = c(0, 0, 0),
                                        spacing = c(3, 3, 4)))

# Access the dimensions of the 4D image
dim(neuro_vec)

# Extract a single 3D volume (e.g., the first time point)
first_volume <- neuro_vec[,,,1]

## End(Not run)

# Load an example 4D brain image
example_file <- system.file("extdata", "global_mask_v4.nii", package = "neuroim2")
example_4d_image <- read_vec(example_file)

# Create a DenseNeuroVec object
dense_vec <- NeuroVec(data = example_4d_image@.Data, 
                      space = space(example_4d_image))
print(dense_vec)

# Create a SparseNeuroVec object with a mask
mask <- array(runif(prod(dim(example_4d_image)[1:3])) > 0.5, 
              dim = dim(example_4d_image)[1:3])
sparse_vec <- NeuroVec(data = example_4d_image@.Data, 
                       space = space(example_4d_image),
                       mask = mask)
print(sparse_vec)


bbuchsbaum/neuroim2 documentation built on Nov. 3, 2024, 9:31 a.m.