convolve | R Documentation |
This function convolves an event sequence with a hemodynamic response function (HRF) over a specified time series grid. The convolution models the expected BOLD response to the events. For event-related designs, each event is convolved with the HRF and the results are summed. For block designs, the duration of each event is taken into account during convolution.
convolve(x, hrf, sampling_frame, ...)
## S3 method for class 'event_term'
convolve(
x,
hrf,
sampling_frame,
drop.empty = TRUE,
summate = TRUE,
precision = 0.3,
...
)
x |
The event sequence (typically an event_term or event_model) |
hrf |
The hemodynamic response function to use for convolution |
sampling_frame |
The time series grid over which to sample the convolved function |
... |
Additional arguments passed to methods |
drop.empty |
Logical; if TRUE, empty events are dropped (default: TRUE) |
summate |
Logical; if TRUE, sum the convolved HRF over event durations (default: TRUE) |
precision |
Numeric; precision of HRF sampling (default: 0.3) |
A tibble containing the convolved design matrix, with columns for each condition
fmrihrf::HRF_SPMG1()
, event_term()
, sampling_frame()
# Create a simple event-related design
event_data <- data.frame(
condition = factor(c("A", "B", "A", "B")),
onsets = c(1, 10, 20, 30),
run = c(1, 1, 1, 1)
)
# Create a sampling frame
sframe <- sampling_frame(blocklens = 50, TR = 2)
# Create an event term
eterm <- event_term(
list(condition = event_data$condition),
onsets = event_data$onsets,
blockids = event_data$run
)
# Convolve with canonical HRF
convolved <- convolve(eterm, HRF_SPMG1, sframe)
# Convolve with multiple basis functions
convolved_fourier <- convolve(
eterm,
fmrihrf::gen_hrf("fourier", nbasis = 2),
sframe
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.