Depression eeg signal classification method and system based on multi-scale convolution and transformer

CN122997685APending Publication Date: 2026-10-30SOUTH CHINA NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611044170.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-14
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0011]针对现有技术中存在的问题,本发明旨在提出一种基于多尺度卷积与Transformer的抑郁症脑电信号分类方法及系统,解决现有脑电抑郁识别方法中局部时序判别特征提取不足、关键脑电特征增强能力不足、全局依赖关系建模不充分、不同脑电样本之间个体风格差异难以补偿、以及小样本条件下训练稳定性和泛化能力较弱的问题

Benefits of technology

[0050]1.创新性地提出个体风格自适应调制机制,有效消除了脑电信号显著的个体差异干扰。 针对脑电信号信噪比低、受试者间波动大导致模型鲁棒性差的问题,本发明在序列编码模块后引入了个体风格自适应调制过程。该方法无需额外的个体标签信息,仅利用原始脑电信号的时域统计特征(如均值、标准差)生成缩放与偏移参数,对高层特征进行自适应调整。这一机制实现了对不同受试者信号分布差异的“风格补偿”,在不改变语义信息的前提下对齐了样本分布,显著提高了模型在跨被试场景下的识别一致性与稳定性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122997685A_ABST
    Figure CN122997685A_ABST
Patent Text Reader

Abstract

The application discloses a depression electroencephalogram signal classification method based on multi-scale convolution and a transformer, and comprises the following steps: collecting original multi-channel electroencephalogram signals and preprocessing the original multi-channel electroencephalogram signals into time series tensors; inputting a multi-scale feature extraction module, capturing multi-band features through different scale convolution kernels and fusing and compressing the multi-band features, performing channel and space weighting on the multi-band features through a convolution block attention module to obtain enhanced features; inputting a transformer encoder, modeling global dependency relationships through a multi-head self-attention mechanism to obtain global representation features; introducing individual style adaptive modulation at a transformer output end, generating scaling and offset parameters based on original signal time domain statistical features to adaptively adjust high-level features; and finally obtaining a depression recognition result through classification output. The application effectively alleviates the problems of insufficient local feature extraction, missing key area enhancement and individual difference interference, improves the recognition accuracy and generalization ability under a small sample condition, and is suitable for electroencephalogram auxiliary screening and mental state recognition scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic information technology, and in particular to a method and system for classifying EEG signals of depression based on multi-scale convolution and Transformer. Background Technology

[0002] Identifying depressive states remains a challenging task in mental health screening and brain-computer interface research. Currently, with the continuous changes in the social environment and diverse pressures, the prevalence of depression is on the rise. However, existing methods for identifying depression are mostly traditional screening techniques, such as scale assessments, clinical interviews, and subjective judgment. These methods have many limitations, especially their heavy reliance on subjective judgment. For example, fluctuations in the subject's instantaneous mental state, the subjectivity of the scales, and differences in physicians' clinical experience can all lead to biased diagnostic results. Furthermore, in practical applications, these methods are difficult to scale up, as a complete assessment takes tens of minutes, clearly failing to meet the practical needs of rapid screening. Therefore, exploring a more objective, quantifiable, and automated method for identifying depressive states is of significant research importance.

[0003] In recent years, facing the problems of insufficient automation and low screening efficiency of traditional methods, the rapid development of brain-computer interface technology and artificial intelligence technology has led to the increasing importance of electroencephalography (EEG). EEG has advantages such as non-invasive acquisition, high temporal resolution, and the ability to directly reflect the activity of brain neuronal populations. Furthermore, it possesses the ability to provide a new physiological basis for objective identification, making it uniquely valuable in emotion decoding and the auxiliary diagnosis of neuropsychiatric disorders. Existing neurophysiological studies indicate that patients with depression exhibit characteristics different from healthy individuals in terms of EEG rhythm distribution, functional connectivity patterns, and the degree of brain region activation. These neurophysiological markers lay the biological foundation for automated identification based on computational models.

[0004] Currently, scholars both domestically and internationally have proposed numerous EEG depression identification methods based on machine learning and deep learning. Taking the traditional machine learning process as an example, researchers typically extract manually designed time-frequency features and then use support vector machines or random forests to complete the classification. However, these methods heavily rely on manual feature engineering and struggle to fully exploit the complex nonlinear patterns in EEG signals. In recent years, the advantages of convolutional neural networks (CNNs) in automatic feature extraction have led to their widespread application in EEG signal analysis. Convolutional operations can effectively extract local temporal and spatial channel features. Simultaneously, the Transformer architecture, due to its excellent global dependency modeling capabilities, has also been gradually introduced into EEG signal analysis to learn dynamic change patterns over long time spans.

[0005] Although existing intelligent recognition methods based on EEG signals have improved recognition performance to some extent, there are still some key issues that need to be addressed in practical applications.

[0006] First, existing models still have limited ability to extract local temporal patterns from raw EEG signals. EEG signals are characterized by low signal-to-noise ratio and large individual variability. The discriminative information related to depressive states is often embedded in microvolt-level waveform fluctuations and short-term transient changes. If the model cannot effectively capture these fine-grained local patterns, it is easy to lose important discriminative information, thereby affecting recognition performance.

