A method and device for training an electroencephalogram emotion recognition model across datasets

By constructing a high-quality source domain training set and a bidirectional semantic alignment during the unsupervised adaptation phase of the target domain, the problems of feature distribution and category shift in cross-dataset EEG emotion recognition are solved, thereby improving the model's recognition accuracy and generalization ability.

CN123178975APending Publication Date: 2026-11-27NORTHWEST NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611490424.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-23
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing cross-dataset EEG emotion recognition technologies have shortcomings in source domain training data selection, alignment of overall feature distribution between the source and target domains, and preservation of cross-domain emotion category structure, leading to a decline in emotion recognition performance, especially poor model performance under unsupervised adaptation conditions.

Method used

By acquiring a high-quality source domain training set, utilizing the Transformer encoding structure and domain adversarial learning, and combining bidirectional semantic alignment between the source domain class prototype and the target domain pseudo-class prototype, the feature distribution difference and class semantic shift between the source and target domains are reduced. A two-stage training method is adopted to improve the model's generalization ability.

Benefits of technology

It improves the accuracy and generalization ability of cross-dataset EEG emotion recognition, and mitigates the impact of differences in the separability of emotion categories among subjects in the source domain, cross-dataset feature distribution shifts, and cross-domain category semantic shifts on the recognition results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178975A_ABST
    Figure CN123178975A_ABST
Patent Text Reader

Abstract

The application provides a cross-dataset electroencephalogram emotion recognition model training method, comprising the following steps: S101, obtaining source domain power spectrum density feature samples represented by feature frequency bands and electroencephalogram channels; S102, taking emotional stimulation trials of source domain subjects as a statistical unit; S103, obtaining an electroencephalogram emotion recognition model comprising a shared encoder and an emotion classifier; S104, obtaining source domain sample features and target domain sample features; S105, performing domain adversarial learning; S106, constructing source domain category prototypes; S107, obtaining a cross-dataset electroencephalogram emotion recognition model. The application also provides a cross-dataset electroencephalogram emotion recognition method and a cross-dataset electroencephalogram emotion recognition device. The application can reduce the influence of poor emotional category separability of source domain subjects, cross-dataset feature distribution deviation and cross-domain category semantic deviation, and improve the accuracy and generalization ability of cross-dataset electroencephalogram emotion recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of human brain electrical signal processing and emotion computing technology, specifically to a method and apparatus for training a cross-dataset brain electrical emotion recognition model. Background Technology

[0002] Electroencephalography (EEG) records electrical signals generated by neural activity in the brain. Emotion recognition based on EEG signals extracts EEG features associated with different emotional states to identify an individual's emotional state. Compared to external emotional information such as facial expressions, speech, and text, EEG signals have advantages such as high temporal resolution and are less susceptible to subjective control, making them valuable for applications in areas such as emotional brain-computer interfaces and intelligent human-computer interaction. With the development of machine learning and deep learning technologies, feature extraction and classification models based on neural networks are increasingly being applied to EEG emotion recognition, improving the representation and classification capabilities of EEG emotional features.

[0003] Existing EEG emotion recognition methods are mostly designed for cross-subject or cross-conversation emotion recognition tasks within a single EEG dataset. In cross-dataset applications, different EEG datasets may differ in subject groups, EEG acquisition devices, electrode configurations, sampling frequencies, emotion-evoking materials, experimental paradigms, and labeling settings, leading to shifts in the distribution of EEG features across different datasets. When an emotion recognition model trained on one EEG dataset is applied to another, the learned feature representations and classification boundaries may struggle to adapt to the target dataset, resulting in a decline in emotion recognition performance.

[0004] To address the aforementioned issues and reduce the data distribution differences between the source and target domains, existing technologies typically employ domain adaptation methods for cross-domain feature learning. For example, domain adversarial learning reduces the data domain information contained in shared features, distribution distance constraints reduce the difference in feature distribution between the source and target domains, and target domain prediction results are used to generate pseudo-labels to obtain category information for the target domain. While these methods can reduce the overall distribution differences between the source and target domains to some extent, the performance of cross-dataset EEG emotion recognition is still affected by differences in source domain training data and cross-domain category structure differences.

[0005] On the one hand, there are individual differences in the EEG responses of subjects from different source domains to emotional stimuli, and the discriminative information related to emotion categories in the EEG data of different subjects may differ. If all source domain subject data are directly used for model training, source domain data with low emotion category separability may affect the model's learning of emotion discrimination features, and further affect the reliability of target domain category prediction and category structure estimation during subsequent unsupervised adaptation of the target domain. Therefore, how to evaluate the training applicability of different source domain subject data based on the statistical differences shown by different emotion categories in the source domain EEG data is one of the problems that needs to be solved in cross-dataset EEG emotion recognition.

[0006] On the other hand, merely reducing the overall feature distribution difference between the source and target domains cannot guarantee a consistent semantic correspondence between EEG features belonging to the same emotion category in different data domains within a shared feature space. Especially under unsupervised adaptation conditions where true emotion labels in the target domain are unavailable, pseudo-labels generated based on model predictions may contain errors, potentially shifting the target domain category center. When category-level semantic constraints between the source and target domains are lacking, issues such as insufficient aggregation of similar cross-domain features or misalignment of features from different emotion categories may arise, impacting the model's cross-dataset emotion recognition performance.

[0007] Therefore, existing cross-dataset EEG emotion recognition technologies still have room for improvement in terms of source domain training data selection, alignment of overall feature distribution between the source and target domains, and preservation of cross-domain emotion category structure. It is difficult to simultaneously reduce the impact of differences in the separability of emotion categories among subjects in the source domain, cross-dataset feature distribution shifts, and cross-domain category semantic shifts on emotion recognition results. Summary of the Invention

[0008] The present invention provides a method and apparatus for training a cross-dataset EEG emotion recognition model, so as to reduce the impact of source domain subject emotion category separability differences, cross-dataset feature distribution shifts, and cross-domain category semantic shifts on EEG emotion recognition, and improve the accuracy and generalization ability of cross-dataset EEG emotion recognition.

[0009] To achieve the above objectives, the technical solution provided by the present invention is as follows:

[0010] A method for training a cross-dataset EEG emotion recognition model includes the following steps:

[0011] S101. Obtain source domain EEG data with emotion category labels and target domain EEG data without emotion category labels. Preprocess the source domain EEG data and the target domain EEG data respectively to obtain source domain power spectral density feature samples and target domain power spectral density feature samples characterized by feature frequency bands and EEG channels.

[0012] S102. Using the emotional stimulus trials of the source domain subjects as statistical units, perform statistical analysis on the multi-band power spectral density characteristics of each source domain subject under different emotional categories. Determine the quality score corresponding to each source domain subject based on the overall statistical difference between different emotional categories and the statistical difference between categories. Screen source domain subjects based on the quality score. Construct a high-quality source domain training set based on the source domain power spectral density characteristic samples corresponding to the screened source domain subjects. The quality score is used to characterize the statistical separability of the EEG power spectral density characteristics of the corresponding source domain subject between different emotional categories.

[0013] S103. Obtain an EEG emotion recognition model including a shared encoder and an emotion classifier, and pre-train the shared encoder and the emotion classifier using the high-quality source domain training set.

[0014] S104. Initialize the target domain unsupervised adaptive model with the parameters of the pre-trained shared encoder and the emotion classifier. Input the source domain power spectral density feature samples and the target domain power spectral density feature samples into the shared encoder to obtain the source domain sample features and the target domain sample features.

[0015] S105. Perform domain adversarial learning based on the source domain sample features and the target domain sample features, and construct cross-domain hybrid samples based on the source domain power spectral density feature samples and the target domain power spectral density feature samples. Perform sentiment category constraints and data domain constraints based on the cross-domain hybrid samples to reduce the feature distribution differences between the source domain and the target domain.

[0016] S106. Construct a source domain category prototype based on the source domain sample features and their true sentiment labels, and construct a target domain pseudo category prototype based on the target domain sample features and their pseudo sentiment labels. Perform bidirectional prototype semantic alignment on the source domain sample features and the target domain sample features based on the source domain category prototype and the target domain pseudo category prototype to reduce the semantic difference between the corresponding sentiment categories of the source domain and the target domain.

[0017] S107. Based on the source domain supervised classification objective, domain adversarial learning objective, cross-domain hybrid learning objective and bidirectional prototype semantic alignment objective, the target domain unsupervised adaptation model is jointly trained, and the trained shared encoder and the emotion classifier are combined to obtain a cross-dataset EEG emotion recognition model.

[0018] The step of determining the quality score for each source domain participant based on the overall statistical difference between different emotion categories and the statistical difference between categories includes:

[0019] For each emotional stimulus trial for each subject in each source domain, the power spectral density features of multiple EEG segments contained in the emotional stimulus trial on multiple EEG channels are aggregated to obtain the trial-level features corresponding to each feature frequency band, expressed as:

[0020] ,

[0021] in, Indicates the first The trial-level feature corresponding to the b-th feature band of the r-th emotional stimulus trial for each source domain subject; Indicates the first The first source domain participant The number of EEG segments in each emotional stimulus test; Indicates the number of brainwave channels; Indicates the first The first source domain participant The power spectral density characteristics of the m-th EEG segment in the c-th EEG channel and the b-th characteristic frequency band of an emotional stimulus trial;

[0022] For each source domain participant and each feature frequency band, a one-way ANOVA was performed on the sub-features belonging to different emotion categories to obtain the significance probability characterizing the overall statistical difference between different emotion categories. Perform a Welch heteroscedasticity t-test on the sub-features corresponding to any two different sentiment categories to obtain the significance probability characterizing the statistical difference between the two corresponding sentiment categories. ;

[0023] The significance score is determined based on the significance probabilities obtained from the one-way ANOVA and Welch heteroscedasticity t-test. The significance score function is as follows:

[0024] ;

[0025] in, This represents the significance probability obtained from any of the aforementioned statistical tests; Indicates an indicator function; Indicates the first significance threshold; This represents the second significance threshold, and ; This represents the additional weight corresponding to a significance probability lower than the second significance threshold;

[0026] Let the set of all pairs of different emotion categories be:

[0027] ;

[0028] Where K represents the number of emotion categories;

[0029] The significance scores of the overall statistical differences corresponding to each feature frequency band and the significance scores of the statistical differences between each emotion category and the corresponding categories are aggregated to obtain the quality scores of the subjects in the corresponding source domain; Quality score corresponding to each source domain participant The formula for calculation is:

[0030] ;

[0031] in, Indicates the first The quality score corresponding to each source domain subject; B represents the number of feature frequency bands; Indicates the first The significance probability obtained by performing a one-way ANOVA on the b-th characteristic frequency band of each source domain subject; Indicates the first For each source domain participant, on the b-th feature frequency band, the k-th emotion category is related to the... The significance probability obtained by performing a Welch heteroscedasticity t-test between the sentiment categories; This represents the set of all pairs of different emotion categories;

[0032] The subjects from multiple source domains are ranked according to the quality scores, and high-quality source domain subjects are selected from the multiple source domain subjects according to a preset selection ratio to construct the high-quality source domain training set.

