Time Window Optimization for Motor Imagery Classification via Temporal Structure Embedded Reinforcement Learning

Huan Luo, Na Lu, Xiaopeng Wang, Ziyang ShangarXiv 2026

TL;DR

TSE-RL (Temporal Structure Embedded Reinforcement Learning) adaptively optimizes the time windows used to decode motor imagery from EEG signals. By embedding neurophysiological prior knowledge into a reinforcement learning framework, it semantically aligns sliding windows with actual neural events, leading to more accurate and robust brain-computer interface (BCI) performance.

What Problem Does This Paper Address?

Most online motor imagery (MI) BCIs rely on fixed-length sliding windows to process continuous brain signals. This is problematic because neural events—like imagining a hand movement—don't happen at fixed intervals or for fixed durations. A window might capture only half an event or be filled with noisy baseline activity, leading to poor classification.

While researchers have tried "window optimization" before, existing methods usually treat each window in isolation. This often results in "fragmented" sequences that don't make sense biologically (e.g., detecting the end of a movement before it starts). The challenge is to create a system that can look at the history of the signal and make decisions that are both accurate and physiologically plausible.

Methods

The authors propose the TSE-RL framework, which reformulates window optimization as a constrained Markov Decision Process (MDP).

The network architecture of TSE-RL, highlighting the Transformer-based history encoder and the FSM-constrained policy.

Key innovations include:

  • Semantic Alignment: Instead of a simple "keep or discard" binary choice, the RL agent assigns each window a specific role: Discard, Onset, Sustain, or Offset.
  • FSM-Constrained Action Masking: To prevent the agent from making "impossible" decisions, they use a Finite State Machine (FSM). The agent must progress through phases—Planning, Execution, and Recovery—ensuring the selected windows follow a logical temporal order (e.g., you can't have a "Sustain" window before an "Onset").
  • Transformer-based History Encoder: Unlike traditional RL that uses unstable Recurrent Neural Networks (RNNs) to remember the past, TSE-RL uses a Transformer. This allows the agent to capture long-range dependencies across previous windows in parallel, leading to much more stable training.
  • Plug-and-Play Design: The framework is designed to sit on top of almost any existing MI classifier (like EEGNet or FBCNet), acting as an "intelligent filter" for the data.
The network architecture of TSE-RL, highlighting the Transformer-based history encoder and the FSM-constrained policy.

Datasets

The authors evaluated TSE-RL on four widely used public MI-EEG benchmark datasets, covering both two-class and four-class imagination tasks.

Summary of the four MI-EEG datasets used for evaluation.

Key Insights and Ideas

  • Hard Constraints are Better than Soft Rewards: Simply penalizing the agent for "bad" sequences (soft constraints) isn't enough. By using an FSM to physically mask out invalid actions (hard constraints), the authors significantly reduced the search space and improved learning efficiency.
  • History Matters: The decision to keep a window depends heavily on what happened in the windows immediately preceding it. The Transformer's self-attention mechanism proved superior to RNNs for capturing this context without the risk of vanishing gradients.
  • Neurophysiological Alignment: Visualization of the learned policies showed that the agent naturally learned to pick windows that overlap with known brain patterns, such as Event-Related Desynchronization (ERD) in the mu and beta frequency bands. It wasn't just "guessing"—it was finding the most informative parts of the brain's response.

Key Results

  • Performance Boost: TSE-RL consistently improved the accuracy of eight different baseline classifiers. On the BNCI2014001 dataset, it improved average accuracy by approximately 2–3 percentage points.
  • Cross-Subject Robustness: The method showed significant gains in "cross-subject" settings, where the model is tested on a person it has never seen before—a notoriously difficult task in BCI research.
  • Real-Time Efficiency: Despite the added complexity of the RL agent and Transformer, the per-window inference time remained well below the 100ms stride interval, making it fully compatible with real-time online use.

Limitations and Future Work

The primary limitation acknowledged by the authors is that these experiments were "simulated" online. While they used continuous data streams to mimic real-world conditions, the user was not receiving real-time feedback (closed-loop).

Future work will focus on closed-loop validation, where the optimized windows actually drive a device (like a robotic arm or cursor) in real-time, allowing researchers to see how the user's brain adapts to the system's optimized timing. They also suggest exploring how this framework handles the "neural pattern shifts" caused by user fatigue over long sessions.

Summary updated

BibTeX
@misc{luo2026time,
  author = {Huan Luo and Na Lu and Xiaopeng Wang and Ziyang Shang},
  title = {{Time Window Optimization for Motor Imagery Classification via Temporal Structure Embedded Reinforcement Learning}},
  year = {2026},
  eprint = {2610.16921},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.16921},
}
Figure