An 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 reweighting mechanism, the stability and adaptability issues of the MI-BCI model in cross-user adaptation are solved, achieving efficient adaptive optimization in class imbalance scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-26
- Publication Date
- 2026-03-24
AI Technical Summary
Existing technologies suffer from several problems in cross-user adaptation, including insufficient adaptability of samples selected by 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. The test-batch renormalization (TBR) technique is combined to decouple the statistical update and parameter optimization. The contribution of each category is balanced through a dynamic online reweighting mechanism, and the feature space distribution is optimized by prototype comparative learning.
It significantly improves the stability and adaptive performance of the MI-BCI model in the target domain, especially in class imbalance scenarios, enhancing the model's generalization ability and robustness, and meeting privacy protection requirements.
Smart Images

Figure CN121561684B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of brain-computer interface (BCI), and particularly relates to an adaptive optimization method and system for online decoding of a motor imagery (MI) oriented brain-computer interface. BACKGROUND
[0002] Motor imagery brain-computer interface is a technology based on decoding electroencephalogram signals generated in the process of user motor imagery, realizing direct communication and interaction between human brain and external devices (such as computers and rehabilitation equipment), and has important application prospects in the field of neural rehabilitation. However, electroencephalogram signals have significant individual differences, non-stationarity and are easily disturbed by noise, etc., resulting in that a decoding model trained on data of one user (source domain) will have a serious decline in system performance when directly applied to another new user (target domain) due to a large shift in the distribution of electroencephalogram features, i.e., a cross-user adaptation problem.
[0003] In order to solve the cross-domain adaptation problem, test-time adaptation (TTA) has attracted attention in recent years. TTA can generate pseudo-labels and filter high-confidence samples through unlabeled test samples in the target domain under the constraint of privacy protection, without source domain data, to update the pre-trained model online, so as to quickly adapt to the electroencephalogram feature distribution of the target user. However, the existing TTA methods have the following limitations: first, the traditional method uses a fixed confidence threshold to filter high-confidence samples, which cannot adapt to the dynamic changes of different categories; second, the batch normalization layer has a fundamental defect in the test-time statistical quantity calibration mechanism: when the model parameters are updated through gradient optimization, the normalization statistics will deviate from the target domain true distribution due to gradient interference, resulting in unstable feature representation, especially in the small batch or sample dependent test scene; in addition, the model updating process is prone to bias towards the dominant category, and the performance significantly degrades when facing class-imbalance test data flow; at the same time, the existing contrast learning strategy fails to fully utilize the prototype information to optimize the feature space distribution, limiting the adaptive effect.
[0004] In summary, in the privacy protection constrained source-free adaptation scene, how to design a dynamic class threshold mechanism to accurately filter high-confidence samples to ensure the reliability of model updating, how to realize the decoupling of statistical quantity updating and parameter optimization to improve the stability of feature representation, and how to optimize the feature space distribution through the prototype-based contrast learning strategy, so as to realize the efficient and reliable adaptation of the MI-BCI model without relying on source data, are the problems that the technical personnel in the field are eager to solve. SUMMARY
[0005] In view of the defects in the prior art, the technical problems to be solved by the present application are embodied in the following aspects.
[0006] Solve the problem of insufficient adaptability of fixed threshold screening samples: In view of the problem that the fixed threshold in the traditional TTA cannot adapt to the dynamic changes of different class confidence distributions, the present application proposes a dynamic class threshold mechanism. By fusing sample prediction entropy and class frequency information, an optimal threshold is dynamically set for each class, thereby improving the accuracy and reliability of high-confidence sample screening.
[0007] Solve the problem of inaccurate estimation of batch normalization statistics: In view of the problem that the normalization statistics do not match the target domain distribution during the adaptive process during testing, the present application introduces the test-time batch renormalization technology (TBR). In the traditional method, the normalization statistics will deviate from the real distribution of the target domain due to gradient interference during parameter optimization, especially in small batch or sample-dependent scenarios. TBR realizes the decoupling of statistics update and parameter optimization by introducing the stop gradient operation, and simultaneously fuses the current test batch statistics and the dynamically maintained moving average statistics using a correction factor, which not only ensures the adaptability of the normalization process to the current data distribution, but also maintains the stability of the statistics estimation, thereby significantly improving the feature representation quality and adaptive performance of the model on distribution-shifted data.
[0008] Solve the problem of optimization bias caused by sample confidence difference and class imbalance: In view of the defects of ignoring the internal confidence difference of high-confidence samples screened by entropy threshold and the imbalance of class distribution in the TTA process, the present application designs a dynamic online reweighting mechanism. This mechanism assigns weights to high-confidence samples that have passed the entropy threshold screening according to their prediction entropy and class frequency: samples with lower entropy values obtain higher weights; at the same time, weight compensation is performed on rare class samples. This design effectively balances the contribution of each class to model updating, significantly improving the adaptive robustness in class-imbalance testing scenarios.
[0009] The technical solution of the present application is as follows:
[0010] On the one hand, the present application provides an adaptive optimization method for online decoding of motor imagery brain-computer interface, characterized in that it comprises an offline preparation stage and an online adaptive stage.
[0011] The offline preparation stage comprises:
[0012] S11. Source domain preprocessing step: pre-process the motor imagery electroencephalogram signals of the source domain user, including baseline drift removal, band-pass filtering and average reference re-reference processing, to obtain pre-processed source domain data;
[0013] S12. Source domain model training step: based on the pre-processed source domain data, an initial classification model for motor imagery is trained;
[0014] S13. Model initialization step: the parameters and normalization statistics of the initial classification model are copied to initialize the teacher model and the student model, respectively;
[0015] The online adaptive phase is iteratively performed based on the real-time unlabeled EEG data stream of the target user, and each iteration includes:
[0016] S21. Target domain online preprocessing and feature extraction step: the same processing as the source domain preprocessing step is performed on the real-time collected single target domain EEG signal, and the pre-processed sample is input into the teacher model and the student model at the same time; during the forward propagation of the model, the test-time batch normalization technique is used to normalize the features, which decouples the updating of the normalization statistics from the gradient optimization of the model parameters by stopping the gradient operation; the pseudo-label output by the teacher model, the intermediate features extracted by the student model, and the prediction entropy of the sample are recorded and stored in the sample buffer;
[0017] S22 Trigger and statistics updating step: when the number of samples accumulated in the sample buffer reaches the preset batch size, the model updating process is triggered, and the moving average statistics for the test-time batch normalization technique 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, the dynamic occurrence frequency of each class is calculated; according to the dynamic occurrence frequency of each class and the prediction entropy distribution of the current batch of samples, a dynamically adjusted entropy threshold is calculated for each class; based on the dynamic entropy threshold, a high-confidence sample set is selected from the sample buffer;
[0019] S24. Dynamic re-weighting step: for each sample in the high-confidence sample set, a dynamic weight is calculated according to its prediction entropy value and the dynamic occurrence frequency of its class, wherein the calculation of the dynamic weight makes the weight of the sample with lower prediction entropy value higher, and the weight compensation of the sample with lower occurrence frequency of its class higher;
[0020] S25. Decoupled prototype contrast learning step: the prototype vectors of each class are extracted from the initial classification model as fixed references; based on the feature vectors extracted by the student model from the high-confidence sample set, a decoupled prototype contrast loss is calculated, which is used to pull the distance between the sample features and the prototype vectors of their corresponding classes closer, and push the distance between the sample features and the prototype vectors of other classes farther, and the prototype vectors remain fixed during the calculation process;
[0021] S26. A weighted distillation learning step: calculating a weighted distillation loss based on the outputs of the teacher model and the student model on the high-confidence sample set, and the dynamic weight calculated in S24;
[0022] S27. A student model updating step: updating the parameters of the student model according to the total loss composed of the decoupled prototype contrastive loss and the weighted distillation loss;
[0023] S28. A teacher model updating step: synchronizing the updated parameters of the student model to the teacher model by an exponential moving average strategy;
[0024] S29. Emptying the sample buffer, preparing for the next iteration.
[0025] Further, the test-time batch normalization technique comprises:
[0026] The preprocessed single target domain sample is input into the teacher model and the student model respectively, and the normalization feature is calculated by the TBR formula using the current maintained test-time moving average statistics and and the single sample statistics:
[0027]
[0028] wherein , ;
[0029] Meanwhile, the prediction output of the teacher model is taken as the pseudo label of the current sample; : the normalized feature value, : the original feature output from the batch normalization layer, : the mean of all sample features in the current input batch, : the standard deviation of all sample features in the current input batch, r: scaling calibration factor, d: offset calibration factor, : the historical feature mean accumulated by the exponential moving average (EMA), : the historical feature standard deviation accumulated by the exponential moving average (EMA),
[0030] : the stop gradient operator, which prevents the gradient from being backpropagated through the calculation within the brackets, maintaining the independence of the statistics estimates.
[0031] When the sample buffer accumulation reaches the preset batch size B, the current batch statistics and are calculated, and the test-time moving average statistics are updated using the stop gradient operation:
[0032]
[0033] wherein is a smoothing coefficient, denotes a stop gradient operation, : historical feature mean accumulated by exponential moving average (EMA), : historical feature standard deviation accumulated by exponential moving average (EMA), : smoothing coefficient controls the weight ratio of historical statistics and current batch statistics, : gradient of current batch mean is blocked, : gradient of current batch standard deviation is blocked.
[0034] Further, the calculating a dynamic entropy threshold for each class specifically comprises:
[0035] calculating the online frequency of each class c wherein is an update rate, is the frequency estimation of class c at the last time, is an indicator function, is the predicted class of the current sample by the teacher model; a boundary constraint is imposed on the frequency value wherein , to prevent extreme estimation;
[0036] calculating a basic dynamic entropy threshold wherein is a basic entropy threshold, is a class imbalance adjustment coefficient; C is the number of classes, : average frequency of all classes, the calculation formula is 1 / C, : cumulative historical frequency of the current class c in the target domain.
[0037] combined with the prediction confidence of the current batch for dynamic adjustment:
[0038]
[0039] wherein is the average entropy of class c in the current batch, is the average entropy of all classes, is the sample set predicted as class c in the current batch, is a time decay coefficient, is a confidence adjustment factor;
[0040] imposing a threshold boundary constraint: ;
[0041] wherein, to prevent extreme values of the threshold value.
[0042] Further, the dynamic reweighting step specifically comprises:
[0043] Calculate the maximum value of the dynamic entropy threshold of all categories in the current batch as the normalization reference:
[0044]
[0045] wherein, is the total number of categories, is the dynamic threshold of each category calculated in step 4.2;
[0046] For each high-confidence sample (predicted category is c), calculate the base weight, the formula is as follows:
[0047]
[0048] wherein, is the predicted entropy of sample , is the average category frequency, is the frequency of category c, is the frequency compensation index, is a small constant to prevent division by zero; Boundary constraints are imposed on the base weight to prevent extreme values:
[0049]
[0050] wherein
[0051] , ;
[0052] Weight normalization and gradient stability guarantee, the weight of high-confidence samples is normalized, and the sum of the normalized weights is equal to the number of high-confidence samples:
[0053]
[0054] : high-confidence sample set, i.e. the sample subset selected for model updating, : the number of high-confidence samples.
[0055] Further, the decoupled prototype contrast learning step specifically calculates the contrast loss for each category prototype independently, and the formula is as follows:
[0056]
[0057] wherein, a subset of features for which the predicted class is k in high-confidence samples, a number of classes actually existing in the current batch, denotes the cosine similarity, a temperature coefficient; : a prototype of class k, : a feature of a high-confidence sample predicted as class k, : a feature of a sample predicted not as class k, : a cosine similarity between the prototype and a positive sample, : a cosine similarity between the prototype and a negative sample.
[0058] Further, in the weighting distillation learning step, the weighting distillation loss formula is as follows:
[0059]
[0060] wherein is a normalized sample weight, and a soft label generated by the teacher model as a target distribution, and the student model is predicted as .
[0061] The application also provides an adaptive optimization system for online decoding of motor imagery brain-computer interface, and has the characteristics that the system comprises:
[0062] a memory for storing a computer program;
[0063] a processor for executing the computer program to realize the above method.
[0064] The application also provides a computer readable storage medium, and has the characteristics that the computer readable storage medium stores a computer program, and the computer program is executed by a processor to realize the above method.
[0065] Due to the adoption of the above technical solutions, the application has the following beneficial effects:
[0066] 1) Significantly improve the stability of feature representation: through the test batch normalization (TBR) technology, the decoupling of statistical quantity updating and parameter optimization is realized, and the statistical quantity drift problem caused by gradient interference in the adaptive process of the traditional batch normalization method in the test is effectively solved. This technology performs particularly outstanding in small batch or sample dependent scenarios, greatly improves the adaptability of the model to the data distribution of the target domain and the consistency of the feature representation, and avoids the sharp degradation of the model performance;
[0067] 2) Effective enhancement of 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 to adaptively compensate for rare classes. This double mechanism not only guarantees the reliability of high-confidence sample screening, but also balances the contribution of each class to model updating, significantly improving the generalization performance in the class imbalance scenario;
[0068] 3) Ensure the stability and real-time performance of online learning: the weight normalization mechanism makes the gradient update amplitude proportional to the number of high-confidence samples, effectively addressing the quality fluctuation problem of electroencephalogram signals. The adaptive minimum sample guarantee strategy ensures the continuous updating ability of the model in extreme situations. The entire design does not require access to source domain data, fully meeting the data security requirements of the medical health scene, and providing reliable support for the actual deployment of cross-user brain-computer interface systems. BRIEF DESCRIPTION OF DRAWINGS
[0069] Figure 1 is the overall flowchart of the online adaptive optimization method provided by the embodiment of the application.
[0070] Figure 2 is the source domain and target domain electroencephalogram signal preprocessing flowchart provided by the embodiment of the application.
[0071] Figure 3 is the source domain model training and initialization flowchart provided by the embodiment of the application.
[0072] Figure 4 is the test time batch normalization technology implementation schematic diagram provided by the embodiment of the application.
[0073] Figure 5 is the high-confidence sample screening and dynamic reweighting flowchart provided by the embodiment of the application. DETAILED DESCRIPTION
[0074] The technical solutions of the application will be described in more detail below in combination with the drawings and embodiments.
[0075] The implementation process of the application is divided into two stages: an offline model preparation stage and an online adaptive stage.
[0076] The offline model preparation stage aims to train a general source domain classification model for a specific motor imagery task, which specifically includes:
[0077] Step S1: Source domain data preprocessing: Referring to FIG. 1, motor imagery electroencephalogram data of multiple source domain users is collected. The standard preprocessing procedure is performed on each trial data of each user, specifically as follows: Figure 2
[0078] Step 1.1: The mean value of the EEG signal 200 ms before the start of the motor imagery task is taken as the baseline, and the data of all channels of this trial are corrected for baseline drift to eliminate slow drift components in the signal; Step 1.2: The source domain motor imagery EEG signal is subjected to 0.5-40 Hz band-pass filtering 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 re-referenced using the average reference method, i.e., the average value of all channel signals is calculated as a reference signal, and the average value is subtracted from each channel signal to eliminate reference electrode bias;
[0079] Step 1.4: All EEG channel data is retained for subsequent processing, or the motor-related channel region is selected according to the actual application scenario to retain complete spatial information.
[0080] Step S2 Source domain model training: The preprocessed source domain data is used to train a deep learning model for motor imagery classification. This embodiment preferably uses the EEGNet network architecture, as shown in Figure 3 , which specifically includes:
[0081] Step 2.1: The EEGNet model is trained using the preprocessed source domain data, and the model parameters are optimized through backpropagation to minimize the training loss: . Wherein is the true label, is the predicted probability, represents the category;
[0082] Step 2.2: The trained source domain model parameters and the normalization statistics are directly copied to initialize the network parameters of the teacher model and the student model, respectively, i.e. These two models have the same architecture and initial state, forming a pair of twin networks for the subsequent online adaptive phase. After this phase, the source domain data can be safely removed or archived, and subsequent processes no longer need to access it, meeting the privacy protection requirements.
[0083] As shown in Figure 1 , the online adaptive phase: Real-time for a single target user, using its unlabeled EEG data stream, and performing model adaptive updates in a loop.
[0084] Step 3: Online preprocessing and feature extraction of target domain data
[0085] Step 3.1: The real-time collected target domain unlabeled EEG signal is subjected to the same preprocessing procedure as the source domain, including 0.5-40 Hz band-pass filtering, average reference re-referencing, and baseline drift processing with the mean value of the signal 200 ms before the start of the motor imagery task as the baseline.
[0086] Step 3.2: As shown in Figure 4 , the pre-processed single target domain sample is input into the teacher model and the student model respectively, and the current maintained test-time moving average statistics , and the single sample statistics are used to calculate the normalized features in real time through the test-time batch normalization (TBR) formula; the TBR calculation formula is
[0087]
[0088] wherein , . The prediction output of the teacher model is used as the pseudo label of the current sample, and the intermediate feature representation of the student model is extracted, and the pseudo label, sample feature and prediction confidence are stored in the buffer;
[0089] Step 3.3: When the buffer accumulation reaches the preset batch size B, the batch statistics (mean and standard deviation ) are calculated based on the complete batch data, and the test-time moving average statistics and )
[0090]
[0091]
[0092] wherein is a smoothing coefficient, indicates the stop gradient operation.
[0093] to provide more accurate normalization statistics for real-time inference of subsequent samples; at the same time, trigger the high-confidence sample screening process, enter the model parameter updating stage, as shown in Figure 5 .
[0094] Step 4: High-confidence sample screening and weight distribution, including the following sub-steps:
[0095] Step 4.1: Class frequency statistics and initialization: based on the pseudo label generated by the teacher model in the buffer, the frequency of occurrence of each class c is calculated online:
[0096]
[0097] wherein is the update rate, is the frequency estimate of class c at the last time, is an indicator function, the predicted class of the current sample for the teacher model; at initialization, binary classification tasks set , and four-class classification tasks set ; impose boundary constraints on the frequency values where , to prevent extreme estimates; simultaneously calculate the average class frequency: where C is the total number of classes;
[0098] Step 4.2: Calculate the class-specific dynamic entropy threshold, as follows:
[0099] Step 4.2.1 first calculates the base dynamic entropy threshold:
[0100]
[0101] where is the base entropy threshold, is the class imbalance adjustment coefficient;
[0102] Step 4.2.2 combines the current batch prediction confidence for dynamic adjustment:
[0103]
[0104] where is the average entropy of class c in the current batch, is the average entropy of all classes, is the set of samples predicted as class c in the current batch, is the time decay coefficient, is the confidence adjustment factor;
[0105] Step 4.2.3 imposes threshold boundary constraints:
[0106]
[0107] where, to prevent extreme values of the threshold;
[0108] Step 4.3: Filter high-confidence samples according to the dynamic entropy threshold:
[0109]
[0110] where, is the predicted entropy of sample ;
[0111] Step 4.4: Simplified weight distribution within high-confidence samples, as follows:
[0112] Step 4.4.1 Set maximum entropy threshold: calculate the maximum value of all category dynamic entropy thresholds in the current batch as the normalization benchmark:
[0113]
[0114] wherein is the total number of categories, is the dynamic threshold of 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 weight
[0117]
[0118] wherein is the predicted entropy of sample , is the average category frequency, is the frequency of category c, is the frequency compensation index, is a small constant to prevent division by zero;
[0119] Step 4.4.3 Weight boundary constraint Apply boundary constraints to the basic weight to prevent extreme values:
[0120]
[0121] wherein , ;
[0122] Step 4.5: Weight normalization and gradient stability guarantee, normalize the weight of high-confidence samples so that the sum of normalized weights is equal to 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 full connection layer weight from the model trained in the source domain as the initial category prototype: . Wherein is the full connection layer weight matrix of the source domain model, d is the feature dimension, and C is the number of categories; for the high-confidence sample set , use the student model to extract the deep feature representation before the full connection layer input ; wherein represents the backbone network in the student model from input to full connection layer, For the sample The d-dimensional embedding vector in the feature space;
[0126] Step 5.2: Calculate the decoupling prototype learning loss Based on the DPL method, calculate the contrastive loss for each class prototype independently:
[0127]
[0128] Wherein is the feature subset of the high-confidence sample whose predicted class is k, is the number of actual existing classes in the current batch, represents the cosine similarity, is the temperature coefficient; Prototype Remain fixed in this step and do not update;
[0129] Step 5.3: Calculate the weighted distillation loss based on the teacher-student model architecture:
[0130]
[0131] Wherein is the normalized sample weight, and the soft label generated by the teacher model is the target distribution, and the student model prediction is ;
[0132] Step 5.4: Calculate the total loss and optimize the student model Combine contrastive learning loss and cross-entropy loss to form the total optimization target:
[0133]
[0134] Wherein , is the balance coefficient; Based on the total loss, update all parameters of the student model by backpropagation: , wherein is the learning rate;
[0135] Step 5.5: Update the teacher model parameters using the exponential moving average strategy: , wherein is the smoothing coefficient, which ensures the stability of the teacher model output and provides a reliable basis for generating pseudo-labels for the next batch processing.
[0136] The specific embodiments of the present application are described above. It should be understood that the present application is not limited to the above specific embodiments, and those skilled in the art can make various modifications or modifications within the scope of the claims, which does not affect the essential content of the present application.
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 is to prevent the threshold from reaching extreme values.
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
Motor imagery electroencephalogram signal classification method based on cognitive uncertainty
CN118512184A
Cross-domain spacecraft pose estimation method based on mask self-distillation domain adaptation
CN121120776A