matricized_access | R Documentation |
This function efficiently extracts values from a 4D tensor (typically neuroimaging data) using a matrix of indices where each row contains
a time index in column 1 and a spatial index in column 2. The spatial index refers to the position
in the flattened spatial dimensions (x,y,z). This is primarily used internally by the series()
method to efficiently access time series data for specific voxels.
matricized_access(x, i, ...)
## S4 method for signature 'SparseNeuroVec,matrix'
matricized_access(x, i)
## S4 method for signature 'SparseNeuroVec,integer'
matricized_access(x, i)
## S4 method for signature 'SparseNeuroVec,numeric'
matricized_access(x, i)
## S4 method for signature 'BigNeuroVec,matrix'
matricized_access(x, i)
## S4 method for signature 'BigNeuroVec,integer'
matricized_access(x, i)
## S4 method for signature 'BigNeuroVec,numeric'
matricized_access(x, i)
x |
a data source, typically a |
i |
Either:
|
... |
additional arguments to be passed to methods. |
When i
is a matrix, returns a numeric vector of values at the specified time-space coordinates.
When i
is a vector, returns a matrix where each column contains the full time series for each spatial index.
# Create a sparse 4D neuroimaging vector
bspace <- NeuroSpace(c(10,10,10,100), c(1,1,1))
mask <- array(rnorm(10*10*10) > .5, c(10,10,10))
mat <- matrix(rnorm(sum(mask)), 100, sum(mask))
svec <- SparseNeuroVec(mat, bspace, mask)
# Extract specific timepoint-voxel pairs
# Get value at timepoint 1, voxel 1 and timepoint 2, voxel 2
idx_mat <- matrix(c(1,1, 2,2), ncol=2, byrow=TRUE)
vals <- matricized_access(svec, idx_mat)
# Get full time series for voxels 1 and 2
ts_mat <- matricized_access(svec, c(1,2))
# Each column in ts_mat contains the full time series for that voxel
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.