[0007] Second, existing methods generally lack effective enhancement mechanisms for key pathway features and key response regions. EEG signals originate from multiple brain regions, each playing a different role in emotion regulation and cognitive activity. For example, the frontal lobe is usually closely related to emotion regulation, while the parietal and occipital lobes are more involved in sensory and cognitive processing. However, if the model cannot adaptively highlight key pathways or key time regions closely related to depressive states, important EEG features will be easily masked by background noise.

[0008] Third, existing methods still have shortcomings in modeling long-range dependencies between EEG features. EEG signals not only contain local instantaneous changes, but also dynamic correlations across time scales. Although traditional CNN structures can extract local patterns, they cannot simultaneously take into account local details and global contextual information; therefore, how to effectively integrate local feature extraction capabilities with global dependency modeling capabilities is one of the important issues in improving the performance of EEG recognition models.

[0009] Furthermore, in practical EEG depression recognition tasks, the data scale is often small and the collection cost is high, which can easily lead to overfitting during model training, thus weakening the model's generalization ability on unknown data. At the same time, EEG signals themselves exhibit significant individual differences, which places higher demands on the robustness and stability of the model. Therefore, how to enhance the model's generalization ability under limited sample size conditions and improve model stability through reasonable training strategies has become a key research focus. Additionally, since different subjects often exhibit significant differences in channel mean distribution, fluctuation intensity, and overall EEG style, directly using uniform parameters to discriminate features can easily affect the consistency and stability of the recognition results. Therefore, how to adaptively compensate for style differences in EEG samples without relying on additional individual label information is also a problem that needs further investigation.

[0010] Based on the aforementioned problems, there is an urgent need to design a method for identifying depression using EEG signals. This method should be able to simultaneously extract local temporal features, enhance attention to key features, model global dependencies, and perform robust training with small samples, thereby achieving efficient modeling of complex EEG features. Furthermore, considering the needs of practical mental health screening scenarios, this method should also possess good generalization ability and stability. Therefore, integrating the advantages of convolutional neural networks, attention mechanisms, and sequence coding to construct a deep learning model is of significant importance for improving the accuracy, robustness, and engineering application value of depression state identification. Summary of the Invention

[0011] To address the problems existing in the prior art, this invention aims to propose a method and system for classifying EEG signals of depression based on multi-scale convolution and Transformer. This method solves the problems of insufficient extraction of local temporal discriminative features, insufficient enhancement of key EEG features, insufficient modeling of global dependencies, difficulty in compensating for individual style differences between different EEG samples, and weak training stability and generalization ability under small sample conditions in existing EEG depression recognition methods.

[0012] This invention proposes a joint modeling scheme for EEG signal depression recognition tasks. By constructing a multi-scale feature extraction structure, a convolutional block attention enhancement structure, and a sequence coding structure, it achieves local temporal feature extraction, key feature enhancement, and global dependency modeling of EEG signals. Preferably, an individual style adaptive modulation module is also introduced to adaptively adjust the high-level features output by the sequence coding module, compensating for signal distribution differences between different EEG samples. Simultaneously, during training, mechanisms such as segmented reconstruction data augmentation, weighted loss, label smoothing, gradient pruning, and early stopping strategies are incorporated to ensure recognition performance under small sample conditions, training stability, and generalization ability.

[0013] To achieve the above objectives, the present invention provides the following technical solution.

[0014] Firstly, this invention discloses a method for classifying electroencephalogram (EEG) signals in depression based on multi-scale convolution and Transformer, comprising the following steps:

[0015] Step S1: Data Acquisition and Preprocessing: Collect raw multi-channel EEG signal data from the subjects, construct an EEG sample dataset, and preprocess the EEG sample data to obtain time-series tensor data in a unified format.

[0016] S2 Multi-scale Feature Extraction and Attention Enhancement: The temporal tensor is input into the multi-scale feature extraction module. The multi-scale feature extraction module captures high-frequency transient features, mid-frequency time-scale features and low-frequency trend features through convolutional kernels of different scales and performs fusion and compression. The fused EEG features are then input into the convolutional block attention enhancement module for channel attention weighting and spatial attention weighting to obtain dual attention-enhanced EEG features.

[0017] S3 Global Dependency Modeling: The enhanced EEG feature sequence vector is input into the Transformer encoder module, and the global dependency relationship of different slice positions in the feature sequence is calculated layer by layer through the multi-head self-attention mechanism to obtain the global representation features;

[0018] S4 Individual Style Adaptive Modulation: Based on the original multi-channel EEG signal, temporal statistical features are extracted by channel, and the temporal statistical features are input into the style coding network to generate scaling and offset parameters that match the output features of the Transformer encoder; the scaling and offset parameters are used to perform sample-level adaptive modulation on the high-level EEG features output by the Transformer encoder to obtain high-level EEG features after individual style compensation, so as to reduce the influence of differences in the distribution of EEG signals of different subjects on the classification results;

[0019] S5 Classification Output: The modulated high-level features are classified and output to obtain the binary classification recognition result of the depressive state corresponding to the EEG sample.

[0020] Furthermore, the multi-scale feature extraction module in step 2 includes multiple parallel convolutional branches. The specific process is as follows: each branch uses convolutional kernels of different sizes to perform convolution along the time dimension, and each branch connects the batch normalization layer, the non-linear activation layer, and the pooling layer.

