Intra- and inter-segment attention weighted cross-subject stress detection using eeg segment-wise riemannian self-clustering

CN122946856APending Publication Date: 2026-10-20CAPITAL NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610950762.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-29
Publication Date
2026-10-20

AI Technical Summary

Technical Problem

[0005]然而,基于EEG的心理压力检测仍面临两大关键问题:第一,现有模型未充分利用脑电信号几何结构特性,常规特征提取方法易破坏其内在结构、损失空间信息,导致模型泛化能力不足,难以对新受试者实现稳定检测;第二,现有方法将连续脑电切分为固定时间切片独立处理,忽略片间时序关联,无法同时建模片内局部频谱与片间全局时序依赖

Benefits of technology

[0011]第五方面,本申请实施例提供一种计算机程序产品,所述程序产品被存储在存储介质中,所述程序产品被至少一个处理器执行以实现如本申请实施例第一方面提供的脑电段内黎曼自聚类与段间注意加权跨被试压力检测方法的步骤。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

This application discloses a method for detecting cross-subject stress using intra-segment Riemannian self-clustering and inter-segment attention weighting, comprising: resampling EEG signals using different acquisition devices with a uniform preset sampling rate, and preprocessing the acquired EEG signals to obtain multiple time slices; extracting Riemannian manifold features for frequency domain perception of each time slice; calculating the importance weights corresponding to each of the multiple time slices based on the Riemannian manifold features through an inter-segment attention aggregation mechanism, and weighting and fusing the Riemannian manifold features of the multiple time slices according to the importance weights to obtain fused features; and predicting the psychological stress level corresponding to the EEG signal based on the fused features. According to the embodiments of this application, the accuracy, stability, and generalization ability of cross-subject psychological stress detection can be significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of artificial intelligence technology, and in particular relates to a method for detecting cross-subject stress by intra-segment Riemann self-clustering and inter-segment attention weighting in electroencephalograms. Background Technology

[0002] With the accelerating pace of society and intensified competition, mental and physical health problems caused by psychological stress have become a significant challenge in the global public health field. Currently, traditional stress assessments rely on self-report scales and clinical interviews, which have significant limitations: First, they are easily influenced by cognitive biases and the social expectation effect, resulting in insufficient reliability and validity. The results of commonly used self-report questionnaires rely entirely on individual perceptions and are difficult to reflect true stress levels. Second, assessments are time-consuming, requiring physicians 2-3 hours to complete detailed analysis, consuming medical resources and failing to meet the needs of large-scale, routine monitoring. Third, they cannot track stress dynamics in real time, making immediate intervention difficult.

[0003] Researchers have attempted to use physiological indicators such as heart rate variability (HRV) and electrical skin activity (EDA) to achieve objective assessment, but these indicators are easily affected by factors such as circadian rhythms, bodily activity, and environment. Multiple potential influences need to be considered when analyzing them, thus limiting their application.

[0004] The development of neuroimaging technology has provided new pathways for stress assessment. Among these, electroencephalography (EEG), as a direct representation of neuronal activity in the brain, has become a core observation tool due to its advantages such as millisecond-level temporal resolution, low cost, portability, and high sensitivity to psychological changes. Compared to peripheral physiological signals, EEG can more intuitively map the state of the central nervous system. Furthermore, the upgrade of wireless dry electrode technology eliminates the need for conductive gel, is easy to operate, and can be rapidly acquired in diverse scenarios, providing technological possibilities for routine monitoring.

[0005] However, EEG-based psychological stress detection still faces two major problems: First, existing models do not fully utilize the geometric structural characteristics of EEG signals. Conventional feature extraction methods are prone to destroying their internal structure and losing spatial information, resulting in insufficient model generalization ability and difficulty in achieving stable detection on new subjects. Second, existing methods divide continuous EEG into fixed time slices for independent processing, ignoring the temporal correlation between slices, and cannot simultaneously model local spectrum within slices and global temporal dependence between slices. Summary of the Invention

[0006] This application provides a method for detecting inter-segmental attentional weighting and cross-subject stress by intra-segmental Riemannian self-clustering and inter-segmental attentional weighting.

[0007] In a first aspect, embodiments of this application provide a method for detecting intra-segment Riemannian self-clustering and inter-segment attention weighted cross-subject stress in electroencephalograms (EEGs), including: EEG signals were resampled using different acquisition devices with a uniform preset sampling rate, and the acquired EEG signals were preprocessed to obtain multiple time slices. For each of the time slices, extract the frequency domain-aware Riemannian manifold features of the time slice; Based on the Riemannian manifold features, the importance weights of each of the multiple time slices are calculated through an inter-slice attention aggregation mechanism, and the Riemannian manifold features of the multiple time slices are weighted and fused according to the importance weights to obtain the fused features. Based on the fusion features, the psychological stress level corresponding to the EEG signal is predicted.

