Time Window Optimization for Motor Imagery Classification via Temporal Structure Embedded Reinforcement Learning
Authors: Huan Luo, Na Lu, Xiaopeng Wang, Ziyang Shang
Organizations: School of Future Technology, Xi’an Jiaotong University, Xi’an, 710049, China · School of Automation Science and Engineering, Xi’an Jiaotong University, Xi’an, 710049, China
Online motor imagery-based brain-computer interfaces (MI-BCIs) typically decode continuous EEG using fixed-length sliding windows that may be misaligned with neural events. Existing window optimization methods often evaluate windows independently, overlooking temporal dependencies and potentially producing fragmented or physiologically implausible selections. We propose Temporal Structure Embedded Reinforcement Learning (TSE-RL), a framework that incorporates prior knowledge of MI event structure into a constrained Markov decision process for adaptive window optimization. First, TSE-RL assigns each window an explicit semantic role through Discard, Onset, Sustain, or Offset actions, extending binary retain/discard decisions to event-level alignment. Second, a finite-state machine masks invalid actions to enforce the temporal order of MI phases and promote physiologically plausible window sequences. Third, a Transformer-based history encoder captures dependencies across windows, improving training stability and computational efficiency compared with recurrent architectures. TSE-RL is plug-and-play and can be integrated with diverse MI classifiers. Experiments on multiple benchmark datasets demonstrate consistent improvements in decoding performance in both cross-session and cross-subject settings. Visualization analyses further suggest that the learned window selection policy aligns with neurophysiological principles.
Figures & tables
Fig. 1: Overview of the proposed TSE-RL framework. (a) MDP formulation with an internal FSM for action masking. At step n , the agent receives the state sn from the environment. The FSM determines the valid action subset Aϕn for the current phase ϕn and constrains the masked policy π~n . The selected action an drives the environment transition and the reward. (b) Network architecture of TSE-RL. The feature extractor encodes each window into a representation, and the discriminator outputs class probabilities for reward computation. A Transformer-based history encoder models temporal dependencies among historical features. The FSM-constrained policy network integrates current features, historical context, and trial progress to produce actions under phase-dependent masking.
Dataset
Number of subjects
Number of channels
Sampling rate (Hz)
Trial length (s)
Number of sessions
Trials in 1st session
Types of imaginations
BNCI2014001
9
22
250
4
2
288
r/l hand, feet, tongue
BNCI2014002
14
15
512
5
1
160
right hand, both feet
BNCI2015001
12
13
512
5
3
400
right hand, both feet
OpenBMI
54
62
1000
4
2
200
right/left hand
TABLE I: Summary of the four MI-EEG datasets
Setting
Method
S0
S1
S2
S3
S4
S5
S6
S7
S8
Avg.
Baseline-full
EEGNet
84.97
53.51
86.15
61.92
54.14
52.54
76.85
80.11
81.16
70.15±2.04
TSLANet
88.38
51.22
84.56
47.40
37.68
58.86
77.61
84.56
82.12
68.04±2.43
EEGConformer
84.51
49.83
89.19
63.41
46.57
55.86
86.50
79.30
81.73
70.77±0.92
FBCNet
82.33
58.38
81.64
68.79
44.14
51.78
84.07
83.38
84.07
70.95±1.58
ATCNet
87.26
54.56
89.21
65.95
57.26
59.07
82.96
83.72
83.65
73.74±1.33
M-ShallowConvNet
86.50
54.84
91.50
70.94
57.47
58.86
89.07
83.51
83.65
75.15±1.21
TABLE II: Within-subject classification accuracy (%) in simulated online experiment on BNCI2014001, with an asterisk () denoting the significance level (: p¡0.05).
Setting
Method
BNCI2014002
BNCI2015001
OpenBMI
Baseline-full
EEGNet
85.59±1.91
82.42±1.96
71.97±1.30
TSLANet
83.33±2.80
85.79±2.64
73.67±1.65
EEGConformer
76.83±1.54
85.29±1.67
73.94±1.31
FBCNet
87.26±1.56
83.91±1.53
74.93±1.09
ATCNet
88.81±1.25
87.96±1.29
75.46±1.35
M-ShallowConvNet
88.73±1.27
86.37±1.14
74.67±1.48
TABLE III: Average within-subject classification accuracy (%) in simulated online experiments on BNCI2014002, BNCI2015001 and OpenBMI . * indicates p<0.05 .
Setting
Method
S0
S1
S2
S3
S4
S5
S6
S7
S8
Avg.
Baseline-full
EEGNet
67.40
31.99
66.01
39.28
30.60
36.50
36.85
69.49
48.31
47.38±2.51
TSLANet
64.97
29.21
62.89
38.24
26.43
33.72
38.93
63.58
55.25
45.91±2.72
EEGConformer
68.79
33.72
67.06
44.14
28.86
34.42
44.14
70.53
51.08
49.19±1.33
FBCNet
63.24
32.33
80.60
40.67
31.99
33.03
53.17
76.08
47.26
50.93±1.65
ATCNet
70.53
32.33
70.53
46.57
28.86
34.07
42.75
75.04
59.76
51.16±1.44
M-ShallowConvNet
71.22
33.72
69.49
39.28
33.03
32.68
39.28
73.31
53.17
49.46±1.47
TABLE IV: Cross-Subject Classification Accuracy (%) in Simulated Online Experiment on BNCI2014001. * indicates p<0.05 .
Fig. 2: Average decision process for Left-hand MI on BNCI2014001. (a) Induced ERD/ERS maps computed following Graimann et al. [ 35 ] with bootstrap significance testing (black contours indicate α<0.05 ). (b) Action distribution over time shown as a stacked profile ordered from bottom to top as Discard, Onset, Sustain, and Offset. (c) Mean classification confidence for the true class at each time window.
Fig. 3: Average decision process for Right-hand MI of subject 0. Layout and analysis pipeline are identical to Fig. 2 .
Setting
Backbone
Time (ms)
FLOPs (M)
Params (M)
Baseline (FE+Disc)
EEGNet
0.57
3.13
0.002
TSLANet
2.73
7.94
0.366
EEGConformer
4.16
14.39
0.278
FBCNet
0.42
0.40
0.002
ATCNet
4.00
12.29
0.036
M-ShallowConvNet
0.49
16.37
0.014
TABLE V: Single-window computational efficiency under Baseline and TSE-RL settings. Time is measured in ms per window (batch size 1). FLOPs and Params are reported per forward pass.
Components
BNCI2014001
BNCI2014002
BNCI2015001
RL
Action mask
History enc.
within-subject
cross-subject
within-subject
within-subject
×
×
×
70.15±2.04
47.38±2.51
85.59±1.91
82.42±1.96
✓
×
×
69.10±2.11
48.07±2.58
86.54±1.81
83.32±1.80
✓
✓
×
70.75±1.82
48.72±2.36
86.86±1.78
83.87±1.71
✓
×
✓
71.41±1.86
49.48±2.17
87.02±1.81
84.25±1.87
✓
✓
✓
72.34±1.91
50.15±2.25
87.62±1.67
84.88±1.71
TABLE VI: Ablation study on the EEGNet backbone across settings and MI datasets. Mean ± s.d. classification accuracy (%).
Fig. 4: Sensitivity analysis of window length L , stride step Δ , and history length k on BNCI2014001 (within-subject), BNCI2014001 (cross-subject), BNCI2014002 (within-subject), and BNCI2015001 (within-subject). The left column displays classification accuracy, while the right column shows the ratio of retained windows.
Motor imagery (MI)-based electroencephalography is widely used in non-invasive brain--computer interfaces (BCIs), but robust decoding remains challenging due to inter-subject variability and cross-session non-stationarity. This work proposes ATCNet-CIAM, an enhanced attention temporal convolutional network that integrates a lightweight channel-integrated attention module (CIAM) into the ATCNet framework to improve channel-spatial feature representation for MI decoding. The proposed model is evaluated on BCI Competition IV-2a, BCI Competition IV-2b, and the multi-day WBCIC-MI dataset under standard, within-session, and cross-session protocols. Experimental results show that ATCNet-CIAM achieves 86.32% accuracy on BCI IV-2a and 87.96% on BCI IV-2b under the standard protocol, while reaching 89.46% and 83.64% in the within-session WBCIC-MI on 2C and 3C, respectively. The proposed framework consistently improves classification stability and robustness under session-varying conditions, and ablation study confirms the complementary contribution of the proposed architectural components.
Le Huu Son Hai, Nguyen Chi Hai, Truong Viet Vu +3
Faculty of Information Technology, Van Lang School of Technology, Van Lang University, Ho Chi Minh City 70000, Vietnam
In clinical motor imagery brain-computer interface (MI-BCI) decoding, cross-day transferability and online operation remain two critical challenges. Hypergraphs can improve transferability by capturing higher-order sample relationships, yet existing hypergraph-based methods for online emotion recognition neglect the cross-day benefits of Riemannian geometry widely adopted in EEG transfer learning. To bridge this gap, we propose the Multi-feature Riemannian Hypergraph (MRieHy), a framework tailored for online test-time adaptation in MI-BCI decoding that leverages Riemannian geometry to strengthen cross-day transferability. MRieHy first computes Riemannian means of covariance matrices from cross-day training data to align multi-day distributions. It then constructs a hypergraph over covariance matrices using Riemannian distance, complemented by a second hypergraph over deep features built with cosine similarity. The two hypergraphs are fused via adaptively learned combination weights, jointly optimized with the label projection matrices. During online testing, MRieHy maintains a first-in-first-out buffer of recent samples, performs Riemannian alignment on the buffered data, and decodes with the learned hypergraph. Extensive experiments on a private four-class ECoG dataset and two public four-class EEG datasets validate that MRieHy achieves notable performance gains over state-of-the-art baselines.
Siqi Li, Zhi Li, Tong Liu +5
Peking University · Chinese Institute for Brain Research, Beijing · NeuCyber Neurotech +2
Brain-computer interfaces (BCIs) enable direct communication between the brain and external devices, providing critical support for individuals with motor impairments. However, accurate motor imagery (MI) decoding from electroencephalography (EEG) remains challenging due to noise and cross-session variability. This study introduces EEG-MFTNet, a novel deep learning model based on the EEGNet architecture, enhanced with multi-scale temporal convolutions and a Transformer encoder stream. These components are designed to capture both short and long-range temporal dependencies in EEG signals. The model is evaluated on the SHU dataset using a subject-dependent cross-session setup, outperforming baseline models, including EEGNet and its recent derivatives. EEG-MFTNet achieves an average classification accuracy of 58.9% while maintaining low computational complexity and inference latency. The results highlight the model's potential for real-time BCI applications and underscore the importance of architectural innovations in improving MI decoding. This work contributes to the development of more robust and adaptive BCI systems, with implications for assistive technologies and neurorehabilitation.
Panagiotis Andrikopoulos, Siamak Mehrkanoon
Department of Information and Computing Sciences, Utrecht University, Utrecht, Netherlands