[0021] The output features of each parallel branch are concatenated and fused along the channel dimension, and the fused EEG features are input into the convolutional block attention module, which includes a channel attention submodule and a spatial attention submodule. The channel attention submodule performs global average pooling and global max pooling on the input feature map, respectively. The pooling results are then passed through a shared fully connected network and summed element-wise. An activation function is then used to generate channel attention weights. The channel attention weights are multiplied element-wise with the input feature map to obtain the channel-enhanced features.

[0022] The spatial attention submodule performs average pooling and max pooling on the channel enhancement features along the channel dimension, respectively. The pooling results are then concatenated and processed by a convolutional layer and activation function to obtain dual attention-enhanced EEG features.

[0023] The enhanced EEG feature data is mapped and transformed into a feature sequence vector suitable for Transformer processing through projection operations.

[0024] Furthermore, in step 4, the Transformer sequence encoding module performs global dependency modeling on the enhanced feature sequence and introduces an individual style adaptive modulation process at the output, specifically including:

[0025] The feature sequence is input into the Transformer encoder, and global representation features of the sequence are extracted through multi-head self-attention sublayer and feedforward network layer;

[0026] The raw EEG signals of the subject are acquired, and a time-domain statistical feature vector is calculated based on the raw EEG signals;

[0027] The temporal statistical feature vector is mapped to a sample style code using an encoding network, and feature scaling parameters and feature offset parameters are generated based on the sample style code.

[0028] The high-level features output by the Transformer encoder are adaptively modulated using the feature scaling parameters and the feature offset parameters to reduce the influence of individual differences between different EEG samples.

[0029] Furthermore, step 5, which involves classifying and outputting the modulated high-level features, specifically includes:

[0030] Global average pooling is performed on the modulated high-level features to obtain the global feature vector;

[0031] The global feature vector is subjected to layer normalization.

[0032] The normalized features are input into a multi-layer fully connected classification network to obtain the final depression classification output vector.

[0033] Furthermore, during the model training phase, a weighted cross-entropy loss function is used as the loss calculation method, and the AdamW optimizer with gradient pruning mechanism is used for parameter updates. At the same time, an early stopping control mechanism is set up so that the current training process is stopped when the validation set loss fails to improve within a preset number of consecutive rounds, and the model parameters with the best performance on the validation set are retained.

[0034] Furthermore, the model training phase also includes a segmented reconstruction data augmentation step: the time axis of each EEG sample is divided into S segments; for samples of the same category in the training set, time segments at corresponding positions are randomly selected from different samples and reassembled to generate new augmented samples; the loss of the augmented samples is added to the total training loss with preset weight coefficients for joint optimization.

[0035] Furthermore, during the training process, the model is optimized by employing class-weighted cross-entropy loss function, label smoothing, segmented reconstruction data augmentation, learning rate scheduling, gradient pruning, and early stopping mechanisms to improve the model's robustness and generalization ability.

[0036] Secondly, this invention discloses a depression EEG signal classification system based on multi-scale convolution and Transformer, used to implement the aforementioned depression EEG signal classification method, including:

[0037] The data acquisition and preprocessing module is used to acquire raw EEG signal data from subjects, preprocess it, and output standardized EEG samples; at the same time, it preprocesses the standardized EEG samples to obtain time-series tensor data in a unified format.

[0038] The feature enhancement module includes a multi-scale feature extraction module and an attention enhancement module. The multi-scale feature extraction module is used to extract the multi-scale features of the temporal tensor and perform fusion and compression. The attention enhancement module enhances the fused EEG feature channels and spatial attention, and outputs dual attention-enhanced EEG features.

[0039] The sequence encoding module, which is a Transformer encoder consisting of a projection layer and multiple encoder blocks, projects dual attention-enhanced EEG features into feature sequences and inputs them into the Transformer encoder module. Multi-head self-attention mechanism and residual connections are used for modeling to collect global representation features.

[0040] The individual style adaptive modulation module is used to extract channel statistical features from the raw EEG signal and encode them into sample style vectors, and adaptively adjust the high-level features of the sequence coding module.

[0041] The classification output module classifies and maps the global representation features, and finally outputs the depression recognition and discrimination result corresponding to the EEG signal through mechanisms such as global pooling, normalization and multi-layer fully connected mapping.

[0042] The training optimization module is used for segmented data augmentation during model training. It employs mechanisms such as class-weighted cross-entropy loss, label smoothing, segmented data augmentation, learning rate scheduling, gradient pruning, and early stopping control to improve the robustness and generalization ability of the model.

[0043] Furthermore, the multi-scale feature extraction module includes three parallel branches: a fine-grained branch, using a first convolutional kernel of a first size, for capturing short-term transient features related to high-frequency EEG rhythms; a medium-grained branch, using a second convolutional kernel of a second size, for capturing medium-time-scale features related to mid-frequency EEG rhythms; and a coarse-grained branch, using a third convolutional kernel of a third size, for capturing long-time-scale trend features related to low-frequency EEG rhythms. The outputs of the three parallel branches are concatenated along the channel dimension to obtain a fused feature map, and the fused feature map is input to the convolutional block attention enhancement module.

