Few-sample motor imagery electroencephalogram signal classification method

Through the deep learning network framework of the meta-learning mechanism, the source domain pre-training and target domain fine-tuning are used to solve the problem of poor classification performance of motor imaginary EEG signals when the number of samples in a single subject is limited, and efficient and accurate classification of EEG signals is achieved, reducing data acquisition costs and improving the practicality of the MI-BCI system.

CN120354201APending Publication Date: 2025-07-22JILI INNOVATION (SHANGHAI) INTELLIGENT TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510394649.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-31
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

In the prior art, when the number of samples in a single subject is limited, the classification performance of the electroencephalogram signal across subjects is poor, and the data acquisition cost is high, which affects the convenience and practicality of the MI-BCI system.

Method used

A deep learning network framework adopts a meta-learning mechanism, through source domain pre-training and target domain fine-tuning, a feature mapping module and classification module are built, a small number of target domain samples are used for model adaptation, and the meta-parameters are optimized in combination with internal loop gradient descent to achieve efficient classification.

Benefits of technology

It improves the classification efficiency and accuracy of the electroencephalogram signal of the motor imagination, reduces the cost of data acquisition, enhances the adaptability and generalization capabilities of the model, and is suitable for the rapid adaptation of the MI-BCI system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120354201A_ABST
    Figure CN120354201A_ABST
Patent Text Reader

Abstract

The invention provides a few-sample motor imagery electroencephalogram signal classification method. In a source domain pre-training stage, a source domain data set, a feature mapping module and a classification module are constructed, the feature mapping module and an auxiliary classifier are pre-trained, and the pre-trained auxiliary classifier is discarded. In the meta learning stage, a source domain data set is divided into a meta training task set, based on a cross-data-set motor imagery decoding framework, task parameters are optimized on a support set through internal circulation gradient descent, loss is calculated in a query set to update meta parameters, a feature mapping module and a classification module are jointly trained, and the adaptability and generalization ability of the model are enhanced. In the target domain verification and classification stage, a small number of electroencephalogram signals of a target domain user are collected to serve as an adaptation set, and the motor imagery electroencephalogram signal classification efficiency and accuracy are improved through an internal circulation gradient descent fine tuning model based on parameter initialization in the meta-learning stage; source domain pre-training lays a foundation, meta-learning enhances adaptability, and target domain fine tuning realizes accurate classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the technical field of brain-computer interface data mining, and specifically relates to a few-shot motor imagery electroencephalogram signal classification method. Background Art

[0002] Brain-Computer Interface (BCI) technology aims to establish an information and control pathway that does not rely on peripheral nerves and muscle tissues between the human brain and the external environment, and it plays an important role in the rehabilitation treatment of upper limb motor disorders after stroke. BCI technology based on Motor Imagery (MI) Electroencephalogram (EEG) signals has been widely applied in clinics and has been proven to effectively promote the remodeling of nerve function. However, most machine learning-based brain decoding methods require dozens of offline signals as training sets to train decoding models; deep learning-based brain decoding methods are limited by the limited sample size of a single subject. As a spontaneous mental strategy, motor imagery EEG signals have large individual differences, and the classification performance across subjects is often poor. Summary of the Invention

[0003] The technical objective of this application aims to solve the technical problem that when the sample size of a single subject is limited, there are large individual differences in motor imagery EEG signals, and the classification performance across subjects is often poor, and provides a few-shot motor imagery EEG signal classification method.

[0004] To achieve the above technical objective, this application adopts the following technical solutions.

[0005] The embodiment of this application provides a few-shot motor imagery EEG signal classification method, including:

[0006] Source domain pre-training stage: constructing a source domain dataset; constructing a deep learning model, the deep learning model includes a feature mapping module and a classification module; based on the source domain dataset, pre-training the feature mapping module and an auxiliary classifier, and discarding the pre-trained auxiliary classifier after pre-training is completed to obtain the pre-trained feature mapping module, and the classification model uses randomly initialized parameters;

