Electroencephalogram signal classification method based on comparative learning
By combining the dual contrast learning methods of SeqCLR and DomCLR, the problems of dependence on labeled data, complexity of feature engineering and poor adaptability in individual differences in EEG signal classification are solved, and efficient feature extraction and privacy protection are achieved.
Patent Information
- Application Number
- CN202411481595.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-02-11
AI Technical Summary
The existing EEG signal classification method relies on a large number of labeled data, has complex feature engineering requirements, and is poorly adaptable to individual differences, which has privacy protection problems.
Using a dual contrast learning method combining sequence contrast representation learning (SeqCLR) and domain contrast learning (DomCLR), the self-supervised learning and semi-supervised learning reduces dependence on labeled data, automatically extracts features, enhances the ability to adapt to individual differences, and Effectively protect privacy.
It significantly reduces the need for labeled data, simplifies the feature engineering process, improves adaptability to individual differences, and enhances privacy protection, suitable for privacy-sensitive application scenarios.
Smart Images

Figure CN119415953A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of machine learning and signal processing, and in particular to an electroencephalogram signal classification method based on contrast learning. Background Art
[0002] Electroencephalography (EEG) is a technique that records the brain's electrical activity by placing electrodes on the scalp. EEG can capture the brain's electrical signals, which are widely used in neuroscience, clinical diagnosis, and Brain-Computer Interface (BCI) systems. Motor imagery (MI) refers to activating brain areas associated with a specific movement by imagining performing the movement in the mind without actually performing the movement. This technology is used to decode the user's intentions in order to control external devices, for example, to help people with movement disorders improve their quality of life. The application of motor imagery in BCI systems has important potential to improve the accuracy of the system and provide innovative solutions.
[0003] Traditional motor imagery decoding methods mainly rely on manual feature extraction and classical classifiers. The process of these methods includes preprocessing the EEG signal to improve the signal quality, then extracting features from the processed signal, and then using classical classifiers such as Support Vector Machine (SVM) or Linear Discriminant Analysis (LDA) for feature selection and classification. Although these methods are effective in some cases, they face many challenges in processing complex EEG signals due to the need for large amounts of labeled data and complex feature engineering. These challenges include the complexity of feature engineering and poor adaptability to different individuals.
[0004] In recent years, deep learning techniques have made significant progress in motor imagery decoding. Deep learning methods can automatically extract and classify features from raw EEG signals, reducing the need for manual feature design. Common deep learning architectures include Convolutional Neural Networks (CNNs) and Recurrent Neural Networks (RNNs). These networks automatically learn feature representations through multiple layers of nonlinear transformations, thereby improving classification performance. However, these methods are still highly dependent on a large amount of labeled data, which may raise privacy issues in practical applications and do not work well for the variability of EEG signals across individuals.
[0005] Among the existing contrastive learning techniques, contrastive learning is a method of learning feature representation by comparing the similarities and differences between samples. There are currently some related contrastive learning techniques, such as SimCLR and MoCo, which are mainly used in computer vision tasks. SimCLR is a self-supervised learning method that optimizes the encoder by generating data augmentation samples and comparing their feature representations. SimCLR uses a contrastive loss function to minimize the distance between different enhanced versions of the same image while maximizing the distance between different images to learn effective feature representations. MoCo improves the stability of contrastive learning by maintaining a dynamic negative sample library, and uses momentum encoders and contrast libraries to optimize feature representations.
[0006] Although these contrastive learning techniques have performed well in computer vision tasks, their application in EEG signal processing is still in the development stage. Existing methods mainly target image data, and the processing effect and applicability of EEG signals still need further exploration. Therefore, the SeqCLR and DomCLR algorithms of the present invention show better performance in processing EEG signals. By combining time series contrastive learning and instance contrastive learning, the limitations of traditional methods are overcome, and the quality of feature representation and the adaptability to individual differences are improved.
[0007] The above prior art has the following disadvantages:
[0008] 1. Dependence on labeled data: Traditional motor imagery decoding methods usually rely on a large amount of labeled data for training. These methods include manual feature extraction and classical classifiers such as support vector machines (SVM) and linear discriminant analysis (LDA). These techniques require manual labeling of a large number of EEG signals, which is a complex and time-consuming process. Since the process of obtaining labeled data is cumbersome and costly, this limits the promotion and popularization of these methods in practical applications.
[0009] 2. Complex feature engineering: The feature extraction and selection process in traditional methods often requires deep domain knowledge and experience. These steps involve multiple stages, including preprocessing, feature calculation and selection, and each stage may introduce human factors and errors, thus affecting the final classification effect. Complex feature engineering not only increases the difficulty of processing, but also makes these methods less adaptable to different individuals and tasks.
[0010] 3. Poor adaptability to different individuals: Although deep learning techniques can automatically extract features from raw EEG signals, these techniques still rely on a large amount of labeled data and perform poorly in the face of individual differences. EEG signals have large variability between different individuals, which may affect the performance of deep learning-based models when generalizing to new individuals, especially in the absence of sufficient labeled data.
[0011] 4. Privacy issues: Deep learning methods require a large amount of labeled data for training, which may cause privacy issues. EEG signals are sensitive data that involves personal privacy, and privacy protection measures need to be in place when processing these data. Traditional labeled data-driven learning methods have failed to adequately address this issue, limiting their application in privacy-sensitive environments.
[0012] The root cause of these shortcomings lies in the high reliance of existing technologies on labeled data when processing EEG signals, complex feature engineering requirements, and insufficient adaptability to individual differences. These problems have led to challenges in the practical application of existing technologies, and new methods are urgently needed to overcome these limitations.
[0013] The present invention aims to solve two key technical problems in the classification of electroencephalography (EEG) signals: how to improve the generalization ability of the model and how to protect data privacy. Traditional brain-computer interface (BCI) systems often face the challenges of unstable classification performance and privacy leakage when processing EEG signals with large individual differences. The present invention proposes a dual contrastive learning method that combines Sequential Contrastive Representation Learning (SeqCLR) and Domain-Specific Contrastive Learning (DomCLR) to enhance feature representation, reduce dependence on labeled data and effectively protect privacy. This technology belongs to the field of machine learning and signal processing, and specifically relates to the application of self-supervised learning and semi-supervised learning in EEG signal processing. Summary of the invention
[0014] The purpose of the present invention is to provide an electroencephalogram signal classification method based on contrast learning in view of the deficiencies of the prior art.
[0015] To achieve the above object, the present invention provides an electroencephalogram signal classification method based on contrastive learning, comprising the following steps:
[0016] (1) Problem definition and data preparation: Define a dataset D containing EEG signals from M subjects, where each EEG signal is represented by l EEG channels and t time steps;
[0017] (2) Data enhancement: For each EEG signal x i Generate two different enhanced signals x i 1 and x i 2 ;
[0018] (3) Time series contrastive learning: Use the encoder to enhance the signal x i 1 and x i 2 Extract features from the i 1 and z i 2 ; Then, the global features are extracted from each vector through the attention mechanism, and the distance between different enhancements of the same EEG signal is minimized, while the distance between different EEG signals is maximized to further train the encoder;
[0019] (4) Instance contrastive learning: Minimize the distance between different enhancements of the same EEG signal and maximize the distance between different EEG signals, so as to learn more representative feature representations and further train the encoder;
[0020] (5) Class contrastive learning: Minimize the distance between different enhancements of the same class of EEG signals, while maximizing the distance between different classes of EEG signals to further train the encoder;
[0021] (6) The trained encoder and a fully connected layer are concatenated to obtain a classifier, which is used to extract features from the original EEG signal to achieve EEG signal classification.
[0022] Furthermore, the step (3) is specifically as follows:
[0023] First, an encoder network consisting of three convolutional layers is used to extract the augmented signal x i 1 and x i 2 Extract features from the i 1 and z i 2 ; Next, each feature vector is divided into three parts; then, the attention mechanism is used to extract global representative features from each vector, that is, a global representation vector c is added to the beginning of the first part of each vector, the concatenated vector ω0 is used as input, and the first vector in the output is used as the global representation vector;
[0024] Finally, the global representation vector is used to predict the second segment of other vectors; the loss is defined by linearly transforming the global representation vector f and performing dot products with the second segments of other vectors; the encoder is trained to learn more representative features by updating the gradient by maximizing the dot product of the same EEG signal enhancement and minimizing the dot product of different signals.
[0025] Furthermore, the step (4) is specifically as follows:
[0026] The loss is defined by calculating the dot products between different enhancements of the same EEG signal and between enhancements of different EEG signals; the gradient is updated to train the encoder to learn more representative features by maximizing the dot product of enhancements of the same EEG signal and minimizing the dot product of enhancements of different EEG signals.
[0027] Furthermore, the step (5) is specifically as follows:
[0028] The loss is defined by calculating the dot product between the enhanced signals of the same category of EEG signals and between the enhanced signals of different categories of EEG signals; by maximizing the dot product of the same category of EEG signals and minimizing the dot product of different category EEG signals, the gradient is updated to train the encoder to learn more representative features.
[0029] Furthermore, the electroencephalogram signal classification method is implemented by combining sequence contrast representation learning SeqCLR and domain contrast learning DomCLR; wherein,
[0030] SeqCLR is a self-supervised learning method that generates two different enhanced signals of the same EEG number and optimizes feature representation using time series contrastive learning and instance contrastive learning. It improves the quality of feature representation by minimizing the distance between different enhancements of the same EEG signal and maximizing the distance between different EEG signals.
[0031] DomCLR performs semi-supervised learning based on SeqCLR and uses the pseudo labels generated by SeqCLR to further optimize feature representation. DomCLR combines time series contrastive learning and class contrastive learning to reduce the distance between EEG signals of the same type and increase the distance between EEG signals of different types, thereby dealing with differences between individuals and categories.
[0032] The beneficial effects of the present invention are:
[0033] 1. Reduced reliance on labeled data: Traditional technologies often require a large amount of labeled data to train models, while this invention significantly reduces the need for labeled data by combining the SeqCLR and DomCLR algorithms. SeqCLR uses self-supervised learning to optimize feature representation by generating different enhancement signals and performing comparative learning; while DomCLR further uses the pseudo-labels generated by SeqCLR for semi-supervised learning. This method reduces the reliance on expensive and time-consuming labeled data, reduces the cost of data labeling, and has better applicability in terms of data privacy protection.
[0034] 2. Simplify the feature engineering process: The complex feature extraction and selection process in traditional methods requires a lot of domain expertise, while the present invention realizes automatic feature learning through SeqCLR and DomCLR algorithms. SeqCLR directly extracts and optimizes features from raw EEG signals through time series contrastive learning and instance contrastive learning, simplifying the feature engineering steps. This automated feature extraction not only improves processing efficiency, but also reduces dependence on domain expertise.
[0035] 3. Improve the adaptability to individual differences: Traditional deep learning methods perform poorly when processing EEG signals with large individual differences, while the SeqCLR and DomCLR algorithms of the present invention enhance the adaptability to individual differences by optimizing feature representation. SeqCLR ensures that the distance between different enhanced signals of the same signal is minimized through time series contrast learning, while maximizing the distance between different signals; DomCLR further optimizes feature representation through class contrast learning, reduces the distance between signals of the same type, and increases the distance between signals of different categories, thereby better handling differences between individuals.
[0036] 4. Enhanced privacy protection: Traditional deep learning methods require a large amount of labeled data, which may cause privacy issues. This invention reduces the risk of privacy leakage by reducing the need for labeled data. The combination of SeqCLR and DomCLR enables the model to be trained on the basis of unlabeled data and pseudo-labels, effectively protecting the user's privacy information and being suitable for privacy-sensitive application scenarios.
[0037] These advantages are achieved thanks to the innovative combination of self-supervised learning and semi-supervised learning in the present invention, and the design of corresponding comparative learning methods based on the characteristics of EEG signals, thereby effectively solving the shortcomings of traditional technologies in data requirements, feature engineering complexity, adaptability to individual differences and privacy protection. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 This is a framework diagram of EEG signal classification based on SeqCLR and DomCLR algorithms in the present invention. DETAILED DESCRIPTION
[0039] The present invention introduces SeqCLR and DomCLR algorithms to overcome the data dependence, feature engineering complexity, poor individual adaptability and privacy issues in traditional motor imagery decoding methods, and provides a new method for EEG signal processing that is more efficient, flexible and privacy-protecting.
[0040] The key point of this invention is to propose a dual contrastive learning method that combines sequence contrastive representation learning (SeqCLR) and domain contrastive learning (DomCLR) for electroencephalogram (EEG) signal classification. It includes the following aspects:
[0041] (1) Sequence Contrastive Representation Learning (SeqCLR): It is a self-supervised learning method that optimizes feature representation by generating two different enhanced versions of the same EEG signal using time series contrastive learning and instance contrastive learning. This method improves the quality of feature representation by minimizing the distance between different enhanced versions of the same EEG signal while maximizing the distance between different EEG signals.
[0042] (2) Domain Contrastive Learning (DomCLR): Based on SeqCLR, semi-supervised learning is performed and the pseudo labels generated by SeqCLR are used to further optimize the feature representation. DomCLR combines time series contrastive learning and class contrastive learning to reduce the distance between EEG signals of the same type and increase the distance between EEG signals of different types, thereby dealing with differences between individuals and categories.
[0043] (3) Privacy protection: By reducing the need for labeled data, this method can protect user privacy while utilizing unlabeled data and pseudo-labels for training, making it suitable for privacy-sensitive application scenarios.
[0044] The comparison between the present invention and the prior art is as follows:
[0045] (1) Comparison point 1: data dependence.
[0046] Existing technology:
[0047] Traditional methods: Traditional EEG signal classification methods (such as SVM and LDA) and deep learning methods (such as CNN and RNN) usually rely on a large amount of labeled data. The acquisition process of labeled data is complicated and costly, which limits the practical application of these methods.
[0048] Contrastive learning techniques: such as SimCLR and MoCo, although they have performed well in computer vision tasks, their application in EEG signal processing is still in the development stage. SimCLR and MoCo are mainly for image data, and the processing effect and applicability of EEG signals need further research.
[0049] The present invention:
[0050] SeqCLR and DomCLR: Reduce the need for labeled data through self-supervised learning and semi-supervised learning. SeqCLR is trained by generating enhanced signals, while DomCLR is further optimized using pseudo labels generated by SeqCLR. This approach significantly reduces the reliance on labeled data and is suitable for situations where data labeling is difficult or costly.
[0051] (2) Contrast point 2: Feature engineering complexity.
[0052] Existing technology:
[0053] Traditional methods: Manual feature extraction and selection requires deep domain knowledge and experience, and the process is complex. Feature engineering involves multiple stages, including preprocessing, feature calculation and selection, and each stage may introduce human errors and affect the classification effect.
[0054] Deep learning techniques: Although they reduce the need for manual feature engineering, they still rely on large amounts of labeled data and perform poorly in handling individual differences.
[0055] The present invention:
[0056] SeqCLR and DomCLR: By automatically learning and optimizing feature representations, they reduce the complex feature engineering steps in traditional methods. SeqCLR automatically extracts useful features from raw EEG signals through time series contrastive learning and instance contrastive learning, while DomCLR further optimizes these feature representations. This approach simplifies the processing flow and reduces the reliance on domain knowledge.
[0057] (3) Contrast point three: adaptability to individual differences.
[0058] Existing technology:
[0059] Traditional methods: Traditional and deep learning methods perform poorly when faced with individual differences. EEG signals vary greatly between individuals, which may affect the performance of deep learning-based models when generalizing to new individuals.
[0060] Contrastive learning technology: Existing contrastive learning technologies (such as SimCLR and MoCo) are mainly aimed at image data, and their effects in EEG signal processing have not been fully verified.
[0061] The present invention:
[0062] SeqCLR and DomCLR: Use contrastive learning strategies to effectively deal with individual differences in EEG signals. SeqCLR improves the robustness of features through time series contrastive learning and instance contrastive learning, while DomCLR further optimizes feature representation through category contrastive learning to improve its adaptability to individual differences.
[0063] (4) Contrast point 4: Privacy protection.
[0064] Existing technology:
[0065] Traditional methods: Deep learning methods require a large amount of labeled data, which may raise privacy issues. Traditional labeled data-driven learning methods fail to adequately address privacy protection issues.
[0066] The present invention:
[0067] SeqCLR and DomCLR: By reducing the need for labeled data, they help reduce the risk of privacy leakage. SeqCLR and DomCLR can be trained with unlabeled data and pseudo-labels while protecting user privacy, and are suitable for privacy-sensitive application scenarios.
[0068] The present invention mainly proposes an electroencephalogram (EEG) signal classification method based on contrastive learning, which specifically includes two algorithms:
[0069] 1. Sequence Contrastive Representation Learning (SeqCLR): This is a self-supervised learning method that optimizes feature representation by generating two different enhanced signals of the same EEG signal using time series contrastive representation learning and instance contrastive learning. SeqCLR aims to minimize the distance between enhanced versions of the same signal while maximizing the distance between different signals, thereby improving the quality of feature representation.
[0070] 2. Domain-specific contrastive learning (DomCLR): This is a semi-supervised learning method that further optimizes feature representation by using pseudo labels generated by the encoder based on SeqCLR. DomCLR combines time series contrastive learning and category contrastive learning, aiming to reduce the distance between signals of the same category and increase the distance between signals of different categories, while dealing with differences between individuals and categories.
[0071] These methods aim to improve the accuracy of EEG signal classification, reduce reliance on labeled data, enhance the model's adaptability to individual differences, and effectively protect user privacy. The specific steps of the method of the present invention are as follows:
[0072] S1: Problem definition and data preparation.
[0073] The present invention uses Sequential Contrastive Representation Learning (SeqCLR) and Domain-Specific Contrastive Learning (DomCLR) to solve the EEG signal classification problem. Consider a dataset D containing EEG signals from M subjects, where each signal x∈R l×tIt is represented by l EEG channels (electrodes) and t time steps (the length of the signal sequence). SeqCLR trains the encoder by generating two augmented versions of the same signal, while DomCLR uses this encoder to generate pseudo labels and uses these labels to improve the feature representation.
[0074] S2: Overall framework.
[0075] The framework of SeqCLR and DomCLR algorithms is shown in the attached Figure 1 As shown. SeqCLR produces two different enhancements for the same EEG signal. By applying time series contrastive learning and instance contrastive learning, the distance between different enhanced signals of the same EEG signal is minimized, while the distance between different EEG signals is maximized, so that the encoder learns more robust and generalizable features. DomCLR uses the pseudo-labels generated by SeqCLR and further optimizes the feature representation through time series contrastive learning and class contrastive learning. Through time series contrastive learning, the distance between different enhanced signals of the same EEG signal is minimized, while the distance between different EEG signals is maximized. Through class contrastive learning, it minimizes the distance between EEG signals of the same type, while maximizing the distance between EEG signals of different types (assuming that the classifier obtained by the SeqCLR algorithm will Figure 1 The EEG signal A and EEG signal B in the image are both judged as the same category). Individual differences and inter-class differences are processed at the same time, so that the encoder learns features with category discrimination. DomCLR optimizes the encoder based on SeqCLR. Both algorithms aim to develop better feature encoders.
[0076] S3: Data augmentation.
[0077] For each EEG signal x i ∈R l×t , generating two different enhanced signals x i 1 and x i 2 .x i 1 =Augumentation1(x i ), x i 2 =Augmentation2(x i ), the subscript i indicates that the signal is the i-th in the batch. Augmentation1 generates an augmented signal by applying a random scaling factor to the EEG signal. Augmentation2 first randomly segments and shuffles the EEG signal, and then adds Gaussian noise to further encrypt the data to generate an augmented signal.
[0078] S4: Contrastive learning of time series.
[0079] Due to the inherent temporal characteristics of EEG signals, the present invention adopts a time series contrast learning method to minimize the distance between different enhancements of the same EEG signal and maximize the distance between different EEG signals, thereby learning representative features.
[0080] First, an encoder network consisting of three convolutional layers is used to extract the augmented signal x i 1 and x i 2 Extract features from i 1 and z i 2 , z i 1 =Encoder(x i 1 ), z i 2 =Encoder(x i 2 ). Next, each eigenvector is divided into three parts, such as z i 1 =((z i 1 ) a ,(z i 1 ) b ,(z i 1 ) c ), z i 2 =((z i 2 ) a ,(z i 2 ) b ,(z i 2 ) c ). Then, an attention mechanism is used to extract global representative features from each vector. Specifically, the first part of each vector (e.g. (z i 1 ) a ), a global representation vector c is added to the beginning of , the concatenated vector ω0 is taken as input, and the first vector in the output is used as the global representation vector (e.g. LN(ω 0 n )). The formula of the attention mechanism is as follows:
[0081] ω0=[c;(z i 1) a ] (1)
[0082] ω ′ τ =MSA(LN(ω τ-1 ))+ω τ-1 τ=1...N (2)
[0083] ω τ =MLP(LN(ω ′ τ ))+ω ′ τ τ=1...N (3)
[0084] (z i 1 ) total =LN(ω 0 N ) (4)
[0085] Among them, Encoder represents the encoder network, which consists of three convolutional layers, subscript a represents the first subvector after the feature vector is divided into three parts, subscript b represents the second subvector after the feature vector is divided into three parts, subscript c represents the third subvector after the feature vector is divided into three parts, ω ′ τ represents the intermediate vector obtained after the normalization layer, multi-head attention, and residual connection, ω τ Represents the intermediate vector obtained through the normalization layer, multi-layer perceptron, and residual connection, ω τ-1 represents the vector calculated after τ times of full attention mechanism; LN(ω 0 N ) represents the output vector, and the superscript 0 represents the first vector in the output. MSA stands for multi-head attention, LN stands for layer normalization, MLP stands for multi-layer perceptron, and N stands for the number of attention layers used.
[0086] Finally, using the global representative vector (e.g., (z i 1 ) total ) to predict the second segment of other vectors (e.g., (z i 2 ) b ). The loss is defined by linearly transforming the global vector f and performing dot products with the second segments of other vectors. The encoder is trained to learn more representative features by updating the gradients by maximizing the dot products of the same EEG signal enhancements and minimizing the dot products of different signals.
[0087]
[0088] in, Represents the time series contrastive learning loss, i indicates that the vector is the i-th vector in the current batch, and j indicates that the vector is the j-th vector in the current batch.
[0089] S5: Example contrastive learning.
[0090] In the SeqCLR algorithm, after applying time series contrastive learning, the present invention further utilizes instance contrastive learning to minimize the distance between different enhancements of the same EEG signal and maximize the distance between different EEG signals, thereby learning more representative feature representations. Specifically, the loss is defined by calculating the dot product between different enhancements of the same EEG signal and between enhancements of different EEG signals. By maximizing the dot product of the same EEG signal enhancement and minimizing the dot product of different EEG signal enhancements, the gradient is updated to train the encoder to learn more representative features.
[0091]
[0092] in, represents the instance contrastive learning loss.
[0093] Total loss of SeqCLR algorithm Including time series contrastive learning loss and instance contrastive learning loss
[0094]
[0095] S6: Class contrastive learning.
[0096] In the DomCLR algorithm, after applying time series contrastive learning, the present invention further utilizes class contrastive learning to minimize the distance between different enhancements of the same class of EEG signals while maximizing the distance between different classes. This method helps to learn more representative feature representations. Specifically, the loss is defined by calculating the dot product between the enhanced signals of the same class of EEG signals and between the enhanced signals of different classes of EEG signals. By maximizing the dot product of the same class of EEG signals and minimizing the dot product of different classes of EEG signals, the gradient is updated to train the encoder to learn more representative features.
[0097]
[0098] H(i)={h∈{{1,...,N}\{i}}:y i ′ =y h ′} (9)
[0099] in, represents the class contrast learning loss, H(i) represents the set of vectors with the same category label as the i-th vector in the current batch, k represents the current vector is an enhanced vector obtained by the first or second data enhancement processing, m represents the m-th vector in the current batch, n represents the current vector is an enhanced vector obtained by the first or second data enhancement processing, o represents the current vector is an enhanced vector obtained by the first or second data enhancement processing, h represents the set of vectors with the same category label as the i-th vector in the current batch, y h ′ Represents the category label of the hth vector in the current batch; y ‘ Represents the pseudo labels generated by a classifier consisting of an encoder trained with the SeqCLR algorithm as the feature extraction layer and a fully connected layer as the classification head.
[0100] The total loss of the DomCLR algorithm Including time series contrastive learning loss and class contrastive learning loss
[0101]
[0102] (7) The trained encoder and a fully connected layer are concatenated to obtain a classifier, which is used to extract features from the original EEG signal to achieve EEG signal classification.
[0103] Specifically, the SeqCLR algorithm and the DomCLR algorithm together form a two-stage algorithm. In the first stage, the encoder is first trained with the SeqCLR algorithm and unlabeled data, and then the trained encoder and a fully connected layer are concatenated to obtain a classifier, and then a certain proportion of labeled data is used to perform supervised fine-tuning on the classifier. The obtained classifier is used to classify and predict the unlabeled data set and label it to obtain a pseudo-labeled data set. In the second stage, the encoder obtained by the SeqCLR algorithm is used as the initial encoder, and the encoder is trained with the DomCLR algorithm and the pseudo-labeled data set, and then the trained encoder and a fully connected layer are concatenated to obtain a classifier, and then a certain proportion of labeled data is used to perform supervised fine-tuning on the classifier. When classifying EEG signals, the classifier trained with the DomCLR algorithm extracts features from the original EEG signals and implements the classification of EEG signals.
Claims
1. A method for classifying electroencephalogram signals based on contrastive learning, characterized in that: The steps include: (1) Problem definition and data preparation: Define a dataset D containing EEG signals from M subjects, where each EEG signal is represented by l EEG channels and t time steps; (2) Data enhancement: For each EEG signal x i Generate two different enhanced signals x i 1 and x i 2 ; (3) Time series contrastive learning: Use the encoder to enhance the signal x i 1 and x i 2 Extract features from the i 1 and z i 2 ; Then, the global features are extracted from each vector through the attention mechanism, and the distance between different enhancements of the same EEG signal is minimized, while the distance between different EEG signals is maximized to further train the encoder; (4) Instance contrastive learning: Minimize the distance between different enhancements of the same EEG signal and maximize the distance between different EEG signals, so as to learn more representative feature representations and further train the encoder; (5) Class contrastive learning: Minimize the distance between different enhancements of the same class of EEG signals, while maximizing the distance between different classes of EEG signals to further train the encoder; (6) The trained encoder and a fully connected layer are concatenated to obtain a classifier, which is used to extract features from the original EEG signal to achieve EEG signal classification.
2. The electroencephalogram signal classification method based on contrastive learning according to claim 1, characterized in that: The step (3) is specifically: First, an encoder network consisting of three convolutional layers is used to extract the augmented signal x i 1 and x i 2 Extract features from the i 1 and z i 2 ; Next, each feature vector is divided into three parts; then, the global representative features are extracted from each vector using the attention mechanism, that is, a global representation vector c is added to the beginning of the first part of each vector, the concatenated vector ω0 is used as input, and the first vector in the output is used as the global representation vector; Finally, the global representation vector is used to predict the second segment of other vectors; the loss is defined by linearly transforming the global representation vector f and performing dot products with the second segments of other vectors; the encoder is trained to learn more representative features by updating the gradient by maximizing the dot product of the same EEG signal enhancement and minimizing the dot product of different signals.
3. The electroencephalogram signal classification method based on contrastive learning according to claim 1, characterized in that: The step (4) is specifically: The loss is defined by calculating the dot products between different enhancements of the same EEG signal and between enhancements of different EEG signals; the gradient is updated to train the encoder to learn more representative features by maximizing the dot product of enhancements of the same EEG signal and minimizing the dot product of enhancements of different EEG signals.
4. The electroencephalogram signal classification method based on contrastive learning according to claim 1, characterized in that: The step (5) is specifically as follows: The loss is defined by calculating the dot product between the enhanced signals of the same category of EEG signals and between the enhanced signals of different categories of EEG signals; by maximizing the dot product of the same category of EEG signals and minimizing the dot product of different category EEG signals, the gradient is updated to train the encoder to learn more representative features.
5. The electroencephalogram signal classification method based on contrastive learning according to claim 1, characterized in that: The electroencephalogram signal classification method is implemented by combining sequence contrast representation learning SeqCLR and domain contrast learning DomCLR; wherein, SeqCLR is a self-supervised learning method that generates two different enhanced signals of the same EEG number and optimizes feature representation using time series contrastive learning and instance contrastive learning. It improves the quality of feature representation by minimizing the distance between different enhancements of the same EEG signal and maximizing the distance between different EEG signals. DomCLR performs semi-supervised learning based on SeqCLR and uses the pseudo labels generated by SeqCLR to further optimize feature representation. DomCLR combines time series contrastive learning and class contrastive learning to reduce the distance between EEG signals of the same type and increase the distance between EEG signals of different types, thereby dealing with differences between individuals and categories.