[0008] Secondly, embodiments of this application provide a device for detecting intra-segment Riemannian self-clustering and inter-segment attention weighting across subject stress in electroencephalograms (EEGs), comprising: The preprocessing module is used to resample the EEG signals using different acquisition devices with a uniform preset sampling rate, and to preprocess the acquired EEG signals to obtain multiple time slices. The extraction module is used to extract the frequency domain-aware Riemannian manifold features of each time slice. The fusion module is used to calculate the importance weights of each of the multiple time slices according to the Riemann manifold features through an inter-slice attention aggregation mechanism, and to perform weighted fusion of the Riemann manifold features of the multiple time slices according to the importance weights to obtain fused features. The prediction module is used to predict the psychological stress level corresponding to the EEG signal based on the fusion features.

[0009] Thirdly, embodiments of this application provide an electronic device, which includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the steps of the intra-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress detection method as described in any embodiment of the first aspect.

[0010] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement the steps of the intra-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress detection method as described in any embodiment of the first aspect.

[0011] Fifthly, embodiments of this application provide a computer program product, which is stored in a storage medium and executed by at least one processor to implement the steps of the intra-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress detection method provided in the first aspect of embodiments of this application.

[0012] The method for detecting cross-subject stress using intra-segment Riemann self-clustering and inter-segment attention-weighted EEG in this application preserves the spatial structural features of EEG signals and effectively overcomes individual differences in EEG signals through frequency-domain-aware Riemann manifold feature extraction. It reduces feature dimensionality and imparts physiological interpretability through frequency clustering mechanism and achieves effective fusion of local spectral features and global temporal dependence through intra-segment and inter-segment feature fusion mechanism. As a result, it can significantly improve the accuracy, stability and generalization ability of cross-subject psychological stress detection. Attached Figure Description

[0013] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0014] Figure 1 This is a flowchart illustrating a method for detecting inter-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress in EEG segments, as provided in an embodiment of this application. Figure 2 This is a flowchart illustrating another method for detecting inter-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress provided in an embodiment of this application. Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0015] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.

[0016] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.

[0017] It should be noted that the acquisition, storage, use, and processing of data in this application embodiment all comply with the relevant provisions of national laws and regulations.

[0018] With the accelerating pace of society and intensified competition, mental and physical health problems caused by psychological stress have become a significant challenge in the global public health field. Currently, traditional stress assessments rely on self-report scales and clinical interviews, which have significant limitations: First, they are easily influenced by cognitive biases and the social expectation effect, resulting in insufficient reliability and validity. The results of commonly used self-report questionnaires rely entirely on individual perceptions and are difficult to reflect true stress levels. Second, assessments are time-consuming, requiring physicians 2-3 hours to complete detailed analysis, consuming medical resources and failing to meet the needs of large-scale, routine monitoring. Third, they cannot track stress dynamics in real time, making immediate intervention difficult.

[0019] Researchers have attempted to use physiological indicators such as heart rate variability (HRV) and electrical skin activity (EDA) to achieve objective assessment, but these indicators are easily affected by factors such as circadian rhythms, bodily activity, and environment. Multiple potential influences need to be considered when analyzing them, thus limiting their application.

[0020] The development of neuroimaging technology has provided new pathways for stress assessment. Among these, electroencephalography (EEG), as a direct representation of neuronal activity in the brain, has become a core observation tool due to its advantages such as millisecond-level temporal resolution, low cost, portability, and high sensitivity to psychological changes. Compared to peripheral physiological signals, EEG can more intuitively map the state of the central nervous system. Furthermore, the upgrade of wireless dry electrode technology eliminates the need for conductive gel, is easy to operate, and can be rapidly acquired in diverse scenarios, providing technological possibilities for routine monitoring.

[0021] However, EEG-based psychological stress detection still faces two major problems: First, existing models do not fully utilize the geometric structural characteristics of EEG signals. Conventional feature extraction methods are prone to destroying their internal structure and losing spatial information, resulting in insufficient model generalization ability and difficulty in achieving stable detection on new subjects. Second, existing methods divide continuous EEG into fixed time slices for independent processing, ignoring the temporal correlation between slices, and cannot simultaneously model local spectrum within slices and global temporal dependence between slices.

[0022] Specifically, the relevant technologies mainly suffer from the following problems: insufficient cross-subject generalization ability. Most existing EEG stress detection models do not fully consider the geometric structural features of EEG signals. Traditional feature extraction methods vectorize the covariance matrix in Euclidean space, destroying the spatial structural information of EEG signals, resulting in limited generalization ability in cross-subject scenarios and difficulty in achieving stable detection results in practical applications; loss of frequency domain spatial structural information. Existing Riemannian manifold methods usually directly construct the covariance matrix of the time domain signal, mixing information from different frequency points, which leads to the submergence of discriminative frequency band features and the inability to fully capture frequency domain discriminative information related to higher cognitive tasks; and insufficient temporal dependency modeling. Existing methods divide continuous EEG signals into fixed-length time slices and process them independently, ignoring the temporal correlation between slices. They cannot simultaneously model local spectral features within a slice and global temporal dependencies between slices, resulting in the loss of important information.

[0023] To address the problems in the related technologies, this application provides a method for detecting cross-subject stress using intra-segment Riemann self-clustering and inter-segment attention weighting in electroencephalograms.

[0024] The following explains the basic concepts involved in the embodiments of this application: Electroencephalogram (EEG) is a method of recording brain activity using electrophysiological indicators. It is formed by summing the postsynaptic potentials that occur synchronously among a large number of neurons during brain activity. EEG offers advantages such as millisecond-level temporal resolution, low cost, portability, and high sensitivity to psychological changes, making it a core observation tool in the field of psychological stress detection.