[0007] Meta-learning stage: dividing the source domain dataset into meta-training task sets, where each meta-training task contains a support set and a query set; based on a cross-dataset motor imagery decoding framework of the meta-learning mechanism, optimizing the meta-parameters of the meta-training task through inner-loop gradient descent on the support set, and calculating the loss on the query set to update the meta-parameters, and jointly training the deep learning model;

[0008] Target domain validation and classification stage: A small amount of motor imagery EEG signals of target domain users are collected as an adaptation set. Based on the initialization of the deep learning model parameters in the meta-learning stage, the deep learning model is fine-tuned through inner-loop gradient descent; the fine-tuned deep learning model is used for task type classification of target domain users.

[0009] Compared with the prior art, the beneficial technical effects of a few-shot motor imagery EEG signal classification method provided by the embodiments of the present application include: Through phased processing, the classification efficiency and accuracy of motor imagery EEG signals are improved. Source domain pre-training lays the foundation, meta-learning enhances adaptability, and target domain fine-tuning achieves accurate classification. The cooperation of each stage effectively solves the few-shot problem, reduces the data collection cost, enables the model to quickly adapt to new users, and demonstrates strong practicality and application potential in the application of EEG signal classification.

[0010] Among them, in the source domain pre-training stage: Pre-training the feature mapping module enables the model to initially learn the feature patterns in the data, provides a good parameter starting point for subsequent training, and improves the training efficiency. In the meta-learning stage: The source domain dataset is divided into a meta-training task set including a support set and a query set, and joint training is carried out based on the cross-dataset motor imagery decoding framework of the meta-learning mechanism. This way can enable the model to learn the commonalities and differences between different tasks, enhance the adaptability and generalization ability of the model to different tasks and datasets, and enable the model to also have good performance when facing new tasks.

[0011] Target domain validation and classification stage: By only collecting a small amount of motor imagery EEG signals of target domain users as an adaptation set, the model can be fine-tuned through inner-loop gradient descent based on the model parameter initialization in the meta-learning stage. This not only saves a large amount of data collection cost and time, but also enables the deep learning model to quickly adapt to target domain users, and finally achieves accurate classification of the task types of target domain users, improving the practicality and application value of the deep learning model. Description of the Drawings

[0012] The drawings described herein are for illustrative purposes only and are not intended to limit the scope of the disclosure of the present application in any way. Additionally, the shapes and proportional dimensions of the components in the figures are only schematic and are used to assist in understanding the present application, rather than specifically limiting the shapes and proportional dimensions of the components of the present application. Those skilled in the art can, under the teaching of the present application, select various possible shapes and proportional dimensions according to specific circumstances to implement the present application. In the drawings:

[0013] Figure 1 It is a schematic flowchart of a few-shot motor imagery EEG signal classification method provided by an embodiment of the present application;

[0014] Figure 2Schematic diagram of the MCANet transfer learning framework process in the embodiment;

[0015] Figure 3 Schematic diagram of a round of calculation in the meta - learning strategy adopted in the meta - learning stage in the embodiment;

[0016] Figure 4 Schematic diagram of the network structure of the feature mapping module in the embodiment;

[0017] Figure 5 Schematic diagram of the parameter settings of each layer of the feature mapping module network;

[0018] Figure 6 Schematic diagram of the network structure of the classification module in the embodiment. Detailed implementation manners

[0019] In order to enable those skilled in the art to better understand the technical solutions in this application, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.

[0020] In the description of this application, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more features.

[0021] The classic decoding process of MI - BCI includes: 1) Using pre - processing techniques such as filtering and noise reduction to enhance the quality of EEG signals; 2) Extracting features that help distinguish different MI tasks through methods such as Common Spatial Patterns (CSP); 3) Feeding these features into machine learning models such as LDA and SVM for classification and recognition. However, there are significant differences in EEG signal patterns between different individuals. Even when recording different time periods of the same subject on the same day, the signal patterns may also be very different. This makes it a challenging task to classify EEG signals of different individuals or the same individual at different times. In order to improve the decoding performance, under the classic decoding process framework, the MI - BCI system needs to conduct a personalized calibration experiment for each user regularly. This process is relatively time - consuming, thus affecting the convenience and practicality of the system. Transfer Learning (TL) technology can apply the knowledge of the source domain to the solution of the target domain, shortening the learning and adaptation time of new users or new environments (target domain).

