Research Note: Markov-Switching State-Space Models for Neural Decoding

4 minute read

Published:

This note documents a direction explored in my weekly reports: using Markov-switching state-space models (SSMs) as a controllable alternative to heavy end-to-end deep pipelines for neural decoding tasks.

Motivation

Three practical constraints motivate this direction:

  • training cost can be high in large neural decoders,
  • throughput can be limited for rapid experimentation,
  • cross-dataset benchmarking needs models with transparent assumptions.

Base SSM

A standard linear SSM writes:

\[\dot{x}(t)=A(t)x(t)+B(t)u(t),\qquad y(t)=C(t)x(t)+D(t)u(t).\]

In discrete form (VAR-style latent dynamics):

\[y_t=Cx_t+w_t,\qquad x_t=\sum_{i=1}^p A_i x_{t-i}+v_t.\]

Regime Switching Extension

With latent regime \(S_t\), both transition and observation structure can switch:

\[y_t=C_{S_t}x_{t,S_t}+w_t,\qquad x_{t,j}=\sum_{i=1}^p A_{i,j}x_{t-i,j}+v_{t,j},\;1\le j\le M.\]

Interpretation:

  • each regime has its own linear dynamics,
  • regime transitions are Markovian,
  • observations are generated by the currently active regime.

Note the index \(j\) on the latent state. All \(M\) chains advance at every step, whichever regime is active. The regime \(S_t\) only selects which chain reaches the sensors, and through which \(C_j\). The figure runs a toy version with \(M = 2\).

0.980 mean dwell 1/(1 − πjj) = 50 samples
0.20 rescales wt over the whole window
  1. 1Regime\(\Pr(S_t = j \mid S_{t-1} = j) = \pi_{jj}\)
    Now St = 1, for the last 1 sample.
    Switches among the N = 240 samples in view: 0 (expected (N − 1)(1 − πjj) = 4.8).
  2. 2All M = 2 chains runSLDS: one chain, switched dynamics\(x_{t,j} = A_{1,j}x_{t-1,j} + A_{2,j}x_{t-2,j} + v_{t,j}\)\(x_t = A_{1,S_t}x_{t-1} + A_{2,S_t}x_{t-2} + v_t\)
    Poles rje±i2πfj, with fj in cycles/sample. σv,j gives each chain variance 1.σv,j would give regime j’s chain variance 1 if it ran alone, but the switched state xt is not held there. Its long-run variance at this πjj is –. In view: – samples beyond the panel’s ±3.5, largest |xt| = –.
    jrjfjA1,jA2,jσv,j
    1
    2
  3. 3Observation\(y_t = C_{S_t}x_{t,S_t} + w_t\)\(y_t = C_{S_t}x_t + w_t\)
    C1 = , C2 =
    wt ~ N(0, σw2I), σw = 0.20

Synthetic toy data, simulated in the page from a fixed seed. Here M = 2, and each regime has a scalar AR(2) chain: the special case p = 2 of the VAR(p) above, with one latent dimension per regime. The coefficients come from the poles, \(A_{1,j} = 2r_j\cos 2\pi f_j\) and \(A_{2,j} = -r_j^2\), and the first 500 samples are discarded as warm-up. Some choices are mine, not the post’s: vt,1 and vt,2 are independent Gaussians, wt is white Gaussian, both regimes share one stay probability πjj (notation introduced here), and C1, C2 are made-up patterns over 3 channels. The bold line’s jump is drawn halfway between samples. Moving the πjj slider redraws St over the window from the same random numbers. The SLDS toggle shows a different model, in which a single state xt is carried across switches, with the same St and noise. Each regime is stable on its own, yet switching a carried-over state between them can amplify it. The SLDS curve overshoots after switches, and its long-run variance is above 1 and grows as πjj falls. That variance is computed from the model’s second-moment recursion, not from the samples in view. Values beyond a panel’s range are clipped, and a triangle at the panel edge marks each clipped excursion. C switches in both models, so the observation rows jump in both; the difference is in the latent panel.

Why This Is Useful for EEG/MEG

Neural recordings are often non-stationary across time, subject condition, and device context. Regime switching gives a principled way to model piecewise-stable dynamics without forcing a single global linear model.

Current Practical Goals

  1. Reduce computational cost compared with heavier baselines.
  2. Maintain competitive decoding quality on open EEG/MEG benchmarks.
  3. Improve interpretability by exposing regime-specific dynamics.

This is still a working direction, but it has strong potential as a bridge between statistical rigor and deployment-friendly decoding.