[0025] Riemannian manifold: A smooth manifold with a Riemannian metric that describes the geometry in curved space and is used to process data with special structures, such as symmetric positive definite matrices.

[0026] Symmetric Positive Definite Matrix (SPD): For a real symmetric matrix C, if for any non-zero vector v, the following holds true: If C is a positive definite matrix, then C is called a symmetric positive definite matrix. The covariance matrix of multichannel EEG signals belongs to this type of matrix, and the set of all N-order symmetric positive definite matrices constitutes a Riemannian manifold, called the SPD manifold.

[0027] Riemannian Tangent Space Mapping: The operation of mapping symmetric positive definite matrices from manifold space to tangent space, implemented through Log-Euclidean transformation, which preserves the geometric structure while enabling linear operations on the data.

[0028] Affine Invariant Riemannian Metric (AIRM): A metric defined on symmetric positive definite manifolds, it is invariant to affine transformations and robust to individual differences in EEG signals.

[0029] Log-Euclidean metric: A computationally efficient Riemannian metric that transforms distances on a manifold into distances in Euclidean space through a logarithmic mapping.

[0030] Fast Fourier Transform (FFT): An efficient algorithm for computing the Discrete Fourier Transform, used to convert time-domain signals into frequency-domain representations.

[0031] Frequency Cluster Aggregation: A feature dimensionality reduction method that clusters multiple frequency points into several frequency clusters based on feature similarity and performs weighted aggregation, so that the feature representation has physiological significance.

[0032] Intra-Inter Slice Fusion: A feature fusion mechanism that simultaneously models local spectral features within a single time slice (intra-slice information) and global temporal dependencies between multiple time slices (inter-slice information).

[0033] The following, in conjunction with the accompanying drawings, provides a detailed description of the intra-segment Riemannian self-clustering and inter-segment attention weighted cross-subject stress detection method provided in this application, through specific embodiments and application scenarios.

[0034] Figure 1 This diagram illustrates a flowchart of the method for detecting inter-segment Riemannian self-clustering and inter-segment attention weighting across subject stress according to an embodiment of this application. Figure 1 As shown, the method for detecting inter-segmental attentional weighting and cross-subject stress in intra-segmental Riemannian self-clustering and inter-segmental attentional weighting may specifically include the following steps: S101. Resample the EEG signal using different acquisition devices with a unified preset sampling rate, and preprocess the acquired EEG signal to obtain multiple time slices. S102. For each of the time slices, extract the frequency domain-aware Riemannian manifold features of the time slice; S103. Based on the Riemannian manifold features, the importance weights of each of the multiple time slices are calculated through an inter-slice attention aggregation mechanism, and the Riemannian manifold features of the multiple time slices are weighted and fused according to the importance weights to obtain fused features. S104. Based on the fusion features, predict the psychological stress level corresponding to the EEG signal.

[0035] Therefore, the intra-segment Riemann self-clustering and inter-segment attention-weighted cross-subject stress detection method preserves the spatial structural features of EEG signals and effectively overcomes the problem of individual differences in EEG signals through frequency domain-aware Riemann manifold feature extraction. It reduces feature dimensionality and imparts physiological interpretability through frequency cluster aggregation mechanism, and achieves effective fusion of local spectral features and global temporal dependence through intra-segment and inter-segment feature fusion mechanism. Thus, it can significantly improve the accuracy, stability and generalization ability of cross-subject psychological stress detection.

[0036] The specific implementation methods for each of the above steps are described below.

[0037] In some embodiments, in S101, the sampling rates of different acquisition devices are uniformly resampled to 200Hz to reduce the subsequent computational complexity; the acquired EEG signals are filtered in a preset frequency band; the artifact components of electrooculography (EOG) and electromyography (EMG) in the filtered EEG signals are separated and removed using the Independent Component Analysis (ICA) method; the EEG signals after artifact removal are z-score normalized and divided into multiple (m) time slices (8 seconds in length) according to a preset time window, each of the time slices including N channels and T sampling points.

[0038] In practice, to remove power frequency interference and high-frequency noise, the signal is filtered in the 0.5-50Hz frequency band using an 8th-order Butterworth bandpass filter, retaining the five main EEG frequency bands related to psychological activity: Delta, Theta, Alpha, Beta, and Gamma.

[0039] In some embodiments, in S102, the time slice is subjected to time-frequency transformation to obtain spectral data at multiple frequency points; for each frequency point, a symmetric positive definite covariance matrix is ​​constructed based on the spectral amplitude of all channels at that frequency point; the symmetric positive definite covariance matrix is ​​projected onto the tangent space using a log-Euclidean mapping algorithm, and its upper triangular elements are extracted to obtain the Riemann eigenvector of that frequency point; the Riemann eigenvectors of multiple frequency points are aggregated to obtain the Riemann manifold features of the time slice.