[0044] The attention enhancement module includes a channel attention submodule and a spatial attention submodule connected in series.

[0045] The channel attention submodule generates channel weights based on global average pooling and global max pooling.

[0046] The spatial attention submodule generates a spatial attention graph based on channel-dimensional pooling operations;

[0047] Furthermore, in the sequence encoding module, the Transformer encoder module contains multiple Transformer encoder blocks connected in series. Each encoder block consists of a multi-head self-attention sub-layer and a feedforward neural network sub-layer, and the sub-layers are connected to each other through residual connections and layer normalization operations.

[0048] Furthermore, the classification output module employs a multi-layer fully connected network with at least two layers, and introduces a Dropout layer in the middle hidden layer to prevent model overfitting, so that the dimension of the final output layer is consistent with the number of categories, in order to output the classification result of the target category.

[0049] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0050] 1. This invention innovatively proposes an individual style adaptive modulation mechanism, effectively eliminating significant individual differences in EEG signals. Addressing the issues of low signal-to-noise ratio and large inter-subject variability in EEG signals leading to poor model robustness, this invention introduces an individual style adaptive modulation process after the sequence encoding module. This method requires no additional individual label information; it only utilizes the temporal statistical features of the original EEG signals (such as mean and standard deviation) to generate scaling and offset parameters, adaptively adjusting high-level features. This mechanism achieves "style compensation" for differences in signal distribution among different subjects, aligning the sample distribution without altering semantic information, and significantly improving the model's recognition consistency and stability across different subject scenarios.

[0051] 2. Multi-scale parallel convolution and attention mechanism work together to solve the problems of coarse local feature extraction and the burying of key information.

[0052] To address the challenge of existing technologies in capturing microvolt-level waveform fluctuations and short-term transient changes, this invention designs a multi-scale parallel convolutional feature extraction structure. Utilizing convolutional kernels at different time scales, it captures high-frequency transients, mid-frequency temporal sequences, and low-frequency trend features, achieving comprehensive extraction of fine-grained local patterns in EEG signals. Simultaneously, by incorporating a block convolutional attention module (CBAM), the fused features are weighted in both channel and spatial dimensions. This adaptively enhances the feature responses of key brain regions closely related to depressive states, such as the frontal and parietal lobes, as well as key time segments. This effectively suppresses background noise interference and significantly improves the model's ability to extract effective discriminative information.

[0053] 3. By introducing Transformer global dependency modeling, this invention overcomes the limitations of traditional CNNs in long-range temporal correlation mining. Addressing the difficulty of existing convolutional neural networks in simultaneously capturing local details and global contextual information, this invention maps enhanced EEG features into sequence vectors and inputs them into the Transformer encoder module. Utilizing a multi-head self-attention mechanism, the model can overcome the limitations of local receptive fields and calculate the dependencies between different time slice locations from a global perspective. This deep integration of local feature extraction and global dependency modeling enables the model to not only perceive instantaneous EEG changes but also capture dynamic evolution patterns across time scales, thereby more accurately representing the complex spatiotemporal topology of EEG in patients with depression.

[0054] 4. A multi-layered robust training strategy system was constructed to address the overfitting and insufficient generalization capabilities under small sample conditions. To address the overfitting problem caused by the high cost of EEG data acquisition and small sample size, this invention integrates segmented data augmentation, class-weighted cross-entropy loss, label smoothing, learning rate scheduling, gradient pruning, and early stopping strategies during the training process. The synergistic effect of this entire robust optimization strategy effectively expands the diversity of training data, balances the class distribution, and standardizes the optimization process, thereby significantly improving the model's training stability under limited sample conditions and enhancing its generalization ability on unknown data.

[0055] 5. This invention achieves objective, automated, and efficient screening for depressive states, possessing high clinical application value. It abandons the subjective reliance on traditional scale assessments and clinical consultations, establishing an end-to-end intelligent EEG signal analysis framework. This method can automatically complete the entire process from raw signal processing and deep feature extraction to state classification, not only avoiding human experience bias but also significantly shortening screening time. It can meet the practical needs of large-scale, rapid mental health screening, providing objective and quantitative biomarker support for the auxiliary diagnosis of depression.

[0056] This invention addresses the problems of feature overload, poor targeting, and small-sample overfitting caused by directly applying general deep learning models in existing EEG depression recognition methods, as well as issues such as insufficient local dynamic feature modeling, low utilization of key brain region response information, and inadequate global temporal correlation mining. It integrates deep convolutional feature extraction, channel-space joint attention enhancement, and Transformer global dependency modeling to construct a multi-level integrated network for feature enhancement and temporal modeling. Combined with data augmentation and robust optimization strategies, it achieves an overall improvement in recognition performance, generalization ability, and engineering stability. Attached Figure Description

[0057] To make the objectives, technical solutions, and advantages of the invention clearer, the invention will now be described in further detail with reference to the accompanying drawings, wherein:

[0058] Figure 1 A flowchart of a depression EEG signal classification system based on multi-scale convolution and Transformer;

[0059] Figure 2 A structural diagram of a depression EEG signal classification method based on multi-scale convolution and Transformer;

[0060] Figure 3 Flowchart of an algorithm for classifying EEG signals of depression based on multi-scale convolution and Transformer;

