blockids: Get block/run indices

View source: R/all_generic.R

blockidsR Documentation

Get block/run indices

Description

Get the block or run number associated with each scan/timepoint in the dataset. Block indices are used to:

  • Track which scans belong to which runs

  • Split data by experimental blocks

  • Align events with their corresponding runs

  • Apply run-specific processing

Usage

blockids(x)

Arguments

x

The object containing block information (typically a sampling_frame or dataset)

Value

A numeric vector where:

  • Each element is the block/run ID for that scan

  • IDs are sequential integers starting from 1

  • Length matches the total number of scans

See Also

blocklens(), split_by_block(), sampling_frame()

Other block_operations: blocklens(), split_by_block()

Examples

# Create a sampling frame with multiple runs
sframe <- sampling_frame(
  blocklens = c(50, 75, 50),  # Different length runs
  TR = 2
)

# Get block IDs for all scans
block_ids <- blockids(sframe)
# Returns: c(1,1,...,1, 2,2,...,2, 3,3,...,3)
# 50 ones, 75 twos, 50 threes

# Create a matrix dataset
X <- matrix(rnorm(175 * 10), 175, 10)  # 175 timepoints (50+75+50), 10 voxels
dset <- matrix_dataset(
  X,
  TR = 2,
  run_length = c(50, 75, 50)
)

# Get block IDs from dataset
dataset_blocks <- blockids(dset)

# Use block IDs to split data by run
run_data <- split(1:nrow(X), dataset_blocks)
# Returns list with indices for each run

bbuchsbaum/fmrireg documentation built on March 1, 2025, 11:20 a.m.