[0022] However, traditional method-based TL mostly focuses on achieving better classification performance under the condition of the same number of calibration samples. The transfer learning mechanism based on meta-learning is more applied to fields such as emotion recognition and sleep staging, where the data acquisition paradigm is single and the difficulty of long-term data acquisition is lower than that of MI. In practical applications, the applicant hopes to minimize the calibration samples, with the number of samples in a single category during the calibration phase being between 1 and 5, so as to compress the calibration time within 2 minutes and better serve the application of the MI-BCI-based rehabilitation system.

[0023] This application proposes a few-shot motor imagery EEG signal classification method. Based on the deep learning network framework of the meta-learning mechanism, it uses a small number of target domain samples to achieve good recognition performance, thereby improving the treatment experience of patients during MI-BCI-based rehabilitation training.

[0024] The following further describes this application in conjunction with the specification drawings and specific embodiments.

[0025] A few-shot motor imagery EEG signal classification method, as Figure 1 shown, includes:

[0026] Source domain pre-training stage: Construct a source domain dataset; construct a deep learning model, where the deep learning model includes a feature mapping module and a classification module; based on the source domain dataset, pre-train the feature mapping module and the auxiliary classifier. After the pre-training is completed, discard the pre-trained auxiliary classifier to obtain the pre-trained feature mapping module, and the classification model uses randomly initialized parameters;

[0027] Meta-learning stage: Divide the source domain dataset into meta-training task sets, where each meta-training task contains a support set and a query set; based on the cross-dataset motor imagery decoding framework based on the meta-learning mechanism (Meta-Learning based Cross-dataset Domain Adaptive Network Framework, MCANet), optimize the meta-parameters of the meta-training task through inner-loop gradient descent on the support set, and calculate the loss on the query set to update the meta-parameters, and jointly train the deep learning model;

[0028] Target domain verification and classification stage: Collect a small amount of motor imagery EEG signals of target domain users as an adaptation set, initialize the parameters of the deep learning model based on the meta-learning stage, and fine-tune the deep learning model through inner-loop gradient descent; use the fine-tuned deep learning model for task type classification of target domain users.

[0029] The few-shot motor imagery EEG signal classification method provided by this application is based on the cross-dataset motor imagery decoding framework of the meta-learning mechanism, asFigure 2 As shown in the figure, this framework aims to pre-train a deep learning model (including a feature mapping module and a classification module) on a large dataset in the source domain, efficiently adapt to a small number of target domain samples, and achieve good classification performance. This method is particularly suitable for cases where the training data in the target domain is limited, and it can maintain a high recognition accuracy, thus facilitating the implementation of an online system for a motor imagery brain-computer interface (MI-BCI).

[0030] The efficient adaptation of the deep learning model to the target domain is the key to achieving excellent performance. The adaptation process can be expressed by the following formula:

[0031]

[0032] where Θ is the set of parameters of the established deep learning model, Θ t is the parameter of the deep learning model after target adaptation, Θ s is Θ pre-trained on a large-scale source domain dataset D s =(s i , y i ); i∈s x i is the source domain EEG signal, y i is the task label corresponding to the source domain EEG signal; T tg is the dataset of the target domain, T tg is the dataset of the target domain. Due to the limitation of calibrating the data acquisition time in practical applications, the amount of data in T tg is very limited; x i is the target domain EEG signal, y i is the task label corresponding to the target domain EEG signal; Θ←Θ s means that in the process of target domain task adaptation , the parameters Θ of the deep learning model are adapted and trained with θ s as the initial parameters.

[0033] As Figure 1 shown, the embodiments of this application are divided into a source domain pre-training stage, a meta-learning stage, and a target domain verification and classification stage.

