| NeuroVec-class | R Documentation |
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.
The NeuroVec class represents a vectorized form of neuroimaging data, supporting both in-memory
and file-backed data modes. It provides efficient data storage and access methods and integrates with
the spatial reference system provided by NeuroSpace.
NeuroVec(data, space = NULL, mask = NULL, label = "")
data |
The image data. This can be:
If a list of NeuroVol objects is provided, the geometric space ( |
space |
An optional |
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. |
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.
A concrete instance of the NeuroVec class:
If mask is provided: a SparseNeuroVec object
Otherwise: a DenseNeuroVec object
A NeuroSpace object defining the spatial properties of the image.
A character string providing a label for the NeuroVec object.
Methods specific to NeuroVec objects may include operations for time series analysis, 4D data manipulation, and extraction of 3D volumes or time courses.
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.
NeuroObj-class for the parent class.
DenseNeuroVec-class and SparseNeuroVec-class for specific implementations.
NeuroSpace for spatial information,
sub_vector for subsetting routines, and
index_to_coord for coordinate conversion.
DenseNeuroVec-class, SparseNeuroVec-class for the
specific NeuroVec types.
NeuroVol-class for 3D volumetric data.
# Load an example 4D brain image
example_4d_image <- read_vec(system.file("extdata", "global_mask_v4.nii", package = "neuroim2"))
# Create a NeuroVec object
neuro_vec <- NeuroVec(data = array(rnorm(64*64*32*10), dim = c(64, 64, 32, 10)),
space = NeuroSpace(dim = c(64, 64, 32,10),
origin = c(0, 0, 0),
spacing = c(3, 3, 4)))
dim(neuro_vec)
# Extract a single 3D volume (e.g., the first time point)
first_volume <- neuro_vec[[1]]
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.