Pain assessment model, method and system based on electroencephalogram signals and contrastive learning
By combining a lightweight channel attention network and a contrastive learning interaction layer, the problems of individual differences and data dependence in existing EEG signal pain assessment technologies are solved, achieving high-precision chronic pain assessment across subjects, which is suitable for biomedical health monitoring systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG UNIV OF TECH
- Filing Date
- 2026-02-06
- Publication Date
- 2026-06-02
AI Technical Summary
Existing EEG pain assessment techniques rely on supervised learning methods, require a large amount of high-quality labeled data, have poor generalization ability across subject scenarios, significant individual differences, serious false negative sample problems, insufficient time dynamic dependence, low signal-to-noise ratio, and difficulty in accurately capturing the temporal dynamic changes of chronic pain.
A cascaded lightweight channel attention network and a contrastive learning interaction layer are employed, including a hierarchical soft contrast module, a temporal dynamic contrast module, and a debiased clustering contrast module. Through self-supervised pre-training and supervised fine-tuning, the latent representations of EEG signals are extracted using unlabeled data, overcoming individual differences and capturing the temporal dynamic changes of pain.
It achieves high-precision chronic pain assessment across subjects, reduces reliance on labeled data, alleviates the problem of spurious negative samples, and improves the generalization ability and accuracy of the assessment model, making it suitable for use in biomedical health monitoring systems.
Smart Images