[0061] Figure 4 Training optimization strategy diagram for a depression EEG signal classification method based on multi-scale convolution and Transformer. Detailed Implementation

[0062] The present invention will now be described in further detail with reference to the accompanying drawings. The technical solutions in the embodiments of the present invention will be clearly and completely described. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0063] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments, but the implementation of the present invention is not limited thereto.

[0064] Example 1: This example provides a method for classifying EEG signals in depression based on multi-scale convolution and Transformer. The specific steps are as follows:

[0065] Step S1: Data Acquisition and Preprocessing

[0066] This invention collects raw electroencephalogram (EEG) signal data from subjects and uses this data to initially construct an EEG dataset.

[0067] In this embodiment, the number of channels in the EEG sample is 19, adopting the international 10-20 system electrode distribution standard. Data from 19 channels (Fp1, Fp2, F3, F4, C3, C4, P3, P4, O1, O2, F7, F8, T3, T4, T5, T6, Fz, Cz, Pz) are preferentially selected from the original signal. When the number of channels in the original file is less than 19, it is padded to the target number according to the recording order. A fixed time length of 1000 sampling points is used for each sample, ultimately constructing an EEG sample dataset of shape (N, 19, 1000), where the healthy control group (H) is marked as 0 and the depression patient group (MMD) is marked as 1. This sample is used in subsequent training experiments.

[0068] Step S1.2: Data Preprocessing

[0069] In this embodiment, the collected EEG sample data is subjected to sample dimension expansion processing to meet the requirements of four-dimensional tensor input, and a height dimension is added, with 1 as the value.

[0070] Step S1.3: Dataset partitioning

[0071] In this embodiment, the EEG sample data is partitioned using a hierarchical k-fold cross-validation strategy. The data is divided into k=10 non-overlapping subsets, and within each fold, the sample data is further divided into a training set, a validation set, and a test set. The training set, validation set, and test set account for approximately 81%, 9%, and 10% of the total data, respectively.

[0072] Step S1.4: Standardize on a sample-by-sample basis

[0073] The sample-by-sample standardization process in this embodiment includes: applying Z-score normalization to each independent sample in the training set, validation set, and test set, calculating the mean and standard deviation respectively, and then performing normalization processing as follows:

[0074]

[0075] in,

[0076] For the original sample,

[0077] This is the mean of the sample.

[0078] This is the standard deviation of the sample.

[0079] To prevent smoothing constants with a denominator of zero.

[0080] Step S2: Multi-scale feature extraction and attention enhancement

[0081] S2.1 The temporal tensor is input into the multi-scale feature extraction module, which includes three parallel branches:

[0082] Fine-grained branch: A convolutional layer with a kernel size of (1,3) is used, filled with (0,1), with 32 output channels, and connected to a batch normalization layer, a GELU activation layer and a (1,4) max pooling layer to capture short-term transient features related to high-frequency EEG rhythms;

[0083] Medium-grained branch: A convolutional layer with a kernel size of (1,7) is used, filled with (0,3), with 32 output channels, and connected to a batch normalization layer, a GELU activation layer and a (1,4) max pooling layer to capture medium-time-scale features related to mid-frequency EEG rhythms.

[0084] Coarse-grained branch: A convolutional layer with a kernel size of (1,15) is used, filled with (0,7), and has 32 output channels. It is connected to a batch normalization layer, a GELU activation layer, and a (1,4) max pooling layer to capture long-term trend features related to low-frequency EEG rhythms.

[0085] The outputs of the three parallel branches are concatenated along the channel dimension to obtain a fused feature map with 96 channels. The concatenated feature map is then enhanced with joint channel and spatial attention by a Convolutional Block Attention (CBAM) module.

[0086] The system then performs dimensionality compression using two layers of compressed convolutions: the first layer has 96 input channels and 64 output channels, with a kernel size of (1,5), a stride of (1,2), padding of (0,2), and max pooling at (1,2); the second layer has 64 input channels and 32 output channels, with a kernel size of (1,3), a stride of (1,2), padding of (0,1), and max pooling at (1,2). After the compressed convolutions, a dropout operation with a dropout rate of 25% is performed, ultimately mapping the number of channels to a target embedding dimension of 40, and then converting it into a feature sequence of shape (B,L,40) through tensor rearrangement.

[0087] S2.2: In convolutional block attention module (CBAM) is introduced into convolutional feature extraction. Channel attention submodule and spatial attention submodule are used to enhance EEG features, highlighting effective features related to depression identification through attention enhancement methods.

[0088] Step S2.2.1 Channel attention submodule performs global average pooling and global max pooling on the input feature map respectively.

[0089] For the processed result and In this embodiment, both are passed through a shared two-layer fully connected network, with ReLU chosen as the intermediate activation function. The outputs of both are summed element-wise, and then channel attention weights are generated using the Sigmoid function. .Will The channel-enhanced features are obtained by multiplying them element-wise with the input feature map. .

[0090] Step S2.2.2: Spatial Attention Submodule

[0091] For the channel enhancement feature F' obtained in step S2.2.1, this embodiment performs average pooling and max pooling processing along the channel dimension respectively.

[0092] For the processed result and, after splicing the two together After passing through a 7x7 convolutional layer with a sigmoid function, dual attention-enhanced features are obtained.

