# Example time series
ts <- data.frame(
subjects = rep(1, 100),
run = rep(1, 100),
time = seq(0, 99),
ROI = rnorm(100)
)
# Create a simple events data frame
events <- data.frame(
subjects = rep(1, 10),
run = rep(1, 10),
onset = seq(0, 90, by = 10),
condition = rep(c("A", "B"), 5),
rt = runif(10, 0.5, 1.5),
accuracy = sample(0:1, 10, replace = TRUE)
)
# Reshape with custom duration for each event_type
reshaped <- reshape_events(events,
event_types = c("condition", "accuracy", "rt"),
duration = list(condition = 0.5,
accuracy = 0.2,
rt = function(x) x$rt))
design_matrices <- convolve_design_matrix(
timeseries = ts,
events = reshaped,
covariates = c('accuracy', 'rt'),
factors = list(cond = c("condition_A", "condition_B")),
contrasts = list(cond = matrix(c(-1, 1))))
# Plot the design matrix
plot_design_fmri(design_matrices)
Run the code above in your browser using DataLab