[0034] In the embodiments, various publicly available motor imagery datasets are collected. Common left / right binary classification motor imagery tasks include: left / right hand clenching, left / right upper limb movement, left / right hand finger movement, etc. Combining a large amount of EEG data of the applicant's patients' left and right hand motor imagery, an original training dataset is formed.

[0035] In the source domain pre-training stage, cross-dataset samples are obtained, such as multiple publicly available MI-EEG datasets (such as BCI Competition IV 2a, GigaDB, etc.). These datasets may be collected by different laboratories using different devices, electrode layouts, or experimental paradigms.

[0036] Preprocess the cross-dataset samples (such as data cleaning, normalization, etc.). After time and channel alignment, they are merged into the source domain training set D s and the target domain test set D t , where D s is used to train the feature mapping module of the proposed deep learning model. On D s , pre-train the underlying feature mapping module and the auxiliary classifier to obtain Θ init (θ fe , θ cls ), where the parameters θ fe of the feature mapping module are pre-trained parameters, and the parameters θ cls of the auxiliary classifier are randomly initialized parameters. This step can effectively accelerate the training process of meta-learning.

[0037] The pre-training process is as Figure 2 shown, mainly including the following steps:

[0038] 1) Randomly initialize the parameters θ fe of the feature mapping module and the pre-training parameters θ′ cls of the auxiliary classifier;

[0039] 2) Use the AdamW (Adam Weight Decay) optimizer for optimization, where AdamW can be expressed as the following formula:

[0040]

[0041] where, Θ t is the parameter after the t-th iteration update; θ t-1 is the parameter after the (t - 1)-th iteration update, is the bias-corrected version of the first moment estimate of the gradient. is the bias-corrected version of the second moment estimate of the gradient, that is, the result obtained by exponentially weighted moving average of the square of the gradient and then through correction, which is used to adjust the scaling ratio of the learning rate and measures the uncertainty or variance of the gradient. ∈ is a very small positive number (usually on the order of 1e-8, etc.), which is used to prevent the denominator from being zero and ensure the numerical stability of the calculation. The learning rate η and the weight decay λ are artificially defined optimizer parameters, and the calculation of the bias-corrected first moment estimate and the second moment estimate can be expressed as:

[0042]

[0043] Among them, the momentum parameters β1 and β2 are optimizer parameters defined as such, and g t is the gradient of the t-th iteration, which can be expressed as:

[0044]

[0045] Among them, the cross-entropy loss function is used to measure the difference between the predicted value of the output and the task label y.

[0046] 3) After completing pre-training, discard the pre-training auxiliary classifier and only use the feature mapping module to participate in subsequent learning and prediction.

[0047] In the meta-learning stage, considering the large differences in EEG signals between individuals and even the significant differences in EEG signals of the same individual at different times, the data in D s is composed of meta-training tasks according to the experiment and subject labels where i and j are the subject label and experiment label respectively, m s is the number of trials for the subject i to perform the motor imagery task in the j-th experiment.

[0048] Using Θ s as the initialization parameters of the deep learning model, simultaneously train the feature mapping module and the classification module on Task train based on the meta-learning mechanism to obtain the deep learning model parameters Θ t .;

[0049] For the test task set of the test set D t k t is the number of experiments used for training in D t and m t is the number of trials for the subject to perform the motor imagery task in a single experiment. Before classifying each target domain test task t i of the deep learning model, a small number of samples are sampled from it to form an adaptation set T tg, and the adaptation process shown in formula (1) is performed to obtain Θ T , and based on this, classify the other samples in the test task to evaluate the model performance.

[0050] In some embodiments, meta-training is carried out in units of episodes. At the beginning of each episode, the source domain dataset is divided into a meta-training task set, including the meta-training task T ij ​Samples of c task categories, and k samples are randomly sampled for each task to form a support set Each support set contains (c·k) samples, and the data is evenly distributed among all categories, T ij The remaining samples in it form a query set

