Creates a BigNeuroVec object, which represents a large neuroimaging vector using memory-mapped file storage. This allows working with neuroimaging data that is too large to fit in memory.
Arguments
- data
The input data to be stored
- space
A NeuroSpace object defining the spatial properties
- mask
A logical mask indicating which voxels contain data
- label
Optional character string label for the vector
- type
Storage type, one of "double", "float", or "integer"
- backingfile
Path to the file used for memory mapping (defaults to tempfile())
Examples
if (FALSE) { # \dontrun{
# 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 mask (e.g., selecting voxels with values > 0)
mask <- array(as.vector(example_4d_image[,,,1]) > 0,
dim = dim(example_4d_image)[1:3])
if(requireNamespace("bigstatsr", quietly = TRUE)) {
# Create a BigNeuroVec with memory mapping
big_vec <- BigNeuroVec(data = example_4d_image@.Data,
space = space(example_4d_image),
mask = mask,
label = "Example BigNeuroVec")
print(big_vec)
}
} # }