[0093] After processing steps s4.1 and s4.2, the model can focus on the central and key time segments in the EEG sample data, realizing the channel-spatial attention mechanism.

[0094] Step S3 Global Dependency Modeling:

[0095] The feature sequence is input into the Transformer encoder, and global representation features of the sequence are extracted through multi-head self-attention sublayer and feedforward network layer;

[0096] Step S3.1 Multi-head self-attention sublayer

[0097] This embodiment will input sequence The query matrix is ​​obtained by using three linear transformation matrices respectively. Key matrix Sum matrix And will , , The attention heads are divided into h=5 along the embedding dimension.

[0098] The scaling point attention is calculated separately in each attention head, specifically as follows:

[0099]

[0100] in:

[0101] : Represents the global representation feature matrix output after computation by the self-attention mechanism.

[0102] : Represents the query matrix, which is generated by linear transformation of the input features and is used to find other positions of interest in the sequence.

[0103] : Represents the key matrix, which represents the identifying features of each position in the sequence.

[0104] : Represents the value matrix, which represents the actual content features of each position in the sequence.

[0105] : Represents the key matrix The transpose of .

[0106] :express and The matrix dot product is used to calculate the correlation score in the sequence.

[0107] : Indicates the target embedding dimension of the feature sequence.

[0108] : Represents the square root of the embedding dimension

[0109] : Represents the normalized exponential function

[0110] Step S3.2 Feedforward Network Layer

[0111] In this embodiment, the feedforward network layer consists of two fully connected layers, with the intermediate hidden layer having a dimension of 4×. =160, using the GELU activation function, with Dropout applied in between. Sub-layers first undergo layer normalization, then perform sub-layer operations, and finally add the input and output through residual connections to ensure model stability.

[0112] Step S4 Individual Style Adaptive Modulation

[0113] In this embodiment, to mitigate the impact of significant differences in channel mean, fluctuation intensity, and overall distribution of EEG signals from different subjects on the recognition results, an individual style adaptive modulation process is introduced after the sequence coding module outputs the data. Specifically, firstly, the temporal mean and standard deviation of the original EEG signals are calculated for each channel, and the resulting sample feature vectors are processed. The statistical feature vectors are then mapped to sample style codes through an encoding network. Based on the sample style codes, feature scaling parameters and offset parameters are generated, and the high-level features output by the sequence coding module are adjusted.

[0114] Its expression can be written as:

[0115] in: This represents the high-level features output by the sequence coding module; This indicates high-level characteristics after individual style modulation. This represents the feature scaling parameter generated by the sample style encoding; This represents the feature offset parameter generated by the sample style encoding; This indicates an element-wise multiplication operation.

[0116] Step S5: Classify and output

[0117] Step S5.1 Perform global average pooling on the modulated high-level features to obtain the global feature vector.

[0118]

[0119] in: Represents the global feature vector; Indicates the length of the feature sequence; This represents the feature vector corresponding to the location.

[0120] s6.2 Perform layer normalization on the global feature vector.

[0121]

[0122] in: This represents the normalized eigenvectors; The normalization operation is represented in step s6.3. The normalized features are then input into a multi-layer fully connected classification network to obtain the final depression classification output vector.

[0123]

[0124]

[0125]

[0126] in: This represents the final classification output vector; Represents the weight matrix; Indicates the bias term;

[0127] Indicates the activation function; Indicates random deactivation operation

[0128] Model training optimization strategy

[0129] During the model training phase, a weighted cross-entropy loss function is used as the loss calculation method:

[0130]

[0131] in: This represents the value of the weighted cross-entropy loss function; Indicates the first The category weight corresponding to the class; Indicates the first The sample at the th Smooth label values ​​on the class; Indicates the first The sample was predicted as the first... The probability of a class;

[0132] The model training phase also includes segmented reconstruction data augmentation, with the following steps:

[0133] In this embodiment, the timeline of each EEG sample is divided into S=8 segments, and each segment has a length of T / S=125 sampling points. For samples of the same category in the training set, time segments at corresponding positions are randomly selected from different samples and reassembled to generate new enhanced samples. The loss of the enhanced samples is added to the total training loss with a weight coefficient of 0.5.

[0134] Optimizer

[0135] This embodiment uses the AdamW optimizer with gradient pruning mechanism for parameter updates, with an initial learning rate of 2×10⁻. 4 β1=0.9, β2=0.999, and the weight decay coefficient is 0.01.

[0136] The gradients of all parameters during the backpropagation process are clipped to ensure they do not exceed 1.0.

[0137] At the same time, an early shutdown control mechanism is set up.

[0138] This embodiment sets up an early stopping control mechanism: if the validation set loss fails to improve within 15 consecutive rounds, the current training process is stopped, and the model parameters with the best performance on the validation set are retained. These parameters are then used as the final model for evaluation on the test set to suppress model overfitting.

[0139] Experimental verification

[0140] In this embodiment, a 10-fold cross-validation was performed using an EEG dataset comprising 86 healthy controls and 95 patients with depression. Each fold test set contained approximately 17-19 samples. Early stopping was employed during model training, and the corresponding model parameters were retained for test set evaluation when the validation set performance was optimal. Experimental results for each fold showed that the method of this invention achieved an average test accuracy of 85.75% under 10-fold cross-validation. Statistical analysis of the fold results showed an average F1 score of approximately 0.874 and an average Cohen's Kappa coefficient of approximately 0.709.