[0051] After aligning the original training data set in terms of time and channels, one motor imagery experiment is regarded as one training task. Each training task contains 50 - 150 left / right motor imagery samples, with a total of N (generally, there are 20 - 200 tasks in a public data set. In this solution example, 5 public data sets are collected, combined with the applicant's own data set, and the number of training tasks > 3000) training tasks. In each training task, k (k = 1, 3, 5) samples are taken from each of the c label categories (in this example, k = 2, that is, 2-class classification of left and right) as support data, and the remaining data is used as query data

[0052] In practical applications, it is necessary to minimize the adaptation sample collection required by the model as much as possible. Therefore, usually k takes a relatively small value (it can take 1 - 5). In each round, traverse Task train the T in ij For each T ij Form the support query pairs in this round according to the above method Perform two gradient update loops, namely internal and external, specifically including:

[0053] 1) Inner loop: Optimize through gradient descent on the support set to generate task-specific parameters. Use the parameters Θ t-1 updated in the outer loop of the previous round as the initial meta-parameters, and on use the Stochastic Gradient Descent (SGD) optimizer to perform E s iterative learning on the model to obtain the parameters after rapid adaptation The process can be expressed by the following formula:

[0054]

[0055] Among them, η s is the learning rate of the inner loop, is the loss function used by the model in the outer loop. In the example, the loss function used in the outer loop can calculate the sum of the cross-entropy loss and the mean squared error loss

[0056] 2) Outer loop update: Calculate the loss on the query set and update the meta-parameters through the AdamW optimizer. After the inner loop is completed, Applied to the outer loop, in compute the loss on

[0057] Collect a small number of samples of target-domain users as the adaptation set (support set) for inner-loop fine-tuning; test the classification performance on the target-domain query set, and calculate the signal reconstruction error as an evaluation metric for regularization constraints.

[0058] Traverse each T in Task train in one episode ij Obtain the loss L after the model is quickly adapted through the above steps ij , and use the AdamW optimizer to update the model parameters, which can be specifically expressed as the following formula:

[0059]

[0060] where adamw(·) is the process represented by formulas (2) to (5). In actual training, in order to improve the training efficiency and model performance, in some embodiments, the mini-batch technique is adopted for the above parameter update. The specific process is as Figure 3 shown.

[0061] In some embodiments, the feature mapping module adopts a CNN-based network structure similar to EEGNet. Its compact model structure and relatively stable performance in various BCI applications make it one of the most popular deep learning architectures successfully applied to BCI systems. It uses separable and depthwise convolutions to develop an explicit model of EEG.

[0062] As Figure 4 shown, compared with other commonly used deep learning architectures used in BCI classification, the number of trainable parameters in EEGNet for model prediction is very small, and it can stably learn interpretable features in various tasks of MI-BCI. The feature mapping module proposed in the embodiments draws on this structure and includes the following three parts:

[0063] 1) Temporal information processing: For an input signal of the form (1, C, T), where C is the number of EEG channels and T is the length of the signal time series, apply F1 two-dimensional convolutional kernels of the form (1, 128) to output F t EEG feature maps of the form (Ft, C, T) containing different frequency bands. Here, the length of the convolutional kernel refers to the existing design of EEGNet and adopts half of the sampling rate (250Hz) of the EEG acquisition device to be used. To improve the convolutional calculation efficiency, 128 (i.e., 2 7 ) is used to ensure that the network processes the information of a time window of about 0.5s each time.

[0064] 2) Spatial information processing: Use F t ×F s deep convolutions of the form (C, 1) to learn spatial filters, and output EEG feature maps of the form (F t ×F s , 1, T). Where D is the number of spatial convolution kernels used for the EEG feature maps of each frequency band, and a maximum norm constraint of 1 is imposed on the weights of each spatial filter (i.e., ||ω|| 2 < 1, where ω is the parameter of a single spatial filter) to regularize it. In the application of convolutional neural networks (CNNs) in computer vision, since these convolutions are not fully connected to all previous feature maps, deep convolutions can effectively reduce the number of trainable parameters to be fitted. In the application of EEG, this operation provides a direct method for each temporal filter to learn spatial filters, enabling the efficient extraction of spatial filters for specific frequencies. This part of the design draws on the Filter-Bank Common Spatial Pattern (FBCSP) algorithm, and arranges the output feature maps into the form of (F t , F s , T) to make subsequent processing more intuitive.