[0040] In practice, a Fast Fourier Transform (FFT) is performed on the time slices to obtain a tensor X_freq, where the dimensions of tensor X_freq are B x m x C x F, where B is the batch size, m is the number of time slices, C is the number of channels, and F is the number of frequency points. For each frequency point, the product of the spectral amplitude vector x of all channels at that frequency point and its transpose is calculated, and a regularization coefficient is added. Multiplying by the identity matrix I yields the covariance matrix R, where the dimension of the spectral magnitude vector x is C, and the regularization coefficients are... Adding a regularization term ensures the positive definiteness of the matrix. Furthermore, for the b-th sample, the j-th slice, and the f-th frequency point, the covariance matrix R has dimensions C multiplied by C. This allows the covariance matrix of each frequency point to be calculated independently, enabling the network to learn frequency-specific channel relationship patterns.

[0041] In practice, for each covariance matrix R, eigenvalue decomposition is first performed to obtain the eigenvector matrix U and the diagonal eigenvalue matrix. Both have dimensions C multiplied by C, satisfying R equal to U multiplied by C. Multiply by the transpose of U; then take the logarithm of the eigenvalues ​​and reconstruct the matrix, i.e., the logarithmically transformed matrix log(R) equals U multiplied by log( Multiply by the transpose of U; expand the upper triangular part of the log(R) matrix into a one-dimensional vector to obtain the Riemann eigenvector h at a single frequency point, with dimension 1. ,in It equals C multiplied by (C+1) and then divided by 2.

[0042] In specific implementation, the optimal number of clusters K is determined based on the elbow rule; multiple frequency points (F frequency points) are clustered into K frequency clusters, each frequency cluster corresponding to a specific frequency band of the EEG signal; for each frequency cluster, the Riemann eigenvectors corresponding to all frequency points within that frequency cluster are weighted and aggregated to obtain the cluster feature tensor H_cluster of that frequency cluster, with dimensions B x m x K x D0; the cluster features of the K frequency clusters are concatenated to obtain the Riemann manifold feature H of the time slice, with dimension D equal to the number of clusters K multiplied by the dimension D0 of a single cluster feature. The weights corresponding to the Riemann eigenvectors of each frequency point are determined based on a constructed allocation matrix A, with dimensions K x F, where the matrix elements... This represents the weight of the f-th frequency point belonging to the k-th cluster.

[0043] Furthermore, in some embodiments, in S103, for each time slice, the frequency domain Riemannian manifold features are linearly transformed and processed by the ReLU activation function using a linear encoder to obtain encoded features H_enc; the encoded features H_enc are averaged and pooled along the feature dimension to obtain pooled features H_pool; based on the pooled features H_pool, the importance weights of the time slices are calculated using a fully connected layer and a normalized exponential function. According to the aforementioned importance weight The encoded features H_enc from multiple time slices are weighted and summed to obtain the fused feature H_agg, where the dimension of H_agg is B times d_enc.

[0044] In practice, a linear encoder maps high-dimensional features to a low-dimensional space. A learnable weight matrix W and a bias vector b are defined, where W has a dimension of D x d_enc, and b has a dimension of d_enc, where d_enc is a hyperparameter representing the encoding dimension. After a linear transformation of each slice, it is activated by a ReLU function to obtain the encoded feature H_enc, which has a dimension of B x m x d_enc.

[0045] In practice, attention weight vectors are calculated using fully connected layers and the Softmax function. Its dimension is 1 by m. The fully connected transformation maps the features to a scalar space, and the Softmax function ensures that the sum of the weights of all slices is 1. It should be noted that, in order to simplify the calculation and enhance the generalization ability of the model, this embodiment adopts a shared weight strategy to keep the attention weights consistent within the batch.

[0046] In some embodiments, in S104, the fused features are input into a classifier, and the fused features are linearly transformed through the fully connected layer of the classifier to obtain initial scores corresponding to each preset psychological stress category. The initial scores are then normalized to a probability distribution using a normalized exponential function, serving as the predicted probability P of the EEG signal corresponding to each preset psychological stress category. The psychological stress level corresponding to the EEG signal is determined based on the predicted probability. Here, the classifier weight matrix W_c has a dimension of d_enc multiplied by G, the bias vector b_c has a dimension of G, the predicted probability P has a dimension of B multiplied by G, and G is the number of stress categories.

[0047] In practice, cross-entropy is used as the loss function to measure the difference between the predicted probability and the true label. The loss function L is equal to the sum of the negative logarithmic products of the true label and the predicted probability of each trial, where P_u represents the predicted probability of the u-th EEG trial, Y_u represents the corresponding true label, and U is the total number of trials.

[0048] In summary, because the embodiments of this application employ a frequency-domain-aware Riemannian manifold feature extraction method, which independently constructs a covariance matrix for each frequency point and maps it to the tangent space, rather than the traditional method of vectorizing the covariance matrix in Euclidean space, and uses the relative spatial correlation between channels instead of absolute amplitude as the feature basis, it has natural robustness to individual EEG amplitude and baseline differences. Therefore, it can preserve the spatial structural features of EEG signals, effectively overcome individual differences, and significantly improve cross-subject generalization ability. At the same time, because a frequency cluster aggregation mechanism is used to cluster frequency points into physiologically meaningful frequency clusters, rather than directly constructing a covariance matrix on the time-domain signal to mix different frequency information, it can preserve the discriminative information of the frequency dimension, avoid the confusion between features of different frequency bands, and fully capture the frequency domain discriminative information related to higher cognitive tasks. Furthermore, since this application designs an inter-slice attention aggregation mechanism to adaptively learn the importance weights of each time slice, rather than processing or aggregating continuous EEG signals independently after segmentation, it can simultaneously model intra-slice local spectral features and inter-slice global temporal dependencies, thereby enhancing important information and suppressing noise, and improving the model's discriminative ability and stability. This method only requires 1.60M parameters and 31.95M FLOPs to achieve high detection performance, and its computational efficiency is significantly better than existing mainstream methods, showing good prospects for practical application and deployment value.

[0049] In addition, this application also provides another method for detecting inter-segmental Riemannian self-clustering and inter-segmental attention-weighted cross-subject stress in EEG segments. (Reference) Figure 2 This is a flowchart illustrating another method for detecting inter-segmental Riemann self-clustering and inter-segmental attention weighting across subject stress in EEG segments.

[0050] like Figure 2As shown, this method is implemented through a combination of an EEG signal preprocessing module, a frequency-domain-aware Riemannian manifold feature extraction module, an intra-slice and inter-slice feature fusion module, and a classifier module. Specifically, the EEG signal preprocessing module provides clean and reliable EEG signals; subsequently, the frequency-domain-aware Riemannian manifold feature extraction module extracts frequency-domain features that preserve spatial structure from these signals, reduces dimensionality through frequency cluster aggregation, and assigns physiological meaning; then, the intra-slice and inter-slice feature fusion module adaptively learns the importance weights of each time slice, achieving effective fusion of local features and global dependencies, ultimately realizing stress level classification.

[0051] The specific implementation of this method may include the following steps: Step 1: EEG signal acquisition and preprocessing.

[0052] Step 1.1: Resampling and Filtering. The sampling rate of different acquisition devices was uniformly resampled to 200Hz to reduce subsequent computational complexity. To remove power frequency interference and high-frequency noise, the signal was filtered in the 0.5-50Hz frequency band using an 8th-order Butterworth bandpass filter, retaining the five main EEG frequency bands related to psychological activity: Delta, Theta, Alpha, Beta, and Gamma.

[0053] Step 1.2: Artifact Removal. Independent component analysis was used to separate and remove artifact components such as electrooculography (EOG) and electromyography (EMG).

[0054] Step 1.3: Standardization and Segmentation. The signal of each channel is z-score standardized, adjusting the mean to 0 and the standard deviation to 1 to eliminate amplitude differences between channels. The continuous EEG is divided into 8-second slices within a fixed time window, with each slice containing N channels and T sampling points, providing standardized input for the subsequent feature extraction module.

[0055] Step 2: Frequency domain-aware Riemannian manifold feature extraction.

[0056] Step 2.1: Fast Fourier Transform and Construction of Frequency Domain Covariance Matrix.

[0057] After Fast Fourier Transform (FFT), the input tensor X_freq has dimensions B x m x C x F, where B is the batch size, m is the number of time slices, C is the number of channels, and F is the number of frequency points. To capture the spatial correlation between channels at different frequency points, the network independently constructs a covariance matrix for each frequency point. For the b-th sample, j-th slice, and f-th frequency point, the covariance matrix R has dimensions C x C, calculated as follows: the covariance matrix R equals the product of the spectral amplitude vector x of all channels at that frequency point and its transpose, plus a regularization coefficient. Multiply by the identity matrix I, where the dimension of the spectral magnitude vector x is C, and the regularization coefficient is... Adding a regularization term ensures the positive definiteness of the matrix. Compared with traditional time-domain covariance methods, this method preserves the discriminative information of the frequency dimension, avoids the confusion of features from different frequency bands, and calculates the covariance matrix of each frequency point independently, enabling the network to learn frequency-specific channel relationship patterns.

[0058] Step 2.2: Riemannian space mapping.

[0059] Each matrix in the covariance tensor R belongs to a symmetric positive definite (SPD) manifold. Since SPD manifolds lack a vector space structure, linear operations in Euclidean space cannot be directly performed; therefore, they need to be mapped to the tangent space. This application employs Log-Euclidean mapping to achieve tangent space projection, which maintains Riemannian geometry while offering good computational efficiency. For each covariance matrix R, eigenvalue decomposition is first performed to obtain the eigenvector matrix U and the diagonal eigenvalue matrix. Both have dimensions C multiplied by C, satisfying R equal to U multiplied by C. Multiply by the transpose of U. Then take the logarithm of the eigenvalues ​​and reconstruct the matrix, i.e., the logarithmically transformed matrix log(R) equals U multiplied by log( Multiply by the transpose of U. Expand the upper triangular part of the log(R) matrix into a one-dimensional vector to obtain the Riemann eigenvector h at a single frequency point, with dimension 1. ,in This equals C multiplied by (C+1) and then divided by 2. The Riemann features at all frequencies constitute the tensor H_freq, whose dimensions are B x m x F x ... .

[0060] Step 2.3: Frequency cluster aggregation.

[0061] While constructing the covariance matrix independently for each frequency point preserves fine-grained frequency domain information, having F frequency points leads to excessively high feature dimensionality, increasing the complexity of subsequent calculations. Furthermore, from a neurophysiological perspective, different frequency bands of EEG (such as...) Wave, A wave (e.g., a pulse) consists of multiple adjacent frequency points, and the physiological significance of a single frequency point is limited. Therefore, this application clusters F frequency points into K frequency clusters, so that each cluster corresponds to a frequency band with physiological significance.

[0062] First, the elbow method is used to determine the optimal number of clusters K. Then, a frequency cluster allocation matrix A is constructed, with dimensions K times F, where the matrix elements... The weight of the f-th frequency point belonging to the k-th cluster is represented by the following. Weighted aggregation is performed on the frequency points within each cluster. The aggregated feature h of the k-th cluster is equal to the weighted sum of the features of all frequency points within that cluster. The weights are determined by the allocation matrix A, resulting in the cluster feature tensor H_cluster, with dimensions B x m x K x D0. Finally, the feature vectors of the K frequency clusters are concatenated sequentially to form the final output H. The final feature dimension D is equal to the number of clusters K multiplied by the single-cluster feature dimension D0. This feature will serve as the input for subsequent intra- and inter-slice feature fusion modules. Furthermore, the frequency clusters formed by self-clustering can adapt to the frequency band peak shifts of different subjects, further improving feature stability across subject scenarios.

[0063] Step 3: Intra- and inter-film feature fusion.

[0064] After processing by the Riemannian manifold feature extraction module, each EEG trial is represented as a feature sequence H of m time slices, with dimensions B x m x D. Existing multi-slice aggregation methods typically employ simple averaging or max pooling strategies, which assume that all slices contribute equally to the classification task. However, in stress recognition tasks, the discriminative information contained in different time slices varies significantly; that is, some slices may capture key changes in mental state, while others may mainly contain noise or irrelevant information. Using equal-weight aggregation leads to the dilution of important information and the accumulation of noise, and also amplifies the temporal differences in stress responses among different subjects, reducing the model's discriminative ability across subject scenarios. To address these issues, this application proposes an inter-slice attention aggregation module, comprising the following sub-steps: Step 3.1: Linear Encoding of Features. The features output by the Riemannian manifold feature extraction module have a high dimension. Directly calculating attention would lead to too many parameters, increasing the risk of overfitting. Therefore, this application first maps the high-dimensional features to a low-dimensional space using a linear encoder. A learnable weight matrix W and a bias vector b are defined, where W has a dimension of D × d_enc, and b has a dimension of d_enc, where d_enc is the encoding dimension hyperparameter. After a linear transformation of each slice, the ReLU activation function is applied to obtain the encoded feature H_enc, with a dimension of B × m × d_enc. The introduction of the ReLU activation function increases the non-linear expressive power of the model while making the feature representation sparser.

[0065] Step 3.2: Attention Weight Calculation. After obtaining the encoded feature H_enc, it is necessary to learn the relative importance of each time slice. In this application, H_enc is averaged along the feature dimension to compress the feature dimension, resulting in H_pool. Then, the attention weight vector is calculated through a fully connected layer and a softmax function. Its dimension is 1 by m. The fully connected transformation maps the features to a scalar space, and the Softmax function ensures that the sum of the weights of all slices is 1. To simplify computation and enhance the generalization ability of the model, this application adopts a shared weight strategy to keep the attention weights consistent within the batch.

[0066] Step 3.3: Weighted Aggregation. Utilizing attention weights. The encoded features H_enc are weighted and aggregated, and the final feature H_agg is equal to the weighted sum of the encoded features of each slice, with the weights being the corresponding attention weights. The dimension of H_agg is B times d_enc. This feature will be used as input to the subsequent classifier.

[0067] Step 4: Classification and stress level prediction.

[0068] The classifier module predicts psychological stress state through a fully connected layer and a Softmax function. The prediction probability P is equal to the linear transformation of H_agg followed by normalization using the Softmax function, where H_agg is the feature vector after inter-slice attention aggregation, the classifier weight matrix W_c has a dimension of d_enc multiplied by G, the bias vector b_c has a dimension of G, and the prediction probability P has a dimension of B multiplied by G, where G is the number of stress categories.

[0069] This application uses cross-entropy as the loss function to measure the difference between the predicted probability and the true label. The loss function L is equal to the sum of the negative logarithmic products of the true label and the predicted probability of each trial, where P_u represents the predicted probability of the u-th EEG trial, Y_u represents the corresponding true label, and U is the total number of trials.

[0070] Step 5: End-to-end joint optimization.

[0071] The frequency-domain-aware Riemannian manifold feature extraction module and the intra- and inter-chip feature fusion module are optimized using an end-to-end joint training approach. The overall loss function is cross-entropy loss, and the parameters of all modules are updated simultaneously through backpropagation, achieving collaborative optimization of feature extraction and downstream recognition tasks. The model uses the Adam optimizer, with an initial learning rate of 1e-3, a decay rate of 1e-2, and 300 training epochs. Batch normalization and Dropout are used to prevent overfitting.

[0072] Furthermore, the intra-segment Riemann self-clustering and inter-segment attention-weighted cross-subject stress detection method of this application was experimentally validated. Specifically, experiments were conducted based on the MIST Control, MIST Stress private datasets, and the publicly available SEED dataset. The experiments employed a cross-subject design, with strict separation of the training and test sets to ensure zero subject overlap. Experimental results show that the method described in this application achieves balanced accuracies of 77.59%, 75.88%, and 82.78% on the MIST Control, MIST Stress, and SEED datasets, respectively, with AUCs of 95.61%, 94.57%, and 94.45%, respectively. These figures outperform mainstream methods such as EEGNet, BIOT, LaBraM, NeuroBOLT, and CorrAtt across all five evaluation metrics. Simultaneously, the method in this application has only 1.60M parameters and 31.95M FLOPs of floating-point operations, demonstrating significantly higher computational efficiency than the comparative methods, thus validating the effectiveness and feasibility of the proposed technical solution.

[0073] Therefore, the intra-segment Riemann self-clustering and inter-segment attention-weighted cross-subject stress detection method of the embodiments of this application has at least the following beneficial technical effects: First, a covariance matrix is ​​independently constructed for each frequency point and mapped to the tangent space, preserving the spatial structural features of the EEG signal, avoiding the information loss caused by traditional Euclidean space feature extraction, effectively overcoming the problem of individual differences in EEG signals, and improving the cross-subject generalization ability. Secondly, clustering multiple frequency points into physiologically significant frequency clusters reduces feature dimensionality and makes the feature representation clearly physiologically interpretable, different from different frequency bands of EEG signals (such as...). This corresponds to enhancing the discriminative power of features; Third, we designed an inter-slice attention aggregation mechanism to adaptively learn the importance weights of each time slice, thereby achieving effective fusion of local spectral features within a slice and global temporal dependencies between slices, reducing information loss to the minimum while reducing model complexity. Fourth, it realizes an end-to-end cross-subject stress detection framework, in which the entire process is automatically completed by the deep model for feature extraction, fusion and classification prediction, without the need for manual feature design, thereby improving detection efficiency, reducing human intervention and improving objectivity; and it achieves detection performance superior to existing mainstream methods on the MIST Control, MIST Stress and SEED datasets, while maintaining low computational cost.

[0074] It should be noted that the above description describes some embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the above embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0075] Based on the same technical concept, corresponding to any of the above embodiments, this application also provides a device for detecting intra-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress in electroencephalogram (EEG) segments.

[0076] Specifically, the device for detecting intra-segment Riemannian self-clustering and inter-segment attention weighting across subject stress may include: The preprocessing module is used to resample the EEG signals using different acquisition devices with a uniform preset sampling rate, and to preprocess the acquired EEG signals to obtain multiple time slices. The extraction module is used to extract the frequency domain-aware Riemannian manifold features of each time slice. The fusion module is used to calculate the importance weights of each of the multiple time slices according to the Riemann manifold features through an inter-slice attention aggregation mechanism, and to perform weighted fusion of the Riemann manifold features of the multiple time slices according to the importance weights to obtain fused features. The prediction module is used to predict the psychological stress level corresponding to the EEG signal based on the fusion features.

[0077] It should be noted that, for ease of description, the above devices are described in terms of function, divided into various modules. Of course, in implementing this application, the functions of each module can be implemented in one or more software and / or hardware.

[0078] The apparatus of the above embodiments is used to implement the corresponding intra-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress detection methods in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0079] Based on the same technical concept, corresponding to any of the above embodiments, this application also provides an electronic device.

