onsets | R Documentation |
Extract the onset times of events from a model object. Onsets represent the timing of experimental events in an fMRI design, typically in seconds from the start of each run. These times are used to:
Create regressors by convolving with HRF
Verify event timing in the design
Analyze temporal patterns of events
onsets(x)
## S3 method for class 'regressor'
onsets(x)
x |
The object containing event information (typically an event_term or event_model) |
A numeric vector of onset times in seconds, where:
Each value represents the start time of an event
Times are relative to the start of each run
Order matches the original event sequence
event_term()
, event_model()
, global_onsets()
Other timing:
durations()
,
global_onsets()
,
samples()
# Create event data with multiple conditions
event_data <- data.frame(
condition = factor(c("face", "house", "face", "house")),
onsets = c(1, 10, 20, 30),
run = c(1, 1, 1, 1)
)
# Create sampling frame
sframe <- sampling_frame(blocklens = 50, TR = 2)
# Create event term
eterm <- event_term(
list(condition = event_data$condition),
onsets = event_data$onsets,
blockids = event_data$run
)
# Get onsets from term
onset_times <- onsets(eterm) # Returns: c(1, 10, 20, 30)
# Create and get onsets from event model
evmodel <- event_model(
onsets ~ hrf(condition),
data = event_data,
block = ~run,
sampling_frame = sframe
)
model_onsets <- onsets(evmodel)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.