[0065] 3) Feature mapping and compression

[0066] Map the EEG feature maps of the form (F t , F s , T) into a feature sequence of the form (Seq dim , Seq len ) through average pooling and separable convolution, where Seq dim is the feature dimension and Seq len is the feature sequence length. For simplicity of representation, they are represented by S d and S l later. Separable convolution, that is, first passing through a deep convolution and then performing pointwise convolution using a (1, 1) convolution kernel, has the advantage of improving computational efficiency and preventing overfitting by reducing model parameters, and at the same time can finely capture and decouple the feature information of different time scales in the EEG signal, thereby enhancing the analysis ability of EEG data.

[0067] The parameter settings of each layer in the feature mapping module network are shown in Figure 5 , aiming to map the input EEG signals into feature sequences with fewer network parameters for subsequent processing.

[0068] As Figure 5 shown, the feature mapping module includes an input layer, a depthwise separable convolution layer, and an average pooling layer.

[0069] Among them, the input layer inputs the electroencephalogram signal (C, T), where C is the number of electrode channels and T is the length of the time series; the electroencephalogram signal (C, T) is reshaped into (1, C, T) to adapt to two-dimensional convolution operations, and the signal is normalized; use F t convolution kernels of size (1, 128) to extract multi-band features along the time dimension, and the output shape is (F1, C, T), where F1 is the number of time feature maps.

[0070] For each time feature map in the depthwise separable convolution layer, D×F spatial filters are used along its electrode channel dimension, D is the depth multiplier, the convolution kernel size is (C, 1), and spatial patterns are extracted along the electrode channel dimension; after normalization, non-linearity is introduced through the ELU activation function, and the output is reshaped into (F1, F t , T) to separate the time and spatial dimension features. t The average pooling layer uses a (1×k1) pooling window along the time dimension to compress the time series to T / / k1, where " / / " means taking the integer of the division result; part of the neurons are discarded with probability p to prevent overfitting; use F