[0080] Figure 3 A schematic diagram of a more specific electronic device hardware structure provided in this embodiment is shown.

[0081] The electronic device 300 may include a processor 301 and a memory 302 storing computer program instructions.

[0082] Specifically, the processor 301 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0083] Memory 302 may include mass storage for data or instructions. For example, and not limitingly, memory 302 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 302 may include removable or non-removable (or fixed) media. Where appropriate, memory 302 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 302 is non-volatile solid-state memory.

[0084] In certain embodiments, the memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Thus, generally, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this application.

[0085] The processor 301 reads and executes computer program instructions stored in the memory 302 to implement any of the methods for detecting intra-segment Riemann self-clustering and inter-segment attention weighting across subject stress in the above embodiments.

[0086] In some examples, the electronic device 300 may also include a communication interface 303 and a bus 310. For example, Figure 3 As shown, the processor 301, memory 302, and communication interface 303 are connected through bus 310 and complete communication with each other.

[0087] The communication interface 303 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.

[0088] Bus 310 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not as a limitation, bus 310 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 310 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.

[0089] For example, the electronic device 300 can be a mobile phone, tablet computer, laptop computer, handheld computer, in-vehicle electronic device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc.

[0090] Based on the same technical concept, corresponding to any of the methods in the above embodiments, this application also provides a non-transitory computer-readable storage medium. This computer-readable storage medium stores computer program instructions; when executed by a processor, these computer program instructions implement any of the intra-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress detection methods in the above embodiments. Examples of computer-readable storage media include non-transitory computer-readable storage media such as portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, etc.

