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.