[0033] The shared encoder employs a Transformer encoding structure, and its operation includes:

[0034] The input power spectral density feature samples are divided into multiple frequency band feature blocks according to the feature frequency bands. The EEG channel features contained in each frequency band feature block are linearly mapped to obtain the corresponding frequency band feature labels, as expressed by:

[0035] ,

[0036] in, This represents the EEG channel characteristics corresponding to the b-th characteristic frequency band; This represents the frequency band feature marker corresponding to the b-th feature frequency band; Represents the linear mapping weight matrix; Indicates the bias term;

[0037] Multiple frequency band feature labels and location codes are combined and input into the Transformer encoding structure, and sample-level features are obtained through pooling.

[0038] ,

[0039] in, The shared encoder is represented by X; X represents the power spectral density feature corresponding to the input EEG data; z represents the sample-level feature.

[0040] The sample-level features are input into the sentiment classifier to obtain the category prediction logical value corresponding to each sentiment category. The category prediction logical value is then subjected to Softmax normalization to obtain the prediction probability corresponding to each sentiment category, expressed as:

[0041] ,

[0042] ,

[0043] in, denoted as the sentiment classifier; a represents the category prediction logical value output by the sentiment classifier; p represents the prediction probability corresponding to each sentiment category.

[0044] A first loss function is constructed based on the predicted probability of sentiment category corresponding to the source domain power spectral density feature samples and the true sentiment labels of the source domain. The first loss is the source domain supervised classification loss, and the parameters of the shared encoder and the sentiment classifier are updated based on the first loss during the pre-training phase. The formula for calculating the first loss is:

[0045] ,

[0046] in, Indicates the true emotional tags of the source domain; CE represents the probability of predicting the sentiment category from the source domain; CE represents the cross-entropy loss function.

[0047] In the unsupervised adaptation phase of the target domain, a domain discriminator is acquired, and a gradient inversion layer is set between the shared encoder and the domain discriminator. During forward propagation, the gradient inversion layer identically transmits the sample-level features output by the shared encoder to the domain discriminator, and during backward propagation, it reverses the gradients returned from the domain discriminator to the shared encoder according to a preset gradient inversion coefficient. The gradient calculation formula is:

[0048] ,

[0049] Wherein, G represents the gradient returned by the domain discriminator to the shared encoder; This represents the gradient after processing by the gradient inversion layer; Indicates the gradient reversal coefficient;

[0050] The source domain sample features and target domain sample features are input into the domain discriminator. The data source label corresponding to the source domain is set to 0, and the data source label corresponding to the target domain is set to 1. The original domain discrimination loss is constructed based on the data source prediction result of the domain discriminator and the corresponding data source label. The calculation formula is as follows:

[0051] ,

[0052] in, This represents the original domain discrimination loss; The domain discriminant represents the predicted probability that the input sample comes from the target domain. This represents the sample-level feature corresponding to the i-th source domain sample; This represents the sample-level feature corresponding to the j-th target domain sample; and These represent the number of source domain samples and the number of target domain samples in the current training batch, respectively.

[0053] The construction of cross-domain hybrid samples based on source domain EEG samples and target domain EEG samples includes:

[0054] The target domain soft pseudo-label probability vector is obtained based on the output of the emotion classifier on the target domain EEG power spectral density feature samples.

[0055] Obtain the mixing coefficient from the preset Beta probability distribution. Based on the mixing coefficients, randomly paired source domain power spectral density feature samples and target domain power spectral density feature samples Perform linear mixing to obtain cross-domain mixed samples. The expression is:

[0056] ,

[0057] Using the same mixing coefficients as the cross-domain mixed samples, a linear mixture is performed on the true sentiment labels of the source domain power spectral density feature samples and the soft pseudo labels of the target domain power spectral density feature samples to obtain the mixed sentiment labels corresponding to the cross-domain mixed samples. The expression is as follows:

[0058] ,

[0059] in, Indicates by the first The source domain sample and the first Hybrid sentiment labels corresponding to cross-domain hybrid samples composed of target domain samples; Indicates the first The true sentiment category labels corresponding to each source domain sample; This represents the K-dimensional one-hot encoded vector corresponding to the true emotion category label; Indicates the first A K-dimensional soft pseudo-label probability vector corresponding to each target domain sample; K represents the number of sentiment categories.

[0060] The target domain soft pseudo-label is determined based on the output of the sentiment classifier for the target domain samples, and is expressed as follows:

[0061] ,

[0062] in, This indicates that the sentiment classifier is for the first... The category prediction logic value output by each target domain sample; T represents the temperature coefficient, used to adjust the smoothness of the soft pseudo-label probability distribution.

[0063] The cross-domain mixed sample is input into the shared encoder and the sentiment classifier to obtain the predicted sentiment category probability corresponding to the cross-domain mixed sample:

[0064] ,

[0065] in, This refers to the shared encoder; This refers to the sentiment classifier; This represents the predicted probability of the sentiment category corresponding to the cross-domain mixed sample;

[0066] A third loss is constructed based on the predicted probability of the sentiment category and the mixed sentiment label. The calculation formula is:

[0067] ,

[0068] in, This indicates the number of cross-domain mixed samples in the current training batch; Represents a cross-domain mixed sample index set; This represents the component of the mixed sentiment label in the k-th sentiment category; This represents the predicted probability that the cross-domain mixed sample belongs to the k-th sentiment category;

[0069] Based on the mixing ratio of the target domain component in the cross-domain mixed sample, determine the continuous data source label corresponding to the cross-domain mixed sample:

[0070] ,

[0071] In this context, the data source label for the source domain is 0, and the data source label for the target domain is 1. This indicates the continuous data source label corresponding to the cross-domain mixed sample;

[0072] The cross-domain mixed samples are input into the shared encoder and the domain discriminator to obtain the corresponding data source prediction probabilities. A mixed domain discrimination loss is then constructed based on the data source prediction probabilities and the continuous data source labels.

[0073] ,in, This represents the sample-level features corresponding to the cross-domain mixed samples; This refers to the domain discriminator; Indicates the discriminative loss in the mixed domain;

[0074] A second loss is constructed based on the original domain discrimination loss and the hybrid domain discrimination loss. The calculation formula is:

[0075] ,

[0076] in, This represents the original domain discrimination loss constructed in claim 4; This represents the discriminative loss of the hybrid domain.

[0077] The step of constructing a source domain category prototype based on source domain sample features and their true sentiment labels, and constructing a target domain pseudo-category prototype based on target domain sample features and their pseudo sentiment labels, includes:

[0078] The source domain sample features and target domain sample features output by the shared encoder are normalized.

[0079] Based on the true sentiment labels of the source domain, the normalized features of the source domain samples are divided into corresponding sentiment categories. The features of source domain samples belonging to the same sentiment category are then averaged and normalized to obtain the source domain category prototypes for each sentiment category. The expression is as follows:

[0080] ,

[0081] in, This represents the source domain category prototype corresponding to the k-th sentiment category; This represents the normalized source domain sample features;

[0082] Based on the predicted probability of the target domain sentiment category output by the sentiment classifier, determine the pseudo-sentiment label corresponding to each target domain sample. and prediction confidence ;

[0083] ,

[0084] ,

[0085] Filter the target domain power spectral density feature samples whose predicted confidence meets the preset confidence conditions, and classify the filtered target domain sample features into the corresponding sentiment categories according to the corresponding pseudo-sentiment labels;

[0086] Based on the predicted confidence level, the target domain sample features belonging to the same sentiment category are subjected to confidence-weighted averaging and normalization to obtain the target domain pseudo-category prototypes corresponding to each sentiment category, expressed as:

[0087] ,

[0088] in, This represents the set of high-confidence target domain EEG samples corresponding to the k-th emotion category; This represents the target domain pseudo-class prototype corresponding to the k-th sentiment category; This indicates a normalization operation.

[0089] This invention also includes using an exponential moving average method to update the source domain category prototype and the target domain pseudo-category prototype for each sentiment category based on historical category prototypes and the category prototypes corresponding to the current training batch, respectively. The calculation formula is as follows:

[0090] ,

[0091] in, Represents data field The category prototype corresponding to the k-th sentiment category; This represents the category prototype corresponding to the k-th sentiment category in the current training batch; Indicates the prototype momentum coefficient;

[0092] Construct the intra-domain prototype loss based on the similarity between the source domain sample features and the prototypes of each source domain category. The intra-domain prototype loss is constructed based on the similarity between the target domain sample features that meet the pre-set confidence conditions and the pseudo-class prototypes of each target domain. Construct a cross-domain prototype alignment loss from the source domain to the target domain based on the similarity between the features of the source domain samples and the pseudo-class prototypes of each target domain. Based on the similarity between the target domain sample features that satisfy the pre-set confidence conditions and the prototypes of each source domain category, a cross-domain prototype alignment loss from the target domain to the source domain is constructed. Based on the prototype loss within the source domain. The prototype loss within the target domain The cross-domain prototype alignment loss from the source domain to the target domain and the cross-domain prototype alignment loss from the target domain to the source domain. Constructing the fourth loss The calculation formula is:

[0093] ,

[0094] Where β represents the weight corresponding to the prototype loss within the target domain; γ represents the weight corresponding to the bidirectional cross-domain prototype alignment loss. When there are no valid samples in the current training batch for constructing the prototype of a certain sentiment category, the historical prototype of the corresponding sentiment category remains unchanged.

[0095] This invention also includes a high-quality source domain pre-training stage and a target domain unsupervised adaptation stage;

[0096] In the high-quality source domain pre-training stage, the parameters of the shared encoder and the sentiment classifier are updated according to the source domain supervised classification loss using the high-quality source domain training set, to obtain the pre-trained shared encoder and sentiment classifier.

[0097] In the unsupervised adaptation stage of the target domain, the parameters of the shared encoder and sentiment classifier obtained in the high-quality source domain pre-training stage are initialized, and source domain supervised classification, domain adversarial learning, cross-domain hybrid learning, and bidirectional prototype semantic alignment are jointly performed based on labeled source domain power spectral density feature samples and unlabeled target domain power spectral density feature samples. The total loss L of the unsupervised adaptation stage of the target domain is constructed based on a weighted combination of the first loss, the second loss, the third loss, and the fourth loss, and the parameters of the shared encoder, the sentiment classifier, and the domain discriminator are updated based on the total loss L. The formula for calculating the total loss L is:

[0098] ,

[0099] Where η represents the balance coefficient between the sentiment category discrimination objective and the domain alignment objective; This represents the weight corresponding to the third loss; This represents the weight corresponding to the fourth loss;

[0100] The weight corresponding to the fourth loss gradually increases from a preset initial weight to a preset maximum weight as the training progress of the unsupervised adaptation phase of the target domain proceeds. The calculation formula is as follows:

[0101] ,

[0102] in, This indicates the training progress of unsupervised adaptation in the target domain; This represents the initial weights corresponding to the fourth loss; This represents the maximum weight corresponding to the fourth loss.

[0103] This invention also provides a cross-dataset EEG emotion recognition method, comprising the following steps:

[0104] Obtain the EEG data to be identified in the target data domain, preprocess the EEG data to be identified, and obtain power spectral density feature samples characterized by feature frequency bands and EEG channels that are consistent with the input data format of the cross-dataset EEG emotion recognition model obtained by the above training method.

[0105] The power spectral density feature samples are input into the cross-dataset EEG emotion recognition model, the corresponding sample-level features are extracted by the shared encoder, and the predicted probabilities of multiple emotion categories are obtained by the emotion classifier.

[0106] The emotion recognition result corresponding to the EEG data to be identified is determined based on the predicted probabilities corresponding to the multiple emotion categories.

[0107] The present invention also provides a cross-dataset EEG emotion recognition device, including a processor and a memory; the memory stores a computer program or computer instructions; the processor is used to execute the computer program or computer instructions, and when the computer program or computer instructions are executed, the device implements the steps of the above method.

[0108] Compared with the prior art, the technical solution provided by this invention has the following advantages:

[0109] 1. This invention employs a two-stage training approach: high-quality source domain pre-training and unsupervised adaptation in the target domain. To address the differences in the separability of emotion categories among participants in the source domain, the high-quality source domain pre-training stage selects participants with high statistical separability of emotion categories through quality scoring and screening. A shared encoder and emotion classifier are then pre-trained based on the selected high-quality source domain training set. To address cross-dataset feature distribution shifts, the unsupervised adaptation stage in the target domain employs a combination of domain adversarial learning and cross-domain hybrid learning to reduce the dataset-level feature distribution differences between the source and target domains. To address cross-domain category semantic shifts, source domain category prototypes and target domain pseudo-category prototypes are constructed, and bidirectional prototype semantic alignment is implemented to maintain semantic consistency between corresponding emotion categories in the source and target domains.

[0110] 2. To address the differences in the separability of emotional categories among participants in the source domain, statistical analysis is conducted on the overall category differences and inter-category differences across multiple feature frequency bands for participants from different source domains, using the number of emotional stimulus trials as the statistical unit. A quality score is then constructed based on the statistical test results. Participants in the source domains are ranked and screened according to these quality scores. Multiple participants with high statistical separability of emotional categories are selected to construct a high-quality source domain training set, allowing the shared encoder to preferentially utilize source domain EEG data with strong emotional category discrimination information for pre-training. The term "high-quality source domain participant" in this invention refers to a participant whose EEG data exhibits high statistical separability of emotional categories and training applicability under the aforementioned quality score; it does not represent an evaluation of the participant's individual psychological attributes, physiological state, or personnel quality.

[0111] 3. To address the feature distribution shift across datasets, domain adversarial learning is implemented during the unsupervised adaptation phase in the target domain using a domain discriminator and a gradient inversion layer. This makes it difficult for the shared encoder to distinguish sample features from the data source by the domain discriminator. Simultaneously, cross-domain hybrid samples are constructed using source and target domain samples, and the sentiment category label and data source label are continuously mixed accordingly to smooth the feature transition between the source and target domains. Domain adversarial learning and cross-domain hybrid learning work synergistically to reduce the feature distribution shift across datasets.

[0112] 4. To address cross-domain category semantic shift, a source domain category prototype is constructed based on the source domain's real sentiment labels, and a target domain pseudo-category prototype is constructed based on the target domain's pseudo-sentiment labels that meet pre-set reliability conditions. The source domain category prototype is used to constrain the target domain sample features, and the target domain pseudo-category prototype is used to inversely constrain the source domain sample features. Cross-domain category semantic shift is reduced through bidirectional prototype semantic alignment.

[0113] 5. This invention uses three complementary technical mechanisms—quality scoring and screening, domain adversarial and cross-domain hybridization, and bidirectional prototype semantic alignment—to mitigate the impact of differences in the separability of emotion categories in the source domain, feature distribution shifts across datasets, and semantic shifts across categories on EEG emotion recognition performance, thereby improving the accuracy and generalization ability of cross-dataset EEG emotion recognition. Attached Figure Description

[0114] Figure 1 This is a schematic diagram of the overall two-stage training framework for the cross-dataset EEG emotion recognition model in this invention.

[0115] Figure 2 This is a flowchart illustrating the preprocessing and feature unification process for source domain EEG data and target domain EEG data in this invention.

[0116] Figure 3 This is a flowchart of the source domain subject emotion discrimination quality assessment, high-quality source domain training set construction and pre-training process in this invention.

[0117] Figure 4 This is a schematic diagram of the structure of the shared encoder and emotion classifier in this invention.

[0118] Figure 5 This is a flowchart of the adversarial domain alignment and cross-domain hybrid learning collaborative training process based on gradient inversion in this invention.

[0119] Figure 6 This is a flowchart illustrating the construction, updating, and bidirectional prototype semantic alignment of the source domain category prototype and the target domain pseudo-category prototype in this invention. Detailed Implementation

[0120] To facilitate understanding of the present invention, a more complete description of the invention will be given below with reference to the accompanying drawings, which illustrate several embodiments of the invention. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that the disclosure of the invention will be more thorough and complete.

[0121] like Figure 1 As shown, a method for training a cross-dataset EEG emotion recognition model includes the following steps:

[0122] Source domain EEG data with emotion category labels and target domain EEG data without emotion category labels are acquired. The source domain EEG data and the target domain EEG data are preprocessed respectively to obtain source domain power spectral density feature samples and target domain power spectral density feature samples characterized by feature frequency bands and EEG channels.

[0123] Source domain EEG data with emotion category labels are represented as follows:

[0124] ,

[0125] Target domain EEG data without emotion category labels are represented as follows:

[0126] ,

[0127] in, This represents the i-th source domain EEG sample; This represents the true emotion label corresponding to the i-th source domain EEG sample; This indicates the subject belonging to the source domain of the i-th source domain EEG sample; Indicates the number of source domain EEG samples; This represents the EEG sample of the j-th target domain; This indicates the number of EEG samples in the target domain. The true sentiment labels of the target domain EEG data are not visible during model training and unsupervised adaptation in the target domain.

[0128] The preprocessing and feature unification process for source domain EEG data and target domain EEG data is as follows: Figure 2 As shown. In some embodiments, for EEG data whose EEG channel configuration is inconsistent with the preset unified channel configuration, channel mapping processing is performed according to the spatial position of the electrodes corresponding to each EEG channel, so that the source domain EEG data and the target domain EEG data have a unified EEG channel configuration; for EEG data that requires the calculation of power spectral density features from time-domain EEG signals, the continuous EEG signals are segmented according to a preset time window, and the Welch power spectral estimation method is used to calculate the power spectral density features corresponding to each EEG segment.

[0129] Five characteristic frequency bands were extracted from the EEG data. These five characteristic frequency bands are delta band, theta band, alpha band, beta band, and gamma band. The delta band corresponds to 1Hz to 4Hz, the theta band corresponds to 4Hz to 8Hz, the alpha band corresponds to 8Hz to 14Hz, the beta band corresponds to 14Hz to 30Hz, and the gamma band corresponds to 30Hz to 45Hz.

[0130] Each EEG sample is converted into a power spectral density feature matrix based on frequency band and EEG channel, represented as:

[0131] ;

[0132] Where B represents the number of feature frequency bands and C represents the unified number of EEG channels; in this embodiment, B=5 and C=62. Thus, EEG samples from different EEG datasets are uniformly represented as power spectral density features consisting of five feature frequency bands and 62 EEG channels.

[0133] In some embodiments, to reduce the impact of differences in the absolute scale of features between different EEG datasets, band-by-band and channel-by-channel standardization is performed on the source domain EEG data and the target domain EEG data, respectively. The standardized mean and standard deviation of the source domain EEG data are calculated from the source domain training data, and the standardized mean and standard deviation of the target domain EEG data are calculated from the unlabeled target domain adaptation data that are allowed to be accessed during the current training process. Independent target domain test data are not involved in the estimation of standardized parameters.

[0134] Using the emotional stimulus trials of source domain participants as the statistical unit, statistical analysis was performed on the multi-band power spectral density characteristics of each source domain participant under different emotional categories. The quality score corresponding to each source domain participant was determined based on the overall category statistical difference and inter-category statistical difference between different emotional categories. Source domain participants were then selected based on the quality scores, and a high-quality source domain training set was constructed based on the source domain power spectral density characteristic samples corresponding to the selected source domain participants. The quality score is used to characterize the statistical separability of the EEG power spectral density characteristics of the corresponding source domain participants across different emotional categories, and the applicability of the corresponding source domain participant's EEG data for model training is determined based on the statistical separability.

[0135] Among them, the source domain subject emotion discrimination quality assessment, high-quality source domain training set construction and pre-training process are as follows: Figure 3 As shown. First, the quality of emotion category discrimination of EEG data from different source domains is evaluated using the number of emotional stimulus trials as the statistical unit. The term "high-quality source domain subject" in this invention refers to a source domain subject whose EEG data, based on the aforementioned quality score, exhibits high statistical separability of emotion categories and a high degree of training applicability.

[0136] In the high-quality source domain pre-training stage, a shared encoder and a sentiment classifier are obtained. The high-quality source domain training set is input into the shared encoder to obtain sample-level features. The sample-level features are input into the sentiment classifier to obtain the prediction probability corresponding to each sentiment category. A first loss is constructed based on the prediction probability and the true sentiment label of the source domain. The shared encoder and the sentiment classifier are pre-trained based on the first loss.

[0137] In the unsupervised adaptation phase of the target domain, the parameters of the pre-trained shared encoder and the sentiment classifier are initialized, and a domain discriminator is obtained. The source domain power spectral density feature samples and the target domain power spectral density feature samples are input into the shared encoder to obtain source domain sample features and target domain sample features, respectively. Domain adversarial learning is performed based on the source domain sample features and the target domain sample features, and the original domain discriminant loss is constructed based on the data source prediction results of the source domain sample features and the target domain sample features by the domain discriminator.

[0138] A cross-domain hybrid sample is constructed based on the power spectral density feature samples of the source domain and the power spectral density feature samples of the target domain. A hybrid sentiment label corresponding to the cross-domain hybrid sample is constructed based on the real sentiment label of the source domain and the pseudo label of the target domain. The cross-domain hybrid sample is input into the shared encoder and the sentiment classifier to obtain the sentiment category prediction probability. A third loss is constructed based on the sentiment category prediction probability and the hybrid sentiment label. A continuous data source label is determined based on the mixing ratio of the source domain component and the target domain component in the cross-domain hybrid sample. A hybrid domain discrimination loss is constructed based on the data source prediction result of the domain discriminator for the cross-domain hybrid sample and the continuous data source label. A second loss is constructed based on the original domain discrimination loss and the hybrid domain discrimination loss.

[0139] A source domain category prototype is constructed based on the source domain sample features and their true sentiment labels. A target domain pseudo-category prototype is constructed based on the target domain sample features and the target domain pseudo-sentiment labels that meet the preset confidence conditions. Category semantic constraints are applied to the target domain sample features based on the source domain category prototype, and category semantic constraints are applied to the source domain sample features based on the target domain pseudo-category prototype to perform bidirectional prototype semantic alignment. A fourth loss is constructed based on the intra-domain category prototype constraints of the source and target domains and the bidirectional cross-domain category prototype alignment.

