Self-adaptive optimization method and system for online decoding of motor imagery brain-computer interface
By combining dynamic category threshold filtering and time-of-test re-normalization (TBR) with a dynamic online reweighting mechanism, the problem of model performance degradation during cross-user adaptation is solved, achieving efficient adaptive optimization of the MI-BCI model on the target user and improving the stability and robustness of feature representation.
Patent Information
- Application Number
- CN202610100392.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-26
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2046-01-26
AI Technical Summary
Existing technologies suffer from several problems in cross-user adaptation, including insufficient adaptability of samples selected with fixed thresholds, inaccurate estimation of batch normalization statistics, and model optimization bias caused by differences in sample confidence and class imbalance, which lead to a decline in the performance of the MI-BCI model on the target users.
A dynamic category threshold mechanism is used to screen high-confidence samples. Combined with test-time batch renormalization (TBR) and dynamic online reweighting mechanism, the update of normalization statistics and parameter optimization are decoupled. The feature space distribution is optimized by decoupling prototype comparative learning, thereby achieving adaptive optimization of the model.
It significantly improves the stability and adaptability of the model's feature representation on target domain data, enhances the adaptive robustness in class imbalance scenarios, ensures the stability and real-time performance of online learning, and meets privacy protection requirements.
Smart Images

Figure CN121561684A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of brain-computer interface (BCI) technology, specifically relating to an adaptive optimization method and system for online decoding of brain-computer interfaces for motor imagery (MI). Background Technology
[0002] Motor imagery brain-computer interfaces (BCIs) are technologies that enable direct communication and interaction between the human brain and external devices (such as computers and rehabilitation equipment) by decoding the electroencephalogram (EEG) signals generated during a user's motor imagery process. They hold significant promise for applications in the field of neurorehabilitation. However, EEG signals exhibit significant individual variability, non-stationarity, and susceptibility to noise interference. This leads to a severe performance degradation when a decoding model trained on data from one user (source domain) is directly applied to another new user (target domain) due to a large shift in the distribution of EEG features—a problem known as the cross-user adaptation problem.
[0003] To address the cross-domain adaptation problem, Test-Time Adaptation (TTA) has gained attention in recent years. TTA, under privacy constraints, can update pre-trained models online without source domain data, generating pseudo-labels from unlabeled test samples in the target domain and selecting high-confidence samples to quickly adapt to the EEG feature distribution of the target user. However, existing TTA methods have the following limitations: First, traditional methods use a fixed confidence threshold to select high-confidence samples, which cannot adapt to dynamic changes in different categories. Second, the batch normalization layer has a fundamental flaw in its test-time statistic calibration mechanism: when model parameters are updated through gradient optimization, the normalized statistics are disturbed by the gradient and deviate from the true distribution of the target domain, leading to unstable feature representations, especially in small-batch or sample-dependent testing scenarios. Furthermore, the model update process tends to favor the dominant class, resulting in significant performance degradation when facing class-imbalanced test data streams. Simultaneously, existing contrastive learning strategies fail to fully utilize prototype information to optimize the feature space distribution, limiting the adaptive effect.
[0004] In summary, in the passive domain adaptive scenario under privacy protection constraints, how to design a dynamic category threshold mechanism to accurately screen high-confidence samples to ensure the reliability of model updates, how to decouple statistical updates and parameter optimization to improve the stability of feature representation, and how to optimize the feature space distribution through a prototype-based contrastive learning strategy, so as to achieve efficient and reliable adaptation of the MI-BCI model without relying on source data, are problems that urgently need to be solved by those skilled in the art. Summary of the Invention
[0005] In view of the deficiencies in the prior art, the technical problems to be solved by the present invention are reflected in the following points.
[0006] Addressing the insufficient adaptability of fixed thresholds for sample screening: To address the problem that fixed thresholds in traditional TTA cannot adapt to the dynamic changes in confidence distribution across different categories, this invention proposes a dynamic category threshold mechanism. By fusing sample prediction entropy and category frequency information, an optimal threshold is dynamically set for each category, thereby improving the accuracy and reliability of high-confidence sample screening.
[0007] Addressing the issue of inaccurate batch normalized statistic estimation: To address the mismatch between normalized statistics and the target domain distribution during test-time adaptation, this invention introduces Test-time Batch Renormalization (TBR). Traditional methods suffer from gradient interference during parameter optimization, causing normalized statistics to deviate from the true distribution of the target domain, particularly in small-batch or sample-dependent scenarios. TBR decouples statistic updates from parameter optimization by introducing a stop gradient operation. Simultaneously, it integrates the current test batch statistics and dynamically maintained moving average statistics using a correction factor. This ensures both the adaptability of the normalization process to the current data distribution and the stability of statistic estimation, significantly improving the model's feature representation quality and adaptive performance on distributed biased data.
[0008] To address the optimization bias caused by sample confidence differences and class imbalance, this invention designs a dynamic online reweighting mechanism to overcome the shortcomings of TTA (Targeted Assessment) in ignoring confidence differences and class imbalances within already selected high-confidence samples. This mechanism assigns weights to high-confidence samples that have passed the entropy threshold selection based on their predicted entropy value and class frequency: samples with lower entropy values receive higher weights. Simultaneously, weight compensation is applied to samples from rare classes. This design effectively balances the contribution of each class to model updates, significantly improving adaptive robustness in class imbalance testing scenarios.
[0009] The technical solution of the present invention is as follows:
[0010] On the one hand, this invention provides an adaptive optimization method for online decoding of brain-computer interfaces for motor imagery, characterized by including an offline preparation phase and an online adaptive phase:
[0011] The offline preparation phase includes:
[0012] S11. Source domain preprocessing steps: Preprocess the motor imagery EEG signals of the source domain users, including baseline drift removal, bandpass filtering, and average reference rereference processing, to obtain preprocessed source domain data;
[0013] S12. Source domain model training steps: Based on the preprocessed source domain data, train an initial classification model for motion imagery;
[0014] S13. Model initialization steps: Copy the parameters and normalized statistics of the initial classification model, and use them to initialize the teacher model and student model respectively;
[0015] The online adaptive phase is executed iteratively based on the target user's real-time unlabeled EEG data stream, with each iteration including:
[0016] S21. Target Domain Online Preprocessing and Feature Extraction Steps: Perform the same processing as the source domain preprocessing steps on the real-time acquired single target domain EEG signals, and simultaneously input the preprocessed samples into the teacher model and the student model; during the forward propagation of the models, use test-time batch renormalization technology to normalize the features. The test-time batch renormalization technology decouples the update of statistics used for normalization from the gradient optimization of model parameters by stopping gradient operations; record the pseudo-labels output by the teacher model, the intermediate features extracted by the student model, and the predicted entropy of the samples, and store them in the sample buffer;
[0017] S22 Triggering and Statistics Update Steps: When the number of samples accumulated in the sample buffer reaches the preset batch size, the model update process is triggered, and the moving average statistics used for the batch renormalization technique during the test are updated based on the batch data.
[0018] S23. Dynamic sample screening step: Based on the pseudo-labels of all samples in the sample buffer, calculate the dynamic occurrence frequency of each category; according to the dynamic occurrence frequency of each category and the predicted entropy distribution of the current batch of samples, calculate a dynamically adjusted entropy threshold for each category; based on the dynamic entropy threshold, screen out a high-confidence sample set from the sample buffer.
[0019] S24. Dynamic reweighting step: For each sample in the high confidence sample set, a dynamic weight is calculated based on its predicted entropy value and the dynamic occurrence frequency of its category, wherein the calculation of the dynamic weight makes the sample with the lower predicted entropy value have a higher weight, and the sample with the lower occurrence frequency of its category receives a higher weight compensation.
[0020] S25. Decoupling Prototype Comparison Learning Steps: Extract prototype vectors for each category from the initial classification model as fixed references; calculate the decoupling prototype comparison loss based on the feature vectors extracted by the student model from the high-confidence sample set. The loss is used to narrow the distance between the sample features and their corresponding category prototype vectors, and to widen the distance between them and other category prototype vectors. The prototype vectors remain fixed during the calculation process.
[0021] S26. Weighted distillation learning step: Based on the output of the teacher model and the student model to the high-confidence sample set, and the dynamic weights calculated in S24, calculate the weighted distillation loss;
[0022] S27. Student model update steps: Update the parameters of the student model based on the total loss consisting of the decoupled prototype contrast loss and the weighted distillation loss;
[0023] S28. Teacher model update steps: Synchronize the updated parameters of the student model to the teacher model using an exponential moving average strategy;
[0024] S29. Clear the sample buffer and prepare for the next iteration.
[0025] Furthermore, the test batch renormalization technique includes:
[0026] Preprocessed single target domain samples Input the teacher model and student model respectively, using the currently maintained test-time moving average statistic ( and The normalized characteristics are calculated using the TBR formula based on the single-sample statistic and the TBR formula:
[0027]
[0028] in , ;
[0029] Simultaneously, the predicted output of the teacher model As a pseudo-label for the current sample; : Normalized eigenvalues The original features output from the batch normalization layer. : The mean of all features in the current input batch. : Standard deviation of all sample features in the current input batch, r: scaling calibration factor, d: offset calibration factor. : The historical characteristic mean accumulated through the exponential moving average (EMA) : Historical characteristic standard deviation accumulated through exponential moving average (EMA)
[0030] : Stop the gradient operator, prevent the gradient from being backpropagated through the calculation within the parentheses, and maintain the independence of the statistical estimate.
[0031] When the accumulated sample buffer reaches the preset batch size B, the current batch statistic is calculated. and ), and update the moving average statistic at test time using the stopping gradient operation:
[0032]
[0033] in For smoothing coefficients, This indicates that the gradient operation is stopped. : The historical characteristic mean accumulated through the exponential moving average (EMA) : Historical characteristic standard deviation accumulated through exponential moving average (EMA) The smoothing coefficient controls the weighting ratio between historical statistics and current batch statistics. The gradient of the current batch mean is blocked. The gradient of the standard deviation of the current batch is blocked.
[0034] Furthermore, the calculation of the dynamic entropy threshold for each category specifically includes:
[0035] Online frequency statistics for each category c ,in For update rate, For the frequency estimate of category c at the previous time step, For indicator functions, Assign the predicted category to the teacher model for the current sample; impose boundary constraints on the frequency values. ,in , To prevent extreme estimations;
[0036] Calculate the basic dynamic entropy threshold ,in Based on the basic entropy threshold, C is the class imbalance adjustment coefficient; C is the number of classes. The average frequency of all categories, calculated using the formula 1 / C. : The cumulative historical frequency of the current category c in the target domain.
[0037] Dynamically adjust based on the current batch prediction confidence level:
[0038]
[0039] in Let c be the average entropy of category c in the current batch. The average entropy of all categories, This is the set of samples predicted as class c in the current batch. The time decay coefficient, This is the confidence level adjustment factor;
[0040] Apply threshold boundary constraints: ;
[0041] in, This prevents extreme values from appearing on the threshold.
[0042] Furthermore, the dynamic reweighting step specifically includes:
[0043] Calculate the maximum value of the dynamic entropy threshold for all categories in the current batch as the normalization baseline:
[0044]
[0045] in, Total number of categories The dynamic thresholds for each category calculated in step 4.2;
[0046] For each high confidence sample (Predicted category is c), calculate the basic weights using the following formula:
[0047]
[0048] in, For the sample Predicted entropy, The average category frequency, For the frequency of category c, This is the frequency compensation index. To prevent division by zero of small constants;
[0049] Apply boundary constraints to the basic weights to prevent extreme values:
[0050]
[0051] in , ;
[0052] Weight normalization and gradient stability are ensured by normalizing the weights of high-confidence samples so that the sum of the normalized weights equals the number of high-confidence samples.
[0053]
[0054] The high-confidence sample set refers to the subset of samples selected for model updates. Number of high-confidence samples.
[0055] Furthermore, the decoupled prototype contrastive learning step specifically calculates the contrastive loss independently for each category prototype, as shown in the following formula:
[0056]
[0057] in, The feature subset of the high-confidence samples that predicts class k. This represents the actual number of categories present in the current batch. Represents cosine similarity. Temperature coefficient; The prototype of category k : Features of high-confidence samples predicted as class k Predict the features of samples that are not of class k. Cosine similarity between the prototype and the positive sample. Cosine similarity between the prototype and the negative sample.
[0058] Furthermore, in the weighted distillation learning step, the weighted distillation loss formula is as follows:
[0059]
[0060] in To normalize sample weights, the teacher model generates soft labels. As the target distribution, the student model predicts as .
[0061] This invention also provides an adaptive optimization system for online decoding of brain-computer interfaces for motor imagery, characterized in that it includes:
[0062] Memory, used to store computer programs;
[0063] A processor for implementing the methods described above when executing the computer program.
[0064] The present invention also provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the method described above.
[0065] Due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0066] 1) Significantly improves feature representation stability: By employing Test-Time Batch Renormalization (TBR) technology, the update of statistics and parameter optimization are decoupled, effectively solving the problem of statistical drift caused by gradient interference during the adaptive process of traditional batch normalization methods during testing. This technique is particularly outstanding in small-batch or sample-dependent scenarios, significantly improving the model's adaptability to the distribution of target domain data and the consistency of feature representation, thus avoiding a sharp degradation in model performance;
[0067] 2) Effectively enhances class imbalance adaptability: High-confidence samples are screened through a dynamic class-specific entropy threshold mechanism; at the same time, fine-grained weight allocation is implemented within high-quality samples, and rare classes are adaptively compensated. This dual mechanism not only ensures the reliability of high-confidence sample screening, but also balances the contribution of each class to model updates, significantly improving generalization performance in class imbalance scenarios;
[0068] 3) Ensuring the stability and real-time performance of online learning: The weight normalization mechanism ensures that the gradient update magnitude is proportional to the number of high-confidence samples, effectively addressing the issue of fluctuations in EEG signal quality. The adaptive minimum sample guarantee strategy ensures the model's ability to continuously update even under extreme conditions. The entire design does not require access to source domain data, fully complying with the data security requirements of healthcare scenarios and providing reliable support for the practical deployment of cross-user brain-computer interface systems. Attached Figure Description
[0069] Figure 1 This is an overall flowchart of the online adaptive optimization method provided in the embodiments of the present invention.
[0070] Figure 2 This is a flowchart of source and target domain EEG signal preprocessing provided in an embodiment of the present invention.
[0071] Figure 3 This is a flowchart of source domain model training and initialization provided in an embodiment of the present invention.
[0072] Figure 4 This is a schematic diagram illustrating the implementation of the batch renormalization technique during testing provided in this embodiment of the invention.
[0073] Figure 5 This is a flowchart of high-confidence sample screening and dynamic reweighting provided in the embodiments of the present invention. Detailed Implementation
[0074] The technical solution of the present invention will be described in more detail below with reference to the accompanying drawings and embodiments.
[0075] The implementation process of this invention is divided into two stages: the offline model preparation stage and the online adaptive stage.
[0076] Offline model preparation phase: This phase aims to train a general source domain classification model for a specific motion visualization task, specifically including:
[0077] Step S1: Source Domain Data Preprocessing: Refer to Figure 2 As shown, motor imagery EEG data were collected from multiple source domain users. A standard preprocessing procedure was performed on each trial data segment for each user, as follows:
[0078] Step 1.1: Using the mean EEG signal 200ms before the start of the motor imagery task as the baseline, perform baseline drift correction on all channels of the data for this trial to eliminate slow drift components in the signal; Step 1.2: Perform 0.5-40Hz bandpass filtering on the source domain motor imagery EEG signal to remove low-frequency drift and high-frequency noise interference, and retain the Mu rhythm and Beta rhythm signals related to motor imagery; Step 1.3: The filtered signal is rereferenced using the average reference method, that is, the average value of all channel signals is calculated as the reference signal, and the average value is subtracted from each channel signal to eliminate the reference electrode deviation.
[0079] Step 1.4: Retain all EEG channel data for subsequent processing, or select motion-related channel regions according to the actual application scenario to retain complete spatial information.
[0080] Step S2: Source Domain Model Training: Using preprocessed source domain data, train a deep learning model for motion image classification. This embodiment preferably uses the EEGNet network architecture, such as... Figure 3 As shown, it specifically includes:
[0081] Step 2.1: Train the EEGNet model using the pre-processed source domain data, and optimize the model parameters through backpropagation to minimize the training loss: .in For real labels, To predict probabilities, Indicates category;
[0082] Step 2.2: Transfer the parameters of the trained source domain model and normalized statistic Directly copy and initialize the network parameters of the teacher model and student model respectively. These two models have identical architectures and initial states, forming a twin network pair for the subsequent online adaptive phase. Once this phase is complete, the source domain data can be securely removed or archived, requiring no further access in subsequent processes, thus meeting privacy requirements.
[0083] like Figure 1 As shown, the online adaptive phase is performed in real time for a single target user, using their unlabeled EEG data stream to iteratively update the model.
[0084] Step 3: Online preprocessing and feature extraction of target domain data
[0085] Step 3.1: Perform the same preprocessing procedure as the source domain on the real-time acquired unlabeled EEG signals of the target domain, including 0.5-40Hz bandpass filtering, average reference rereference processing, and baseline drift removal processing with the mean signal value 200ms before the start of the motor imagery task as the baseline.
[0086] Step 3.2: As Figure 4 As shown, the preprocessed single target domain samples are input into the teacher model and student model respectively, using the currently maintained test-time moving average statistic ( , The normalized feature is calculated in real time using the time-batch renormalization (TBR) formula, along with the single-sample statistic; where the TBR calculation formula is:
[0087]
[0088] in , The teacher model's prediction output is used as the pseudo-label for the current sample, while the intermediate feature representation of the student model is extracted, and the pseudo-label, sample features, and prediction confidence are stored in a buffer.
[0089] Step 3.3: When the buffer accumulates to the preset batch size B, calculate the batch statistic (mean) based on the complete batch data. and standard deviation And update the moving average statistic at test time using the stopping gradient operation. and )
[0090]
[0091]
[0092] in For smoothing coefficients, This indicates that the gradient operation is stopped.
[0093] This provides more accurate normalized statistics for real-time inference of subsequent samples; simultaneously, it triggers the high-confidence sample screening process, entering the model parameter update phase, such as... Figure 5 As shown.
[0094] Step 4: High-confidence sample screening and weight allocation, including the following sub-steps:
[0095] Step 4.1: Category Frequency Statistics and Initialization: Based on the pseudo-labels generated by the teacher model in the buffer, the frequency of occurrence of each category c is counted online.
[0096]
[0097] in For update rate, For the frequency estimate of category c at the previous time step, For indicator functions, The teacher model predicts the category of the current sample; during initialization, the binary classification task is set... Four-category task setting Apply boundary constraints to the frequency values. ,in , To prevent extreme estimations; and simultaneously calculate the average class frequency: Where C is the total number of categories;
[0098] Step 4.2: Calculate the category-specific dynamic entropy threshold, as follows:
[0099] Step 4.2.1 First, calculate the basic dynamic entropy threshold:
[0100]
[0101] in Based on the basic entropy threshold, This is the category imbalance adjustment coefficient;
[0102] Step 4.2.2: Dynamically adjust based on the current batch prediction confidence level:
[0103]
[0104] in Let c be the average entropy of category c in the current batch. The average entropy of all categories, This is the set of samples predicted as class c in the current batch. The time decay coefficient, This is the confidence level adjustment factor;
[0105] Step 4.2.3 Apply threshold boundary constraints:
[0106]
[0107] in, To prevent extreme values from appearing in the threshold;
[0108] Step 4.3: Filter high-confidence samples based on dynamic entropy threshold:
[0109]
[0110] in, For the sample Predicted entropy;
[0111] Step 4.4: Simplified weight allocation within high-confidence samples, as follows:
[0112] Step 4.4.1 Set the maximum entropy threshold: Calculate the maximum value of the dynamic entropy threshold for all categories in the current batch as the normalization benchmark:
[0113]
[0114] in Total number of categories The dynamic thresholds for each category calculated in step 4.2;
[0115] Step 4.4.2 Basic Weight Calculation
[0116] For each high confidence sample (Predicted category is c), calculate the basic weights.
[0117]
[0118] in For the sample Predicted entropy, The average category frequency, For the frequency of category c, This is the frequency compensation index. To prevent division by zero of small constants;
[0119] Step 4.4.3 Weight Boundary Constraints: Apply boundary constraints to the basic weights to prevent extreme values.
[0120]
[0121] in , ;
[0122] Step 4.5: Weight normalization and gradient stability assurance. The weights of high-confidence samples are normalized so that the sum of the normalized weights equals the number of high-confidence samples.
[0123]
[0124] Step 5: Calculate the loss function and update the model parameters, including the following sub-steps:
[0125] Step 5.1: Prototype initialization and feature extraction. Extract the weights of the fully connected layers from the model trained in the source domain as the initial class prototypes: .in Here, d represents the weight matrix of the fully connected layer in the source domain model, d is the feature dimension, and C is the number of classes; for the high-confidence sample set... The student model is used to extract the deep feature representation before the input of the fully connected layer. ;in This represents the backbone network in the student model, from the input to the fully connected layers. For the sample A d-dimensional embedding vector in the feature space;
[0126] Step 5.2: Calculate the decoupled prototype learning loss. Based on the DPL method, calculate the contrastive loss independently for each category prototype:
[0127]
[0128] in The feature subset of the high-confidence samples that predicts class k. This represents the actual number of categories present in the current batch. Represents cosine similarity. Temperature coefficient; prototype This step remains unchanged and is not updated.
[0129] Step 5.3: Calculate the weighted distillation loss based on the teacher-student model architecture:
[0130]
[0131] in To normalize sample weights, the teacher model generates soft labels. As the target distribution, the student model predicts as ;
[0132] Step 5.4: Calculate the total loss and optimize the student model combination. Compare the learning loss and cross-entropy loss to form the overall optimization objective:
[0133]
[0134] in , represents the balancing coefficient; backpropagation is performed based on the total loss to update all parameters of the student model: ,in The learning rate;
[0135] Step 5.5: Update the teacher model parameters using an exponential moving average strategy: ,in To smooth out the coefficients, ensure the stability of the teacher model output, and provide a reliable basis for generating pseudo-labels for the next batch of processing.
[0136] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various modifications or variations within the scope of the claims, which do not affect the essence of the present invention.
Claims
1. An adaptive optimization method for online decoding of brain-computer interfaces for motor imagery, characterized in that, Includes an offline preparation phase and an online adaptation phase: The offline preparation phase includes the following steps: S11. Preprocess the EEG signals of the source domain users’ motor imagery, including baseline drift removal, bandpass filtering and average reference rereference processing, to obtain the preprocessed source domain data. S12. Based on the preprocessed source domain data, an initial classification model for motion imagery is trained; S13. Copy the parameters and normalized statistics of the initial classification model and use them to initialize the teacher model and student model, respectively; The online adaptive phase includes the following steps: S21. Perform the same processing steps as the source domain preprocessing steps on the real-time acquired single target domain EEG signals, and simultaneously input the preprocessed samples into the teacher model and the student model; during the forward propagation of the models, use the test-time batch renormalization technique to normalize the features. The test-time batch renormalization technique decouples the update of statistics used for normalization from the gradient optimization of model parameters by stopping gradient operations; record the pseudo-labels output by the teacher model, the intermediate features extracted by the student model, and the predicted entropy of the samples, and store them in the sample buffer. S22 When the number of samples accumulated in the sample buffer reaches the preset batch size, the model update process is triggered, and the moving average statistic used for the test batch renormalization technique is updated based on the batch data. S23. Based on the pseudo-labels of all samples in the sample buffer, calculate the dynamic occurrence frequency of each category; according to the dynamic occurrence frequency of each category and the predicted entropy distribution of the current batch of samples, calculate a dynamically adjusted entropy threshold for each category; Based on the dynamic entropy threshold, a high-confidence sample set is selected from the sample buffer; S24. For each sample in the high confidence sample set, a dynamic weight is calculated based on its predicted entropy value and the dynamic occurrence frequency of its category, wherein the calculation of the dynamic weight makes the sample with the lower predicted entropy value have a higher weight, and the sample with the lower occurrence frequency of its category receives a higher weight compensation. S25. Extract prototype vectors of each category from the initial classification model as fixed references; calculate the decoupled prototype contrast loss based on the feature vectors extracted by the student model from the high-confidence sample set. The loss is used to narrow the distance between the sample features and their corresponding category prototype vectors, and to widen the distance between them and other category prototype vectors. The prototype vectors remain fixed during the calculation process. S26. Based on the output of the teacher model and the student model to the high-confidence sample set, and the dynamic weights calculated in S24, calculate the weighted distillation loss; S27. Student model update steps: Update the parameters of the student model based on the total loss consisting of the decoupled prototype contrast loss and the weighted distillation loss; S28. Synchronize the updated parameters of the student model to the teacher model using an exponential moving average strategy; S29. Clear the sample buffer and prepare for the next iteration.
2. The adaptive optimization method for online decoding of brain-computer interfaces for motor imagery according to claim 1, characterized in that, The batch renormalization technique used in the test includes: Preprocessed single target domain samples Input the teacher model and student model respectively, using the currently maintained test-time moving average statistic. and Based on the single-sample statistic, the normalized feature is calculated using the TBR formula: in , ; Simultaneously, the predicted output of the teacher model As a pseudo-label for the current sample; : Normalized eigenvalues The original features output from the batch normalization layer. : The mean of all features in the current input batch. : Standard deviation of all sample features in the current input batch, r: scaling calibration factor, d: offset calibration factor. : The historical characteristic mean accumulated through the exponential moving average (EMA). : The historical characteristic standard deviation accumulated through the exponential moving average (EMA) Stop the gradient operator to prevent the gradient from being backpropagated through the calculation within the parentheses, thus maintaining the independence of the statistical estimates; When the accumulated sample buffer reaches the preset batch size B, calculate the current batch statistic. and And update the moving average statistic at test time using the stopping gradient operation: in For smoothing coefficients, This indicates that the gradient operation is stopped. : The historical characteristic mean accumulated through the exponential moving average (EMA). : The historical characteristic standard deviation accumulated through the exponential moving average (EMA) The smoothing coefficient controls the weighting ratio between historical statistics and current batch statistics. The gradient of the current batch mean is blocked. The gradient of the standard deviation of the current batch is blocked.
3. The adaptive optimization method for online decoding of brain-computer interfaces for motor imagery according to claim 1, characterized in that, The calculation of the dynamic entropy threshold for each category specifically includes: Online frequency statistics for each category c ,in For update rate, For the frequency estimate of category c at the previous time step, For indicator functions, Assign the predicted category to the teacher model for the current sample; impose boundary constraints on the frequency values. ,in , To prevent extreme estimations; Calculate the basic dynamic entropy threshold ,in Based on the basic entropy threshold, C is the class imbalance adjustment coefficient; C is the number of classes. The average frequency of all categories, calculated using the formula 1 / C. : The cumulative historical frequency of the current category c in the target domain; Dynamically adjust based on the current batch prediction confidence level: in Let c be the average entropy of category c in the current batch. The average entropy of all categories, This is the set of samples predicted as class c in the current batch. The time decay coefficient, This is the confidence level adjustment factor; Apply threshold boundary constraints: ; in, This prevents extreme values from appearing on the threshold.
4. The adaptive optimization method for online decoding of brain-computer interfaces for motor imagery according to claim 1, characterized in that, Step S24 specifically includes: Calculate the maximum value of the dynamic entropy threshold for all categories in the current batch as the normalization baseline: in, Total number of categories The dynamic thresholds for each category calculated in step 4.2; For each high confidence sample If the predicted category is c, the basic weights are calculated using the following formula: in, For the sample Predicted entropy, The average category frequency, For the frequency of category c, This is the frequency compensation index. To prevent division by zero of small constants; Apply boundary constraints to the basic weights to prevent extreme values: in , ; Weight normalization and gradient stability are ensured by normalizing the weights of high-confidence samples so that the sum of the normalized weights equals the number of high-confidence samples. The high-confidence sample set refers to the subset of samples selected for model updates. Number of high-confidence samples.
5. The adaptive optimization method for online decoding of brain-computer interfaces for motor imagery according to claim 1, characterized in that, Step S25 specifically involves independently calculating the contrast loss for each category prototype, using the following formula: in, The feature subset of the high-confidence samples that predicts class k. This represents the actual number of categories present in the current batch. Represents cosine similarity. Temperature coefficient; The prototype of category k Features of high-confidence samples predicted as class k Predict the features of samples that are not of class k. Cosine similarity between the prototype and the positive sample. Cosine similarity between the prototype and the negative sample.
6. The adaptive optimization method for online decoding of brain-computer interfaces for motor imagery according to claim 1, characterized in that, In step S26, the weighted distillation loss formula is as follows: in To normalize sample weights, the teacher model generates soft labels. As the target distribution, the student model predicts as .
7. An adaptive optimization system for online decoding of brain-computer interfaces for motor imagery, characterized in that, include: Memory, used to store computer programs; A processor for implementing the method as described in any one of claims 1 to 6 when executing the computer program.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Testing adaptation method and system applied to calibration-free brain-computer interface
CN117056837A
Motor imagery electroencephalogram signal classification method based on cognitive uncertainty
CN118512184A
Motor imagery brain-computer interface self-adaptive classification method based on confrontation automatic encoder
CN119046779A
Cross-domain spacecraft pose estimation method based on mask self-distillation domain adaptation
CN121120776A
Calibrated Distillation
US20250356210A1
Cited By
Motor imagery training system based on brain-computer interface
CN122182943A