blocklens | R Documentation |
Get the number of scans or timepoints in each block/run of the dataset. Block lengths are used to:
Define the temporal structure of the experiment by specifying scan counts and timing per run
Allocate memory for data matrices by pre-allocating arrays based on scan counts
Validate data dimensions across runs by checking against expected lengths
Calculate global timing information by computing cumulative timing across runs
blocklens(x, ...)
x |
The object containing block information (typically a sampling_frame or dataset) |
... |
Additional arguments passed to methods |
A numeric vector where:
Each element is the number of scans in a block or run
Length equals the number of blocks/runs
Values are positive integers
blockids()
, split_by_block()
, sampling_frame()
Other block_operations:
blockids()
,
split_by_block()
# Create a sampling frame with varying run lengths
sframe <- sampling_frame(
blocklens = c(100, 150, 100), # Different length runs
TR = 2
)
# Get number of scans per run
run_lengths <- blocklens(sframe) # Returns: c(100, 150, 100)
# Use block lengths to create a dataset
total_scans <- sum(run_lengths) # 350 total timepoints
X <- matrix(rnorm(total_scans * 10), total_scans, 10) # 10 voxels
dset <- matrix_dataset(
X,
TR = 2,
run_length = run_lengths
)
# Verify block lengths in dataset
dset_lengths <- blocklens(dset)
# Use lengths to create time vectors for each run
time_vectors <- lapply(run_lengths, function(len) seq(0, by = 2, length.out = len))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.