[0141] Example 2: A Classification System for Electroencephalogram (EEG) Signals of Depression

[0142] As shown in the figure, this embodiment provides a brainwave signal classification system for depression, including the following modules.

[0143] The data acquisition and preprocessing module is used to acquire raw multi-channel EEG signals from the subject from the EEG acquisition device, and extract EEG sequence data of target channels (preferably 19 channels in this embodiment) according to preset international standards (such as the 10-20 system standard), and output standardized EEG samples; at the same time, it performs preprocessing on the standardized EEG samples; it is used to perform dimensionality expansion, K-fold cross-validation set partitioning and sample-by-sample Z-score standardization, and output temporal tensor data in a unified format adapted to the input of convolutional networks.

[0144] The feature enhancement module includes a multi-scale feature extraction module and an attention enhancement module. The multi-scale feature extraction module is used to extract the multi-scale features of the temporal tensor and perform fusion and compression. The attention enhancement module enhances the fused EEG feature channels and spatial attention, and outputs dual attention-enhanced EEG features.

[0145] The sequence encoding module, which is a Transformer encoder consisting of a projection layer and multiple encoder blocks, projects dual attention-enhanced EEG features into feature sequences and inputs them into the Transformer encoder module. Multi-head self-attention mechanism and residual connections are used for modeling to collect global representation features.

[0146] The individual style adaptive modulation module is used to extract channel statistical features from the raw EEG signal and encode them into sample style vectors, and adaptively adjust the high-level features of the sequence coding module.

[0147] The classification output module classifies and maps the global representation features, and finally outputs the depression recognition and discrimination result corresponding to the EEG signal through mechanisms such as global pooling, normalization and multi-layer fully connected mapping.

[0148] The training optimization module is used for segmented data augmentation during model training. It employs mechanisms such as class-weighted cross-entropy loss, label smoothing, segmented data augmentation, learning rate scheduling, gradient pruning, and early stopping control to improve the robustness and generalization ability of the model.

[0149] To preliminarily verify the effectiveness of the individual style adaptive modulation module, this embodiment conducted an ablation comparison experiment under the conditions of fixed random seeds and the same training parameters.

[0150] index No module (mean ± std) There is a module (mean ± std). promote Accuracy 0.7900±0.0978 0.8222±0.0925 +3.22% F1 0.7980±0.1174 0.8526±0.0809 +5.46% AUC 0.8595±0.1267 0.8917±0.0574 +3.22% Kappa 0.5715±0.1955 0.6322±0.1848 +6.07%

[0151] Experimental results show that this module can improve the model's ability to adapt to differences in the distribution of EEG signals among different subjects, and improve the accuracy and stability of depressive state identification.

