Optimized EEGNet-based electroencephalogram signal online decoding method
By combining Euclidean alignment and optimization of the EEGNet network with five-fold cross-training and test-time adaptation, the robustness and real-time performance issues of EEG decoding models under cross-time periods and label-free conditions were solved, achieving lightweight online decoding of EEG signals and improving the stability and adaptability of online BCI systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-07
AI Technical Summary
Existing EEG decoding models lack robustness across time periods, sessions, and environments, struggle to adapt and update in unlabeled conditions, and have large parameter counts and high computational costs, making them unsuitable for real-time deployment in online BCI systems.
By employing Euclidean alignment preprocessing, optimizing the EEGNet network, and implementing a five-fold cross-integration training and testing time adaptation mechanism, combined with entropy minimization, consistency constraints, and contrastive loss, a lightweight online EEG signal decoding method is constructed to achieve real-time adaptive decoding under label-free conditions.
It significantly improves the stability and overall generalization performance of cross-time decoding, reduces the number of model parameters and computational load, enhances robustness to noise and distribution drift, and meets the real-time and resource-constrained deployment requirements of online BCI systems.
Smart Images

Figure CN121808495A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of electroencephalogram (EEG) signal processing, deep learning, and motor brain-computer interface technology. Specifically, it relates to an online decoding method for EEG signals based on an optimized EEGNet, which can be applied to scenarios such as motor imagery brain-computer interface control, neurorehabilitation training, and online neural monitoring. Background Technology
[0002] Brain-computer interfaces (BCIs) acquire and analyze electroencephalogram (EEG) signals, decoding them into control commands for external devices. They have been widely used in fields such as assistive control, rehabilitation training, and human-computer interaction. However, EEG signals are characterized by strong time-varying properties, high noise levels, and significant individual differences, which makes the performance of decoding models prone to significant degradation under conditions that span across time periods, sessions, or even days.
[0003] Transfer learning is an important technique for addressing cross-domain distribution differences. Its basic idea is to learn transferable feature representations in the source domain and then transfer them to the target domain to reduce the need for target domain annotation. A typical process includes: pre-training a model on large-scale source domain data, fixing a portion of the network as a feature extractor, fine-tuning subsequent layers in the target domain, and applying the transferred model to downstream tasks. Transfer learning has achieved significant results in image recognition, natural language processing, and recommender systems, and has also been used in EEG decoding to address issues related to cross-subject, cross-time, and cross-device data.
[0004] However, traditional transfer learning typically relies on labeled samples from the target domain for fine-tuning or domain alignment. For online BCI systems, the target domain often lacks real-time labels during actual operation, subject states change rapidly, and annotation costs are extremely high, making it impossible to frequently retrain the model using conventional transfer learning procedures.
[0005] Online Test-Time Adaptation (TTA) aims to improve the model's adaptability to the current distribution by updating model parameters through unsupervised optimization of the current input samples or mini-batch samples, without requiring target domain labels during the testing phase. Typical methods achieve model self-correction during the inference phase by minimizing prediction entropy, enhancing consistency, or constraining the latent space structure based on contrastive learning. For EEG signals exhibiting strong time-varying and drift characteristics, TTA can continuously correct the model without relying on manual annotation, contributing to improved stability of online BCI systems.
[0006] On the other hand, existing EEG decoding models mostly employ complex deep network structures, such as multi-layer convolutional or Transformer networks. These structures have a large parameter size and high forward inference overhead, making them difficult to deploy in resource-constrained or low-latency online systems. To meet real-time requirements, a lightweight network with a relatively simple structure and a small number of parameters is needed, which can still effectively extract temporal and spatial features.
[0007] EEGNet (Electroencephalogram Convolutional Neural Network) is a lightweight convolutional neural network designed specifically for electroencephalogram (EEG) signals. It uses depthwise separable convolutions to capture temporal and spatial features and is widely used for tasks such as motor imagery and event-related potentials (ERPs). However, the original EEGNet has limited capabilities in frequency band segmentation and attention focusing, and it does not consider online adaptation mechanisms for testing time, which may still lead to performance degradation when faced with cross-time period drift.
[0008] Therefore, how to build a label-free online decoding method for EEG signals that can be continuously updated over time based on the original EEGNet network structure by combining source domain training and target domain online testing time adaptation has become a technical problem that urgently needs to be solved in this field.
[0009] Existing online EEG decoding methods have the following shortcomings: 1. The model is not robust enough under cross-time period, cross-session and cross-environment conditions, and is easily affected by changes in electrode contact and fluctuations in physiological state, resulting in a significant decrease in classification accuracy; 2. Online target domains often lack labels, making it impossible to employ supervised fine-tuning strategies in traditional transfer learning, and the model struggles to adaptively update to new distributions; 3. Existing deep networks have a large number of parameters and high computational cost, which is not conducive to real-time deployment in online BCI systems; 4. Existing methods lack a unified technical solution that combines band-interpretable modeling, Euclidean alignment, and test time adaptation, resulting in a disconnect between feature modeling and online updating of EEG signals. Summary of the Invention
[0010] The present invention aims to overcome the above-mentioned shortcomings of the prior art and provide an online decoding method for electroencephalogram (EEG) signals based on an optimized EEGNet.
[0011] This invention achieves real-time adaptive decoding of unlabeled EEG signals in the target domain by employing Euclidean alignment preprocessing, introducing an optimized EEGNet network, source domain five-fold cross-integration training, and online test time adaptation based on entropy minimization, consistency constraints, and contrast loss.
[0012] The present invention provides an online decoding method for electroencephalogram (EEG) signals based on an optimized EEGNet, comprising the following steps: Step 1: Data preprocessing and domain construction. Through bandpass filtering, channel normalization and Euclidean alignment operations, the raw EEG signal is transformed into the covariance normalized space to construct source domain and target domain data, and the source domain is further divided into training set and validation set.
[0013] Step 2: Construct an optimized EEGNet network. The structure of the optimized EEGNet network is as follows: starting from the input layer, it is connected sequentially to the Sinc convolutional layer, the temporal convolutional layer, the depthwise separable convolutional layer, the batch normalization layer, the channel attention layer, the Dropout layer, the global average pooling layer, the fully connected layer, and the output layer.
[0014] The Sinc convolutional layer is used for learnable band filtering and frequency domain feature extraction of the input EEG signal; the temporal convolutional layer is used for extracting features in the time dimension; the depthwise separable convolution is used to model fine-grained features within a single channel and spatial correlations between channels; the channel attention layer is used to adaptively allocate weights based on the feature responses of each channel; the global average pooling layer is used to reduce the feature dimensionality; the fully connected layer is used to map the EEG embedding vector to the category representation space; and the output layer is used to output the predicted probability of each EEG signal category.
[0015] Step 3: Offline training and ensemble modeling. The source domain training set is trained using a five-fold cross-validation strategy. The classification error is minimized using the cross-entropy loss function to obtain multiple sub-models with complementary generalization performance. Then, an ensemble model is constructed using a soft voting strategy.
[0016] Step 4: Online testing and in-memory database construction. The target domain data input by streaming is pre-aligned and then input into the pre-trained ensemble model. Soft voting is performed on the class probabilities output by each sub-model to obtain the prediction results. The aligned target domain test samples and their predicted probability vectors are then stored in the in-memory database. Step 5: Test the online adaptation. Select target domain samples from the memory library to construct two random mask views, calculate the entropy minimization loss, consistency loss, and latent space structure constraint loss based on contrastive learning, and combine the three in a weighted manner into a joint objective. Use the Adam optimization algorithm to update the selected trainable parameters in the encoding network and classification head, so that the model can continuously adapt to the actual distribution of the target domain under unlabeled conditions.
[0017] After step 5, step 4 is executed to predict new streaming target domain data, thus forming a closed loop between step 4 and step 5 until no target domain data arrives.
[0018] Furthermore, step 1 specifically includes: Step 101: Bandpass filtering of the raw EEG signal Apply a 4–38 Hz bandpass filter The filtered signal is obtained as follows: (1) Step 102: Channel normalization, calculate the mean of each channel for each test sample along the time dimension. with standard deviation Perform z-score normalization to obtain the normalized signal: (2) Step 103: Euclidean alignment, for the normalized source domain sample set Calculate the reference covariance matrix:
[0019] Obtained through eigenvalue decomposition or singular value decomposition. And perform a linear transformation on each sample: (4) Step 104: Domain partitioning and dataset construction. The aligned data is divided into source domain and target domain according to experimental sessions, time periods, or subject information. The source domain samples are labeled with categories, while the target domain samples are unlabeled. The source domain samples are then divided into training set and validation set.
[0020] Furthermore, step 2 specifically includes: Step 201: Sinc convolution frequency feature extraction, utilizing multiple learnable frequency parameters in the time dimension. Defined Sinc convolution kernel: (5) Perform one-dimensional or two-dimensional convolution operations on the input signal to obtain a frequency feature map; Step 202: Temporal convolution feature extraction. In the time dimension, a convolution kernel with a kernel size of (1, k_t) is used to perform temporal convolution on the output of the Sinc convolution to extract local temporal patterns and instantaneous change features. Step 203: Depth-separable convolution spatial feature extraction, using channel-wise convolution with kernel size (1, k_s) and pointwise convolution with kernel size (C, 1), where C is the number of EEG channels. The combination of channel-wise convolution and pointwise convolution extracts spatial distribution features and reduces the number of parameters. Step 204: Batch normalization and nonlinear activation. Apply BatchNorm and ReLU activation functions to the depthwise separable convolution output to suppress internal covariate shift and enhance the model's nonlinear representation capability. Step 205: Channel attention and feature compression, processing the convolutional feature map. Using channel attention mechanism: (6) in As a trainable weight matrix, a weighted feature map is obtained to highlight key channel information. Subsequently, a global average pooling layer is used to downsample the temporal and spatial dimensions, and Dropout is used to suppress overfitting. Finally, the feature map is flattened into an embedding vector. ; Step 206: The classifier outputs probabilities, and the embedding vectors are... Inputting a fully connected layer and a Softmax classifier yields the category conditional probability distribution, which is used for EEG signal category discrimination.
[0021] Furthermore, step 3 specifically includes: Step 301: Five-fold cross partitioning, dividing the source domain training set into 5 non-overlapping subsets.
[0022] Each time, one set is selected as the validation set, and the other four are selected as the training subset. Step 302: Sub-model training and validation. In each fold, minimize the cross-entropy loss for the training subset:
[0023] in Let k be the number of samples in the kth fold. For the sample In category The function that indicates the true label on the surface. For the corresponding predicted probability; Step 303: Ensemble model construction. Fix the parameters of the five trained sub-models, and average the prediction probabilities of each sub-model during inference to obtain the ensemble probability.
[0024] Furthermore, step 4 specifically includes: Step 401: Target domain pre-alignment. The raw EEG data of the target domain arriving by streaming is bandpass filtered, channel normalized and Euclidean aligned according to steps 101 to 103 to ensure that the input and source domains are distributed as consistent as possible in the covariance space. Step 402: Integrated model prediction, aligning the target domain samples Input each sub-model and obtain the output probability vector of each sub-model. The integration probability is obtained through soft voting:
[0025] Step 403: Online output prediction, based on The predicted category of the current experiment is obtained by using the category index corresponding to the largest component, thus enabling online decoding of streaming target domain data; Step 404: Update the memory library, and add the aligned target domain sample. Its integrated probability vector Write to memory in chronological order If the memory library capacity exceeds the preset limit, samples from earlier periods or with low confidence will be removed according to the first-in-first-out or confidence-first strategy.
[0026] Furthermore, step 5 specifically includes: Step 501: Construct a random masked view by sampling a batch of target domain samples from the memory library. Two random enhancement or masking operations are applied to each sample to obtain the view. The enhancements include at least one of time occlusion, channel occlusion, Gaussian noise perturbation, and slight time stretching; Step 502: Calculate the entropy minimization loss by inputting the augmented view into the current model to obtain the predicted probability. The loss for minimizing entropy is defined as:
[0027] Step 503: Calculate consistency loss and extract the feature vectors of the two views from the layer before the classifier. The consistency loss is defined as:
[0028] Step 504: Compare the loss calculation, select the high-confidence sample as the positive sample pair, and compare the two views of the same original sample. As positive pairs, different samples are considered negative pairs, with temperature parameters used as... InfoNCE form of contrast loss:
[0029] Step 505: Joint Loss and Parameter Update. The three types of losses are adjusted according to preset weighting coefficients. The combination is a joint loss:
[0030] The stochastic Adam optimization algorithm is used to update the selected trainable parameters in the encoder and classifier head in multiple steps to obtain an online decoding model that is more adapted to the distribution of the target domain.
[0031] The present invention has the following beneficial effects: 1. By channel normalization and Euclidean alignment, combined with five-fold cross-training and ensemble modeling, the covariance difference between the source and target domains is significantly reduced, suppressing overfitting of the source domain and enabling the feature extraction network to work in a unified space, thereby improving the stability of cross-time decoding and the overall generalization performance.
[0032] 2. A learnable Sinc convolutional kernel is introduced into the original EEGNet encoding network to parameterize the frequency band division process and allow the network to automatically optimize it. This enables adaptive frequency band modeling for different tasks and individuals, offering both good interpretability and flexibility. While maintaining feature representation capabilities, the number of model parameters and computational load are significantly reduced, meeting the deployment requirements of online BCI systems in real-time and resource-constrained scenarios.
[0033] 3. Under the condition of no label in the target domain, an online adaptation mechanism for test time is introduced. By using the joint loss consisting of entropy minimization, consistency constraint and contrast loss, the model can be continuously updated by relying only on the structural information of the current and historical target domain samples. This enhances the robustness of the model to noise, short-term fluctuations and gradual distribution drift, and improves the maintainability of the system in the long term. Attached Figure Description
[0034] To more clearly illustrate the technical solution of the present invention, the present invention will be further described below with reference to the accompanying drawings. The accompanying drawings schematically illustrate the structure and process of the present invention and do not constitute a limitation on the scope of protection of the present invention.
[0035] Figure 1 This is a flowchart illustrating the overall processing flow of the online EEG signal decoding method of the present invention, showing steps 1 to 5. A loop structure is formed between steps 4 and 5 to continuously process streaming target domain data.
[0036] Figure 2 This is a schematic diagram illustrating the structure of the optimized EEGNet encoding network of this invention.
[0037] Figure 3 This diagram illustrates the memory library and joint loss optimization process of the online testing time adaptation module of the present invention, showing the construction of random mask view, entropy minimization, calculation of consistency loss and contrast loss, and online update of model parameters. Detailed Implementation
[0038] The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be understood that the embodiments described herein are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. Without departing from the concept of the present invention, those skilled in the art can substitute or adjust the parameters, structures, and order of steps, all of which shall fall within the scope of protection of the present invention.
[0039] This embodiment provides an online decoding method for electroencephalogram (EEG) signals, including the following steps.
[0040] 1. Data preprocessing and domain construction; like Figure 1 As shown, the system first acquires multi-channel EEG signals, and then divides the continuous signals into two-dimensional data blocks according to the test or time window. .
[0041] In step 101, each data block is bandpass filtered from 4 to 38 Hz to eliminate DC drift and high-frequency noise, while preserving the μ-rhythm and β-rhythm components associated with motion imagery.
[0042] In step 102, the mean value of each channel within the current test time window is subtracted and divided by the standard deviation to ensure comparability between different tests and channels.
[0043] In step 103, the reference covariance matrix is calculated for all normalized samples in the source domain. And through eigenvalue decomposition get Alignment transformation is performed on each sample. The same transformation is applied to the target domain samples using the same reference matrix to achieve cross-domain Euclidean alignment.
[0044] In step 104, based on the collection period or experimental information, the aligned samples are divided into source and target domains according to whether they are labeled. Then, the source domain samples are randomly divided into training and validation sets, for example, in an 8:2 ratio.
[0045] 2. Build and optimize the EEGNet network; like Figure 2 As shown, step 2 employs a lightweight coding network based on an improved EEGNet. The input is the aligned sample. .
[0046] First, Input to a Sinc convolutional layer, utilizing multiple sets of learnable frequency parameters Defined Sinc convolution kernel One-dimensional convolution is performed on each channel to achieve learnable frequency band filtering and frequency domain feature extraction of EEG signals.
[0047] Subsequently, local temporal patterns and instantaneous change features are extracted by sliding temporal convolutional layers along the time axis. Then, a depthwise separable convolutional structure is used to perform channel-by-channel convolution within each channel and fuse cross-channel spatial information through pointwise convolution. At the same time, a batch normalization layer and a ReLU activation function are added after convolution to stabilize network training and enhance nonlinear representation capabilities.
[0048] Next, the convolutional output is fed into the channel attention module, where channel weights are generated through global pooling and linear mapping to recalibrate the feature map, giving higher weights to channels related to motor imagery. Then, a global average pooling layer compresses the temporal and spatial dimensions, and a Dropout layer suppresses overfitting. The compressed features are then flattened into EEG embedding vectors. .
[0049] Finally, embedding vector By inputting a fully connected layer and a Softmax output layer, the predicted probabilities of each EEG signal category are obtained.
[0050] 3. Source domain offline training and ensemble modeling; In step 3, the source domain training set is divided into 5 subsets, which are used alternately as the validation set in each fold, and the remainder as the training set. In each fold, the Adam optimization algorithm is used to train the set with cross-entropy loss as the objective, until the validation set accuracy or loss converges.
[0051] After training, the optimal model parameters for each fold are retained, forming five sub-models. During online prediction, the prediction probabilities of the five sub-models on the same input are calculated and averaged to obtain a more robust ensemble prediction result, effectively reducing the risk of a single model being affected by initialization and sample partitioning.
[0052] 4. Online prediction and in-memory library construction; During the system deployment phase, target domain EEG data is continuously input in streaming form. Upon reaching a new experimental window, the system performs preprocessing and alignment according to steps 101 to 103, and then inputs it into the five source domain sub-models to obtain their respective predicted probabilities.
[0053] The final ensemble probability distribution is obtained by averaging the five probability vectors through soft voting, and the predicted category of the current experiment is output accordingly. This can be used to control external devices or provide feedback.
[0054] Simultaneously, in step 404, the system stores the aligned sample and its integration probability vector in a memory database as key-value pairs. The memory database can be implemented using a circular queue or a priority queue. When the number of stored samples exceeds a set upper limit, old samples are removed according to a first-in-first-out (FIFO) or confidence-first strategy to ensure that online adaptation is always based on the latest target domain distribution.
[0055] The aforementioned in-memory database data will be used for online testing time adaptation in step 5, and will continue to participate in a new round of online predictions after the model is updated.
[0056] 5. Online adaptation for testing time; like Figure 3As shown, the online adaptation module is triggered periodically or at fixed steps. A batch of target domain samples is randomly sampled from the memory library, and two random mask views are generated for each sample to enhance the model's robustness to noise and perturbations.
[0057] The current model performs forward inference on the two views separately to obtain predicted probabilities and intermediate feature vectors. Entropy minimization, consistency loss, and contrastive loss are calculated, and the three are weighted and summed to obtain the joint loss. .
[0058] Use a small learning rate to update selected parameters in the network to avoid significantly compromising the discriminative ability already learned in the source domain. Optionally, update only the scaling and translation parameters of the batch normalization layers or the parameters of the last few layers to further control the stability of the model.
[0059] Over time, the model gradually adapts to the statistical characteristics of the target domain based on the knowledge of the source domain, effectively mitigating the performance degradation caused by changes in electrode impedance, subject fatigue, and environmental interference, and achieving long-term stable operation of online decoding of EEG signals.
[0060] After each parameter update based on joint loss, the model returns to step 4 to continue online prediction and storage of subsequent streaming target domain samples until no more target domain data arrives.
[0061] Those skilled in the art will understand that, without departing from the technical concept of the present invention, various modifications and adjustments can be made to the frequency initialization of Sinc convolution, the type of attention module, the sampling strategy of contrastive loss, the memory bank update mechanism, etc. For example, replacing contrastive learning with prototype-based clustering constraints, introducing a temperature adaptive mechanism, etc., should all be considered to fall within the protection scope of the present invention.
[0062] In summary, this invention organically combines domain alignment preprocessing, optimized EEGNet feature extraction, source domain integration training, and online adaptation of target domain testing time to form a lightweight online EEG signal decoding scheme with a complete technical chain, engineering feasibility, and quantitatively verifiable results, meeting the requirements of technicality, feasibility, and verifiability in my country's patent law.
Claims
1. A method for online decoding of electroencephalogram (EEG) signals based on an optimized EEGNet, characterized in that, Includes the following steps: Step 1: Data preprocessing and domain construction. The raw EEG signals are preprocessed to obtain source domain data and target domain data. The source domain data is used for offline training, and the target domain data is used for online testing and adaptation. Step 2: Build an optimized EEGNet network. The structure of the optimized EEGNet network is as follows: starting from the input layer, it is connected sequentially to the Sinc convolutional layer, the temporal convolutional layer, the depthwise separable convolutional layer, the batch normalization layer, the channel attention layer, the Dropout layer, the global average pooling layer, the fully connected layer, and the output layer. The Sinc convolutional layer is used to perform learnable band filtering and frequency domain feature extraction on the input EEG signal; the temporal convolutional layer is used to extract features in the time dimension; the depthwise separable convolution is used to model fine-grained features within a single channel and spatial correlations between channels; and the channel attention layer is used to adaptively allocate weights based on the feature responses of each channel. The global average pooling layer is used to reduce the feature dimension; The fully connected layer is used to map the EEG embedding vector to the category representation space; the output layer is used to output the predicted probability of each EEG signal category. Step 3: Offline training and ensemble modeling. Based on the source domain training set, five-fold cross-training is used to minimize the cross-entropy loss, resulting in multiple sub-models. The sub-models are then combined to form a pre-trained ensemble model. Step 4: Online testing and in-memory database construction. The target domain data input by streaming is pre-aligned and then input into the pre-trained ensemble model. Soft voting is performed on the class probabilities output by each sub-model to obtain the prediction results. The aligned target domain test samples and their predicted probability vectors are then stored in the in-memory database. Step 5: Online testing for time adaptation. Construct a random mask view for the target domain samples in the memory library, calculate the joint loss consisting of entropy minimization loss, consistency loss, and contrast loss, and use the joint loss to perform online iterative updates to the encoding network and classification head, so that the model can adapt under the condition of no label target domain; continue to execute step 4 to predict new streaming target domain data, thus forming a closed loop between step 4 and step 5, until no target domain data arrives.
2. The method according to claim 1, characterized in that, Step 1 includes: Step 101: Bandpass filtering of the raw EEG signal Apply a 4–38 Hz bandpass filter The filtered signal is obtained as follows: Step 102: Channel normalization, calculate the mean of each channel for each test sample along the time dimension. with standard deviation Perform z-score normalization to obtain the normalized signal: Step 103: Euclidean alignment, for the normalized source domain sample set Calculate the reference covariance matrix: Obtained through eigenvalue decomposition or singular value decomposition. And perform a linear transformation on each sample: Step 104: Domain partitioning and dataset construction. The aligned data is divided into source domain and target domain according to experimental sessions, time periods, or subject information. The source domain samples are labeled with categories, while the target domain samples are unlabeled. The source domain samples are then divided into training set and validation set.
3. The method according to claim 1, characterized in that, Step 2 includes: Step 201: Sinc convolution frequency feature extraction, utilizing multiple learnable frequency parameters in the time dimension. Defined Sinc convolution kernel: Perform one-dimensional or two-dimensional convolution operations on the input signal to obtain a frequency feature map; Step 202: Temporal convolution feature extraction. In the time dimension, a convolution kernel with a kernel size of (1, k_t) is used to perform temporal convolution on the output of the Sinc convolution to extract local temporal patterns and instantaneous change features. Step 203: Depth-separable convolution spatial feature extraction, using channel-wise convolution with kernel size (1, k_s) and pointwise convolution with kernel size (C, 1), where C is the number of EEG channels. The combination of channel-wise convolution and pointwise convolution extracts spatial distribution features and reduces the number of parameters. Step 204: Batch normalization and nonlinear activation. Apply BatchNorm and ReLU activation functions to the depthwise separable convolution output to suppress internal covariate shift and enhance the model's nonlinear representation capability. Step 205: Channel attention and feature compression, processing the convolutional feature map. Using channel attention mechanism: (6) in As a trainable weight matrix, a weighted feature map is obtained to highlight key channel information. Subsequently, a global average pooling layer is used to downsample the temporal and spatial dimensions, and Dropout is used to suppress overfitting. Finally, the feature map is flattened into an embedding vector. ; Step 206: The classifier outputs probabilities, and the embedding vectors are... Inputting a fully connected layer and a Softmax classifier yields the category conditional probability distribution, which is used for EEG signal category discrimination.
4. The method according to claim 1, characterized in that, Step 3 includes: Step 301: Five-fold cross partitioning, dividing the source domain training set into 5 non-overlapping subsets. Each time, one set is selected as the validation set, and the other four are selected as the training subset. Step 302: Sub-model training and validation. In each fold, minimize the cross-entropy loss for the training subset: in Let k be the number of samples in the kth fold. For the sample In category The function that indicates the true label on the surface. For the corresponding predicted probability; Step 303: Ensemble model construction. Fix the parameters of the five trained sub-models, and average the prediction probabilities of each sub-model during inference to obtain the ensemble probability. 。 5. The method according to claim 1, characterized in that, Step 4 includes: Step 401: Target domain pre-alignment. The raw EEG data of the target domain arriving by streaming is bandpass filtered, channel normalized and Euclidean aligned according to steps 101 to 103 to ensure that the input and source domains are distributed as consistent as possible in the covariance space. Step 402: Integrated model prediction, aligning the target domain samples Input each sub-model and obtain the output probability vector of each sub-model. The integration probability is obtained through soft voting: Step 403: Online output prediction, based on The predicted category of the current experiment is obtained by using the category index corresponding to the largest component, thus enabling online decoding of streaming target domain data; Step 404: Update the memory library, and add the aligned target domain sample. Its integrated probability vector Write to memory in chronological order If the memory library capacity exceeds the preset limit, early or low-confidence samples are removed according to the first-in-first-out or confidence-first strategy; these samples are then used for online adaptation in subsequent step 5 and prediction updates of a new batch of streaming target domain data.
6. The method according to claim 1, characterized in that, Step 5 includes: Step 501: Construct a random masked view by sampling a batch of target domain samples from the memory library. Two random enhancement or masking operations are applied to each sample to obtain the view. The enhancements include at least one of time occlusion, channel occlusion, Gaussian noise perturbation, and slight time stretching; Step 502: Calculate the entropy minimization loss by inputting the augmented view into the current model to obtain the predicted probability. The loss for minimizing entropy is defined as: Step 503: Calculate consistency loss and extract the feature vectors of the two views from the layer before the classifier. The consistency loss is defined as: Step 504: Compare the loss calculation, select the high-confidence sample as the positive sample pair, and compare the two views of the same original sample. As positive pairs, different samples are considered negative pairs, with temperature parameters used as... InfoNCE form of contrast loss: Step 505: Joint Loss and Parameter Update. The three types of losses are adjusted according to preset weighting coefficients. The combination is a joint loss: The stochastic Adam optimization algorithm is used to update the selected trainable parameters in the encoder and classifier in multiple steps to obtain an online decoding model that is more adapted to the distribution of the target domain. After the parameter update is completed, the algorithm returns to step 4 to continue to predict and store new streaming target domain samples online, so as to achieve continuous cyclic adaptation.