July 01, 2026
Cross-subject EEG stress detection remains challenging because discriminative stress-related patterns are both subject-dependent and frequency-specific. Conventional Riemannian methods model spatial covariance mainly in the time domain, overlooking neural oscillations that are critical for high-level cognitive state decoding, while standard temporal tokenization often fragments inter-slice temporal coherence. To address these limitations, we propose I2RiMA, an Intra-Inter Riemannian Manifold Attention Network for EEG-based stress detection. I2RiMA constructs spatial covariance matrices independently at each frequency point and maps them to the SPD tangent space, preserving channel-wise geometry together with frequency-specific discriminative cues. It further introduces frequency cluster aggregation to select informative spectral components and reduce redundancy by forming compact, data-driven frequency clusters aligned with EEG rhythms. Finally, an intra-inter slice attention module adaptively integrates local slice-level spectral dynamics and global temporal context across EEG sequences. Experiments on three datasets show that I2RiMA consistently outperforms five state-of-the-art baselines, achieving up to 82.78% balanced accuracy while remaining efficient with only 1.60M parameters and 31.95M FLOPs.
Mental stress is a widespread public health issue, especially among young people, with over 60% reporting chronic moderate-to-severe stress [1], [2]. As prolonged stress increases the risk of depression, anxiety, and cardiovascular disease [3], objective and scalable stress detection is urgently needed. EEG offers a promising solution due to its millisecond temporal resolution, non-invasive and portable nature, and sensitivity to psychological states [4]. Recent wireless dry-electrode systems further support everyday EEG-based stress monitoring beyond clinical settings [5].
Considerable work has explored EEG-based stress detection using traditional machine learning, deep learning, and Riemannian geometry. However, existing methods face two key limitations. First, conventional Riemannian approaches usually build covariance matrices from time-domain EEG signals [6], which is suitable for low-level tasks with temporally localized responses, such as visual evoked potential decoding [7]. In contrast, high-level states like stress and emotion involve distributed, spectrally structured neural dynamics, making time-domain channel covariance insufficient. Although frequency-domain covariance is a natural alternative, naive construction can mix frequency information and obscure physiologically meaningful band-specific patterns. Moreover, EEG covariance matrices lie on the SPD manifold [8]; direct Euclidean vectorization ignores this geometry and causes information loss, especially under cross-subject distribution shifts [9].
Second, most existing EEG tokenization pipelines segment continuous signals into fixed-length windows and process each window independently. This design discards temporal coherence across adjacent slices, even though such context has been shown to carry discriminative information for mental state classification [10]. Recent transformer-based EEG models [11]–[13] have improved sequence modeling, but they still often treat each EEG slice as an isolated token. As a result, they struggle to jointly capture intra-slice local spectral structure and inter-slice global temporal dependencies, both of which are essential for robust high-level cognitive state recognition.
Motivated by these observations, we propose I2RiMA, an Intra-Inter Riemannian Manifold Attention Network for EEG-based stress detection. I2RiMA is built on two key insights. First, stress- and emotion-related EEG signals exhibit state-dependent, frequency-specific spatial patterns. Since distinct EEG bands reflect different neural dynamics [14], I2RiMA constructs covariance matrices independently at each frequency point and maps them to the SPD tangent space, preserving channel-wise Riemannian geometry without prematurely mixing spectral information. A frequency cluster aggregation module further selects informative frequency-specific Riemannian features and reduces redundancy, yielding compact and interpretable representations. Second, longer temporal windows improve intra-slice separability while reducing inter-slice variability, suggesting complementary local and global temporal cues. To capture this structure, I2RiMA introduces an intra-inter slice attention fusion module that adaptively aggregates EEG slices via linear encoding, attention weighting, and weighted fusion, preserving local discriminative patterns while modeling sequence-level temporal context. Together, the frequency-aware Riemannian representation and intra-inter slice attention fusion enable geometry-preserving, physiologically grounded, and temporally contextualized EEG representations for robust cross-subject stress detection.
Our main contributions are summarized as follows:
We propose I2RiMA, a frequency-aware Riemannian network for cross-subject EEG stress detection. It constructs covariance matrices at each frequency point and maps them to the SPD tangent space, preserving channel-wise geometry and frequency-specific discriminative patterns.
We introduce frequency cluster aggregation for data-driven feature selection and redundancy reduction, together with intra-inter slice attention fusion to capture both local slice-level patterns and global temporal dependencies in continuous EEG.
Experiments show that I2RiMA achieves state-of-the-art B.ACC of 77.59%, 75.88%, and 82.78% on MIST Control, MIST Stress, and SEED, respectively, while using only 1.60M parameters and 31.95M FLOPs.
EEG-Based Stress Detection EEG-based stress detection methods generally follow two paradigms: traditional machine learning and deep learning. Traditional methods rely on handcrafted temporal, spectral, or nonlinear features with classifiers such as SVM and KNN. Representative studies include feature fusion for workload identification [15], frontal alpha asymmetry for real-time stress assessment [5], multi-level stress classification with combined EEG and ECG features [16], and linear/nonlinear EEG features for depression detection [17]. Deep learning methods enable end-to-end representation learning by capturing spatial, spectral, and temporal EEG patterns, including spatio-temporal modeling for cross-subject motor imagery decoding [18], R3DCNN for workload assessment [19], MuLHiTA with multi-branch LSTM and hierarchical attention [20], and phase-space reconstruction with geometric features for depression detection [21]. Despite their progress, many methods remain limited to single-subject or small-scale evaluations and often suffer substantial performance degradation in cross-subject settings due to inter-subject variability [22].
Cross-Subject EEG Learning. Cross-subject generalization is a core challenge in EEG decoding. BIOT [11] employs channel embedding alignment to mitigate individual differences, LaBraM [12] leverages large-scale pre-training for enhanced generalization, and NeuroBOLT [13] synthesizes fMRI signals from raw EEG via multi-dimensional representation learning. Domain adaptation and transfer learning are dominant strategies [23], yet they primarily address cross-subject distribution shifts while neglecting intra-subject temporal domain drift (ISTDS) [24]—the phenomenon where a single subject’s EEG distribution shifts across experimental sessions due to fatigue, electrode impedance changes, and physiological fluctuations [25].
Riemannian Learning for EEG. Covariance matrices of multi-channel EEG signals lie on the SPD manifold \(\mathcal{S}_{++}^{C}\), which possesses non-Euclidean geometric structure. Traditional vectorization in Euclidean space destroys this structure, leading to information loss [8]. The affine-invariant Riemannian metric (AIRM) provides robustness to individual differences [26], while the Log-Euclidean metric offers computational efficiency with geometric consistency [27]. Riemannian methods have demonstrated significant performance improvements in BCI and EEG classification, particularly in cross-subject scenarios [9]. However, existing Riemannian approaches typically construct a single covariance matrix from time-domain signals, mixing frequency information and obscuring frequency-specific spatial patterns [27].
Temporal Aggregation and Attention Modeling. Transformer-based methods [11]–[13] model EEG sequences at the token level, but often process each slice independently, overlooking both intra-slice spectral dynamics and inter-slice temporal coherence. Although hierarchical and manifold attention mechanisms [20], [28] have been explored for temporal aggregation, they typically assume stable feature distributions across subjects and sessions. In contrast, I2RiMA jointly integrates frequency-aware Riemannian manifold learning with intra-inter slice attention fusion for cross-subject EEG stress detection, addressing this gap [22].
Let \(\mathcal{D} = \{(\mathbf{X}_u, y_u)\}_{u=1}^{U}\) denote an EEG dataset where \(\mathbf{X}_u \in \mathbb{R}^{C \times L}\) is the \(u\)-th trial with \(C\) channels and \(L\) samples, and \(y_u \in \{1, \ldots, G\}\) is the class label. Each trial is segmented into \(m\) non-overlapping slices \(\mathcal{S} = \{s_1, \ldots, s_m\}\) with \(s_i \in \mathbb{R}^{C \times T}\). The FFT transforms each slice into the frequency domain: \(\mathbf{X}_{\text{freq}} \in \mathbb{R}^{B \times m \times C \times F}\), with \(B\) batch size and \(F\) frequency points.
We define the cross-subject stress detection task as learning a classifier \(f_\theta\) that generalizes to unseen subjects. Formally, given training subjects \(\mathcal{P}_{\text{train}}\) and test subjects \(\mathcal{P}_{\text{test}}\) with \(\mathcal{P}_{\text{train}} \cap \mathcal{P}_{\text{test}} = \emptyset\), the objective is to minimize the expected cross-entropy loss \(\ell\) over the test distribution, as defined in Eq. 1 : \[\theta^* = \arg\min_\theta \; \mathbb{E}_{(\mathbf{X}, y) \sim \mathcal{D}_{\text{test}}} \left[ \ell\left(f_\theta(\mathbf{X}), y\right) \right] \label{eq:task95obj}\tag{1}\]
We seek a representation mapping \(\phi: \mathbb{R}^{C \times L} \to \mathbb{R}^d\) that satisfies three properties: (1) geometry preservation—\(\phi\) retains the spatial structure of EEG signals via Riemannian manifold modeling; (2) temporal coherence—\(\phi\) encodes both intra-slice local spectral patterns and inter-slice global dependencies through attention fusion; (3) cross-subject robustness—\(\phi\) is invariant to inter-subject distribution shifts.
I2RiMA addresses cross-subject EEG stress detection through the two-module architecture illustrated in Figure 1. Given raw multi-channel EEG signals of dimension \(\mathbb{R}^{C \times L}\) (\(C = 64\) channels), each trial is first segmented into \(m\) non-overlapping slices and transformed into the frequency domain via FFT, yielding \(\mathbf{X}_{\text{freq}} \in \mathbb{R}^{m \times C \times F}\) where \(F\) is the number of frequency bins. Standard preprocessing steps including resampling, ICA artifact removal, bandpass filtering (0.5–50 Hz), and z-score normalization are applied prior to segmentation.
The Riemannian Manifold Feature Extraction (RMFE) module constructs a covariance matrix \(\mathbf{R}_{f} \in \mathcal{S}_{++}^{C}\) independently at each frequency point \(f\), preserving frequency-specific spatial correlations that are critical for stress discrimination. Each SPD matrix is then mapped to the tangent space via the Log-Euclidean operator and vectorized as \(\mathbf{h}_{f} \in \mathbb{R}^{D_0}\), yielding spectral-spatial features \(\mathbf{H}_{\text{freq}} \in \mathbb{R}^{m \times F \times D_0}\) with \(D_0 = C(C+1)/2\).
The Unsupervised Slice Attention Aggregation (USAA) module then processes these features in two stages. First, K-Means clustering groups correlated frequencies into \(K\) clusters corresponding to canonical EEG bands; within-cluster weighted aggregation followed by across-cluster concatenation produces compact slice features \(\mathbf{H} \in \mathbb{R}^{m \times D}\) with \(D = K \times D_0\). Second, an intra-inter slice attention fusion mechanism adaptively weights the \(m\) temporal slices: each slice feature is projected through a linear encoding layer to \(\mathbf{H}_{\text{enc}} \in \mathbb{R}^{m \times d_{\text{enc}}}\), followed by channel-wise mean pooling and a fully connected softmax layer to compute slice-specific attention weights \(\boldsymbol{\alpha}\). The weighted aggregation \(\mathbf{H}_{\text{agg}} = \sum_{j} \alpha_j \mathbf{H}_{\text{enc}}(:, j, :)\) produces a fixed-dimensional trial-level representation, which is fed to a fully connected classifier for stress level prediction. All parameters are jointly optimized end-to-end via backpropagation.
Traditional Riemannian EEG methods construct a single covariance matrix from time-domain signals, mixing frequency information across bands. For stress detection—a task where frequency-domain features have been shown to carry critical discriminative information [4]—this obscures frequency-specific spatial patterns.
After FFT, the input tensor has dimension \(\mathbf{X}_{\text{freq}} \in \mathbb{R}^{B \times m \times C \times F}\). For each frequency point \(f \in \{1, \ldots, F\}\), we extract the spectral amplitude vector across all channels, as defined in Eq. 2 . We then independently construct a covariance matrix from \(\mathbf{x}_{b,j,:,f}\), adding \(\varepsilon = 10^{-6}\) times the identity matrix \(\mathbf{I}\) to ensure positive definiteness, as defined in Eq. 3 . This preserves frequency-specific spatial correlations that single time-domain covariance matrices would conflate. \[\mathbf{x}_{b,j,:,f} = \mathbf{X}_{\text{freq}}(b, j, :, f) \in \mathbb{R}^C \label{eq:freq95index}\tag{2}\] \[\mathbf{R}_{b,j,f} = \mathbf{x}_{b,j,:,f} \, \mathbf{x}_{b,j,:,f}^\top + \varepsilon \mathbf{I} \label{eq:freq95cov}\tag{3}\]
Each covariance matrix \(\mathbf{R}_{b,j,f} \in \mathcal{S}_{++}^{C}\) resides on the SPD manifold, which lacks vector space structure. We employ the Log-Euclidean mapping to project onto the tangent space and extract the tangent-space feature vector, as defined in Eq. 4 : \[\mathbf{h}_{b,j,f} = \operatorname{vech}\!\left(\log(\mathbf{R}_{b,j,f})\right) \in \mathbb{R}^{D_0} \label{eq:vech}\tag{4}\] where \(\log(\mathbf{R}_{b,j,f}) = \mathbf{U} \log(\boldsymbol{\Lambda}) \mathbf{U}^\top\) is computed via eigendecomposition \(\mathbf{R}_{b,j,f} = \mathbf{U} \boldsymbol{\Lambda} \mathbf{U}^\top\) with \(\mathbf{U} \in \mathbb{R}^{C \times C}\) and diagonal \(\boldsymbol{\Lambda} \in \mathbb{R}^{C \times C}\), \(\operatorname{vech}(\cdot)\) extracts the upper triangular portion, and \(D_0 = C(C+1)/2 = 2080\) for \(C = 64\). Collecting all frequency features yields \(\mathbf{H}_{\text{freq}} \in \mathbb{R}^{B \times m \times F \times D_0}\), which serves as input to the frequency cluster aggregation module (Section 4.3).
The covariance matrix encodes spatial information: diagonal elements reflect channel power, off-diagonal elements capture inter-channel functional connectivity [14]. The Log-Euclidean mapping preserves the geometric structure of the SPD manifold, whereas traditional vectorization in Euclidean space destroys this structure, leading to information loss that is amplified under cross-subject conditions.
A key insight from neuroscience is that low-frequency bands (delta, theta) reflect global brain-state modulation across widespread cortical regions, while high-frequency bands (beta, gamma) capture local, task-specific processing [14]. Under stress, high-frequency components exhibit greater sensitivity to state transitions [29]. This spatial-frequency duality—global structure in low frequencies, local structure in high frequencies—motivates our frequency-aware approach: by constructing covariance matrices independently per frequency point rather than collapsing across frequencies, we preserve both global and local spatial-frequency relationships that are critical for cross-subject stress detection.
The Log-Euclidean mapping preserves the structure of the affine-invariant Riemannian metric on \(\mathcal{S}_{++}^{C}\), which is invariant to affine transformations \(\mathbf{R}_{b,j,f} \mapsto \mathbf{W}\mathbf{R}_{b,j,f}\mathbf{W}^\top\) for any invertible \(\mathbf{W}\) [26]. Consequently, our tangent-space features \(\mathbf{h}_{b,j,f}\) (Eq. 4 ) are inherently robust to inter-subject variations such as electrode displacement and impedance changes, and the subsequent cluster aggregation and attention fusion operate in a geometry-aware feature space where cross-subject variability is naturally mitigated.
Constructing \(F\) covariance matrices yields high-dimensional features (\(F \times D_0\)), increasing computational cost. Moreover, individual frequency points carry limited independent physiological significance, as established EEG bands span multiple adjacent frequencies [4]. We propose frequency cluster aggregation not as mere dimensionality reduction, but as a principled feature selection and redundancy elimination mechanism that groups correlated frequency points into physiologically interpretable clusters.
We apply the elbow method to determine the optimal number of clusters \(K\) by analyzing the inertia curve across cluster counts. For MIST Control, \(K = 5\); for MIST Stress, \(K = 6\). In this section, \(k \in \{1, \ldots, K\}\) denotes the cluster index and \(K\) the total number of clusters. We construct a frequency cluster assignment matrix \(\mathbf{A} \in \mathbb{R}^{K \times F}\), where \(A_{k,f}\) indicates the membership weight of frequency \(f\) to cluster \(k\). The aggregation proceeds in three steps: (1) for each cluster \(k\), the cluster feature is computed as the weighted sum of its member frequency features; (2) the \(K\) cluster features are concatenated along the feature dimension to form the slice representation \(\mathbf{H}_{b,j}\); (3) all \(m\) slice representations are collected into the batch-level tensor \(\mathbf{H}\), where \(j \in \{1, \ldots, m\}\) indexes the temporal slices. The resulting \(\mathbf{H}\) serves as input to the intra-inter slice fusion module (Section 4.4). The complete aggregation process is formalized as follows: \[\begin{align} \mathbf{h}_{b,j,k} &= \sum_{f=1}^{F} A_{k,f} \cdot \mathbf{h}_{b,j,f} \tag{5} \\ \mathbf{H}_{b,j} &= [\mathbf{h}_{b,j,1}, \ldots, \mathbf{h}_{b,j,K}] \in \mathbb{R}^{D}, \quad D = K \times D_0 \tag{6} \\ \mathbf{H} &= [\mathbf{H}_{b,1}; \ldots; \mathbf{H}_{b,m}] \in \mathbb{R}^{B \times m \times D} \tag{7} \end{align}\]
The data-driven clustering aligns with canonical EEG bands [30]: Cluster 1 (\(1\)–\(3\) Hz) corresponds to delta, Cluster 2 (\(4\)–\(12\) Hz) spans theta and alpha, Cluster 3 (\(13\)–\(25\) Hz) maps to beta, Cluster 4 (\(26\)–\(49\) Hz) corresponds to gamma, and Cluster 5 (\(50\) Hz) captures line noise. This alignment validates that EEG frequency structure exhibits intrinsic cluster patterns, and our aggregation leverages this structure for stable, efficient representation. The geometric interpretation showing that frequency cluster aggregation performs principled data-driven grouping in Riemannian geometry is provided in Appendix 13.
After Riemannian feature extraction, each trial is represented as \(m\) slice features \(\mathbf{H} \in \mathbb{R}^{B \times m \times D}\) (Eq. 7 ). Existing methods aggregate slices via simple averaging or max pooling, assuming equal contribution from all slices. However, in stress detection, slices differ significantly in discriminative information—some capture critical state transitions while others contain mostly noise. Equal-weight aggregation dilutes informative signals and accumulates noise.
The slice number \(m\) is a key hyperparameter that controls the granularity of temporal modeling. Increasing \(m\) provides finer temporal resolution but incurs additional computation. Inspired by microeconomics—where the optimal consumption level is reached when marginal utility approaches zero—we define the marginal effect \(\text{ME}(m)\) as the accuracy gain per unit of additional computation, where \(\text{Acc}(m)\) denotes the accuracy with \(m\) slices and \(\text{FLOPs}(m)\) the corresponding computational cost, as defined in Eq. 8 : \[\text{ME}(m) = \frac{\text{Acc}(m) - \text{Acc}(m-1)}{\text{FLOPs}(m) - \text{FLOPs}(m-1)} \label{eq:marginal}\tag{8}\] When \(\text{ME}(m) > 0\), adding the \(m\)-th slice still improves accuracy; when \(\text{ME}(m) \leq 0\), further slices yield no benefit. The optimal slice number \(m^*\) is the largest \(m\) with positive marginal effect, subject to a minimum accuracy threshold \(\text{Acc}_{\min}\) and a computational budget \(\text{FLOPs}_{\text{limit}}\), as defined in Eq. 9 : \[m^* = \max\{m : \text{ME}(m) > 0\} \quad \text{s.t.} \quad \text{Acc}(m) \geq \text{Acc}_{\min}, \; \text{FLOPs}(m) \leq \text{FLOPs}_{\text{limit}} \label{eq:m95optimal}\tag{9}\]
When \(m^* = 1\), the network processes a single slice, and the Riemannian feature extraction module alone provides intra-slice local spectral-spatial modeling. This corresponds to the R-I2RiMA variant in our ablation study.
For \(m^* > 1\), we propose an attention mechanism [31] that adaptively weights \(m^*\) temporal slices to highlight discriminative information. Let \(d_{\text{enc}} = 128\) denote the encoding dimension. The attention fusion proceeds in four steps: (1) linear encoding with weight \(\mathbf{W} \in \mathbb{R}^{D \times d_{\text{enc}}}\) and bias \(\mathbf{b} \in \mathbb{R}^{d_{\text{enc}}}\) projects slice features \(\mathbf{H} \in \mathbb{R}^{B \times m^* \times D}\) to a lower-dimensional space; (2) channel-wise mean pooling compresses each encoded slice to a scalar; (3) a fully connected layer with softmax computes attention weights \(\boldsymbol{\alpha} = [\alpha_1, \ldots, \alpha_{m^*}]^\top\) with \(\sum_{j=1}^{m^*} \alpha_j = 1\); (4) weighted aggregation produces the trial-level representation. Shared weights across the batch enhance generalization. The complete process is formalized as follows: \[\begin{align} \mathbf{H}_{\text{enc}} &= \text{ReLU}(\mathbf{H} \mathbf{W} + \mathbf{b}) \in \mathbb{R}^{B \times m^* \times d_{\text{enc}}} \tag{10} \\ \mathbf{h}_{\text{pool}}(:, j) &= \frac{1}{d_{\text{enc}}} \sum_{d=1}^{d_{\text{enc}}} \mathbf{H}_{\text{enc}}(:, j, d) \tag{11} \\ \boldsymbol{\alpha} &= \text{Softmax}(\text{FC}(\mathbf{h}_{\text{pool}})) \in \mathbb{R}^{B \times m^*} \tag{12} \\ \mathbf{H}_{\text{agg}} &= \sum_{j=1}^{m^*} \alpha_j \cdot \mathbf{H}_{\text{enc}}(:, j, :) \in \mathbb{R}^{B \times d_{\text{enc}}} \tag{13} \end{align}\]
The classifier maps the aggregated features \(\mathbf{H}_{\text{agg}} \in \mathbb{R}^{B \times d_{\text{enc}}}\) to stress level probabilities via a fully connected layer with weight \(\mathbf{W}_c \in \mathbb{R}^{d_{\text{enc}} \times G}\) and bias \(\mathbf{b}_c \in \mathbb{R}^G\), where \(G\) is the number of stress classes. The model is trained by minimizing the cross-entropy loss over all \(U\) trials, where \(\mathbf{P}_u \in \mathbb{R}^G\) denotes the predicted probability vector for the \(u\)-th trial and \(y_u \in \mathbb{R}^G\) is the one-hot label. Optimization uses Adam (learning rate \(10^{-3}\), weight decay \(10^{-2}\)) for 300 epochs with batch normalization and dropout. The classification and loss are formalized as follows: \[\begin{align} \mathbf{P} &= \text{Softmax}(\mathbf{W}_c \mathbf{H}_{\text{agg}} + \mathbf{b}_c) \in \mathbb{R}^{B \times G} \tag{14} \\ \mathcal{L} &= -\sum_{u=1}^{U} y_u \log(\mathbf{P}_u) \tag{15} \end{align}\]
Datasets. We evaluate on three datasets: MIST Control (30 subjects, 64 channels, 4-class stress levels), MIST Stress (same subjects under time-pressure and negative feedback, 4-class), and SEED (15 subjects, 62 channels, 3-class emotion). We adopt stratified 5-fold cross-validation at the subject level with zero subject overlap. Full dataset details and evaluation metrics are provided in Appendices 9 and 10. Baselines and Metrics. We compare against five baselines: EEGNet [32], BIOT [11], LaBraM [12], NeuroBOLT [13], and CorrAtt [33]. All models are trained from scratch under identical data splits. We adopt B.ACC, Precision, Recall, F1, and AUC as evaluation metrics. Baseline descriptions, metric definitions, and implementation details are provided in Appendices 11–12.
To demonstrate the effectiveness of I2RiMA, we compare it against five state-of-the-art (SOTA) baselines networks covering diverse architectures: EEGNet [32] (compact CNN), BIOT [11] (brain imaging transformer), LaBraM [12] (large brain model), NeuroBOLT [13] (bolt encoder), and CorrAtt [33] (correlation attention). All models are trained from scratch using identical data splits and training configurations.
Table ¿tbl:tab:main? summarizes the classification performance across three datasets. I2RiMA consistently achieves the best results across all metrics. On MIST Control, I2RiMA attains 77.59% B.ACC with 95.61% AUC, substantially outperforming the strongest baseline EEGNet (53.26% B.ACC) by 24.33 percentage points and delivering 83.61% precision and 75.79% F1 score. On MIST Stress, which involves more subtle cognitive distinctions under induced pressure, I2RiMA reaches 75.88% B.ACC and 94.57% AUC, surpassing CorrAtt (46.67% B.ACC) by 29.21%—the largest margin among all datasets. On SEED, I2RiMA achieves 82.78% B.ACC and 94.45% AUC, exceeding EEGNet by 24.77% while maintaining 83.74% precision and 82.76% F1. The consistent improvements are particularly pronounced on MIST datasets, which employ cognitively complex paradigms with stronger low-frequency components [10]. In such scenarios, signal slicing aggravates information loss, making the preservation of spatial structure and temporal coherence critical—precisely what I2RiMA provides through frequency-aware Riemannian modeling and intra-inter slice fusion.
To assess each component of I2RiMA, we design four ablation variants: baseline without Riemannian modeling or inter-slice fusion, R-I2RiMA using only the Riemannian module (\(m{=}1\)), I-I2RiMA using only inter-slice fusion, and the full I2RiMA. Results are reported in Table [tbl:tab:ablation]. The Riemannian module consistently improves over baseline, increasing B.ACC by 8.23%, 9.95%, and 5.85% on MIST Control, MIST Stress, and SEED, respectively. This shows that preserving the intrinsic covariance geometry of EEG channels enhances cross-subject generalization. Inter-slice fusion yields even larger gains, especially on MIST Control with a 37.09% B.ACC improvement, highlighting the importance of modeling temporal coherence under fragmented slice-wise EEG information. The two modules are also complementary. The full I2RiMA outperforms the stronger single-module variant, I-I2RiMA, by 4.26%, 33.59%, and 23.94% B.ACC on the three datasets. This suggests that Riemannian features provide geometrically meaningful spatial representations that enable attention-based fusion to better exploit cross-slice dependencies. Overall, the full model achieves 77.59%/75.88%/82.78% B.ACC and 95.61%/94.57%/94.45% AUC, confirming the benefit of joint spatial-temporal modeling.
Table ¿tbl:tab:efficiency? compares computational efficiency. I2RiMA requires only 1.60M parameters and 31.95M FLOPs (\(m{=}20\)), which is 11.9% of EEGNet’s FLOPs, 0.4% of BIOT’s, and 0.3% of LaBraM’s and NeuroBOLT’s. Even with \(m{=}1\), I2RiMA achieves 1.60M FLOPs while maintaining competitive accuracy. This demonstrates that geometry-preserving, attention-based feature integration is far more parameter-efficient than scaling up model capacity.
\begin{table}[t]
-4ex \end{table}
To further visualize the performance–efficiency trade-off, Figure [tbl:fig:fig6] presents a bubble chart where the x-axis (log scale) denotes FLOPs, the y-axis represents test accuracy on MIST Control, and bubble size encodes parameter count. I2RiMA (magenta bubbles) occupies the upper-left region—the Pareto-optimal zone of low computational cost and high accuracy. Specifically, I2RiMA with \(m{=}20\) achieves 77.59% accuracy at merely 31.95M FLOPs and 1.60M parameters, which amounts to only 11.9% of EEGNet’s FLOPs (268.10M) and less than 0.4% of large-scale baselines such as BIOT (8140.23M), LaBraM (11095.78M), and NeuroBOLT (10504.58M). Even as \(m\) increases from 1 to 30, I2RiMA variants remain tightly clustered in the low-FLOPs regime (\(<\)50M) while monotonically improving accuracy—a scalability property that baseline models, which reside in the high-FLOPs / lower-accuracy quadrant, cannot match. This geometry-preserving design thus delivers order-of-magnitude efficiency gains over brute-force capacity scaling, making I2RiMA particularly attractive for resource-constrained deployment scenarios such as wearable brain-computer interfaces.
To interpret which EEG channels I2RiMA relies on for classification, we visualize the learned channel attention weights as scalp topographic maps in Figure 2. The revealed attention patterns align closely with the cognitive demands of each paradigm.
On MIST Control (Figure 2a), I2RiMA assigns the highest importance to bilateral frontotemporal channels (FT11, FT12; green boxes) and occipitocerebellar channels (CB1, CB2; purple boxes). The frontotemporal emphasis reflects their established role in cognitive control and executive function during sustained mental arithmetic [34], while the occipital/cerebellar activation is consistent with visual attention maintenance and sensorimotor coordination required by the MIST task.
The MIST Stress condition (Figure 2b) exhibits a distinct reconfiguration: while frontotemporal channels (FT11, FT12; green boxes) remain highly weighted—now subserving stress regulation in addition to cognitive control—the occipital focus shifts centrally to Oz (purple box), and overall occipital sensitivity intensifies. This pattern is consistent with enhanced visual processing of evaluative feedback (e.g., error messages and time-pressure warnings) that characterizes the stress induction mechanism [35], suggesting that I2RiMA adaptively recruits visual cortical resources when emotional salience increases. In contrast, SEED (Figure 2c) engages a qualitatively different network: temporal channels (T7, T8; green boxes) and prefrontal channels (Fp1, Fp2; purple boxes) dominate the attention map. This topology aligns with canonical emotion processing circuits [34], where the temporal lobes support emotional memory and semantic appraisal, and the prefrontal cortex regulates affective responses—a pattern markedly different from the cognitively-driven MIST topographies.
Figure 2: Channel Importance Topographic Maps of I2RiMA in MIST Control, MIST Stress and SEED Datasets. a — MIST Control Datasets, b — MIST Stress Datasets, c — SEED Datasets
The affine-invariant Riemannian metric on the SPD manifold possesses inherent invariance to affine transformations [26], providing robustness to inter-subject variations such as electrode displacement. Our ablation confirms that even the Riemannian-only variant (R-I2RiMA) improves over baseline by 8–10 percentage points, demonstrating that spatial structure preservation is critical for cross-subject transfer. The frequency-wise construction preserves spatial-frequency duality: under stress, high-frequency components (beta, gamma) exhibit greater sensitivity to state transitions [29], enabling capture of stress-specific local cortical patterns.
Stress formation follows a dynamic allostatic process [36] where different temporal windows contribute unequally. Intra-slice modeling captures local spectral patterns, while inter-slice modeling captures global temporal coherence [37]. The ablation shows that I-I2RiMA yields 37.09% improvement on MIST Control, and the full model further improves by 4.26%, confirming complementarity. Moderate increases in slice count stabilize low-frequency feature estimation and capture cross-cycle temporal coherence [38].
(1) Our evaluation covers stress detection and emotion classification; generalization to other EEG decoding tasks (motor imagery, seizure detection) requires further validation. (2) Dataset sizes remain limited (30 and 15 subjects); larger-scale studies are needed.
We propose I2RiMA, an Intra-Inter Riemannian Manifold Attention Network for cross-subject EEG stress detection. EEG signal segmentation into temporal slices inevitably causes information loss and insufficient feature extraction. I2RiMA addresses this challenge via two complementary mechanisms: spatial structure preservation via frequency-aware Riemannian modeling with cluster-based feature selection, and temporal coherence recovery via intra-inter slice attention fusion. On three datasets, I2RiMA achieves SOTA performance (B.ACC: 77.59%/75.88%/82.78%) with only 1.60M parameters and 31.95M FLOPs, demonstrating that geometry-preserving, attention-based feature integration is both effective and efficient. I2RiMA provides a detection foundation for closed-loop stress regulation systems, with future work targeting online deployment and multi-modal fusion.
This work was supported in part by the Beijing Natural Science Foundation under Grant 4242033 and partially funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – SFB 1574 – 471687386.
This appendix provides supplementary material organized as follows: Section 9 describes the datasets and cross-subject protocol; Section 10 defines evaluation metrics; Section 11 details the baseline methods; Section 12 provides implementation details; Section 13 presents the geometric interpretation of frequency cluster aggregation; Sections 14–5.2 contain additional spectral and sensitivity analyses; and Section 17 discusses broader societal impacts.
MIST Dataset. This dataset contains EEG recordings from 30 healthy subjects performing mental arithmetic tasks under two conditions. EEG signals were recorded using 64 channels at 1000 Hz (downsampled to 200 Hz). Each session consists of a 20-minute mental arithmetic task subdivided into four difficulty levels. The two sessions differ in experimental manipulation: MIST Control imposes no time constraints or evaluative feedback, while MIST Stress introduces strict time limits and negative social-evaluative feedback. The two sessions are separated by \(\geq 7\) days to minimize learning effects. We treat them as independent datasets due to the systematic differences in cognitive load and emotional stress. Both use 4-class stress labeling based on difficulty levels.
SEED Dataset. This dataset comprises EEG recordings from 15 subjects (8 females, 7 males; mean age \(23.27 \pm 2.37\) years) during an emotion-eliciting video-watching task. EEG signals were recorded from 62 electrodes at 1000 Hz and downsampled to 200 Hz. Each subject watched 15 film clips (5 positive, 5 neutral, 5 negative), with 3-class emotion labels.
Cross-subject protocol. We adopt stratified 5-fold cross-validation (CV) at the subject level: subjects are partitioned into 5 disjoint folds preserving label proportions. In each fold, 4 folds serve as training subjects and 1 fold as test subjects, with zero subject overlap. Data is split 8:2 into training and test sets; the training set undergoes 5-fold CV for model selection, followed by retraining on the full training set.
We adopt five metrics: Balanced Accuracy (B.ACC) averages per-class recall to handle class imbalance, defined as \(\text{B.ACC} = \frac{1}{G}\sum_{g=1}^{G} \text{Rec}_g\); Precision (Pre) measures the fraction of correct positive predictions; Recall (Rec) measures the fraction of actual positives correctly identified; F1-Score (F1) is the harmonic mean of precision and recall; and AUC computes the area under the receiver operating characteristic curve. All metrics are reported as percentages.
We compare against five representative methods: EEGNet [32] is a compact CNN with depthwise and separable convolutions (0.05M params); BIOT [11] is a biosignal transformer with channel embedding alignment for cross-subject generalization (3.20M params); LaBraM [12] is a large-scale pretrained brain model with masked EEG modeling (6.23M params); NeuroBOLT [13] synthesizes fMRI signals from raw EEG via multi-dimensional representation learning (10.45M params); and CorrAtt [33] employs correlation-matrix self-attention for EEG classification (0.22M params). All models are trained from scratch under identical data splits and training configurations.
Preprocessing. Resampling to 200 Hz, ICA artifact removal, 8th-order Butterworth bandpass filter (0.5–50 Hz), z-score normalization, 8-second non-overlapping segmentation, and covariance computation. The slice number \(m\) is set to 29 for MIST Control, 28 for MIST Stress, and 26 for SEED, determined via marginal effect optimization (Eq. 9 ).
Training. The model is optimized with Adam (learning rate \(10^{-3}\), weight decay \(10^{-2}\)) for 300 epochs with batch normalization and dropout.
Hardware and Software. AMD Ryzen 9 3950X CPU, NVIDIA RTX 6000 GPU, 64 GB RAM. Software: Ubuntu 20.04, Python 3.8, PyTorch 1.12, MNE-Python 0.24.
Since the tangent-space features \(\mathbf{h}_{b,j,f}\) are obtained via the Log-Euclidean map from the SPD manifold, the Euclidean distance between any two tangent-space vectors \(\mathbf{h}_{b,j,f_1}, \mathbf{h}_{b,j,f_2}\) equals the Log-Euclidean distance between their corresponding SPD matrices on the manifold, i.e., \(\|\mathbf{h}_{b,j,f_1} - \mathbf{h}_{b,j,f_2}\|_2 = d_{\text{LE}}(\mathbf{R}_{b,j,f_1}, \mathbf{R}_{b,j,f_2})\). Consequently, minimizing the K-Means objective in tangent space is equivalent to grouping frequency points according to their Riemannian distance on \(\mathcal{S}_{++}^{C}\). Moreover, the cluster feature \(\mathbf{h}_{b,j,k}\) (Eq. 5 ) is exactly the tangent-space representation of the Log-Euclidean Fréchet mean of cluster \(k\) on \(\mathcal{S}_{++}^{C}\). Define the Fréchet mean as \(\bar{\mathbf{R}}_k = \exp(\sum_{f} A_{k,f} \cdot \log(\mathbf{R}_{b,j,f})) \in \mathcal{S}_{++}^{C}\); then its tangent-space feature satisfies: \[\operatorname{vech}\!\left(\log(\bar{\mathbf{R}}_k)\right) = \sum_{f=1}^{F} A_{k,f} \cdot \mathbf{h}_{b,j,f} = \mathbf{h}_{b,j,k} \label{eq:frechet95exact}\tag{16}\] where the first equality follows from \(\log(\exp(\cdot)) = \cdot\) and the linearity of \(\operatorname{vech}(\cdot)\), and the second from Eq. 5 . This establishes that frequency cluster aggregation performs principled data-driven grouping in Riemannian geometry rather than arbitrary dimensionality reduction, with each cluster feature precisely corresponding to the tangent-space representation of the Log-Euclidean Fréchet mean on \(\mathcal{S}_{++}^{C}\).
This section investigates the impact of temporal window length on the stability of frequency-domain representations and the discriminative power of EEG features. Analysis is conducted across all datasets, each of which is sampled at 200 Hz. Window lengths vary from 100 to 3200 samples (0.5 s to 16 s), spanning durations from brief segments that capture fast transient dynamics to windows that encompass two full 8 s for MIST Stress arithmetic cycles—ensuring both robust estimation of low-frequency activity and assessment of inter-cycle coherence.
Spectral analysis in Figure 3 (x-axis: frequency in Hz; y-axis: power in dB) reveals that EEG signals are dominated by low-frequency components. The green box highlights regions with strong low-frequency power, which are more susceptible to being distorted by short slices. Welch’s method and STFT are employed to effectively capture frequency information under different temporal conditions. The former provides stable spectral estimates by averaging periodograms, while STFT retains temporal dynamics in non-stationary signals through a time-frequency representation. These methods complement each other, ensuring robust feature extraction across varying slice lengths. Short slice windows fail to retain low-frequency energy (e.g., unstable spectral peaks), whereas I2RiMA’s intra-/interslice modeling preserves both local dynamics and global coherence across varying temporal granularities. This enables superior performance over BIOT on MIST/SEED datasets, addressing slicing-induced temporal inconsistencies.
Figure 4 visualizes the class-wise discriminability of EEG channels under different window lengths using Welch power spectral features. For each window size, we compute the average Euclidean distance between classes for each channel. Warmer colors (red) indicate higher discriminability, while cooler colors (blue) denote lower relevance. Green boxes highlight FC2 and C2 in the MIST Control paradigm, where extending the window from 100 to 3200 samples markedly increases inter-class distance in frontal electrodes linked to mental arithmetic load.
Purple boxes mark O1 and O2 in the MIST Stress paradigm, suggseting similar gains in occipital channels that likely reflect enhanced visual processing of error/time-limit feedback under stress. Orange boxes surround C5, C6, FT7 and FT8 in the SEED dataset, where longer windows length boosts separability in temporal electrodes associated with emotion processing.
Across all datasets, larger window lengths yield richer low-frequency estimates and amplify region-specific discriminative patterns. This demonstrates that appropriately extending slice duration is critical for early detection of mental stress and affective states, as it stabilizes low-frequency features and captures cross-cycle coherence in channels.
To further quantify the effect of window length on temporal stability and spectral dynamics (as visualized in Figure 5), we introduce two metrics: Intraslice Information and Interslice Information.
Intraslice Information measures the Euclidean distance between average spectral representations of different classes within the same temporal slice, reflecting inter-class separability and intra-class consistency; higher values indicate more distinguishable class-specific patterns.
Interslice Information captures local temporal dynamics by computing the mean spectral distance between adjacent slices of the same class; smaller values suggest more stable temporal evolution, while larger values indicate higher dynamism. Formally, let \(\bar{\mathbf{h}}_{c,j} = \frac{1}{N_c} \sum_{i \in \mathcal{S}_c} \mathbf{h}_{i,j}\) denote the mean spectral representation of class \(c\) in slice \(j\), where \(N_c\) is the number of samples of class \(c\), \(C\) is the number of classes and \(m\) is the number of slices. The two metrics are defined as: \[\begin{align} I_{\text{intra}}(j) &= \frac{1}{C(C-1)} \sum_{c_1=1}^{C} \sum_{c_2 > c_1}^{C} \|\bar{\mathbf{h}}_{c_1,j} - \bar{\mathbf{h}}_{c_2,j}\|_2 \tag{17} \\ I_{\text{inter}}(c) &= \frac{1}{m-1} \sum_{j=1}^{m-1} \|\bar{\mathbf{h}}_{c,j} - \bar{\mathbf{h}}_{c,j+1}\|_2 \tag{18} \end{align}\]
As window size increases, Intraslice Information increases and Interslice Information decreases across all datasets, indicating that longer windows enhance class separability.
The slice number \(m\) is a key hyperparameter controlling the granularity of temporal modeling. We sweep \(m \in \{1, \ldots, 32\}\) and quantify the computational efficiency of each setting via the marginal effect criterion defined in Eq. 8 , which measures accuracy gain per unit of additional FLOPs. Figure 6 plots the marginal effect curves for all three datasets, where the shaded regions denote variance across cross-validation folds. All three curves exhibit a consistent pattern: marginal effect rises initially as additional slices provide richer temporal information, peaks at an intermediate range, then declines—and eventually turns negative—as redundant slices introduce noise without commensurate accuracy gains.
Applying the constrained optimization formulation in Eq. 9 , which maximizes marginal effect subject to minimum accuracy requirements, yields \(m^* = 29\) for MIST Control, \(m^* = 28\) for MIST Stress, and \(m^* = 26\) for SEED, as annotated in Figure 6. These optimal points reside near where each curve crosses zero from above, indicating the sweet spot before further slices degrade cost-effectiveness. Notably, MIST datasets tolerate larger \(m\) values than SEED, reflecting their longer task durations and richer temporal dynamics that benefit from finer slicing.
This work has both positive and negative societal implications. On the positive side, I2RiMA enables objective, portable mental stress monitoring that could benefit early intervention for stress-related disorders and support closed-loop stress regulation systems, particularly in resource-constrained settings where its low computational cost (1.60M parameters) enables deployment on wearable devices. On the negative side, EEG-based stress detection could be misused for workplace surveillance or discriminatory screening without informed consent. Cross-subject generalization limitations may also lead to biased assessments for underrepresented populations not well-represented in training data. We strongly advocate that any real-world deployment of I2RiMA requires informed consent, regulatory oversight, and fairness auditing across demographic groups.