📋 KEY INSIGHTS
- Brain-computer interfaces (BCIs) decode neural activity — recorded as electrical signals from electrodes on or inside the brain — into commands for external devices, restoring communication and motor function to paralysed patients.
- Neural decoding is fundamentally a time series classification or regression problem: map a window of multi-channel neural recordings to a motor intention, speech phoneme, or imagined letter.
- EEG-based BCIs (non-invasive, cheap) achieve 70–90% accuracy on motor imagery tasks but are limited by signal noise; ECoG and Utah array recordings (invasive, high spatial resolution) enable typing at 90+ characters per minute.
- Neural population dynamics — the trajectory of collective activity across hundreds of neurons — is more informative than individual neuron firing rates, requiring dimensionality reduction methods like GPFA and LFADS.
- Foundation models for neural data (NDT-2, POYO) pre-train on large multi-session neural recording datasets, achieving zero-shot decoding on new subjects without session-specific fine-tuning.
- Closed-loop BCIs adapt stimulation parameters in real time based on decoded neural state — a feedback control system where the ML model is the controller and the brain is the plant.
The brain generates electrical signals that encode perception, intention, memory, and emotion — signals that ML can learn to decode, interpret, and respond to. Brain-computer interfaces translate these signals into device commands for patients who have lost motor function due to ALS, spinal cord injury, or stroke. Beyond medical applications, computational neuroscience uses ML to understand how neural circuits compute — a bidirectional relationship where neuroscience inspires new ML architectures and ML provides new tools for understanding the brain.
This guide covers neural signal types and recording modalities, motor imagery decoding for BCIs, speech BCI from cortical recordings, neural population dynamics and latent variable models, closed-loop neurostimulation, and the emerging class of neural data foundation models.
Neural Signals, Motor Decoding and Speech BCIs
Neural recording modalities span a wide range of spatial resolution and invasiveness. Electroencephalography (EEG) records electrical potentials from the scalp using 32–256 electrodes — non-invasive, portable, and cheap, but subject to muscle artefacts and poor spatial resolution (each electrode averages across millions of neurons). Electrocorticography (ECoG) places electrode grids directly on the cortical surface during neurosurgery — higher signal quality than EEG, with millimetre spatial resolution. Utah arrays (the type used in Neuralink and BrainGate) penetrate the cortex with 96–1024 microelectrodes, recording individual neuron action potentials (spikes) with submillisecond temporal resolution. The choice of modality determines the ML approach: EEG data requires aggressive artefact rejection and benefits from spatial filtering methods like Common Spatial Pattern (CSP); spike train data from Utah arrays can be decoded with relatively simple linear models because the signal quality is high.
Motor imagery decoding — classifying imagined hand movements (left vs. right grip, finger extension, wrist rotation) from EEG or ECoG — is the most studied BCI paradigm. The standard pipeline applies bandpass filtering in the mu (8–13 Hz) and beta (13–30 Hz) frequency bands (which desynchronise during motor imagery), computes log-bandpower features across electrode-band combinations, and trains a linear discriminant analysis (LDA) or gradient boosting classifier. EEGNet (Lawhern et al., 2018) replaced this hand-crafted pipeline with a compact depthwise separable CNN that processes raw EEG directly, achieving state-of-the-art on motor imagery benchmarks while generalising across BCI paradigms (P300, SSVEP, slow cortical potentials) with the same architecture. EEGNet’s key design: depthwise convolutions over the temporal dimension capture frequency-band features; pointwise convolutions combine features across channels; a spatial filter layer (1×C depthwise conv) learns subject-specific electrode weightings. This is the same depthwise separable convolution from MobileNet described in our model compression guide, applied here because EEG classifiers must run on embedded hardware with strict power budgets.
Speech BCIs decode intended speech directly from motor cortex recordings, restoring communication to patients with locked-in syndrome. The BrainGate and Chang Lab (UCSF) groups have demonstrated remarkable results: Frank Willett et al. (Nature 2023) implanted Utah arrays in the hand/arm motor cortex of an ALS patient and trained an RNN to decode attempted handwriting from neural population activity — achieving 90 characters per minute with 94% accuracy, faster than any prior BCI. The speech synthesis BCI (Metzger et al., Nature 2023) decoded speech at 78 words per minute from ECoG recordings of the speech motor cortex, synthesising a continuous audio stream of the patient’s intended speech rather than discrete word outputs. Both systems rely on the same core idea: the motor cortex encodes intended movements (of the hand for handwriting, of the vocal tract for speech) even when no movement occurs, and an RNN or transformer trained on paired neural-and-movement data can decode the latent intention. The recurrent neural network architectures used here — specifically multi-layer GRUs with highway connections — are the same as those used in time series forecasting, adapted for the low-latency online decoding requirement of a real-time BCI system.
| Modality | Spatial Resolution | Invasiveness | Typical BCI Performance |
|---|---|---|---|
| EEG | ~1 cm | Non-invasive | 70–90% motor imagery accuracy |
| ECoG | ~1 mm | Surface (surgical) | 78 wpm speech BCI |
| Utah array (single units) | ~50 µm | Penetrating (surgical) | 90 cpm handwriting BCI |
| fMRI (non-real-time) | ~1 mm (voxels) | Non-invasive | Visual reconstruction; dream decoding |
Neural Population Dynamics, Latent Variable Models and Foundation Models
Recording from hundreds of neurons simultaneously reveals that neural computation is best understood at the population level, not the single-neuron level. Rather than asking “what does neuron 42 encode?”, modern systems neuroscience asks: “what low-dimensional trajectory does the population trace through neural state space during a behaviour?” Gaussian Process Factor Analysis (GPFA, Yu et al., 2009) models neural population activity as a low-dimensional Gaussian process latent trajectory plus Poisson noise — the same Gaussian process framework used for regression, applied here to extract smooth latent dynamics from noisy spike train data. GPFA reveals that motor cortex during reaching follows a rotational trajectory in a 10–15 dimensional latent space, and the speed and accuracy of arm movements are encoded in the radius and phase of this rotation — a discovery that would have been invisible at the single-neuron level.
LFADS (Latent Factor Analysis via Dynamical Systems, Pandarinath et al., 2018) is a sequential VAE for neural population data: an encoder RNN processes the observed spike trains and infers a low-dimensional initial condition; a generator RNN (implementing a learned dynamical system) produces the latent trajectory; a linear readout produces Poisson rates for each neuron. LFADS acts as a powerful denoiser — by constraining the latent dynamics to follow a smooth RNN trajectory, it recovers the true underlying neural signal from noisy single-trial spike counts. The resulting denoised population activity enables decoding models to achieve 30–50% lower decoding error than raw spike counts, without requiring additional data collection. This is the same variational autoencoder architecture (encoder, latent space, decoder with reconstruction loss plus KL divergence) applied to sequential neural data, with the latent dynamics constrained by an RNN rather than a standard diagonal Gaussian prior.
Neural data foundation models represent the latest paradigm: rather than training a separate decoding model for each subject and session (which requires 30–60 minutes of calibration data), pre-train a large transformer on neural recordings from many subjects and sessions, then decode from new subjects with zero or few shots. NDT-2 (Neural Data Transformer 2) pre-trains on the International Brain Laboratory dataset (hundreds of Neuropixels probe recordings across dozens of mice), masked-modelling style: randomly mask 25% of neural tokens and predict them from context. The pre-trained NDT-2 achieves competitive decoding accuracy on new sessions from new animals without any fine-tuning — demonstrating that neural representations are transferable across subjects, analogous to how transfer learning from ImageNet pre-training transfers visual features across image domains. POYO (Population of Your Own) extends this to multi-species data, learning a shared neural code that transfers across mouse, monkey, and human recordings by using a session-specific tokeniser that maps electrode identities to learned embeddings.
Closed-loop neurostimulation delivers electrical pulses to the brain in real time based on the decoded neural state — turning the BCI from a one-way decoder into a bidirectional brain-machine interface. Applications include: responsive deep brain stimulation for Parkinson’s and depression (stimulate the subthalamic nucleus when beta oscillations exceed a threshold, suppressing the pathological oscillations that cause motor symptoms), closed-loop transcranial magnetic stimulation for stroke rehabilitation (time stimulation to the phase of motor cortex oscillations when plasticity is highest), and spinal cord stimulation for chronic pain (decode pain-related neural signatures and adjust stimulation to suppress them). The control policy is a reinforcement learning problem: the state is the decoded neural state, the action is the stimulation parameter set, and the reward is the clinical outcome (tremor reduction, pain rating) — an RL agent that learns the optimal stimulation policy from closed-loop interaction with the patient’s nervous system.