[0140] In the unsupervised adaptation stage of the target domain, the first loss is constructed based on the predicted probability of the sentiment category corresponding to the power spectral density feature sample of the source domain and the real sentiment label of the source domain. The shared encoder, sentiment classifier and domain discriminator are jointly trained based on the first loss, the second loss, the third loss and the fourth loss.

[0141] The shared encoder and the emotion classifier, after joint training, are combined to obtain a cross-dataset EEG emotion recognition model.

[0142] In some embodiments of the present invention, for the r-th trial of the u-th source domain subject, the EEG power spectral density features within the same trial are aggregated, and the calculation formula is as follows:

[0143] ,

[0144] in, Indicates the first The trial-level feature corresponding to the b-th feature band of the r-th emotional stimulus trial for each source domain subject; This indicates the number of EEG segments included in the test. Indicates the number of brainwave channels; This represents the power spectral density characteristics of the corresponding EEG segment in the c-th channel and the b-th frequency band;

[0145] For the u-th source domain participant and the b-th feature frequency band, a one-way ANOVA was performed on the sub-features corresponding to different emotion categories to obtain the significance probability of the overall category difference. For any two distinct emotion categories k and The corresponding sub-features were subjected to a Welch heteroscedasticity t-test to obtain the significance probability representing the statistical difference between the two corresponding sentiment categories. ;

[0146] The significance score is determined based on the significance probabilities obtained from the one-way ANOVA and Welch heteroscedasticity t-test. The significance score function is as follows:

[0147] ;

[0148] in, This represents the significance probability obtained from any of the aforementioned statistical tests; Indicates an indicator function; Indicates the first significance threshold; This represents the second significance threshold, and ; This represents the additional weight corresponding to a significance probability lower than the second significance threshold;

[0149] Let the set of all pairs of different emotion categories be:

[0150] ;

[0151] Where K represents the number of emotion categories;

[0152] The significance scores of the overall statistical differences corresponding to each feature frequency band and the significance scores of the statistical differences between each emotion category and the corresponding categories are aggregated to obtain the quality scores of the subjects in the corresponding source domain; Quality score corresponding to each source domain participant The formula for calculation is:

[0153] ;

[0154] in, Indicates the first The quality score corresponding to each source domain subject; B represents the number of feature frequency bands; Indicates the first The significance probability obtained by performing a one-way ANOVA on the b-th characteristic frequency band of each source domain subject; Indicates the first For each source domain participant, on the b-th feature frequency band, the k-th emotion category is related to the... The significance probability obtained by performing a Welch heteroscedasticity t-test between the sentiment categories; This represents the set of all pairs of different emotion categories;

[0155] Based on the source domain subject quality scores, multiple high-quality source domain subjects are selected according to a preset ratio. The calculation formula is as follows:

[0156] ,

[0157] ,

[0158] in, This indicates the number of subjects selected from high-quality source domains; This represents the floor function; Indicates the preset selection ratio; Indicates the total number of subjects in the source domain; This represents a high-quality source domain subject set; Indicated by mass fraction Select from high to low The subject number corresponding to each source domain subject.

[0159] Construct a high-quality source domain training set based on a high-quality source domain subject set:

[0160] ,

[0161] The shared encoder and emotion classifier are pre-trained using the high-quality source domain training set, enabling the model to preferentially learn initial emotion discrimination features using source domain EEG data with significant differences in emotion categories.

[0162] The structure of the cross-dataset EEG emotion recognition model is as follows Figure 4 As shown, in some embodiments of the present invention, the shared encoder adopts a Transformer coding structure. For the input power spectral density feature matrix, different feature frequency bands are respectively used as non-overlapping frequency band feature blocks. Each frequency band feature block contains the power spectral density features of the corresponding feature frequency band on all EEG channels. Its working process includes:

[0163] The input power spectral density feature samples are divided into multiple frequency band feature blocks according to the feature frequency bands. The EEG channel features contained in each frequency band feature block are linearly mapped to obtain the corresponding frequency band feature labels, as expressed by:

[0164] ,

[0165] in, This represents the EEG channel characteristics corresponding to the b-th characteristic frequency band; This represents the frequency band feature marker corresponding to the b-th feature frequency band; Represents the linear mapping weight matrix; Indicates the bias term;

[0166] The feature tags of all frequency bands are combined with the position codes to form a feature tag sequence:

[0167] ,

[0168] in, This represents positional encoding, used to preserve the positional information of different feature frequency bands in the input sequence;

[0169] Multiple frequency band feature labels and location codes are combined and input into the Transformer encoding structure, and then processed through pooling operations to obtain sample-level features:

[0170] ,

[0171] in, The shared encoder is represented by X; X represents the power spectral density feature corresponding to the input EEG data; z represents the sample-level feature.

[0172] The sample-level features are input into the sentiment classifier to obtain the category prediction logical value corresponding to each sentiment category. The category prediction logical value is then subjected to Softmax normalization to obtain the prediction probability corresponding to each sentiment category, expressed as:

[0173] ,

[0174] ,

[0175] in, denoted as the sentiment classifier; a represents the category prediction logical value output by the sentiment classifier; p represents the prediction probability corresponding to each sentiment category.

[0176] A first loss function is constructed based on the predicted probability of sentiment category corresponding to the source domain power spectral density feature samples and the true sentiment labels of the source domain. The first loss is the source domain supervised classification loss, and the parameters of the shared encoder and the sentiment classifier are updated based on the first loss during the pre-training phase. The formula for calculating the first loss is:

[0177] ,

[0178] in, Indicates the true emotional tags of the source domain; CE represents the probability of predicting the sentiment category from the source domain; CE represents the cross-entropy loss function.

[0179] In the high-quality source domain pre-training stage, the first loss is calculated using the high-quality source domain training set, and the parameters of the shared encoder and the emotion classifier are updated. By using only the selected high-quality source domain training set for pre-training, the shared encoder prioritizes learning the relatively stable EEG frequency band differences between different emotion categories, providing model parameter initialization for the unsupervised adaptation stage of the target domain.

[0180] The gradient-inverted adversarial domain alignment and cross-domain hybrid learning collaborative training process is as follows: Figure 5 As shown, after completing high-quality source domain pre-training, the shared encoder and emotion classifier are initialized using the pre-trained parameters, and a domain discriminator is obtained. Labeled source domain EEG data are reused in the target domain unsupervised adaptation stage, primarily to maintain the emotion category discrimination structure formed during pre-training and the coverage of source domain samples. The parameter initialization obtained from high-quality source domain screening, together with subsequent domain adversarial learning, cross-domain hybrid learning, and bidirectional prototype semantic alignment, work together to mitigate the impact of differences in the separability of subject emotion categories in the source domain, cross-dataset feature distribution shifts, and cross-domain category semantic shifts on the target domain unsupervised adaptation.

[0181] In each unsupervised adaptation iteration of the target domain, EEG samples are selected from both the source domain and target domain EEG data, and source domain features and target domain features are extracted using a shared encoder:

[0182] ,

[0183] ,

[0184] During the unsupervised adaptation process in the target domain, the first loss is calculated using the real emotion labels corresponding to the source domain EEG samples, so that the shared encoder and emotion classifier can maintain the emotion category discrimination structure while performing cross-dataset feature alignment.

[0185] In some embodiments of the present invention, a domain discriminator is obtained during the unsupervised adaptation stage of the target domain, and a gradient inversion layer is set between the shared encoder and the domain discriminator; the gradient inversion layer transmits the sample-level features output by the shared encoder to the domain discriminator identically during forward propagation, and reverses the gradients returned from the domain discriminator to the shared encoder according to a preset gradient inversion coefficient during backpropagation, wherein the gradient calculation formula is:

[0186] ,

[0187] Wherein, G represents the gradient returned by the domain discriminator to the shared encoder; This represents the gradient after processing by the gradient inversion layer; Indicates the gradient reversal coefficient;

[0188] The source domain sample features and target domain sample features are input into the domain discriminator. The data source label corresponding to the source domain is set to 0, and the data source label corresponding to the target domain is set to 1. The original domain discrimination loss is constructed based on the data source prediction result of the domain discriminator and the corresponding data source label. The calculation formula is as follows:

[0189] ,

[0190] in, This represents the original domain discrimination loss; The domain discriminant represents the predicted probability that the input sample comes from the target domain. This represents the sample-level feature corresponding to the i-th source domain sample; This represents the sample-level feature corresponding to the j-th target domain sample; and These represent the number of source domain samples and the number of target domain samples in the current training batch, respectively.

[0191] The domain adversarial learning reduces cross-dataset feature distribution shift by enabling the shared encoder to learn features that are difficult for the domain discriminator to distinguish the data source.

[0192] In some embodiments of the present invention, constructing cross-domain hybrid samples based on source domain EEG samples and target domain EEG samples includes:

[0193] The target domain soft pseudo-label probability vector is obtained based on the output of the emotion classifier on the target domain EEG power spectral density feature samples.

[0194] Obtain the mixing coefficient from the preset Beta probability distribution. : ,in, The shape parameter corresponding to the Beta distribution is used to determine the source domain power spectral density feature samples based on the mixing coefficient. and target domain power spectral density feature samples Perform linear mixing to obtain cross-domain mixed samples. The expression is:

[0195] ,

[0196] in, This represents the power spectral density feature sample of the i-th source domain; This represents the power spectral density feature sample of the j-th target domain; λ represents the corresponding cross-domain mixed sample; λ represents the mixing coefficient and the proportion of the target domain component in the cross-domain mixed sample.

[0197] Using the same mixing coefficients as the cross-domain mixed samples, a linear mixture is performed on the true sentiment labels of the source domain power spectral density feature samples and the soft pseudo labels of the target domain power spectral density feature samples to obtain the mixed sentiment labels corresponding to the cross-domain mixed samples. The expression is as follows:

[0198] ,

[0199] in, Indicates by the first The source domain sample and the first Hybrid sentiment labels corresponding to cross-domain hybrid samples composed of target domain samples; Indicates the first The true sentiment category labels corresponding to each source domain sample; This represents the K-dimensional one-hot encoded vector corresponding to the true emotion category label; Indicates the first A K-dimensional soft pseudo-label probability vector corresponding to each target domain sample; K represents the number of sentiment categories.

[0200] The target domain soft pseudo-label is determined based on the output of the sentiment classifier for the target domain samples, and is expressed as follows:

[0201] ,

[0202] in, This indicates that the sentiment classifier is for the first... The category prediction logic value output by each target domain sample; T represents the temperature coefficient, used to adjust the smoothness of the soft pseudo-label probability distribution.

[0203] The cross-domain mixed sample is input into the shared encoder and the sentiment classifier to obtain the predicted sentiment category probability corresponding to the cross-domain mixed sample:

[0204] ,

[0205] in, This refers to the shared encoder; This refers to the sentiment classifier; This represents the predicted probability of the sentiment category corresponding to the cross-domain mixed sample;