[0091] Based on the same technical concept, corresponding to any of the above-described embodiments, this application also provides a computer program product, which includes computer program instructions. In some embodiments, the computer program instructions can be executed by one or more processors of a computer to cause the computer and / or the processor to perform the intra-segment Riemann self-clustering and inter-segment attention-weighted cross-subject stress detection method. Corresponding to the execution entity for each step in each embodiment of the intra-segment Riemann self-clustering and inter-segment attention-weighted cross-subject stress detection method, the processor executing the corresponding step can belong to the corresponding execution entity.

[0092] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.

[0093] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0094] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0095] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0096] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.

Claims

1. A method for detecting intra-segment Riemannian self-clustering and inter-segment attention weighted cross-subject stress in electroencephalograms, characterized in that, include: EEG signals were resampled using different acquisition devices with a uniform preset sampling rate, and the acquired EEG signals were preprocessed to obtain multiple time slices. For each of the time slices, extract the frequency domain-aware Riemannian manifold features of the time slice; Based on the Riemannian manifold features, the importance weights of each of the multiple time slices are calculated through an inter-slice attention aggregation mechanism, and the Riemannian manifold features of the multiple time slices are weighted and fused according to the importance weights to obtain the fused features. Based on the fusion features, the psychological stress level corresponding to the EEG signal is predicted.

