arXiv:2610.30422cs.LGOct 2026

Manuscript Offprint

arXiv:2610.30422

Memory-Augmented Online Test-Time Adaptation for EEG Motor Imagery via Perturbation Consistency and Confidence Calibration

Kunkun Zhang, Kehao Wu, Zhitao Chen, Haigen Hu, Qianwei Zhou

Kunkun Zhang, Kehao Wu, Zhitao Chen, Haigen Hu, Member, IEEE, and Qianwei Zhou, Member, IEEE

Abstract—Recently, electroencephalography (EEG)-based brain-computer interfaces (BCIs) have gained traction as portable neural measurement systems. However, the practical deployment of these instruments is often hindered by nonstationarity and cross-subject distribution shifts, which lead to significant intersubject inconsistency. Existing adaptation methods remain impractical for real-time measurement scenarios, as they typically require offline access to source or aggregated target data. To address these challenges, this article proposes memory-augmented online test-time adaptation (OTTA) with perturbation consistency and confidence calibration (MOPC), a source-free framework designed to enhance the reliability of BCI instrumentation. MOPC enables the measurement system to update its decoding parameters on the fly during the inference stage, facilitating single-pass adaptation without accessing sensitive source data. We introduce random-mask perturbations to enforce prediction consistency against inherent EEG signal noise and acquisition artifacts. Furthermore, a confidence-calibrated reweighting loss is designed to integrate feature-space similarity, effectively mitigating unreliable pseudolabels and class imbalance during continuous signal acquisition. To ensure system stability and prevent the catastrophic forgetting of established neural patterns, a lightweight memory module is incorporated to regularize parameter updates within a tight latency budget. Evaluated on the BCI IV IIb and OpenBMI datasets, MOPC achieves state-of-the-art performance, outperforming prior methods by 2.22 % and 3.67 %, respectively, while keeping the per-trial adaptation latency to approximately 40–60 ms. This study provides a robust, recalibration-free solution for real-time EEG decoding, marking a significant advancement in the precision and usability of practical BCI measurement instruments. The source code is available at https://github.com/KunKun-Zhang/MOPC.git

Index Terms—Brain-computer interface (BCI), electroencephalography, motor imagery (MI), test-time adaptation (TTA).

I. INTRODUCTION

Received 25 March 2026; revised 21 August 2026; accepted 28 August 2026. Date of publication 22 September 2026; date of current version 5 October 2026. This work was supported in part by the National Natural Science Foundation of China under Grant 62271448 and Grant 62373324 and in part by the “Pioneer” and “Leading Goose” Research and Development Program of Zhejiang under Grant 2026C02A1221 and Grant 2025C02160. The Associate Editor coordinating the review process was Dr. Susanna Spinsante. (Corresponding author: Qianwei Zhou.)

The authors are with the College of Computer Science and Technology, Zhejiang University of Technology, Hangzhou 310023, China, and also with Zhejiang Key Laboratory of Visual Information Intelligent Processing, Hangzhou 310023, China (e-mail: zqw@zjut.edu.cn).

Digital Object Identifier 10.1109/TIM.2026.3736160

© 2026 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. DOI: 10.1109/TIM.2026.3736160

BRAIN-COMPUTER interfaces (BCIs) serve as advanced neural measurement instruments, establishing direct pathways between the human brain and external devices for neurorehabilitation and robotics [1, 2]. Among various paradigms, electroencephalography (EEG)-based motor imagery (MI) is a pivotal measurement technique due to its noninvasiveness and portability [3]. By decoding imagined movements from EEG signals, MI-based BCIs can restore motor function in paralyzed patients and enhance human capabilities in virtual environments. These systems have been successfully applied in multiple fields, including wheelchair control [4] and lower limb exoskeleton assistance systems [5].