[0206] A third loss is constructed based on the predicted probability of the sentiment category and the mixed sentiment label. The calculation formula is:

[0207] ,

[0208] in, This indicates the number of cross-domain mixed samples in the current training batch; Represents a cross-domain mixed sample index set; This represents the component of the mixed sentiment label in the k-th sentiment category; This represents the predicted probability that the cross-domain mixed sample belongs to the k-th sentiment category;

[0209] Based on the mixing ratio of the target domain component in the cross-domain mixed sample, determine the continuous data source label corresponding to the cross-domain mixed sample:

[0210] ,

[0211] In this context, the data source label for the source domain is 0, and the data source label for the target domain is 1. This indicates the continuous data source label corresponding to the cross-domain mixed sample;

[0212] The cross-domain mixed samples are input into the shared encoder and the domain discriminator to obtain the corresponding data source prediction probabilities, and a mixed domain discrimination loss is constructed based on the data source prediction probabilities and the continuous data source labels:

[0213] ,in, This represents the sample-level features corresponding to the cross-domain mixed samples; This refers to the domain discriminator; Indicates the discriminative loss in the mixed domain;

[0214] A second loss is constructed based on the original domain discrimination loss and the hybrid domain discrimination loss. The calculation formula is:

[0215] ,

[0216] in, This represents the original domain discrimination loss constructed in claim 4; This represents the discriminative loss of the hybrid domain.

[0217] The process of constructing and updating the source domain category prototype and the target domain pseudo-category prototype, as well as the bidirectional prototype semantic alignment, is as follows: Figure 6 As shown. To reduce the impact of differences in feature magnitudes among different samples on category prototype estimation and feature similarity calculation, the source domain features and target domain features are first normalized:

[0218] ,

[0219] Where z represents the sample-level features output by the shared encoder. This represents the normalized sample-level features. This represents the L2 norm. The normalization operation described in this invention... For L2 normalization, for any non-zero vector a, we have:

[0220] .

[0221] The domain adversarial learning and cross-domain hybrid learning are used together to reduce the feature distribution shift across datasets.

[0222] The step of constructing a source domain category prototype based on source domain sample features and their true sentiment labels, and constructing a target domain pseudo-category prototype based on target domain sample features and their pseudo sentiment labels, includes:

[0223] The source domain sample features and target domain sample features output by the shared encoder are normalized.

[0224] Based on the true sentiment labels of the source domain, the normalized features of the source domain samples are divided into corresponding sentiment categories. The features of source domain samples belonging to the same sentiment category are then averaged and normalized to obtain the source domain category prototypes for each sentiment category. The expression is as follows:

[0225] ,

[0226] in, This represents the source domain category prototype corresponding to the k-th sentiment category; This represents the normalized source domain sample features;

[0227] Based on the predicted probability of the target domain sentiment category output by the sentiment classifier, determine the pseudo-sentiment label corresponding to each target domain sample. and prediction confidence ;

[0228] ,

[0229] ,

[0230] To reduce the impact of erroneous target domain pseudo-labels on the prototype estimation of target domain categories, only target domain EEG samples with a prediction confidence greater than or equal to a pre-set confidence threshold are selected. The set of high-confidence target domain EEG samples corresponding to the k-th emotion category is represented as:

[0231] ,

[0232] in, This represents the set of high-confidence target domain EEG samples corresponding to the k-th emotion category. Indicates the preset confidence threshold

[0233] Filter the target domain power spectral density feature samples whose predicted confidence meets the preset confidence conditions, and classify the filtered target domain sample features into the corresponding sentiment categories according to the corresponding pseudo-sentiment labels;

[0234] Based on the predicted confidence level, the features of target domain samples belonging to the same sentiment category are subjected to confidence-weighted averaging and normalization to obtain the target domain pseudo-category prototypes corresponding to each sentiment category, expressed as:

[0235] ,

[0236] in, This represents the target domain pseudo-class prototype corresponding to the k-th sentiment category. This represents the normalized features of the target domain samples. This represents the corresponding prediction confidence level. The prediction confidence level serves as the sample weight, ensuring that target domain EEG samples with higher prediction confidence levels contribute more significantly to the target domain pseudo-class prototype. This indicates a normalization operation.

[0237] When the set of high-confidence target domain EEG samples corresponding to the k-th emotion category is empty, the target domain pseudo-category prototype corresponding to the k-th emotion category is not updated according to the current training batch, and the corresponding target domain prototype constraint is not imposed on the emotion category in the current training batch.

[0238] If there are no target domain EEG samples with a prediction confidence greater than or equal to a preset confidence threshold in the current training batch, target domain pseudo-class prototype update is not performed for the current training batch, and the intra-target domain prototype loss and the target domain to source domain prototype alignment loss are both set to zero. If the set of valid source domain EEG samples corresponding to the source domain to target domain prototype alignment is empty, the source domain to target domain prototype alignment loss is set to zero.

[0239] This invention also includes using an exponential moving average method to update the source domain category prototype and the target domain pseudo-category prototype for each sentiment category based on historical category prototypes and the category prototypes corresponding to the current training batch, respectively. The calculation formula is as follows:

[0240] ,

[0241] in, Represents data field The category prototype corresponding to the k-th sentiment category; This represents the category prototype corresponding to the k-th sentiment category in the current training batch; This represents the prototype momentum coefficient. Represents the source domain. The target domain is defined as follows. For sentiment categories that exhibit a valid category prototype for the first time, their global category prototype is initialized directly using the category prototype corresponding to the current training batch. This category prototype is updated using a moving average method and is not used as an independent learnable network parameter in gradient backpropagation.

[0242] Given the set of category prototypes corresponding to the data domain v The prototype-based class probability is calculated based on the cosine similarity between the normalized sample features and the prototypes of each class:

[0243] ,

[0244] in, This represents the class probability of a sample feature relative to the k-th sentiment category prototype; Indicates cosine similarity; This represents the category prototype corresponding to the k-th emotion category; This represents the prototype temperature parameter. By using the prototype category probability, sample features are made closer to the category prototype of the corresponding emotion category, while reducing the similarity between them and prototypes of other emotion categories.

[0245] For source domain EEG samples, construct the source domain prototype loss based on the source domain true emotion label and the source domain category prototype:

[0246] ,

[0247] in, Indicates the prototype loss within the source domain. Represents the source domain category prototype set.

[0248] For EEG samples in the target domain, only high-confidence target domain EEG samples are selected to participate in the prototype constraint within the target domain. Let the set of all high-confidence target domain samples be defined. The prototype loss within the target domain is expressed as:

[0249] ,

[0250] in, This represents the prototype loss within the target domain; Represents the set of pseudo-class prototypes for the target domain; target domain prediction confidence. At the same time, as a loss weight, it enables high-confidence target domain EEG samples to play a greater role in the target domain category structure learning process.

[0251] To ensure that source domain samples are not only close to the source domain's same-class prototypes, but also close to the pseudo-class prototypes of the corresponding sentiment category in the target domain, a prototype alignment loss from the source domain to the target domain is constructed for sentiment categories that already have effective pseudo-class prototypes in the target domain:

[0252] ,

[0253] in, This represents the set of source domain EEG samples whose true emotional category already has an effective pseudo-class prototype in the target domain.

[0254] For high-confidence target domain EEG samples, in addition to bringing them closer to the pseudo-class prototype corresponding to the target domain, the source domain class prototype is also used to constrain them, and a prototype alignment loss from the target domain to the source domain is constructed:

[0255] ,

[0256] in, This represents the prototype alignment loss from the target domain to the source domain.

[0257] Construct the intra-domain prototype loss based on the similarity between the source domain sample features and the prototypes of each source domain category. The intra-domain prototype loss is constructed based on the similarity between the target domain sample features that meet the pre-set confidence conditions and the pseudo-class prototypes of each target domain. Construct a cross-domain prototype alignment loss from the source domain to the target domain based on the similarity between the features of the source domain samples and the pseudo-class prototypes of each target domain. Based on the similarity between the target domain sample features that satisfy the pre-set confidence conditions and the prototypes of each source domain category, a cross-domain prototype alignment loss from the target domain to the source domain is constructed. Based on the prototype loss within the source domain. The prototype loss within the target domain The cross-domain prototype alignment loss from the source domain to the target domain and the cross-domain prototype alignment loss from the target domain to the source domain. Constructing the fourth loss The calculation formula is:

[0258] ,

[0259] Where β represents the weight corresponding to the prototype loss within the target domain; γ represents the weight corresponding to the bidirectional cross-domain prototype alignment loss. When there are no valid samples in the current training batch for constructing the prototype of a certain sentiment category, the historical prototype of the corresponding sentiment category remains unchanged.

[0260] This invention also includes a high-quality source domain pre-training stage and a target domain unsupervised adaptation stage;

[0261] In the high-quality source domain pre-training stage, the parameters of the shared encoder and the sentiment classifier are updated according to the source domain supervised classification loss using the high-quality source domain training set, to obtain the pre-trained shared encoder and sentiment classifier.

[0262] In the unsupervised adaptation stage of the target domain, the parameters of the shared encoder and sentiment classifier obtained in the high-quality source domain pre-training stage are initialized, and source domain supervised classification, domain adversarial learning, cross-domain hybrid learning, and bidirectional prototype semantic alignment are jointly performed based on labeled source domain power spectral density feature samples and unlabeled target domain power spectral density feature samples. The total loss L of the unsupervised adaptation stage of the target domain is constructed based on a weighted combination of the first loss, the second loss, the third loss, and the fourth loss, and the parameters of the shared encoder, the sentiment classifier, and the domain discriminator are updated based on the total loss L. The formula for calculating the total loss L is:

[0263] ,

[0264] Where η represents the balance coefficient between the sentiment category discrimination objective and the domain alignment objective; This represents the weight corresponding to the third loss; This represents the weight corresponding to the fourth loss;

[0265] The weight corresponding to the fourth loss gradually increases from a preset initial weight to a preset maximum weight as the training progress of the unsupervised adaptation phase of the target domain proceeds. The calculation formula is as follows:

[0266] ,

[0267] in, This indicates the training progress of unsupervised adaptation in the target domain; This represents the initial weights corresponding to the fourth loss; This represents the maximum weight corresponding to the fourth loss.

[0268] In the early stages of training, a preliminary shared feature space is established mainly through source domain supervised classification, domain adversarial learning, and cross-domain hybrid learning. As the target domain prediction results gradually stabilize, the bidirectional prototype semantic alignment constraints are then gradually enhanced.

[0269] During the unsupervised adaptation process in the target domain, the parameters of the shared encoder, sentiment classifier, and domain discriminator are updated based on the total loss. Specifically, source domain supervised classification is used to maintain the sentiment category discrimination structure; domain adversarial learning and cross-domain hybrid learning are used together to reduce cross-dataset feature distribution shifts; and bidirectional prototype semantic alignment is used to reduce cross-domain category semantic shifts.