2. The method according to claim 1, characterized in that, The step of extracting the frequency-domain-aware Riemannian manifold features for each of the time slices includes: Perform time-frequency transformation on the time slice to obtain spectral data at multiple frequency points; For each of the aforementioned frequency points, a symmetric positive definite covariance matrix is ​​constructed based on the spectral amplitudes of all channels at that frequency point. The symmetric positive definite covariance matrix is ​​projected onto the tangent space using the log-Euclidean mapping algorithm, and its upper triangular elements are extracted to obtain the Riemann eigenvector at that frequency point. The Riemann feature vectors at multiple frequency points are aggregated to obtain the Riemann manifold features of the time slice.

3. The method according to claim 2, characterized in that, The step of aggregating the Riemann feature vectors at multiple frequency points to obtain the Riemann manifold features of the time slice includes: Determining the optimal number of clusters K based on the elbow rule; Multiple frequency points are clustered into K frequency clusters, and each frequency cluster corresponds to a specific frequency band of the EEG signal. For each frequency cluster, the Riemann feature vectors corresponding to all frequency points within the frequency cluster are weighted and aggregated to obtain the cluster feature of the frequency cluster. The cluster features of the K frequency clusters are spliced ​​together to obtain the Riemannian manifold features of the time slice.

4. The method according to claim 1, characterized in that, The step involves calculating the importance weights of multiple time slices based on the Riemannian manifold features using an inter-slice attention aggregation mechanism, and then weighting and fusing the frequency domain Riemannian manifold features of the multiple time slices according to the importance weights to obtain fused features, including: For each of the aforementioned time slices, the frequency domain Riemann manifold features are subjected to linear transformation and ReLU activation function processing using a linear encoder to obtain coded features; The encoded features are averaged along the feature dimension to obtain pooled features; Based on the pooling characteristics, the importance weights of the time slices are calculated using a fully connected layer and a normalized exponential function. Based on the importance weights, the encoded features of multiple time slices are weighted and summed to obtain the fused features.

