Active Sensing in BCI: How Active Inference Closes the Loop on Uncertainty

Most BCI pipelines are reactive: a stimulus fires, the brain responds, the decoder reads the signal, and the system acts. The system has no say in what stimulus comes next. It waits.
Active Inference offers a fundamentally different model. Under the Free Energy Principle, an agent doesn't just respond to observations — it selects actions that are expected to minimize future surprise. Applied to BCI, this means the system can choose which stimulus to present next based on what will most efficiently resolve its uncertainty about the user's intent. That capability is called active sensing, and it's one of the most powerful ideas in the Active Inference toolkit.
In this post, we'll break down what active sensing is, why it matters for BCI, how Expected Free Energy (EFE) connects theory to implementation, and what it looks like to build an actively-sensing BCI pipeline with RxInfer and Nimbus Studio.
What Is Active Sensing?
Active sensing is the process by which an agent selects observations — rather than passively receiving them. In everyday terms: instead of looking at a fixed point, you move your eyes to the part of the scene most likely to answer your current question. Your visual system is not just a camera; it's an active interrogator of the environment.
In a BCI context, the "observations" are EEG epochs locked to stimuli. In classical paradigms like P300 spellers, stimuli fire in a fixed, predetermined sequence — rows, columns, or random subsets. The decoder accumulates evidence and eventually commits. The order of stimuli doesn't adapt to what the decoder already knows.
An actively-sensing BCI changes that. After each stimulus-response pair, the system asks: given what I've already observed, which stimulus should I present next to maximally resolve my remaining uncertainty about the user's intent? The answer updates the stimulus queue. The system converges faster — and more robustly — because each observation is chosen to be informative rather than arbitrary.
This is not just an engineering trick. It falls out naturally from the mathematics of Active Inference.
Expected Free Energy as an Information-Seeking Objective
In the EFE post, we introduced Expected Free Energy as the quantity that drives policy (action) selection in Active Inference. Recall:
EFE decomposes into two terms:
- Epistemic value (information gain): how much the action is expected to reduce uncertainty about hidden states.
- Pragmatic value (goal pursuit): how much the action is expected to produce preferred outcomes.
For active sensing, epistemic value is the dominant term. The system prefers stimuli that are expected to make the posterior over the user's intended target sharper — that is, stimuli where different targets would produce maximally different observations.
Formally, epistemic value is the expected reduction in posterior entropy:
This is exactly mutual information between observations and latent states — a principled measure of how much a stimulus is expected to "tell" the decoder. Maximizing this recovers Bayesian optimal experimental design as a special case.
The practical consequence: after each observation, the decoder maintains a probability distribution over user intents. EFE scores each candidate stimulus by how much it would sharpen that distribution. The highest-scoring stimulus is presented next.
From Theory to RxInfer: Belief Propagation Meets Active Selection
Implementing active sensing requires two things to happen in real time:
- Belief updating: after each stimulus, update the posterior over user intent.
- Policy evaluation: score candidate stimuli using EFE and select the next one.
Both steps sit naturally in the reactive message-passing framework that powers RxInfer.
Beliefs are updated by running a forward inference pass over the generative model: the likelihood of the observed EEG epoch under each candidate intent flows through the factor graph and updates the posterior. This is exactly what happens in a standard closed-loop pipeline — no additional machinery needed.
Policy evaluation adds one more pass. For each candidate stimulus , the agent simulates: if I present , what distribution of EEG epochs do I expect? This requires a forward prediction through the observation model. The difference in entropy between prior and expected posterior gives the epistemic value of . The stimulus with the highest EFE score wins.
In RxInfer, both passes are message passing operations on the same factor graph — the generative model for stimuli, latent states, and EEG observations. The only addition is a policy layer that iterates over candidate stimuli before each trial.
Because RxInfer's reactive message passing runs at millisecond timescales, the policy evaluation loop is fast enough to run between trials without introducing perceptible delays in the stimulus presentation schedule.
Building an Actively-Sensing P300 Pipeline in Nimbus Studio
Let's make this concrete. Consider a classic P300 speller: the user focuses on a target character, and the system must identify it from EEG responses to row/column highlights.
In the standard paradigm, all rows and columns are highlighted in a fixed or random order, repeated multiple times. The decoder averages across repetitions and classifies at the end.
In an actively-sensing paradigm:
- Prior: the system starts with a uniform prior over all characters.
- Trial loop:
- Score each un-presented stimulus (row or column) by EFE — prioritizing those that would most sharply differentiate the remaining high-probability characters.
- Present the highest-scoring stimulus.
- Record the EEG epoch.
- Update the posterior via belief propagation.
- Terminate if posterior entropy falls below a confidence threshold; otherwise, continue.
- Output: the character with the highest posterior probability.
In Nimbus Studio, this loop is expressed as a pipeline with a feedback edge from the decoder back into the stimulus scheduler. The scheduler node accepts a belief vector and a set of candidate stimuli, evaluates EFE for each, and emits the next stimulus. The decoder node runs a Bayesian update after each epoch and outputs the current posterior.
The result is a speller that adapts its presentation order in real time. High-confidence trials terminate early — sometimes after just two or three stimuli per character instead of the standard five to ten repetitions. Low-confidence trials (noisy sessions, fatigued users) automatically extend, presenting more stimuli until the posterior is sharp enough.
This adaptive termination alone can cut average trial duration by 30–50% in practice, without any loss in accuracy — and often with gains, because the system stops wasting stimuli on characters that are already ruled out.
Why Active Sensing Matters Beyond Speed
Faster trials are the obvious benefit, but active sensing has deeper implications for BCI robustness:
Noise adaptation: when EEG quality degrades (movement artifact, electrode drift, low SNR), the posterior updates more slowly. The pipeline responds by presenting more trials — automatically increasing evidence accumulation where it's needed most. The system is self-calibrating to signal quality.
Personalization without retraining: epistemic value is computed from the current posterior, which already encodes the user's recent response patterns via Bayesian updating. The stimulus selection policy naturally adapts to individual users and sessions without any explicit retraining step.
Graceful degradation: under severe noise, the system continues to function — it just takes more trials. There is no hard failure mode where the classifier breaks and returns a uniform output. Uncertainty propagates forward rather than collapsing into an overconfident wrong answer.
These properties are difficult to recover in purely discriminative pipelines. A softmax classifier trained on pooled data doesn't know what it doesn't know. An Active Inference agent does.
Conclusion
Active sensing is where Active Inference stops being a better decoder and starts being a genuine agent. By selecting stimuli based on Expected Free Energy, the BCI system participates in the experiment it's running — reducing uncertainty efficiently rather than waiting for it to resolve.
The implementation path is natural for anyone already working with RxInfer and Nimbus Studio: the generative model is the same, the inference passes are the same, and the policy evaluation layer is a lightweight addition that closes the loop between belief and action.
The practical payoff — faster trials, adaptive noise handling, and built-in personalization — makes actively-sensing pipelines attractive for both research and clinical settings where user fatigue and session variability are real constraints.
In the next post, we'll look at multi-step planning in Active Inference: how to extend EFE over horizons longer than one trial, and what that means for BCIs that must orchestrate sequences of actions — not just classify individual intents.