Bayesian & State-Space Decoding

Kalman filter

The Kalman filter is the exact recursive Bayesian estimator for a linear-Gaussian state-space model: the state evolves as x_t = A x_{t-1} + w_t with process noise w ~ N(0, W), and the observation is y_t = C x_t + q_t with measurement noise q ~ N(0, Q). Because linear maps of Gaussians stay Gaussian, the posterior is fully described by a mean and covariance that update in closed form. Each step runs a prediction (x_pred = A x_est, P_pred = A P A^T + W) and a correction that blends the prediction with the new measurement through the Kalman gain.

In motor BCI the state x is the kinematic intention (commonly position and velocity plus a constant term), A encodes a smoothness/inertia prior, C is the linearized tuning matrix mapping kinematics to per-channel firing rates, and Q captures neural noise and un-modelled variability. The filter is optimal in the minimum-mean-square-error sense when the model is correct and, remarkably, remains the best linear estimator even when the noise is non-Gaussian. Its practical appeal is a physiologically interpretable prior, a principled treatment of uncertainty, and cheap constant-time updates suitable for real-time loops.

The main caveats are that its guarantees hold only insofar as the linear-Gaussian assumptions and the fitted A, C, W, Q hold. Neural tuning is not truly linear, noise is not stationary, and channels drift day to day, so the filter can be biased or overconfident; in closed loop these errors interact with the user, which motivates the intention-corrected and adaptive variants.

A cursor-control decoder holds a 5-dimensional state (x-position, y-position, x-velocity, y-velocity, 1). Every 50 ms it reads ~100 binned spike counts, predicts where the intended velocity should be given inertia, then nudges that prediction toward whatever the population activity implies — the balance set by how noisy the neurons are that instant.

The velocity state, not raw position, is what makes such decoders usable in practice.

Also called
linear-Gaussian filterKF線性高斯濾波器