Early MI-BCI decoding methods relied on manual feature extraction techniques, such as common spatial patterns (CSPs) and statistical bandpower measures, followed by conventional classifiers [6, 7]. The advent of deep learning has led to the development of end-to-end neural models that automatically learn spatial-temporal representations from raw EEG, resulting in significant improvements in measurement accuracy and robustness [8, 9]. Despite these advancements, MI-EEG models trained on a set of subjects (source domain) often experience a sharp decline in decoding reliability when applied to new individuals (target domain) [10]. This is attributed to the differences in signal amplitude and frequency characteristics between subjects [11]. In metrological terms, the decoder is an instrument whose reliability and reproducibility must hold across subjects and over time, yet this cross-subject variability behaves as instrument drift whose usual remedy, per-subject recalibration, lengthens setup and undermines repeatability [12].

Because such drift degrades any model transferred to a new user, robust transfer learning has become essential [13–15]. Domain adaptation (DA) addresses it by transferring knowledge from a labeled source to an unlabeled target [16], and is commonly divided, depending on whether the source data remain accessible, into unsupervised DA (UDA) and source-free UDA (SFUDA). UDA aligns the two distributions during joint training [17]. DANN, for instance, learns domain-invariant features with a gradient-reversal adversary [18]. The instrumentation and measurement literature has pursued this line to reconcile cross-subject and cross-device recordings, through multiview contrastive learning [19], prototype-supervised transfer across multiple source brains (PSATs) [20], interdevice sample reweighting (SRENet) [21], multisource associate alignment across subjects and sessions [22], and semisupervised multisource joint-distribution adaptation that further exploits a few labeled target trials [23], as illustrated in Fig. 1(a). Instead, SFUDA adapts a pretrained model without revisiting the source, thereby preserving subject privacy [24].

Figure

Fig. 1. Conceptual comparison of three domain-adaptation paradigms for cross-subject EEG decoding. (a) UDA. (b) SFUDA. (c) OTTA.

SHOT aligns the target with the source hypothesis through information maximization and pseudolabeling [25], while USFDA adds a generative classifier for out-of-distribution rejection [26], as shown in Fig. 1(b). Effective as these methods are, they all operate offline: each collects the entire target set, or even a labeled calibration subset of it, and revisits it over several passes before producing a prediction, and the UDA variants further require the source recordings to remain accessible at the deployment site. This assumption does not fit a BCI that must decode a continuous stream one trial at a time.

Online test-time adaptation (OTTA) lifts the offline requirement by updating the model during inference, in a single pass over the incoming data [27, 28], which matches the low-latency operation a deployed BCI needs, as depicted in Fig. 1(c). Existing OTTA methods fall into four families. Entropy minimization sharpens predictions by tuning batch-normalization (BN) parameters, as in TENT [29] and the sharpness-aware SAR [30]. Pseudolabeling supervises the model with its own outputs, as in the paired-view DPLOT [31] and the backpropagation-free T3A [32]. Consistency regularization enforces stable predictions across perturbed views, as used for EEG sleep staging [33] and for masked self-supervision [10]. Antiforgetting regularization preserves source knowledge over long runs, as in the teacher-based CoTTA [34] and the probabilistic PETAL [35]. All four were designed for image streams, however, and overlook two properties of EEG: its trials are short and noisy, and their class balance drifts as the user's engagement varies. The few EEG-specific efforts remain partial. MD-CAT copes with evolving distributions, but by continual retraining rather than test-time adaptation (TTA) [36]; Wang et al. [37] refine a personalized MI decoder trial by trial, retraining on the user's own cue-locked online trials to track day-to-day nonstationarity; Jiao et al. [38] combine subject-specific stimulation and filter-bank settings, optimized offline, with periodic retraining of the decoder during online use; neither considers label-free, source-free transfer to a new user; and T-Time, the closest online baseline, maximizes information over an ensemble yet treats trials as independent, so it cannot exploit their temporal order [39]. Offline prototype networks such as SST-DPN confirm that temporal context is informative [40], but they cannot adapt once deployed.