[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described with reference to preferred embodiments, those skilled in the art should understand that various changes in form and detail can be made. All obvious changes derived from the technical solutions of the present invention are still within the scope of protection of the present invention.

Claims

1. A method for classifying EEG signals in depression based on multi-scale convolution and Transformer, characterized in that, include: S1 Data Acquisition and Preprocessing: Collect raw multi-channel EEG signal data from the subjects, construct an EEG sample dataset, and preprocess the EEG sample data to obtain time-series tensor data in a unified format. S2 Multi-scale Feature Extraction and Attention Enhancement: The temporal tensor is input into the multi-scale feature extraction module. The multi-scale feature extraction module captures high-frequency transient features, mid-frequency time-scale features and low-frequency trend features through convolutional kernels of different scales and performs fusion and compression. The fused EEG features are then input into the convolutional block attention enhancement module for channel attention weighting and spatial attention weighting to obtain dual attention-enhanced EEG features. S3 Global Dependency Modeling: The enhanced EEG feature sequence vector is input into the Transformer encoder module, and the global dependency relationship of different slice positions in the feature sequence is calculated layer by layer through the multi-head self-attention mechanism to obtain the global representation features; S4 Individual Style Adaptive Modulation: Based on the original multi-channel EEG signal, temporal statistical features are extracted by channel, and the temporal statistical features are input into the style coding network to generate scaling and offset parameters that match the output features of the Transformer encoder; the scaling and offset parameters are used to perform sample-level adaptive modulation on the high-level EEG features output by the Transformer encoder to obtain high-level EEG features after individual style compensation, so as to reduce the influence of differences in the distribution of EEG signals among different subjects on the classification results; S5 Classification Output: The modulated high-level features are classified and output to obtain the binary classification recognition result of the depression state corresponding to the EEG sample.

2. The method according to claim 1, characterized in that, The multi-scale feature extraction module includes multiple parallel convolutional branches. The specific process is as follows: each branch uses convolutional kernels of different sizes to perform convolution along the time dimension, and each branch is connected to a batch normalization layer, a non-linear activation layer, and a pooling layer. The output features of each parallel branch are concatenated and fused along the channel dimension, and the fused EEG features are input into the convolutional block attention module. The convolutional block attention module includes a channel attention submodule and a spatial attention submodule. The channel attention submodule performs global average pooling and global max pooling on the input feature map respectively. The pooling results are added element by element through a shared fully connected network and then activated by an activation function to generate channel attention weights. The channel attention weights are multiplied element by element with the input feature map to obtain the channel enhancement features. The spatial attention submodule performs average pooling and max pooling on the channel enhancement features along the channel dimension, respectively. The pooling results are concatenated and then processed by a convolutional layer and activation function to obtain dual attention-enhanced EEG features. The enhanced EEG feature data is mapped and transformed into a feature sequence vector suitable for Transformer processing through projection operations.

3. The method according to claim 2, characterized in that, The Transformer sequence encoding module performs global dependency modeling on the enhanced feature sequence and introduces an individual style adaptive modulation process at the output, specifically including: The feature sequence is input into the Transformer encoder, and global representation features of the sequence are extracted through multi-head self-attention sublayer and feedforward network layer; The raw EEG signals of the subject are acquired, and a time-domain statistical feature vector is calculated based on the raw EEG signals; The temporal statistical feature vector is mapped to a sample style code using an encoding network, and feature scaling parameters and feature offset parameters are generated based on the sample style code. The high-level features output by the Transformer encoder are adaptively modulated using the feature scaling parameters and the feature offset parameters to reduce the influence of individual differences between different EEG samples.

4. The method according to claim 1, wherein classifying and outputting the modulated high-level features specifically includes: Global average pooling is performed on the modulated high-level features to obtain the global feature vector; The global feature vector is subjected to layer normalization. The normalized features are input into a multi-layer fully connected classification network to obtain the final depression classification output vector.

5. The method according to claim 1, characterized in that, During the model training phase, a weighted cross-entropy loss function is used as the loss calculation method, and the AdamW optimizer with gradient pruning mechanism is used for parameter updates. At the same time, an early stopping control mechanism is set up so that the current training process is stopped when the validation set loss fails to improve within a preset number of consecutive rounds, and the model parameters with the best performance on the validation set are retained.

6. The method according to claim 5, characterized in that, The model training phase also includes a segmented reconstruction data augmentation step: the time axis of each EEG sample is divided into S segments; for samples of the same category in the training set, time segments at corresponding positions are randomly selected from different samples and reassembled to generate new augmented samples; the loss of the augmented samples is added to the total training loss with preset weight coefficients for joint optimization.

7. A classification system for EEG signals of depression based on multi-scale convolution and Transformer, characterized in that, To implement the method of any one of claims 1-6, comprising: The data acquisition and preprocessing module is used to acquire raw EEG signal data from subjects, preprocess it, and output standardized EEG samples; at the same time, it preprocesses the standardized EEG samples to obtain time-series tensor data in a unified format. The feature enhancement module includes a multi-scale feature extraction module and an attention enhancement module. The multi-scale feature extraction module is used to extract the multi-scale features of the temporal tensor and perform fusion and compression. The attention enhancement module enhances the fused EEG feature channels and spatial attention, and outputs dual attention-enhanced EEG features. The sequence encoding module, which is a Transformer encoder consisting of a projection layer and multiple encoder blocks, projects dual attention-enhanced EEG features into feature sequences and inputs them into the Transformer encoder module. Multi-head self-attention mechanism and residual connections are used for modeling to collect global representation features. The individual style adaptive modulation module is used to extract channel statistical features from the raw EEG signal and encode them into sample style vectors, and adaptively adjust the high-level features of the sequence coding module. The classification output module classifies and maps the global representation features, and finally outputs the depression recognition and discrimination result corresponding to the EEG signal through mechanisms such as global pooling, normalization and multi-layer fully connected mapping. The training optimization module is used for segmented data augmentation during model training. It employs mechanisms such as class-weighted cross-entropy loss, label smoothing, segmented data augmentation, learning rate scheduling, gradient pruning, and early stopping control to improve the robustness and generalization ability of the model.

8. The system according to claim 7, characterized in that, The multi-scale feature extraction module includes three parallel branches: a fine-grained branch, which uses a first convolutional kernel of the first size to capture short-term transient features related to high-frequency EEG rhythms; The medium-grained branch uses a second-size second convolutional kernel to capture medium-time-scale features associated with mid-frequency EEG rhythms; the coarse-grained branch uses a third-size third convolutional kernel to capture long-time-scale trend features associated with low-frequency EEG rhythms. The outputs of the three parallel branches are concatenated along the channel dimension to obtain a fused feature map, which is then input into the convolutional block attention enhancement module. The attention enhancement module includes a channel attention submodule and a spatial attention submodule connected in series. The channel attention submodule generates channel weights based on global average pooling and global max pooling. The spatial attention submodule generates a spatial attention graph based on channel-dimensional pooling operations.

9. The system according to claim 7, characterized in that, The Transformer encoder module in S3 contains multiple Transformer encoder blocks connected in series. Each encoder block consists of a multi-head self-attention sub-layer and a feedforward neural network sub-layer, and the sub-layers are connected to each other through residual connections and layer normalization operations.

10. The system according to claim 7, characterized in that, The classification output module employs a multi-layer fully connected network with at least two layers, and introduces a Dropout layer in the middle hidden layer to prevent model overfitting, so that the dimension of the final output layer is consistent with the number of categories, in order to output the classification result of the target category.