[0270] Once the unsupervised adaptation in the target domain reaches the preset number of training epochs or the model reaches the preset convergence condition, the parameter-updated shared encoder and emotion classifier are combined to obtain the final cross-dataset EEG emotion recognition model. The domain discriminator, cross-domain mixing process, and category prototype update process are used in the model training phase and do not participate in emotion category prediction during the model inference phase.

[0271] This invention also provides a cross-dataset EEG emotion recognition method, wherein the EEG data to be recognized comes from a target data domain that has undergone unsupervised adaptation to the target domain according to the above-described training method, and includes the following steps:

[0272] Obtain the EEG data to be identified in the target data domain, preprocess the EEG data to be identified, and obtain power spectral density feature samples characterized by feature frequency bands and EEG channels that are consistent with the input data format of the cross-dataset EEG emotion recognition model obtained by the above training method.

[0273] The power spectral density feature sample is input into the cross-dataset EEG emotion recognition model. The corresponding sample-level features are extracted by the shared encoder, and the predicted probabilities of multiple emotion categories are obtained by the emotion classifier. The emotion category with the highest predicted probability is taken as the emotion recognition result corresponding to the EEG data to be recognized.

[0274] The emotion recognition result corresponding to the EEG data to be identified is determined based on the predicted probabilities corresponding to the multiple emotion categories;

[0275] During the model inference phase, only the trained shared encoder and sentiment classifier are retained. The predicted sentiment category corresponding to the EEG data to be identified is represented as follows:

[0276] ,

[0277] Where X represents the power spectral density feature corresponding to the EEG data to be identified. This indicates that the shared encoder has completed training. This represents the completed training of the sentiment classifier. This indicates the predicted sentiment category corresponding to the EEG data to be identified.

[0278] The present invention also provides a cross-dataset EEG emotion recognition device, including a processor and a memory; the memory stores a computer program or computer instructions; the processor is used to execute the computer program or computer instructions, and when the computer program or computer instructions are executed, the device implements the steps of the above method.

[0279] The present invention will now be described with reference to a specific embodiment:

[0280] This embodiment verifies the effectiveness of the invention based on three publicly available EEG datasets: SEED, SEED-IV, and DEAP. One EEG dataset is used as the labeled source domain, and another as the target domain, to construct a cross-dataset EEG emotion recognition task. After data preprocessing and emotion label unification, the emotion categories of the three EEG datasets are unified into three categories: negative, neutral, and positive. The EEG features are uniformly represented as power spectral density features consisting of five feature frequency bands and 62 EEG channels.

[0281] The SEED dataset includes 15 participants, each participating in three independent experiments. Each experiment consisted of 15 movie stimulus trials, inducing negative, neutral, and positive emotional states. EEG signals were acquired from 62 EEG channels. This embodiment uses the official SEED dataset preprocessed EEG signals with a sampling rate of 200Hz. Each emotional stimulus trial was divided into 1-second non-overlapping time windows, and the Welch power spectral density features for the delta, theta, alpha, beta, and gamma bands were calculated using the Welch power spectral estimation method, followed by a natural logarithmic transformation. The original labels of the SEED dataset were mapped to the three emotional categories: negative, neutral, and positive.

[0282] The SEED-IV dataset included 15 participants, each of whom participated in 3 experiments. Each experiment consisted of 24 movie stimulus trials. The original emotion categories included sadness, neutrality, fear, and happiness. EEG data were collected from 62 EEG channels. This embodiment uses the smoothed power spectral density features provided by the official SEED-IV dataset and performs a logarithmic transformation on the linear power. The sadness, neutrality, and happiness emotion categories are retained and mapped to negative, neutral, and positive, respectively. Trials corresponding to the fear emotion category are removed.

[0283] The DEAP dataset includes 32 participants, each of whom watched 40 emotionally stimulating videos, each approximately 1 minute long. The official preprocessed data sampling rate is 128Hz, and each emotional stimulus trial includes 32 EEG channels, 8 peripheral physiological signal channels, a 3-second baseline signal, and a 60-second emotional evoked signal. This embodiment only uses 32 of these EEG channels.

[0284] To ensure that the DEAP dataset has the same number of EEG channels as the SEED and SEED-IV datasets, spherical spline interpolation was used to map 32 EEG channels in the DEAP dataset to 62 target electrode locations based on standard electrode positions.

[0285] When preprocessing the DEAP dataset, the baseline signal of the first 3 seconds of each emotional stimulus trial was removed, and the emotional evoked signal of the subsequent 60 seconds was divided into 60 EEG segments according to a 1-second non-overlapping time window. The Welch power spectrum estimation method was used to calculate the power spectral density features corresponding to the five characteristic frequency bands, where the Welch segment length was set to 64 sampling points and adjacent segments overlapped by 32 sampling points.

[0286] Based on the valence scores in the DEAP dataset, three-category sentiment labels were established: negative, neutral, and positive. EEG samples with a valence score less than or equal to 4 corresponded to the negative sentiment category; EEG samples with a valence score greater than 4 and less than 6 corresponded to the neutral sentiment category; and EEG samples with a valence score greater than or equal to 6 corresponded to the positive sentiment category. The same sentiment category label was used for 60 EEG segments within the same emotional stimulus trial.

[0287] After the above data processing, the SEED, SEED-IV, and DEAP EEG datasets were all uniformly converted into power spectral density features consisting of three emotion categories (negative, neutral, and positive), five feature frequency bands, and 62 EEG channels. In each cross-dataset training task, the source domain EEG data and the unlabeled target domain adaptation data were standardized band-wise and channel-wise according to the above standardization method. Data from independent target domain test subjects were not included in the calculation of standardized parameters.

[0288] In the source domain participant quality assessment phase, following the aforementioned source domain participant quality assessment method, the statistical differences of each source domain participant under different feature frequency bands and different emotion categories are calculated using the emotional stimulus trials as the statistical unit, and the corresponding quality score for each source domain participant is obtained. In this embodiment, the selection ratio of high-quality source domain participants is set to 20%. The top 20% of source domain participants are selected according to their quality scores from high to low to construct a high-quality source domain training set, and the shared encoder and emotion classifier are pre-trained using the high-quality source domain training set.

[0289] In this embodiment, the shared encoder adopts a Vision Transformer structure. The five input feature frequency bands are respectively used as five frequency band feature blocks, and each frequency band feature block includes power spectral density features corresponding to 62 EEG channels. The shared encoder includes 6 Transformer coding blocks, the feature embedding dimension is set to 256, the number of multi-head self-attention heads is set to 8, the feedforward network expansion ratio is set to 4, and the Dropout is set to 0.1.

[0290] This embodiment uses the PyTorch deep learning framework for model training, and the training device is a computer equipped with an NVIDIA GeForce RTX 4080 graphics processor.

[0291] During the high-quality source domain pre-training phase, the AdamW optimizer is used to update the parameters of the shared encoder and the sentiment classifier, with the initial learning rate set to 1×10⁻⁶. -4 The weight decay is set to 1×10. -4 The batch size was set to 32, and the maximum number of training epochs was set to 100. The learning rate was adjusted using a cosine annealing strategy, the early stopping patience value was set to 10, and the gradient norm pruning threshold was set to 1.0. The model updates the parameters of the shared encoder and the sentiment classifier by minimizing the first loss.

[0292] After high-quality source domain pre-training, the parameters of the pre-trained shared encoder and sentiment classifier are used to initialize the unsupervised adaptation stage in the target domain. In the unsupervised adaptation stage in the target domain, the model is trained according to the above-mentioned source domain supervised classification, domain adversarial learning, cross-domain hybrid learning, and bidirectional prototype semantic alignment methods, and the parameters of the shared encoder, sentiment classifier, and domain discriminator are updated according to the total loss composed of the first loss, second loss, third loss, and fourth loss.

[0293] In this embodiment, the unsupervised adaptation phase in the target domain is trained for 25 training epochs, using the AdamW optimizer for parameter updates, with the initial learning rate set to 1×10⁻⁶. -4 The weight decay is set to 1×10. -4 The batch size was set to 256, and the learning rate was adjusted using a cosine annealing strategy.

[0294] During the unsupervised adaptation process in the target domain, the gradient reversal coefficient gradually increases from 0.01 to 0.10; the prototype temperature parameter is set to 0.07; the prototype momentum coefficients of both the source domain class prototype and the target domain pseudo-class prototype are set to 0.90; the target domain pseudo-label confidence threshold is set to 0.75; the Beta distribution parameter for cross-domain hybrid use is set to 0.25; the weight corresponding to the third loss is set to 0.80; the weight corresponding to the fourth loss gradually increases from 0.05 to 0.15; the weight corresponding to bidirectional cross-domain prototype alignment is set to 0.20; and the balance coefficient between the sentiment category discrimination target and the domain alignment target is set to 0.70.

[0295] In the cross-dataset evaluation process, one dataset from each of the three EEG datasets—SEED, SEED-IV, and DEAP—was selected as the labeled source domain, and the other dataset was selected as the target domain. A total of six directed cross-dataset EEG emotion recognition tasks were constructed: SEED to SEED-IV, SEED to DEAP, SEED-IV to SEED, SEED-IV to DEAP, DEAP to SEED, and DEAP to SEED-IV.

[0296] For each subject in the target domain, all EEG samples corresponding to that subject are used as independent test data for the current training session. The EEG data of other subjects in the target domain are used only in unlabeled form to constitute the target domain adaptation data. The data of the independent target domain test subjects do not participate in domain adversarial training, cross-domain mixed sample construction, target domain pseudo-label generation, target domain pseudo-class prototype construction, or class prototype updating.

[0297] For the SEED and SEED-IV datasets, a 15-fold target domain leave-one-out-of-subject evaluation was performed; for the DEAP dataset, a 32-fold target domain leave-one-out-of-subject evaluation was performed. For the SEED and SEED-IV datasets with three experimental sessions, each experimental session independently performed cross-dataset training and testing. When SEED or SEED-IV was paired with the DEAP dataset, the three experimental sessions of SEED or SEED-IV were transferred across datasets to the DEAP dataset, and the results corresponding to different experimental sessions were statistically weighted equally.

[0298] After the above training and testing, to verify the cross-dataset emotion recognition capability of this invention across different EEG datasets, six directed cross-dataset EEG emotion recognition tasks were set up between the SEED, SEED-IV, and DEAP datasets. Following the leave-one-out-of-target-domain evaluation method described above, the recognition accuracy for each target domain was calculated, and the target domain participants were statistically weighted equally. The experimental results for each cross-dataset EEG emotion recognition task are shown in Table 1.

[0299] .

[0300] As shown in Table 1, the average recognition accuracy of this invention in six directed cross-dataset EEG emotion recognition tasks is higher than 70%, and the overall average recognition accuracy across the six transfer directions is 77.02%. Specifically, when using SEED-IV as the source domain and SEED as the target domain, an average recognition accuracy of 84.08% is achieved; in the cross-dataset transfer task including the DEAP dataset, the average recognition accuracy ranges from 71.53% to 78.25%. These results demonstrate that even when the source and target domains have different subject groups, EEG acquisition conditions, channel configurations, sampling frequencies, and experimental paradigms, this invention can still effectively recognize the target domain's EEG emotion category.