Figure CN121647613B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electroencephalogram (EEG) signal assessment technology, and in particular to pain assessment models, methods and systems based on EEG signals and contrastive learning. Background Technology
[0002] Chronic pain is a complex physiological and psychological state, and its objective assessment is crucial for clinical diagnosis and treatment. Traditional pain assessment mainly relies on patients' subjective self-reports (such as the visual analog scale), which suffers from problems such as high subjectivity and difficulty in continuous monitoring. In recent years, objective assessment techniques based on electroencephalogram (EEG) signals have gradually become a research hotspot.
[0003] Existing EEG pain assessment techniques primarily employ supervised learning-based deep learning methods, such as using convolutional neural networks (CNNs), recurrent neural networks (RNNs), or Transformers and their variants to extract features from EEG signals. However, supervised learning heavily relies on large amounts of high-quality labeled data, and acquiring expert-labeled pain EEG data is costly and time-consuming.
[0004] To reduce reliance on labeled data, self-supervised contrastive learning (SSCL) has been introduced into this field. These methods learn general representations from unlabeled data by designing pre-training tasks. While contrastive learning frameworks such as SimCLR and TS-TCC have achieved success in image and general time-series processing, their direct application in cross-subject chronic pain assessment tasks still faces significant challenges.
[0005] First, significant individual differences and poor generalization ability: Significant individual differences exist in pain perception and EEG response patterns among different subjects, leading to a substantial decrease in the model's generalization performance across different subject scenarios. Second, the problem of false negatives: Traditional contrastive learning typically treats different EEG signal segments as independent negative sample pairs. However, chronic pain is a continuous process, and different segments may correspond to the same pain state (semantic similarity). Existing methods forcibly separate these semantically similar samples, disrupting the underlying semantic consistency and causing bias in representation learning. Third, insufficient modeling of temporal dynamic dependencies: Existing contrastive strategies focus primarily on local window features, ignoring the dynamic dependencies of pain states over time, making it difficult to capture long-term pain-related patterns in EEG signals. Fourth, low signal-to-noise ratio: Chronic pain EEG signals often contain numerous artifacts, and existing methods lack robustness in feature extraction under low signal-to-noise ratio conditions.
[0006] Therefore, there is an urgent need for a cross-subject assessment method that can effectively utilize unlabeled data, overcome individual differences, and accurately capture the dynamic changes in pain over time. Summary of the Invention
[0007] Therefore, it is necessary to provide a cross-subject chronic pain assessment model, method, and system that can effectively utilize unlabeled data and overcome individual differences, addressing the aforementioned technical problems. This system is characterized by its ability to accurately capture the dynamic changes in pain over time.
[0008] To achieve the above-mentioned objectives of this invention, the technical solution adopted is as follows:
[0009] A pain assessment model based on EEG signals and contrastive learning includes a cascaded lightweight channel attention network and a contrastive learning interaction layer.
[0010] The lightweight channel attention network serves as the backbone network, used to receive preprocessed standardized EEG signal segments and output the latent representation vector of the EEG signal.
[0011] The contrastive learning interaction layer is used for pre-training and includes a hierarchical soft contrast module, a temporal dynamic contrast module, and a debiased clustering contrast module connected in parallel to the output of the lightweight channel attention network. The hierarchical soft contrast module receives EEG signal segments from different views and their time indices as input, and outputs a hierarchical soft contrast loss that includes the geometric distance between segments and the time span difference within segments. The temporal dynamic contrast module receives the concatenated vector of the latent representation vector and the context label as input, and outputs a temporal dynamic contrast loss that predicts the future based on the context. The debiased clustering contrast module receives the nonlinear projection of the latent representation vector as input, and outputs a debiased clustering contrast loss that combines pseudo-labels and semantic similarity correction. The evaluation model obtains pre-trained weights based on the loss functions of the above three modules.
[0012] The lightweight channel attention network adjusts parameters based on the pre-trained weights and outputs pain assessment results through a classifier.
[0013] Preferably, the lightweight channel attention network consists of multiple cascaded convolutional blocks; the processing flow of each convolutional block is as follows: first, the input features are extracted at multiple time scales through a one-dimensional convolutional layer to generate an intermediate feature vector; then, the average influence of each channel on other channels over the entire time dimension is calculated through a channel attention mechanism to generate channel importance weights; finally, the channel importance weights are applied to the intermediate feature vectors and processed by a reversible instance normalization layer before output.
[0014] A method for assessing chronic pain, based on the aforementioned pain assessment model, includes the following steps:
[0015] The subject's electroencephalogram (EEG) signal data was acquired and segmented into several EEG signal segments;
[0016] The chronic pain assessment model is self-supervised pre-trained using unlabeled data through a contrastive learning interaction layer. The lightweight channel attention network is used to extract latent representations of EEG signal segments. The hierarchical soft contrast module calculates the hierarchical soft contrast loss based on the geometric distance between EEG signal segments and the temporal span difference within segments. The temporal dynamic contrast module predicts the representation of future moments based on the contextual information of EEG signal segments and calculates the temporal dynamic contrast loss. The bias-reduced clustering contrast module clusters EEG signal segments to generate pseudo-labels and combines semantic similarity to correct the positive and negative sample sets, calculating the bias-reduced clustering contrast loss. The parameters of the assessment model are updated based on the weighted sum of the above three losses.
[0017] The pre-trained evaluation model is fine-tuned by using EEG signal data with pain annotations through a classification output layer.
[0018] It receives EEG signal fragments from the test subject, inputs a finely tuned assessment model, and outputs pain assessment results.
[0019] Preferably, the hierarchical soft contrast module calculates the hierarchical soft contrast loss in two dimensions: inter-segment soft contrast and intra-segment soft contrast. Specifically, the inter-segment soft contrast involves using the Dynamic Time Warping (DTW) algorithm to pre-calculate the distance between different EEG signal segments, defining soft assignment weights between segments based on the distance, and calculating the loss based on these soft assignment weights to maintain the representational similarity of adjacent EEG signal segments in the data space. Specifically, the intra-segment soft contrast involves defining time-level soft assignment weights based on the time difference between different time points within the same EEG signal segment, and calculating the loss based on these soft assignment weights to model the time dependence of pain evolution.
[0020] Furthermore, the time dynamic contrast module includes a Transformer encoder and a linear predictor, and the specific steps for calculating the time dynamic contrast loss include:
[0021] The input EEG signal segments were subjected to weak enhancement and strong enhancement processing, respectively;
[0022] Input the EEG signal segments under weak enhancement view into the evaluation model and extract the corresponding contextual representation vectors;
[0023] Using the linear predictor, the representation vector of the strongly enhanced view is predicted within a future preset time window based on the context representation vector of the weakly enhanced view;
[0024] The similarity between the predicted representation vector and the true future representation vector in the strongly augmented view is maximized by comparing the loss function.
[0025] Furthermore, the specific steps for calculating the partial clustering comparison loss by the partial clustering comparison module include:
[0026] Nonlinear projection is performed on the potential representation of the current batch of EEG signal segments;
[0027] The projected representations are clustered using a spectral clustering algorithm, and a pseudo-label is assigned to each EEG signal segment. A positive sample set is constructed, which consists of the following three parts:
[0028] Different enhanced views of the same EEG signal segment, EEG signal segments with the same pseudo-labels, and EEG signal segments with different pseudo-labels but semantic similarity higher than a preset threshold;
[0029] In the calculation of contrastive learning loss, the distance between the current EEG signal segment and all samples in the positive sample set is reduced, while the distance between it and the negative sample set is increased.
[0030] Furthermore, when constructing the positive sample set, the debiased clustering comparison module calculates the semantic similarity between different EEG signal segments based on the soft assignment weights calculated in the hierarchical soft comparison module; if the soft assignment weights between two EEG signal segments indicate that their similarity is higher than the preset threshold, then these two segments are considered positive samples, even if their pseudo-labels are different.
[0031] Furthermore, the biased clustering comparison module introduces a weight-based negative sample suppression mechanism when calculating the loss; specifically, it calculates the average similarity between the current EEG signal segment and all its negative samples, and generates a weight coefficient based on the average similarity; the weight coefficient is used to adjust the contribution of the current EEG signal segment in the total loss function, so as to reduce the impact of highly similar negative samples on model training.
[0032] Furthermore, the total loss function The construction method is as follows:
[0033]
[0034] in, The hierarchical soft contrast loss is a weighted sum of inter-segment soft contrast loss and intra-segment soft contrast loss. and These represent the time-dynamic contrast loss when using a weak augmented view to predict a strong augmented view, and when using a strong augmented view to predict a weak augmented view, respectively. To remove biased clustering contrast loss; and These are preset hyperparameters used to balance the contributions of each module.
[0035] A chronic pain assessment system, based on the aforementioned pain assessment model, includes:
[0036] The data acquisition module is used to acquire the subject's electroencephalogram (EEG) signal data and segment it into several EEG signal segments;
[0037] The model building module is used to build an evaluation model, which includes a lightweight channel attention network for feature extraction, a hierarchical soft contrast module, a temporal dynamic contrast module, and a debiased clustering contrast module for self-supervised training.
[0038] The model training module is configured to extract latent representations of EEG signal segments using the lightweight channel attention network; calculate the hierarchical soft contrast loss based on the geometric distance between EEG signal segments and the temporal span difference within segments using the hierarchical soft contrast module; calculate the temporal dynamic contrast loss based on the contextual information of EEG signal segments to predict representations of future moments using the temporal dynamic contrast module; and calculate the biased clustering contrast loss by clustering EEG signal segments to generate pseudo-labels and correcting the positive and negative sample sets based on semantic similarity using the biased clustering contrast module. The parameters of the evaluation model are updated based on the weighted sum of the above three losses.
[0039] The assessment inference module is configured to fine-tune the pre-trained assessment model using EEG signal data labeled with pain, and output pain assessment results.
[0040] The beneficial effects of this invention are as follows:
[0041] This invention provides a cross-subject chronic pain assessment model based on debiased soft contrastive learning. It includes a lightweight channel attention network for feature extraction, and hierarchical soft contrastive modules, temporal dynamic contrastive modules, and debiased clustering contrastive modules for self-supervised training. This overcomes the technical problems of insufficient model generalization ability and limited assessment accuracy in existing objective chronic pain assessment methods due to significant individual differences, low signal-to-noise ratio of EEG signals, and scarcity of labeled data. This invention extracts invariant and highly discriminative feature representations from unlabeled EEG data through self-supervised debiased soft contrastive learning, thereby achieving high-precision cross-subject assessment of chronic pain type and intensity, providing an objective and reliable pain assessment solution for biomedical health monitoring systems. Attached Figure Description
[0042] Figure 1 This is a schematic diagram of the overall architecture of the pain assessment model based on EEG signals and contrastive learning according to one embodiment of the present invention;
[0043] Figure 2 This is a graph showing the ROC and AUC curves of the present invention and other methods in a pain type assessment task in one embodiment;
[0044] Figure 3 This is a comparison chart of ROC and AUC between the present invention and other methods in a pain intensity assessment task in one embodiment;
[0045] Figure 4 This is a flowchart illustrating the pain assessment method based on electroencephalogram (EEG) signals and contrastive learning according to one embodiment of the present invention. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0047] The specific implementation methods will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0048] Example 1
[0049] The overall framework of the pain assessment model based on electroencephalogram signals and contrastive learning of this invention is as follows: Figure 1 As shown, this embodiment proposes a cross-subject chronic pain assessment method, DSCL4CPA, based on debiased soft contrastive learning. The proposed assessment model mainly comprises a lightweight channel attention network (LCANet) as its backbone, and three interactively coupled contrastive learning modules: Hierarchical Soft Contrast Module (HSCM), Temporal Dynamic Contrast Module (TDCM), and Debiased Clustering Contrast Module (DCCM). The training process of this method consists of two stages: the first stage is self-supervised pre-training, where the parameters of LCANet are optimized using the three contrastive learning modules on unlabeled EEG signal data; the second stage is supervised fine-tuning, where the pre-trained LCANet is fine-tuned using a small amount of labeled data and connected to a classifier for chronic pain type identification or intensity assessment.
[0050] In this embodiment, the acquisition and preprocessing of EEG signal data utilizes the CBPFM dataset, which includes 20 patients with chronic back pain, 20 patients with fibromyalgia, and 20 healthy controls. This dataset contains labels for pain type and pain intensity. To obtain standardized model input, the following preprocessing operations were performed on the raw EEG signals: Downsampling: The sampling rate of the EEG signals from all subjects was uniformly reduced to 250 Hz. Filtering and denoising: A 1-100 Hz bandpass filter was used to filter out low-frequency drift and high-frequency noise, and a 50 Hz notch filter was used to remove power frequency interference. Artifact removal and rereference: Artifacts such as electrooculography (EOG) and electromyography (EMG) were removed. After manual inspection and removal of undesirable segments, a whole-brain average rereference was used. Data segmentation: Continuous EEG signals were segmented into non-overlapping segments (Epochs) of 2 seconds each, which served as input samples for the model to achieve pain type and pain intensity classification.
[0051] In this embodiment, as Figure 1 As shown, the lightweight channel attention network is designed with three cascaded 1D convolutional blocks and a channel attention mechanism. In each convolutional module, multi-timescale feature extraction is performed on the input sample (EEG signal fragments) to generate a representation vector. (Cb is the number of channels, Lb is the time length), and then the channel attention mechanism is used for analysis and evaluation. The average influence of each channel on all other channels over the entire time dimension is used to assign differentiated importance weights to each EEG signal channel. To mitigate the distribution bias between training and testing EEG signals, this invention employs Reversible Instance Normalization (RevIN) in the channel attention mechanism. Furthermore, during the supervised fine-tuning phase, labeled EEG signal data is used as input samples, and a simple linear classifier is ultimately used to identify the pain type and intensity.
[0052] In the self-supervised pre-training phase, unlabeled EEG signal fragments are input. First, two views are generated through data augmentation (including strong and weak augmentation). and , and input LCANet to extract features.
[0053] like Figure 1 As shown in (a), the Hierarchical Soft Contrast Module (HSCM) is designed to address the problem of hard labels destroying semantic similarity by providing soft contrast in both inter-segment and intra-segment dimensions.
[0054] Inter-segment soft contrast: The distance between EEG signal segments is pre-calculated using the Dynamic Time Warping (DTW) algorithm, defining two segments... and Soft allocation weights between Define the softmax probability of relative similarity. :
[0055]
[0056] Then the soft contrast loss between segments The calculation formula is:
[0057]
[0058] in, Where is the batch size, and the total number of samples is (Includes enhanced view).
[0059] Intra-segment soft contrast: defining time points within the same segment by utilizing the differences between time points. and Soft allocation weights between Define the relative similarity probability between time points. :
[0060]
[0061] Intra-fragment soft contrast loss The calculation formula is:
[0062]
[0063] in, The time length is a characteristic.
[0064] Total HSCM losses:
[0065]
[0066] In this embodiment, hyperparameters Set it to 0.5.
[0067] The Time Dynamic Comparison (TDCM) module utilizes the Transformer to capture temporal evolution features. It then applies the features output by LCANet. With learnable context label vectors Concatenate the input Transformer. Extract the contextual representation from the output. (Weakly enhanced view) and (Enhanced view).
[0068] like Figure 1As shown in (b), the Temporal Dynamic Contrast Module (TDCM) proposed in this invention mines causal relationships and temporal dynamic patterns in discriminative feature representations from the output representation of the HSCM by combining the Transformer with contrastive loss. Specifically, the Transformer combines efficiency and flexibility in capturing dynamic correlations across time scales, and its core components include a multi-head attention mechanism and a multilayer perceptron. The multilayer perceptron uses two fully connected layers for feature mapping, introduces nonlinear transformations between layers through the ReLU nonlinear activation function, and employs Dropout to prevent overfitting. To ensure training stability, pre-normalization and residual connection structures are used to alleviate gradient anomaly problems in deep Transformer networks.
[0069] Given the latent representation vector of LCANet output ,make (1 <k K), Where C4 and L4 represent the feature dimension and time length, respectively, and K represents a specific time point in the EEG segment's time dimension. To capture the global context representation, the learnable context label vector is... The input vector is embedded in the Transformer, where H represents the hidden dimension of the Transformer. Specifically, it is first passed through a linear projector. The input representation vector at time point [0, t] Mapping to the hidden space yields Then, through Transformer... and The concatenated input is used for feature extraction to form a contextual representation vector. .
[0070] Therefore, in order to learn a more robust temporal dynamic representation of pain, weakly enhanced contextual representation vectors are generated. Used to predict strong enhancement The representation at future time points [t + 1, t + k], and vice versa. In this process, a contrastive loss function is used to maximize the similarity between the predicted future representation and the actual future representation within the same EEG signal segment, while minimizing the similarity between the predicted future representation and the actual future representation of other EEG signal segments. Accordingly, the loss function of TDCM... and Represented as:
[0071]
[0072] Wherein, linear prediction function Will and Map back to or In a space of the same dimension.
[0073] Due to the lack of prior label information, existing self-supervised contrastive learning strategies typically suffer from the following limitations when constructing discriminative positive and negative sample pairs:
[0074] The NT-Xent loss-based approach treats each EEG signal segment as an independent category, ignoring the correlation between segments. Furthermore, this strategy hinders the clustering of EEG signal segments of consistent categories in the contrastive representation space.
[0075] Category-aware semi-supervised learning strategies rely on pre-generated pseudo-labels and require a multi-stage training process, resulting in high computational overhead.
[0076] To address the aforementioned limitations, this invention designs a partial clustering comparison module (DCCM), such as... Figure 1 As shown in (c), the accuracy and diversity of positive and negative sample selection are improved during the contrastive learning process, while weight suppression is applied to highly similar negative samples to mitigate the impact of false negative samples on model pre-training. Specifically, DCCM first uses a nonlinear projector to process the context representation vector... Perform nonlinear transformation to obtain .like Figure 1 As shown in (g), the projector consists of two fully connected layers with batch normalization between them, and introduces nonlinearity through the ReLU activation function. Subsequently, a positive sample mask is constructed based on three key factors, from which a negative sample mask is derived: First, two enhanced views of the same EEG signal segment are considered strongly consistent positive sample pairs. Second, based on the soft-label similarity matrix... The algorithm uses spectral clustering to classify EEG signal segments within the current batch into pseudo-classes. EEG signal segments within the same pseudo-class are considered to have potential semantic consistency and can be treated as positive sample pairs. During the pre-training phase, spectral clustering is used to generate pseudo-labels for the EEG signal segments of the current batch. Used to distinguish between positive and negative samples, the calculation formula is:
[0077]
[0078] set up Let E be a symmetric matrix, where E represents the number of fragments in the current batch. Represents the identity matrix, elements This represents the similarity weight between the i-th and j-th EEG signal segments in the current batch. Naturally, and The pseudo-labels for the two enhanced views are defined as follows: ,in , This represents the number of clusters. Then, based on... When the semantic similarity of EEG signal segments exceeds a given threshold, they are still considered positive sample pairs even if the pseudo-labels are different. Finally, the three sets of positive sample masks are merged to form a positive sample set. By excluding positive samples, self-samples, and homologous augmentation sample pairs, a negative sample set can be derived. .
[0079] Furthermore, to mitigate the impact of semantically similar negative samples (such as categories with similar pain intensity levels), this invention introduces a weight-based approach. coefficient This adaptively adjusts the contribution of each EEG signal segment to the loss function. Specifically, the similarity weight matrix S is expanded to... And calculate the average similarity between the i-th EEG signal segment and its negative sample. Thus, the weighting coefficients are calculated. Therefore, the loss of DCCM Defined as:
[0080]
[0081] in, This represents the index set of all augmented samples in the current batch. The representative represents the current sample. The representation of positive samples. The representation of the comparison sample. For temperature parameters, and This represents an index set containing all positive and negative samples.
[0082] In summary, the overall self-supervised contrast loss is a weighted combination of hierarchical soft contrast loss, temporal dynamic contrast loss, and debiased clustering contrast loss.
[0083]
[0084] Among them, λ1 and λ2 are preset non-negative hyperparameters, which are determined based on experience and experimental debugging, and are used to adjust the weight ratio of each loss term in the overall loss function.
[0085] In this embodiment, the self-supervised pre-training step is specifically as follows:
[0086] Input unlabeled EEG signal data and generate two views of combined correlation and dissimilarity through data augmentation (strong and weak enhancement);
[0087] The enhanced EEG signal data is input into LCANet to extract features;
[0088] Calculate the loss of the three contrastive learning modules, and finally calculate the total self-supervised contrastive loss;
[0089] Update network parameters using the Adam optimizer with a learning rate of 3×10. 4 The weight decays to 3×10 4 The number of training rounds is 300.
[0090] The specific steps for monitoring and fine-tuning are as follows:
[0091] Load the parameters of the pre-trained model;
[0092] Supervised fine-tuning was performed using labeled data at different proportions (e.g., 1%, 5%, 10%, 50%).
[0093] A fully connected layer is added after LCANet, with the output dimension being the number of classes, and the cross-entropy loss function is used.
[0094] The pre-trained model parameters were optimized using the Adam optimizer with a learning rate of 3×10⁻⁶. 4 The weight decays to 3×10 4 The number of training rounds is 100.
[0095] In this embodiment, to ensure a fair comparison of all methods, a leave-one-subject cross-validation training strategy was employed in all experiments on the CBPFM dataset. Since each chronic pain patient in the dataset corresponds to only one pain type or one pain intensity level, this invention considers the difference in sample size for each category when evaluating the performance of chronic pain assessment. Accordingly, the accuracy (ACC), weighted average F1 score (WF1), and average area under the curve (AUC) evaluation metrics are calculated as follows:
[0096]
[0097] in, and These represent in-class precision and in-class recall, respectively; TP i FP i and FN i These represent true positives, false positives, and false negatives for each category, respectively. N a Represents the total number of samples. N c This represents the number of categories in the EEG signal dataset. This represents the number of samples in category i. This represents the independent AUC score for the i-th category.
[0098] On the CBPFM dataset, the proposed DSCL4CPA method is compared with state-of-the-art methods to evaluate its performance in pain type and intensity assessment tasks. Table 1 shows the comparison results of accuracy (ACC) and weighted F1 score (WF1) for the pain assessment task, and the comparison results of ROC curves and AUC for the pain type and intensity assessment tasks are shown in [Table 1]. Figure 2 , Figure 3 As shown, on the CBPFM dataset, the proposed DSCL4CPA method consistently outperforms all comparable methods in pain type and intensity assessment. In pain type assessment, it achieves 98.05% ACC, 98.99% WF1, and 99.76% AUC, significantly surpassing the second-best method, CRT. In pain intensity assessment on the same dataset, DSCL4CPA achieves 94.82% ACC, 97.09% WF1, and 98.85% AUC, demonstrating superior discrimination ability compared to existing self-supervised baseline methods.
[0099] Table 1 compares the ACC and WF1 (mean ± standard deviation) performance of different methods on the CBPFM dataset for the pain assessment task. Best results are shown in bold, and second-best results are shown underlined.
[0100]
[0101] Classical methods like SimCLR and FreRA rely on simple instance-level contrastive learning or single data augmentation strategies, which perform relatively poorly on the CBPFM dataset. These strategies may result in insufficient discriminative power in the learned representations when dealing with significant inter-individual variability and low signal-to-noise ratios in pain-related EEG signals. TS-TCC shows relatively stable performance across different pain assessment tasks, demonstrating its ability to extract temporal and contextual representations. The CRT model exhibits relatively stable performance and a moderate standard deviation; its architecture, combining time-frequency reconstruction, instance discrimination, and curriculum learning, effectively captures pain-related representations. EEG2Rep, as a self-predictive framework, performs comparably to CRT, particularly excelling in the pain intensity task on the CBPFM dataset. This model validates its effectiveness in handling inter-individual variability through latent representation space prediction and semantic subsequence preservation masking strategies. Notably, DSCL4CPA achieves higher mean and lower standard deviations for both ACC and WF1 indices on both datasets, demonstrating strong robustness and generalization ability. This reliability stems from the synergistic effect of the three contrastive learning modules and the custom-designed LCANet, highlighting the superior performance of DSCL4CPA in handling diverse chronic pain assessment tasks.
[0102] In this embodiment, box plots, scatter plots, and violin plots were used to visualize the performance distribution of different methods on the CBPFM dataset for each subject in terms of ACC and WF1. The results show that, compared to other methods, DSCL4CPA exhibits a more concentrated distribution and fewer outliers at the subject level, demonstrating stronger generalization ability for cross-subject pain assessment. The suboptimal method, CRT, also shows a relatively stable distribution among subjects. Notably, in the pain type assessment of the CBPFM dataset, DSCL4CPA's ACC and WF1 are mainly distributed above 90% and 94%, respectively; while in the pain intensity assessment of the CBPFM dataset, the corresponding values are mainly above 65% and 79%.
[0103] The model complexity comparison results are summarized in Table 3. LCANet within the DSCL4CPA framework demonstrates a significant advantage in balancing performance and model complexity. On the CBPFM dataset, compared to SimCLR, FreRA, TS-TCC, and CRT methods, DSCL4CPA maintains a similar level of complexity to MGTC while significantly reducing computational complexity (FLOPs) and the number of parameters (Params). Overall, DSCL4CPA achieves competitive pain assessment performance while maintaining relatively low model complexity, highlighting its suitability for computationally limited applications, such as wearable medical monitoring systems.
[0104] Table 3 compares the model complexity and parameter count of different methods for assessing pain intensity on the CBPFM dataset. The best results are shown in bold, and the second-best results are indicated by underline.
[0105]
[0106] As can be seen from this embodiment, compared with the prior art, the present invention has at least the following beneficial effects:
[0107] (1) Significantly improves generalization performance across subjects: Through self-supervised pre-training and a designed bias-free contrastive learning module, the influence of individual differences is effectively reduced.
[0108] (2) Significantly reduce reliance on labeled data: utilize unlabeled EEG signal data for high-quality representation learning.
[0109] (3) To alleviate the problem of false negative samples and improve the discriminative power of representation: soft label and clustering comparison strategy avoids the incorrect separation of semantically similar samples.
[0110] (4) Better modeling of the temporal dynamic characteristics of chronic pain: hierarchical soft contrast and temporal dynamic contrast strategies can better adapt to the long-term evolution characteristics of chronic pain.
[0111] (5) The evaluation model has a lightweight structure, making it suitable for wearable and real-time monitoring scenarios: LCANet has a small number of parameters and high computational efficiency.
[0112] (6) Experimental verification shows superior performance: It significantly outperforms existing methods on multiple publicly available EEG signal chronic pain datasets.
[0113] Example 2
[0114] like Figure 4 As shown, a chronic pain assessment method, based on the aforementioned pain assessment model, includes the following steps:
[0115] The subject's electroencephalogram (EEG) signal data was acquired and segmented into several EEG signal segments;
[0116] An evaluation model is constructed, which includes a lightweight channel attention network for feature extraction, and a hierarchical soft contrast module, a temporal dynamic contrast module, and a debiased clustering contrast module for self-supervised training.
[0117] The lightweight channel attention network is used to extract latent representations of EEG signal segments; the hierarchical soft contrast module is used to calculate the hierarchical soft contrast loss based on the geometric distance between EEG signal segments and the temporal span difference within segments; the temporal dynamic contrast module is used to predict the representation of future moments based on the contextual information of EEG signal segments, and calculate the temporal dynamic contrast loss; the bias-reduced clustering contrast module is used to cluster EEG signal segments to generate pseudo-labels, and combines semantic similarity to correct the positive and negative sample sets, and calculate the bias-reduced clustering contrast loss; the parameters of the evaluation model are updated based on the weighted sum of the above three losses.
[0118] The pre-trained assessment model was fine-tuned using EEG signal data labeled with pain, and the pain assessment results were output.
[0119] In one specific embodiment, the lightweight channel attention network consists of multiple cascaded convolutional blocks. The processing flow of each convolutional block is as follows: first, the input features are extracted at multiple time scales through a one-dimensional convolutional layer to generate an intermediate feature vector; then, the average influence of each channel on other channels over the entire time dimension is calculated through a channel attention mechanism to generate channel importance weights; finally, the channel importance weights are applied to the intermediate feature vectors and processed by a reversible instance normalization layer before output.
[0120] In one specific embodiment, the hierarchical soft contrast module calculates the hierarchical soft contrast loss in two dimensions: inter-segment soft contrast and intra-segment soft contrast. Specifically, the inter-segment soft contrast involves using the Dynamic Time Warping (DTW) algorithm to pre-calculate the distance between different EEG signal segments, defining soft assignment weights between segments based on the distance, and calculating the loss based on these soft assignment weights to maintain the representational similarity of adjacent EEG signal segments in the data space. Specifically, the intra-segment soft contrast involves defining time-level soft assignment weights based on the time difference between different time points within the same EEG signal segment, and calculating the loss based on these soft assignment weights to model the time dependence of pain evolution.
[0121] In one specific embodiment, the time dynamic contrast module includes a Transformer encoder and a linear predictor, and the specific steps for calculating the time dynamic contrast loss include:
[0122] The input EEG signal segments were subjected to weak enhancement and strong enhancement processing, respectively;
[0123] Input the EEG signal segments under weak enhancement view into the evaluation model and extract the corresponding contextual representation vectors;
[0124] Using the linear predictor, the representation vector of the strongly enhanced view is predicted within a future preset time window based on the context representation vector of the weakly enhanced view;
[0125] The similarity between the predicted representation vector and the true future representation vector in the strongly augmented view is maximized by comparing the loss function.
[0126] In one specific embodiment, the specific steps for the debiased clustering comparison module to calculate the debiased clustering comparison loss include:
[0127] Nonlinear projection is performed on the potential representation of the current batch of EEG signal segments;
[0128] The projected representations are clustered using a spectral clustering algorithm, and a pseudo-label is assigned to each EEG signal segment. A positive sample set is constructed, which consists of the following three parts:
[0129] Different enhanced views of the same EEG signal segment, EEG signal segments with the same pseudo-labels, and EEG signal segments with different pseudo-labels but semantic similarity higher than a preset threshold;
[0130] In the calculation of contrastive learning loss, the distance between the current EEG signal segment and all samples in the positive sample set is reduced, while the distance between it and the negative sample set is increased.
[0131] In one specific embodiment, when constructing a positive sample set, the debiased clustering comparison module calculates the semantic similarity between different EEG signal segments based on the soft assignment weights calculated in the hierarchical soft comparison module; if the soft assignment weights between two EEG signal segments indicate that their similarity is higher than the preset threshold, then these two segments are considered positive samples for each other, even if their pseudo-labels are different.
[0132] In one specific embodiment, the debiased clustering comparison module also introduces a weight-based negative sample suppression mechanism when calculating the loss; specifically, it calculates the average similarity between the current EEG signal segment and all its negative samples, and generates a weight coefficient based on the average similarity; the weight coefficient is used to adjust the contribution of the current EEG signal segment in the total loss function, so as to reduce the impact of highly similar negative samples on model training.
[0133] In one specific embodiment, the total loss function The construction method is as follows:
[0134]
[0135] in, The hierarchical soft contrast loss is a weighted sum of inter-segment soft contrast loss and intra-segment soft contrast loss. and These represent the time-dynamic contrast loss when using a weak augmented view to predict a strong augmented view, and when using a strong augmented view to predict a weak augmented view, respectively. To remove biased clustering contrast loss; and These are preset hyperparameters used to balance the contributions of each module.
[0136] In one specific embodiment, a data preprocessing step is also included, specifically: downsampling the original EEG signal to a preset sampling rate, performing bandpass filtering and notch filtering to remove noise and power frequency interference, and performing whole-brain average rereference processing; the pain assessment results include chronic pain type classification results or pain intensity level classification results.
[0137] Example 3
[0138] A chronic pain assessment system, based on the aforementioned pain assessment model, includes:
[0139] The data acquisition module is used to acquire the subject's electroencephalogram (EEG) signal data and segment it into several EEG signal segments;
[0140] The model building module is used to build an evaluation model, which includes a lightweight channel attention network for feature extraction, a hierarchical soft contrast module, a temporal dynamic contrast module, and a debiased clustering contrast module for self-supervised training.
[0141] The model training module is configured to extract latent representations of EEG signal segments using the lightweight channel attention network; calculate the hierarchical soft contrast loss based on the geometric distance between EEG signal segments and the temporal span difference within segments using the hierarchical soft contrast module; calculate the temporal dynamic contrast loss based on the contextual information of EEG signal segments to predict representations of future moments using the temporal dynamic contrast module; and calculate the biased clustering contrast loss by clustering EEG signal segments to generate pseudo-labels and correcting the positive and negative sample sets based on semantic similarity using the biased clustering contrast module. The parameters of the evaluation model are updated based on the weighted sum of the above three losses.
[0142] The assessment inference module is configured to fine-tune the pre-trained assessment model using EEG signal data labeled with pain, and output pain assessment results.
Claims
1. A pain assessment model based on electroencephalogram (EEG) signals and contrastive learning, characterized in that, Includes a cascaded lightweight channel attention network and a contrastive learning interaction layer; The lightweight channel attention network serves as the backbone network, used to receive preprocessed standardized EEG signal segments and output the latent representation vector of the EEG signal. The contrastive learning interaction layer is used for pre-training and includes a hierarchical soft contrastive module, a temporal dynamic contrastive module, and a debiased clustering contrastive module that are connected in parallel to the output of the lightweight channel attention network. The hierarchical soft contrast module receives EEG signal segments from different views and their time indices as input, and outputs a hierarchical soft contrast loss that includes the geometric distance between segments and the time span difference within segments; the temporal dynamic contrast module receives the concatenated vector of the latent representation vector and the context label as input, and outputs a temporal dynamic contrast loss based on context prediction of the future; the debiased clustering contrast module receives the nonlinear projection of the latent representation vector as input, and outputs a debiased clustering contrast loss that combines pseudo-labels and semantic similarity correction; the evaluation model obtains pre-trained weights based on the loss functions of the above three modules. The time-dynamic contrast module includes a Transformer encoder and a linear predictor. The specific steps for calculating the time-dynamic contrast loss include: The input EEG signal segments were subjected to weak enhancement and strong enhancement processing, respectively; Input the EEG signal segments under weak enhancement view into the evaluation model and extract the corresponding contextual representation vectors; Using the linear predictor, the representation vector of the strongly enhanced view is predicted within a future preset time window based on the context representation vector of the weakly enhanced view; By comparing the similarity between the predicted representation vector, which is maximized by the loss function, and the true future representation vector in the strongly augmented view; The specific steps for calculating the debiased clustering comparison loss by the debiased clustering comparison module include: Nonlinear projection is performed on the potential representation of the current batch of EEG signal segments; The projected representations are clustered using a spectral clustering algorithm, and a pseudo-label is assigned to each EEG signal segment. A positive sample set is constructed, which consists of the following three parts: Different enhanced views of the same EEG signal segment, EEG signal segments with the same pseudo-labels, and EEG signal segments with different pseudo-labels but semantic similarity higher than a preset threshold; In the calculation of contrastive learning loss, the distance between the current EEG signal segment and all samples in the positive sample set is reduced, while the distance between it and the negative sample set is increased. The lightweight channel attention network adjusts parameters based on the pre-trained weights and outputs pain assessment results through a classifier; Total loss function The construction method is as follows: in, The hierarchical soft contrast loss is a weighted sum of inter-segment soft contrast loss and intra-segment soft contrast loss. and These represent the time-dynamic contrast loss when using a weak augmented view to predict a strong augmented view, and when using a strong augmented view to predict a weak augmented view, respectively. To remove biased clustering contrast loss; and These are preset hyperparameters used to balance the contributions of each module.
2. The model according to claim 1, characterized in that, The lightweight channel attention network consists of multiple cascaded convolutional blocks. The processing flow of each convolutional block is as follows: First, the input features are extracted at multiple time scales through a one-dimensional convolutional layer to generate an intermediate feature vector. Then, the average influence of each channel on other channels over the entire time dimension is calculated through a channel attention mechanism to generate channel importance weights. Finally, the channel importance weights are applied to the intermediate feature vector and processed by a reversible instance normalization layer before being output.
3. The model according to claim 1, characterized in that, The hierarchical soft contrast module calculates the hierarchical soft contrast loss in two dimensions: inter-segment soft contrast and intra-segment soft contrast. Specifically, inter-segment soft contrast involves using the Dynamic Time Warping (DTW) algorithm to pre-calculate the distance between different EEG signal segments, defining soft assignment weights based on these distances, and calculating the loss based on these soft assignment weights to maintain the representational similarity of adjacent EEG signal segments in the data space. Intra-segment soft contrast involves defining time-level soft assignment weights based on the time difference between different time points within the same EEG signal segment, and calculating the loss based on these soft assignment weights to model the time dependence of pain evolution.
4. The model according to claim 1, characterized in that, When constructing a positive sample set, the debiased clustering comparison module calculates the semantic similarity between different EEG signal segments based on the soft assignment weights calculated in the hierarchical soft comparison module. If the soft assignment weights between two EEG signal segments indicate that their similarity is higher than the preset threshold, then these two segments are considered positive samples, even if their pseudo-labels are different.
5. The model according to claim 1, characterized in that, The debiased clustering comparison module also introduces a weight-based negative sample suppression mechanism when calculating the loss. Specifically, it calculates the average similarity between the current EEG signal segment and all its negative samples, and generates a weight coefficient based on the average similarity. The weight coefficient is then used to adjust the contribution of the current EEG signal segment in the total loss function to reduce the impact of highly similar negative samples on model training.
6. A chronic pain assessment system based on the aforementioned model, characterized in that, For running the model as described in any one of claims 1 to 5, comprising: The data acquisition module is used to acquire the subject's electroencephalogram (EEG) signal data and segment it into several EEG signal segments; The model training module is configured to perform self-supervised pre-training on the chronic pain assessment model using unlabeled data through a contrastive learning interaction layer; extract latent representations of EEG signal segments using the lightweight channel attention network; calculate the hierarchical soft contrast loss based on the geometric distance between EEG signal segments and the temporal span difference within segments using the hierarchical soft contrast module; calculate the temporal dynamic contrast loss by predicting the representation of future moments based on the contextual information of EEG signal segments using the temporal dynamic contrast module; and calculate the biased clustering contrast loss by clustering EEG signal segments to generate pseudo-labels and correcting the positive and negative sample sets based on semantic similarity using the biased clustering contrast module. The parameters of the assessment model are updated based on the weighted sum of the above three losses. The model fine-tuning module is configured to supervise the fine-tuning of the pre-trained evaluation model using EEG signal data with pain annotations. The assessment inference module is configured to receive EEG signal fragments from the subject, input a finely tuned assessment model, and output pain assessment results.