5. The method according to claim 1, characterized in that, The step of predicting the psychological stress level corresponding to the EEG signal based on the fusion features includes: The fused features are input into a classifier, and the fused features are linearly transformed through the fully connected layer of the classifier to obtain initial scores corresponding to each preset psychological stress category; The initial scores are normalized into probability distributions by a normalized exponential function, which serve as the predicted probabilities of the EEG signals corresponding to each of the preset psychological stress categories. The psychological stress level corresponding to the EEG signal is determined based on the predicted probability.

6. The method according to claim 1, characterized in that, The acquired EEG signals are preprocessed to obtain multiple time slices, including: The acquired EEG signals are filtered using a preset frequency band. The artifact components of electrooculography (EOG) and electromyography (EMG) in the filtered EEG signal were separated and removed using independent component analysis. The EEG signal after artifact removal is z-score normalized and divided into multiple time slices according to a preset time window. Each time slice includes N channels and T sampling points.

7. A device for detecting intra-segment Riemannian self-clustering and inter-segment attention weighting across subject stress in electroencephalograms, characterized in that, include: The preprocessing module is used to resample the EEG signals using different acquisition devices with a uniform preset sampling rate, and to preprocess the acquired EEG signals to obtain multiple time slices. The extraction module is used to extract the frequency domain-aware Riemannian manifold features of each time slice. The fusion module is used to calculate the importance weights of each of the multiple time slices according to the Riemann manifold features through an inter-slice attention aggregation mechanism, and to perform weighted fusion of the Riemann manifold features of the multiple time slices according to the importance weights to obtain fused features. The prediction module is used to predict the psychological stress level corresponding to the EEG signal based on the fusion features.

8. An electronic device, characterized in that, The device includes: a processor and a memory storing computer program instructions; when the processor invokes the computer program instructions, it implements the intra-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress detection method as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when invoked by a processor, implement the intra-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress detection method as described in any one of claims 1-6.

10. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the electronic device, the electronic device performs the intra-segment Riemann self-clustering and inter-segment attention weighted cross-subject stress detection method as described in any one of claims 1-6.