HRFBold#
- class brainmass.HRFBold(k_1=5.6, V_0=0.02, period=Quantity(1000., 'ms'), downsample_period=Quantity(4., 'ms'), kernel=None, convolution_mode='valid', method='fft', history=None)#
Convolution-based fMRI BOLD observation (HRF kernel).
Forms the BOLD signal by convolving downsampled neural activity with a closed-form hemodynamic response function (HRF) kernel, then decimating to the repetition time (TR). The pipeline is:
Downsample neural activity from the simulation step
dttodownsample_periodwith aTemporalAverage.Convolve each region’s series (after prepending a warm-up
history, zeros by default) withkernelevaluated on thedownsample_periodgrid.Scale to BOLD: \(\mathrm{BOLD} = k_1 V_0 (c - 1)\), where \(c\) is the convolution output (the
-1removes the unit baseline, matching the TVB convention).Decimate to the TR by taking every
round(period / downsample_period)sample.
Unlike the four-state Balloon-Windkessel ODE in
brainmass.BOLDSignal, this is a single linear convolution – fast, simple and fully differentiable in its scalar parameters, which makes it the natural choice for fitting. Preferbrainmass.BOLDSignalwhen biophysical realism matters. Both are kept.- Parameters:
k_1 (float) – BOLD signal scaling factor (default
5.6).V_0 (float) – Resting blood volume fraction (default
0.02).period (brainunit.Quantity) – Final BOLD sampling period / TR (default
1000 * u.ms).downsample_period (brainunit.Quantity) – Intermediate downsampling period the kernel is sampled on (default
4 * u.ms).kernel (HRFKernel) – HRF kernel to convolve with (default
FirstOrderVolterraHRFKernel).convolution_mode ({'valid', 'same', 'full'}) – Convolution edge mode (default
'valid'; with the zerohistoryprepend this yields a causal output of lengthT_ds + 1).method ({'fft', 'direct'}) –
'fft'usesjax.scipy.signal.fftconvolve();'direct'usesjax.numpy.convolve(). They agree numerically (default'fft').history (array-like, optional) – Warm-up buffer prepended before convolution, shape
(round(duration / downsample_period), *regions).None(default) prepends zeros.
See also
brainmass.BOLDSignalthe physiologically detailed Balloon-Windkessel ODE BOLD.
TemporalAveragethe windowed-mean downsampler used internally.
Examples
>>> import brainmass >>> import brainunit as u >>> import jax.numpy as jnp >>> t = jnp.arange(2000.) >>> z = 1.0 + 0.5 * jnp.sin(2 * jnp.pi * t[:, None] / 800.0) >>> bold = brainmass.HRFBold( ... period=200. * u.ms, downsample_period=4. * u.ms, ... kernel=brainmass.FirstOrderVolterraHRFKernel(duration=400. * u.ms), ... ) >>> y = bold(z, dt=1. * u.ms) >>> y.shape[1] 1