split_by_block | R Documentation |
Split a vector or matrix of values into separate pieces based on block/run IDs. This function is useful for:
Separating data into individual runs
Processing blocks independently
Analyzing run-specific patterns
split_by_block(x, ...)
x |
The object containing data to split (typically a sampling_frame or dataset) |
... |
Additional arguments passed to methods |
vals |
The values to split by block (if not contained in x) |
A list where each element contains data from one block:
List length equals number of blocks
Each element contains values from one block
Order matches the original block sequence
sampling_frame()
, blockids()
, blocklens()
Other block_operations:
blockids()
,
blocklens()
# Create a sampling frame with multiple runs
sframe <- sampling_frame(
blocklens = c(50, 50, 50), # 3 runs of 50 scans each
TR = 2
)
# Create some example data
data_values <- rnorm(150) # 150 values (50 per run)
# Split data by run
run_data <- split_by_block(sframe, data_values)
# Returns list with 3 elements, each containing 50 values
# Create matrix dataset
X <- matrix(rnorm(150 * 10), 150, 10) # 150 timepoints, 10 voxels
dset <- matrix_dataset(
X,
TR = 2,
run_length = c(50, 50, 50)
)
# Split matrix data by run
run_matrices <- split_by_block(dset)
# Returns list with 3 matrices, each 50 x 10
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.