split_onsets | R Documentation |
Split a vector of event onsets into separate lists based on factor levels and/or block IDs. This is useful for:
split_onsets(x, ...)
x |
The object containing onset information (typically an event_term or event_model) |
... |
Additional arguments passed to methods. Common arguments include:
|
Separating events by experimental conditions
Organizing onsets by scanning runs/blocks
Preparing onset times for AFNI analysis
Analyzing timing patterns within conditions
A list of numeric vectors where:
Each element contains onsets for one condition/block
Names correspond to condition labels
If blocksplit=TRUE, each condition contains a nested list of blocks
event_term()
, sampling_frame()
, global_onsets()
# Create example data with multiple conditions and blocks
event_data <- data.frame(
condition = factor(c("A", "B", "A", "B", "A", "B")),
onsets = c(1, 10, 30, 40, 70, 80),
run = c(1, 1, 2, 2, 3, 3)
)
# Create sampling frame
sframe <- sampling_frame(blocklens = c(25, 25, 25), TR = 2)
# Create event term
eterm <- event_term(
list(condition = event_data$condition),
onsets = event_data$onsets,
blockids = event_data$run
)
# Split onsets by condition
split_by_cond <- split_onsets(eterm, sframe)
# Returns list with onsets for conditions A and B
# Split by condition and block
split_by_block <- split_onsets(eterm, sframe, blocksplit = TRUE)
# Returns nested list: conditions -> blocks -> onsets
# Get global onset times
split_global <- split_onsets(eterm, sframe, global = TRUE)
# Returns onsets adjusted for block timing
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.