[0071] convolution kernels of (1×k2) to further fuse the time features, and the output shape is (F1, F t , S t , where S l is the compressed length of the time dimension; the feature is mapped to (F1, S l / / F1, S d through a (1×1) convolution, and finally reshaped into (S l , S d , S l ) to output a low-dimensional spatio-temporal feature sequence for subsequent classification modules to process.

[0072] In some embodiments, the convolution kernels of the first-layer input layer are set according to the sampling rate of the dataset used, so as to ensure that the time-domain processing contains at least 0.5 s of information. For example, for dataset 1 with a sampling rate of 250 Hz, 0.5 s is 125 points, so the convolution kernel is (1, 128); for dataset 2 with a sampling rate of 1000 Hz, 0.5 s is 500 points, and the convolution kernel is (1, 512).

[0073] The second-layer depthwise separable convolution layer will set multiple convolution kernels according to the number of datasets used, and automatically match the corresponding convolution kernels according to the actual number of channels of the datasets used to achieve channel alignment across datasets. For example: 1: For dataset 1 with 16 channels, the convolution kernel is (16, 1); 2: For dataset 2 with 64 channels, the convolution kernel is (64, 1). After the spatial processing of the depthwise separable convolution layer, the spatial dimensions are aligned.

[0074] In some embodiments, the classification module adopts a Transformer-based network structure similar to ViT (Vision Transformer). By splitting the image into small patches and embedding them into a high-dimensional space, and combining the self-attention mechanism to capture global dependencies, it shows excellent performance in visual tasks. ViT has achieved outstanding performance in multiple computer vision tasks, including image classification, object detection, and segmentation. The core of the Transformer architecture is the self-attention mechanism, which allows the model to consider all other vectors in the input sequence when processing each vector. This mechanism enables ViT to capture the global dependencies in the image, rather than just local features. In the application of EEG, the Transformer-based network structure can capture the global dependencies across time points and electrodes in EEG signals, while retaining the temporal information through positional encoding. With its flexible architecture, it becomes a powerful tool for processing EEG data.

[0075] As Figure 6 shown, the classification module classifies and identifies the feature sequence S in the form of (S d , S l ) output by the aforementioned feature mapping module, where S d and S l are the spatial dimension and temporal dimension of the feature sequence respectively, and are usually controlled to a relatively small value to control the computational complexity of the model. It specifically includes the following three parts:

[0076] 1) Spatial feature processing unit, used to implement spatial feature processing based on the attention mechanism: Based on the feature sequence S, a spatial attention network composed of N s layers of Transformer Encoder is introduced. The core of this network is the self-attention mechanism, which allows the model to dynamically refer to and integrate information from other spatial positions when processing the features at each spatial position. Through the iterative processing of multiple layers of Transformer Encoder, the intermediate feature representation S1 is obtained. It not only retains the key information in the original feature sequence, but also enhances the correlation and discriminability between spatial features through the guidance of spatial attention. The output S1 of this step provides a richer spatial feature basis for the subsequent temporal dimension processing.

[0077] 2) Temporal Attention Mechanism Unit: To further explore the temporal dependencies in the feature sequence, S1 is transposed so that the temporal dimension becomes dominant, and a special classification token (cls_token) is added at the front of the sequence. This cls_token serves as a global context vector, aiming to aggregate the information of the entire time series. After the above processing, the resulting intermediate feature representation S1′ is a feature sequence in the form of (S l +1, S d ). Subsequently, positional encoding is incorporated into the transposed sequence to explicitly represent the order information in the time series, which is an essential step when Transformer processes sequence data. After positional encoding, the sequence is fed into a temporal attention network consisting of another N t layers of Transformer encoders. In this network, the self-attention mechanism is used to capture the long-term dependencies in the time series, as well as the dynamic interactions between the cls_token and each temporal feature. Finally, a feature sequence S2 containing rich spatio-temporal features is obtained.

[0078] 3) Task Classification and Signal Reconstruction Unit: In the feature sequence S2, the output at the position of the cls_token is specifically used for the classification task and is fed into a top-level classifier composed of fully connected layers to achieve effective classification of the EEG signals. At the same time, to ensure that the feature sequence can still retain sufficient original signal information after being processed by the deep network, a decoder network (which can include deconvolution layers and fully connected layers) is designed to perform the signal reconstruction task, using the remaining part of S2 except the cls_token as the input to attempt to restore the original EEG signals. The introduction of the signal reconstruction task not only serves as a regularization method to help prevent model overfitting, but also ensures the information integrity of the features and the generalization ability of the model by forcing the model to learn the feature representation that can reconstruct the original signal.

[0079] In the embodiment, by jointly optimizing the classification loss (classificationLclassification) and the reconstruction loss (reconstructionLreconstruction), the model is more robust under few-shot conditions. As an example, the cross-entropy loss function can be used for classification, and the mean squared error loss can be used for reconstruction. The total loss used for training is the sum of the two.

[0080] The above has introduced in detail a few-shot motor imagery EEG signal classification method provided by the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the concept of the present application and should not be construed as a limitation on the protection scope of the present application.

Claims