[0301] To further verify the effects of high-quality source domain pre-training, domain adversarial learning, cross-domain hybrid learning, and bidirectional prototype semantic alignment on the performance of cross-dataset EEG emotion recognition, module ablation experiments were conducted in two transfer directions: SEED to SEED-IV and SEED-IV to SEED. All ablation configurations used the same data partitioning, shared encoder structure, and training settings, only changing the corresponding technical steps. The experimental results are shown in Table 2.

[0302] .

[0303] Table 2 shows that when using only source domain supervised training, the average recognition accuracy for the two transfer directions, SEED to SEED-IV and SEED-IV to SEED, is 61.92% and 66.71%, respectively. After adopting the complete training method of this invention, these accuracy rates are improved to 77.13% and 84.08%, respectively. After removing high-quality source domain pre-training, domain adversarial learning, cross-domain hybrid learning, or bidirectional prototype semantic alignment from the complete training method, the recognition accuracy for both transfer directions decreases to varying degrees. These results indicate that high-quality source domain pre-training, domain adversarial learning, cross-domain hybrid learning, and bidirectional prototype semantic alignment play roles in source domain training data selection, cross-dataset feature distribution alignment, and cross-domain category semantic constraints, respectively, and these techniques are complementary.

[0304] To further verify the effectiveness of selecting high-quality source domain participants based on their quality scores, three methods for selecting source domain pre-training data were set up under the same shared encoder structure and training settings: the first method used all source domain participants; the second method randomly selected 20% of the source domain participants from all participants; and the third method selected the top 20% of the source domain participants according to their quality scores from high to low, as described in this invention. The random selection method was repeated using 10 independent subsets of random source domain participants. The experimental results are shown in Table 3.

[0305] .

[0306] As shown in Table 3, compared with the use of all source domain subjects, the average recognition accuracy of the two migration directions SEED to SEED-IV and SEED-IV to SEED improved by 5.56 percentage points and 6.12 percentage points, respectively, after using the source domain subjects selected from the top 20% of the quality scores as described in this invention.

[0307] Compared to randomly selecting the same proportion of source domain participants, selecting according to the quality score further improved the average recognition accuracy for the two transfer directions by 2.97 percentage points and 3.21 percentage points, respectively. Therefore, the performance improvement resulting from the high-quality source domain pre-training is not solely due to the reduced number of source domain participants in the pre-training, but is related to the use of the quality score to screen source domain participants with high statistical separability of emotion categories.

[0308] The experimental results summarized in Tables 1 to 3 show that the training method described in this invention can achieve cross-dataset EEG emotion recognition across three datasets: SEED, SEED-IV, and DEAP, which have different EEG acquisition conditions and experimental paradigms. Quality scoring and screening based on the statistical differences in emotion categories according to the multi-band EEG power spectral density characteristics of the source domain subjects helps reduce the impact of low-discriminatory source domain EEG data on model initialization. Domain adversarial learning and cross-domain hybrid learning can synergistically reduce the cross-dataset feature distribution shift between the source and target domains. Constructing category prototypes based on real emotion labels from the source domain and high-confidence pseudo-emotion labels from the target domain, and implementing bidirectional prototype semantic alignment, helps maintain semantic consistency between corresponding emotion categories in the source and target domains. These technical aspects work together to improve the accuracy and generalization ability of cross-dataset EEG emotion recognition.

[0309] Under the dataset, labeling unification method, and target domain leave-one-out-of-subjects evaluation protocol adopted in this embodiment, the above results show that the method can perform cross-dataset emotion recognition across EEG datasets with different subject groups, EEG acquisition conditions, number of channels, sampling frequency, and experimental paradigms. The method mitigates the differences in the separability of emotion categories among subject groups in the source domain through quality scoring and screening, and high-quality source domain pre-training; it reduces cross-dataset feature distribution shift through domain adversarial learning and cross-domain hybrid learning; and it reduces cross-domain category semantic shift through bidirectional prototype semantic alignment.

[0310] In the actual emotion recognition process, the EEG data to be recognized from the target data domain that has completed unsupervised adaptation is preprocessed in the same way as the model training and target domain adaptation stages to obtain power spectral density features consisting of five feature frequency bands and 62 EEG channels. The power spectral density features are then input into the trained shared encoder to obtain sample-level features, which are then input into the emotion classifier to obtain the predicted probabilities corresponding to the three emotion categories of negative, neutral, and positive. The emotion category with the highest predicted probability is taken as the emotion recognition result corresponding to the EEG data to be recognized.

[0311] Corresponding to the above method, the present invention also provides a cross-dataset EEG emotion recognition device, including a processor, a memory, and a computer program / instructions stored in the memory. The processor is used to execute the computer program / instructions, and when the computer program / instructions are executed, the device implements the steps of the above method.

[0312] In summary, the cross-dataset EEG emotion recognition model training method and apparatus of the present invention addresses the differences in the separability of emotion categories among source domain subjects by constructing quality scores through multi-band power spectral density statistical analysis and selecting high-quality source domain subjects for pre-training; it addresses cross-dataset feature distribution shift by aligning feature distributions through domain discriminators, gradient inversion layers, and cross-domain hybrid learning; and it addresses cross-domain category semantic shift by constructing source domain category prototypes and target domain pseudo-category prototypes based on the true emotion labels of the source domain and the high-confidence pseudo-labels of the target domain, and implementing bidirectional prototype semantic alignment, thereby improving the accuracy and generalization ability of the cross-dataset EEG emotion recognition model.

[0313] Those skilled in the art will understand that the exemplary components, systems, and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. Whether implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0314] It should be clarified that the present invention is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of the present invention.

[0315] In this invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with or in place of features of other embodiments.

[0316] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations of the embodiments of the present invention are possible. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for training a cross-dataset EEG emotion recognition model, characterized in that: Includes the following steps: S101. Obtain source domain EEG data with emotion category labels and target domain EEG data without emotion category labels. Preprocess the source domain EEG data and the target domain EEG data respectively to obtain source domain power spectral density feature samples and target domain power spectral density feature samples characterized by feature frequency bands and EEG channels. S102. Using the emotional stimulus trials of the source domain subjects as statistical units, perform statistical analysis on the multi-band power spectral density characteristics of each source domain subject under different emotional categories. Determine the quality score corresponding to each source domain subject based on the overall statistical difference between different emotional categories and the statistical difference between categories. Screen source domain subjects based on the quality score. Construct a high-quality source domain training set based on the source domain power spectral density characteristic samples corresponding to the screened source domain subjects. The quality score is used to characterize the statistical separability of the EEG power spectral density characteristics of the corresponding source domain subject between different emotional categories. S103. Obtain an EEG emotion recognition model including a shared encoder and an emotion classifier, and pre-train the shared encoder and the emotion classifier using the high-quality source domain training set. S104. Initialize the target domain unsupervised adaptive model with the parameters of the pre-trained shared encoder and the emotion classifier. Input the source domain power spectral density feature samples and the target domain power spectral density feature samples into the shared encoder to obtain the source domain sample features and the target domain sample features. S105. Perform domain adversarial learning based on the source domain sample features and the target domain sample features, and construct cross-domain hybrid samples based on the source domain power spectral density feature samples and the target domain power spectral density feature samples. Perform sentiment category constraints and data domain constraints based on the cross-domain hybrid samples to reduce the feature distribution differences between the source domain and the target domain. S106. Construct a source domain category prototype based on the source domain sample features and their true sentiment labels, and construct a target domain pseudo category prototype based on the target domain sample features and their pseudo sentiment labels. Perform bidirectional prototype semantic alignment on the source domain sample features and the target domain sample features based on the source domain category prototype and the target domain pseudo category prototype to reduce the semantic difference between the corresponding sentiment categories of the source domain and the target domain. S107. Based on the source domain supervised classification objective, domain adversarial learning objective, cross-domain hybrid learning objective and bidirectional prototype semantic alignment objective, the target domain unsupervised adaptation model is jointly trained, and the trained shared encoder and the emotion classifier are combined to obtain a cross-dataset EEG emotion recognition model.

2. The method for training a cross-dataset EEG emotion recognition model according to claim 1, characterized in that: The determination of the quality score for each source domain participant based on the overall statistical difference between different emotion categories and the statistical difference between categories includes: For each emotional stimulus trial for each subject in each source domain, the power spectral density features of multiple EEG segments contained in the emotional stimulus trial on multiple EEG channels are aggregated to obtain the trial-level features corresponding to each feature frequency band, expressed as: , in, Indicates the first The trial-level feature corresponding to the b-th feature band of the r-th emotional stimulus trial for each source domain subject; Indicates the first The first source domain participant The number of EEG segments in each emotional stimulus test; Indicates the number of brainwave channels; Indicates the first The first source domain participant The power spectral density characteristics of the m-th EEG segment in the c-th EEG channel and the b-th characteristic frequency band of an emotional stimulus trial; For each source domain participant and each feature frequency band, a one-way ANOVA was performed on the sub-features belonging to different emotion categories to obtain the significance probability characterizing the overall statistical difference between different emotion categories. Perform a Welch heteroscedasticity t-test on the sub-features corresponding to any two different sentiment categories to obtain the significance probability characterizing the statistical difference between the two corresponding sentiment categories. ; The significance score is determined based on the significance probabilities obtained from the one-way ANOVA and Welch heteroscedasticity t-test. The significance score function is as follows: ; in, This represents the significance probability obtained from any of the aforementioned statistical tests; Indicates an indicator function; Indicates the first significance threshold; This represents the second significance threshold, and ; This represents the additional weight corresponding to a significance probability lower than the second significance threshold; Let the set of all pairs of different emotion categories be: ; Where K represents the number of emotion categories; The significance scores of the overall statistical differences corresponding to each feature frequency band and the significance scores of the statistical differences between each emotion category and the corresponding categories are aggregated to obtain the quality scores of the subjects in the corresponding source domain; Quality score corresponding to each source domain participant The formula for calculation is: ; in, Indicates the first The quality score corresponding to each source domain subject; B represents the number of feature frequency bands; Indicates the first The significance probability obtained by performing a one-way ANOVA on the b-th characteristic frequency band of each source domain subject; Indicates the first For each source domain participant, on the b-th feature frequency band, the k-th emotion category is related to the... The significance probability obtained by performing a Welch heteroscedasticity t-test between the sentiment categories; This represents the set of all pairs of different emotion categories; The subjects from multiple source domains are ranked according to the quality scores, and high-quality source domain subjects are selected from the multiple source domain subjects according to a preset selection ratio to construct the high-quality source domain training set.

