Observation Models#

Observation models map region-level neural activity to a measurable signal by post-processing a simulated trajectory. brainmass ships two complementary observation paths:

  1. Convolution BOLDHRFBold convolves (temporally-averaged) neural activity with a closed-form hemodynamic response function (HRF) kernel and decimates to the fMRI repetition time (TR). It is a single linear operator that is differentiable in its few scalar parameters, so it is the BOLD path of choice for fitting.

  2. Temporal averagingTemporalAverage is a standalone, anti-aliased downsampler (block mean over non-overlapping windows). It is the averaging complement to the point-decimation Simulator(sample_every=k) subsampling and the downsampler HRFBold uses internally.

The biophysical Balloon-Windkessel BOLDSignal ODE and the EEG/MEG lead-field forwards live on Forward Models; pick BOLDSignal over HRFBold when biophysical realism (flow, volume, deoxyhemoglobin) matters more than speed or differentiability.

HRF kernels#

A hemodynamic response function (HRF) is the impulse response of the neural-to-BOLD transform. Each kernel below is a callable instance – h = kernel(t) returns a dimensionless \(h(t)\) (t is a time Quantity, or a plain array interpreted as milliseconds, the TVB convention). They differ only in their closed form:

Kernel

Closed form / reference

FirstOrderVolterraHRFKernel

TVB canonical first-order Volterra (underdamped damped oscillator; Friston et al. 2000)

GammaHRFKernel

Peak-normalised gamma probability density (Boynton et al. 1996)

DoubleExponentialHRFKernel

Difference of damped oscillations (Polonsky et al. 2000)

MixtureOfGammasHRFKernel

Difference of two gammas / SPM canonical HRF (Glover 1999)

HRFKernel is the shared abstract base; subclass it to add a new kernel.

API Reference#

HRF kernel family#

HRFKernel

Base class for hemodynamic response function (HRF) kernels.

FirstOrderVolterraHRFKernel

First-order Volterra kernel of the hemodynamic system (TVB canonical).

GammaHRFKernel

Gamma HRF kernel (Boynton et al. 1996).

DoubleExponentialHRFKernel

Double-exponential (damped-oscillation difference) HRF kernel.

MixtureOfGammasHRFKernel

Mixture-of-gammas HRF kernel (Glover 1999).

Convolution BOLD#

HRFBold

Convolution-based fMRI BOLD observation (HRF kernel).

HRFBold downsamples the neural trajectory (via TemporalAverage), convolves it with the chosen HRF kernel, and decimates to the TR:

\[\text{BOLD} = k_1 V_0 \,(\,h * y_{\text{ds}} - 1\,),\]

where \(y_{\text{ds}}\) is the temporally-averaged neural activity, \(h\) the HRF kernel and \(*\) 1-D convolution along time.

Temporal averaging#

TemporalAverage

Downsample a trajectory by averaging over non-overlapping time windows.

TemporalAverage downsamples a trajectory by averaging over non-overlapping windows of w = round(period / dt) samples (y[k] = mean(signal[k*w : (k+1)*w]); the trailing partial window is dropped). It preserves units and is smoother / anti-aliased relative to point decimation.

Examples#

A closed-form HRF kernel is a callable returning a dimensionless impulse response:

>>> import brainmass
>>> import brainunit as u
>>> import jax.numpy as jnp
>>> kernel = brainmass.MixtureOfGammasHRFKernel()
>>> t = jnp.arange(0., 20000., 100.)        # 20 s grid in ms
>>> h = kernel(t)
>>> h.shape
(200,)
>>> bool(jnp.all(jnp.isfinite(h)))
True

Convolve a slow neural drive to a BOLD trace, then average a signal down a second way:

>>> t = jnp.arange(2000.)
>>> z = 1.0 + 0.5 * jnp.sin(2 * jnp.pi * t[:, None] / 800.0)   # (2000, 1) drive
>>> 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
>>> signal = jnp.arange(20.).reshape(20, 1)
>>> brainmass.TemporalAverage(period=5. * u.ms)(signal, dt=1. * u.ms).shape
(4, 1)

See Also#

  • Forward Models – the Balloon-Windkessel BOLDSignal ODE and the EEG/MEG lead-field forwards.

  • OrchestrationSimulator(sample_every=k) point-decimation subsampling and the FCD-distribution objectives that consume BOLD traces.

  • Neural Mass Models – the neural mass models whose activity these observers transform.