1. A few-shot motor imagery EEG signal classification method, characterized in that, Including: Source domain pre-training stage: Construct a source domain dataset; Construct a deep learning model, the deep learning model includes a feature mapping module and a classification module; Based on the source domain dataset, pre-train the feature mapping module and the auxiliary classifier. After the pre-training is completed, discard the pre-trained auxiliary classifier to obtain the pre-trained feature mapping module; Meta-learning stage: Divide the source domain dataset into meta-training task sets, where each meta-training task contains a support set and a query set; Based on the cross-dataset motor imagery decoding framework of the meta-learning mechanism, jointly train the deep learning model by optimizing the meta-parameters of the meta-training task through inner-loop gradient descent on the support set and calculating the loss on the query set to update the meta-parameters; Target domain validation and classification stage: Collect a small amount of motor imagery EEG signals of target domain users as an adaptation set. Based on the initialization of the deep learning model parameters in the meta-learning stage, fine-tune the deep learning model through inner-loop gradient descent; use the fine-tuned deep learning model for task type classification of target domain users.

2. The few-shot motor imagery EEG signal classification method according to claim 1, characterized in that The feature mapping module uses a depthwise separable convolutional network to extract spatio-temporal features, and the classification module fuses spatial attention and temporal attention mechanisms based on the Transformer architecture.

3. The few-shot motor imagery EEG signal classification method according to claim 2, characterized in that, The feature mapping module includes an input layer, a depthwise separable convolutional layer, and an average pooling layer; Among them, the input layer inputs the electroencephalogram signal (C, T), where C is the number of electrode channels and T is the length of the time series; the electroencephalogram signal (C, T) is reshaped into (1, C, T) to adapt to two-dimensional convolution operations, and the signal is normalized; use F t convolution kernels of size (1, 128) to extract multi-band features along the time dimension, and the output shape is (F1, C, T), where F1 is the number of time feature maps; The depthwise separable convolutional layer uses D×F spatial filters along the electrode channel dimension for each temporal feature map, where D is the depth multiplier, the convolution kernel size is (C, 1), and spatial patterns are extracted along the electrode channel dimension; after normalization, non-linearity is introduced through the ELU activation function, and the output is reshaped into (F1, F t , T) to separate the features of the temporal and spatial dimensions; t ​ The average pooling layer uses a (1×k1) pooling window along the time dimension to compress the time series to T / / k1, where " / / " represents taking the integer of the division result; discard some neurons with probability p to prevent overfitting; Use F t (1×k2) convolutional kernels are further used to fuse the temporal features, and the output shape is (F1, F t , S1), where S l is the length of the compressed temporal dimension; Map the features to (F1, S) through a (1×1) convolution d / / F1, S l ), and finally reshape it to (S d , S l ), and the output is a low-dimensional spatio-temporal feature sequence for processing by the classification module described later.

4. The few-shot motor imagery EEG signal classification method according to claim 1, characterized in that Dividing the source domain dataset into meta-training task sets includes: Forming meta-training tasks from the source domain dataset according to the experimental task type label and the subject task type label; Randomly select samples of c task categories from the source domain datasets corresponding to multiple experiments of the same subject. Extract k trials for each category as the support set, and the remaining trials as the query set.

5. The few-shot motor imagery EEG signal classification method according to claim 1, wherein The classification module includes: a spatial feature processing unit, a temporal attention mechanism unit, and a task classification and signal reconstruction unit; Among them, the spatial feature processing unit includes N s layer Transformer encoders to form a spatial attention network, which is used to obtain an intermediate feature representation S1 based on the spatio-temporal feature sequence output by the feature mapping module; The temporal attention unit is used to transpose the intermediate feature representation S1, and add a classification token cls_token at the front end of the sequence to obtain the intermediate feature representation S1' with tokens; incorporate the intermediate feature representation S1' with tokens into the positional encoding, and then send it into another temporal attention network composed of N t layers of Transformer encoders to obtain a feature sequence S2 containing rich spatio-temporal features; The task classification and signal reconstruction unit is used to send the classification tokens in the feature sequence S2 containing rich spatio-temporal features into a top-level classifier composed of fully connected layers to achieve effective classification of EEG signals, and input the remaining part excluding the classification tokens into the decoder network to restore the original EEG signals.

Citation Information

Cited By

  • Electroencephalogram intention decoding method and system based on multi-level adaptive system

    CN122594990A

  • Electroencephalogram intention decoding method and system based on multi-level adaptive system

    CN122594990B