Skip to contents

This function convolves a hemodynamic response function (HRF) with a block duration, producing a time-varying response for the specified duration. The function supports various HRFs, block widths, precision levels, half-lives, and normalization.

Usage

convolve_block(
  t,
  hrf = hrf_gaussian,
  width = 5,
  precision = 0.2,
  half_life = Inf,
  summate = TRUE,
  normalize = FALSE,
  ...
)

Arguments

t

A vector of time points in seconds at which the convolved response will be evaluated

hrf

The hemodynamic response function to be convolved, provided as a function (default: hrf_gaussian)

width

The fixed width of the response block in seconds (default: 5)

precision

The sampling precision of the response in seconds (default: 0.2)

half_life

The half-life of the exponential decay function in seconds, used to model attenuation (default: Inf)

summate

A logical value indicating whether to sum the impulse response functions (default: TRUE) If FALSE, the function returns the maximum value at each time point.

normalize

A logical value indicating whether to normalize the output so that its peak value is 1 (default: FALSE)

...

Additional arguments passed to the HRF function

Value

A vector of convolved responses at the specified time points

Examples

time_points <- seq(0, 20, by = 0.5)
block_response <- convolve_block(time_points, hrf=hrf_spmg1, width=5, precision=0.2)
plot(time_points, block_response, type='l', main='Convolved Hemodynamic Response with Block Duration')