We close this gap with MOPC, a memory-augmented OTTA method with perturbation consistency and confidence calibration. MOPC keeps a short first-in-first-out memory of recent prealigned trials together with their predictions, and this memory serves two purposes. First, it continuously re-estimates the Euclidean alignment (EA) of the incoming stream, turning a normally static prealignment [41] into an adaptive one. Second, it provides the context for three coupled objectives tailored to EEG: a perturbation-consistency term that keeps the prediction stable when the trial is corrupted by a random time-mask [10], a joint entropy term that sharpens the predictions on both the original and masked views, and a confidence-calibrated reweighting term that discounts unreliable pseudolabels and offsets class drift using feature similarity among same-class neighbors in memory together with an effective-number class weight [42]. Every arriving trial is first labeled by an ensemble of N=5 models and then used to update only the BN parameters of one member, selected in round-robin. Since the update touches nothing else, its cost is independent of the number of classes, which keeps the method fast enough for real-time use. The overall MOPC framework is illustrated in Fig. 2.

MOPC therefore differs from prior work in both setting and design. Unlike the offline adaptation of PSAT and SRENet or the continual retraining of MD-CAT, it adapts to each trial in a single streaming pass and never revisits the source; unlike the personalized online MI-BCIs of [37] and [38], which train the decoder on the user's own recordings and refine it by retraining on that user's online trials, it starts from a cross-subject source ensemble and adapts from unlabeled trials in a single pass without any retraining, so it can serve as the decoder-adaptation component of such systems. Unlike the entropy-only, memoryless T-Time, it uses its memory both to stay stable and to follow the changing class balance. Its novelty lies not in any single mechanism, several of which exist in isolation, but in their integration into one lightweight scheme suited to nonstationary EEG. Practically, this targets the outcomes that matter in deployment: it sustains decoding reliability as the signal drifts, reduces the per-subject recalibration burden, and runs on the acquisition hardware in real time, extending the cross-subject transfer line from offline calibration to online operation.

The main contributions of this work are as follows.

  1. We formulate cross-subject MI decoding as source-free, single-pass OTTA under real-time constraints, in which target trials arrive one at a time and the source is never revisited. This setting is distinct from offline source-free DA and from methods that rely on continual retraining.

  2. We propose MOPC, in which a fixed-capacity FIFO memory drives a dynamic EA of the stream and couples three EEG-aware objectives: a time-masked perturbation-consistency loss, a joint entropy-minimization loss, and a confidence-calibrated reweighting loss that suppresses noisy pseudolabels and corrects class imbalance.

  3. We keep the adaptation lightweight: each trial updates only the BN parameters of a single member of an N=5 ensemble, so the number of trainable parameters does not grow with the number of classes.

Offline training

Figure

Fig. 2. Overview of MOPC. Top (offline training): EEG data from K source subjects are prealigned and concatenated to train an N-model ensemble via cross-entropy loss Lce\mathcal{L}_{ce}. Bottom (online testing): For each trial xtmx_t^m in the real-time measurement stream: 1) inference: the trial is prealigned and evaluated by the ensemble to yield the soft-voted prediction y^tm\hat{y}_t^m, while the aligned data is pushed to the FIFO memory bank; and 2) adaptation: a random-mask view is generated to compute Lpcr\mathcal{L}_{pcr} and Ljem\mathcal{L}_{jem}. Simultaneously, a pairwise feature-similarity matrix is constructed from the memory bank to derive the confidence-calibrated loss Lccr\mathcal{L}_{ccr}. The framework minimizes the hybrid loss to update the BN parameters of ensemble members sequentially in a round-robin fashion, ensuring a highly efficient, single-pass adaptation.

The remainder of this article is structured as follows. Section II presents the methodology. Section III provides experimental results. Section IV offers an interpretable analysis of system stability. Section V concludes this article.

References (48)