3. The method for training a cross-dataset EEG emotion recognition model according to claim 1, characterized in that: The shared encoder adopts a Transformer encoding structure, and its working process includes: The input power spectral density feature samples are divided into multiple frequency band feature blocks according to the feature frequency bands. The EEG channel features contained in each frequency band feature block are linearly mapped to obtain the corresponding frequency band feature labels, as expressed by: , in, This represents the EEG channel characteristics corresponding to the b-th characteristic frequency band; This represents the frequency band feature marker corresponding to the b-th feature frequency band; Represents the linear mapping weight matrix; Indicates the bias term; Multiple frequency band feature labels and location codes are combined and input into the Transformer encoding structure, and sample-level features are obtained through pooling. , in, The shared encoder is represented by X; X represents the power spectral density feature corresponding to the input EEG data; z represents the sample-level feature. The sample-level features are input into the sentiment classifier to obtain the category prediction logical value corresponding to each sentiment category. The category prediction logical value is then subjected to Softmax normalization to obtain the prediction probability corresponding to each sentiment category, expressed as: , , in, denoted as the sentiment classifier; a represents the category prediction logical value output by the sentiment classifier; p represents the prediction probability corresponding to each sentiment category. A first loss is constructed based on the predicted probability of sentiment category corresponding to the source domain power spectral density feature samples and the true sentiment labels of the source domain. The first loss is the source domain supervised classification loss, and the parameters of the shared encoder and the sentiment classifier are updated based on the first loss during the pre-training phase. The formula for calculating the first loss is: , in, Indicates the true emotional tags of the source domain; CE represents the probability of predicting the sentiment category from the source domain; CE represents the cross-entropy loss function.

4. The method for training a cross-dataset EEG emotion recognition model according to claim 3, characterized in that: In the unsupervised adaptation stage of the target domain, a domain discriminator is obtained, and a gradient inversion layer is set between the shared encoder and the domain discriminator. During forward propagation, the gradient inversion layer identically transmits the sample-level features output by the shared encoder to the domain discriminator, and during backpropagation, it reverses the gradients returned from the domain discriminator to the shared encoder according to a preset gradient inversion coefficient. The gradient calculation formula is: , Wherein, G represents the gradient returned by the domain discriminator to the shared encoder; This represents the gradient after processing by the gradient inversion layer; Indicates the gradient reversal coefficient; The source domain sample features and target domain sample features are input into the domain discriminator. The data source label corresponding to the source domain is set to 0, and the data source label corresponding to the target domain is set to 1. The original domain discrimination loss is constructed based on the data source prediction result of the domain discriminator and the corresponding data source label. The calculation formula is as follows: , in, This represents the original domain discrimination loss; The domain discriminant represents the predicted probability that the input sample comes from the target domain. This represents the sample-level feature corresponding to the i-th source domain sample; This represents the sample-level feature corresponding to the j-th target domain sample; and These represent the number of source domain samples and the number of target domain samples in the current training batch, respectively.

5. The method for training a cross-dataset EEG emotion recognition model according to claim 4, characterized in that: The construction of cross-domain hybrid samples based on source domain EEG samples and target domain EEG samples includes: The target domain soft pseudo-label probability vector is obtained based on the output of the emotion classifier on the target domain EEG power spectral density feature samples. Obtain the mixing coefficient from the preset Beta probability distribution. Based on the mixing coefficients, randomly paired source domain power spectral density feature samples and target domain power spectral density feature samples Perform linear mixing to obtain cross-domain mixed samples. The expression is: , Using the same mixing coefficients as the cross-domain mixed samples, a linear mixture is performed on the true sentiment labels of the source domain power spectral density feature samples and the soft pseudo labels of the target domain power spectral density feature samples to obtain the mixed sentiment labels corresponding to the cross-domain mixed samples. The expression is as follows: , in, Indicates by the first The source domain sample and the first Hybrid sentiment labels corresponding to cross-domain hybrid samples composed of target domain samples; Indicates the first The true sentiment category labels corresponding to each source domain sample; This represents the K-dimensional one-hot encoded vector corresponding to the true emotion category label; Indicates the first A K-dimensional soft pseudo-label probability vector corresponding to each target domain sample; K represents the number of sentiment categories. The target domain soft pseudo-label is determined based on the output of the sentiment classifier for the target domain samples, and is expressed as follows: , in, This indicates that the sentiment classifier is for the first... The category prediction logic value output by each target domain sample; T represents the temperature coefficient, used to adjust the smoothness of the soft pseudo-label probability distribution. The cross-domain mixed sample is input into the shared encoder and the sentiment classifier to obtain the predicted sentiment category probability corresponding to the cross-domain mixed sample: , in, This refers to the shared encoder; This refers to the sentiment classifier; This represents the predicted probability of the sentiment category corresponding to the cross-domain mixed sample; A third loss is constructed based on the predicted probability of the sentiment category and the mixed sentiment label. The calculation formula is: , in, This indicates the number of cross-domain mixed samples in the current training batch; Represents a cross-domain mixed sample index set; This represents the component of the mixed sentiment label in the k-th sentiment category; This represents the predicted probability that the cross-domain mixed sample belongs to the k-th sentiment category; Based on the mixing ratio of the target domain component in the cross-domain mixed sample, determine the continuous data source label corresponding to the cross-domain mixed sample: , In this context, the data source label for the source domain is 0, and the data source label for the target domain is 1. This indicates the continuous data source label corresponding to the cross-domain mixed sample; The cross-domain mixed samples are input into the shared encoder and the domain discriminator to obtain the corresponding data source prediction probabilities. A mixed domain discrimination loss is then constructed based on the data source prediction probabilities and the continuous data source labels. ,in, This represents the sample-level features corresponding to the cross-domain mixed samples; This refers to the domain discriminator; Indicates the discriminative loss in the mixed domain; A second loss is constructed based on the original domain discrimination loss and the hybrid domain discrimination loss. The calculation formula is: , in, This represents the original domain discrimination loss constructed in claim 4; This represents the discriminative loss of the hybrid domain.

6. The method for training a cross-dataset EEG emotion recognition model according to claim 5, characterized in that: The process of constructing a source domain category prototype based on source domain sample features and their true sentiment labels, and constructing a target domain pseudo-category prototype based on target domain sample features and their pseudo-sentiment labels, includes: The source domain sample features and target domain sample features output by the shared encoder are normalized. Based on the true sentiment labels of the source domain, the normalized features of the source domain samples are divided into corresponding sentiment categories. The features of source domain samples belonging to the same sentiment category are then averaged and normalized to obtain the source domain category prototypes for each sentiment category. The expression is as follows: , in, This represents the source domain category prototype corresponding to the k-th sentiment category; This represents the normalized source domain sample features; Based on the predicted probability of the target domain sentiment category output by the sentiment classifier, determine the pseudo-sentiment label corresponding to each target domain sample. and prediction confidence ; , , Filter the target domain power spectral density feature samples whose predicted confidence meets the preset confidence conditions, and classify the filtered target domain sample features into the corresponding sentiment categories according to the corresponding pseudo-sentiment labels; Based on the predicted confidence level, the target domain sample features belonging to the same sentiment category are subjected to confidence-weighted averaging and normalization to obtain the target domain pseudo-category prototypes corresponding to each sentiment category, expressed as: , in, This represents the set of high-confidence target domain EEG samples corresponding to the k-th emotion category; This represents the target domain pseudo-class prototype corresponding to the k-th sentiment category; This indicates a normalization operation.

7. The method for training a cross-dataset EEG emotion recognition model according to claim 6, characterized in that: It also includes using an exponential moving average method to update the source domain category prototype and the target domain pseudo-category prototype for each sentiment category based on historical category prototypes and the category prototypes corresponding to the current training batch, respectively. The calculation formula is as follows: , in, Represents data field The category prototype corresponding to the k-th sentiment category; This represents the category prototype corresponding to the k-th sentiment category in the current training batch; Indicates the prototype momentum coefficient; Construct the intra-domain prototype loss based on the similarity between the source domain sample features and the prototypes of each source domain category. The intra-domain prototype loss is constructed based on the similarity between the target domain sample features that meet the pre-set confidence conditions and the pseudo-class prototypes of each target domain. Construct a cross-domain prototype alignment loss from the source domain to the target domain based on the similarity between the features of the source domain samples and the pseudo-class prototypes of each target domain. Based on the similarity between the target domain sample features that satisfy the pre-set confidence conditions and the prototypes of each source domain category, a cross-domain prototype alignment loss from the target domain to the source domain is constructed. Based on the prototype loss within the source domain. The prototype loss within the target domain The cross-domain prototype alignment loss from the source domain to the target domain and the cross-domain prototype alignment loss from the target domain to the source domain. Constructing the fourth loss The calculation formula is: , Where β represents the weight corresponding to the prototype loss within the target domain; γ represents the weight corresponding to the bidirectional cross-domain prototype alignment loss. When there are no valid samples in the current training batch for constructing the prototype of a certain sentiment category, the historical prototype of the corresponding sentiment category remains unchanged.

8. The method for training a cross-dataset EEG emotion recognition model according to claim 7, characterized in that: It also includes a high-quality source domain pre-training phase and a target domain unsupervised adaptation phase; In the high-quality source domain pre-training stage, the parameters of the shared encoder and the sentiment classifier are updated according to the source domain supervised classification loss using the high-quality source domain training set, to obtain the pre-trained shared encoder and sentiment classifier. In the unsupervised adaptation stage of the target domain, the parameters of the shared encoder and sentiment classifier obtained in the high-quality source domain pre-training stage are initialized, and source domain supervised classification, domain adversarial learning, cross-domain hybrid learning, and bidirectional prototype semantic alignment are jointly performed based on labeled source domain power spectral density feature samples and unlabeled target domain power spectral density feature samples. The total loss L of the unsupervised adaptation stage of the target domain is constructed based on a weighted combination of the first loss, the second loss, the third loss, and the fourth loss, and the parameters of the shared encoder, the sentiment classifier, and the domain discriminator are updated based on the total loss L. The formula for calculating the total loss L is: , Where η represents the balance coefficient between the sentiment category discrimination objective and the domain alignment objective; This represents the weight corresponding to the third loss; This represents the weight corresponding to the fourth loss; The weight corresponding to the fourth loss gradually increases from a preset initial weight to a preset maximum weight as the training progress of the unsupervised adaptation phase of the target domain proceeds. The calculation formula is as follows: , in, This indicates the training progress of unsupervised adaptation in the target domain; This represents the initial weights corresponding to the fourth loss; This represents the maximum weight corresponding to the fourth loss.

9. A cross-dataset EEG emotion recognition method, characterized in that, Includes the following steps: Obtain the EEG data to be identified in the target data domain, preprocess the EEG data to be identified, and obtain power spectral density feature samples characterized by feature frequency bands and EEG channels that are consistent with the input data format of the cross-dataset EEG emotion recognition model obtained by the training method of any one of claims 1 to 8. The power spectral density feature samples are input into the cross-dataset EEG emotion recognition model, the corresponding sample-level features are extracted by the shared encoder, and the predicted probabilities of multiple emotion categories are obtained by the emotion classifier. The emotion recognition result corresponding to the EEG data to be identified is determined based on the predicted probabilities corresponding to the multiple emotion categories.

10. A cross-dataset EEG emotion recognition device, characterized in that, The device includes a processor and a memory; the memory stores a computer program or computer instructions; the processor is used to execute the computer program or computer instructions, and when the computer program or computer instructions are executed, the device implements the steps of the method as described in any one of claims 1 to 9.