Electroencephalographic pain localization device, training method and apparatus
By using a dual-branch spatiotemporal coding backbone network and a hybrid expert-weight decomposition low-rank adaptation module, the problem of EEG signal analysis in existing technologies is solved, enabling effective capture of acute and chronic pain features and improving the accuracy and stability of pain localization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN UNIV
- Filing Date
- 2026-02-26
- Publication Date
- 2026-04-28
AI Technical Summary
Existing EEG signal analysis methods are ineffective at resolving the complex dynamic characteristics of pain over time. In particular, traditional deep learning models show a significant performance decline when faced with unseen subjects, and the competitive gating of hybrid expert models inhibits the distributed characteristics of pain neural mechanisms, leading to negative transfer.
A bi-branch spatiotemporal coding backbone network and a hybrid expert-weight decomposition low-rank adaptation module were used to extract EEG signal features through coarse-grained and fine-grained branches, and weighted fusion was performed using non-competitive gating weights. Combined with empirical mode decomposition and multi-head attention mechanism, an EEG pain localization device was constructed.
It significantly improves cross-subject robustness and performance stability, effectively capturing the transient high-frequency features of acute pain and the continuous low-frequency oscillation features of chronic pain. It solves the problem that single-scale networks cannot take into account the dynamic characteristics of different pain types, and improves the accuracy and stability of pain localization.
Smart Images

Figure CN121730846B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to an EEG pain localization device, training method and equipment. Background Technology
[0002] Electroencephalography (EEG) is a detection technique that records spontaneous bioelectrical potential patterns in the brain through electronic instruments on the scalp. It is mainly used for the diagnosis of epilepsy, mental illnesses, etc. The relevant department is the neurology department, and the main detection methods include routine EEG, ambulatory EEG monitoring, and video EEG monitoring.
[0003] Electroencephalogram (EEG) signals are highly non-stationary. Traditional standard spectral analysis uses fixed basis functions, which makes it difficult to analyze the complex dynamic characteristics of time-varying pain, such as the transient high-frequency response of acute pain and the continuous low-frequency oscillation of chronic pain.
[0004] Because of the huge differences in the distribution of electroencephalographic signals among different individuals, existing deep learning models, such as standard convolutional neural networks (CNNs) or Transformers, show a significant performance drop when faced with unseen subjects.
[0005] Existing parameter fine-tuning methods, such as standard low-rank adaptation (LoRA), employ a "one-size-fits-all" global uniform update strategy, which cannot adapt to the highly uneven distribution of EEG signals across different frequency bands (such as Delta waves and Gamma waves) and brain regions.
[0006] Furthermore, traditional hybrid expert models (MoE) typically use a normalized exponential function (Softmax function) to generate gating weights. The Softmax function has a "zero-sum competition property," forcing the model to make exclusive selections among experts. However, neurophysiological studies have shown that pain processing (especially chronic pain) involves the co-activation of the frontal (cognitive assessment) and parietal (sensory processing) networks. Competitive gating inhibits this crucial distributed feature, making it difficult for the model to capture the real neural mechanisms of pain, thus triggering the "negative transfer" phenomenon. Summary of the Invention
[0007] This application proposes an EEG pain localization device, training method, and equipment, which can solve one of the problems existing in the background art.
[0008] To achieve the above objectives, this application adopts the following technical solution:
[0009] In a first aspect, a brainwave pain localization device is provided, comprising:
[0010] The preprocessing module is used to preprocess the EEG signals;
[0011] A dual-branch spatiotemporal coding backbone network is used to extract features from the preprocessed EEG signal to obtain an initial feature vector;
[0012] A hybrid expert-weighted decomposition low-rank adaptation module is used to segment the initial feature vector to obtain several subspace feature blocks. Subspace experts are then used to fine-tune the corresponding subspace feature blocks to obtain fine-tuned subspace features. Finally, non-competitive gated weights are used to weight and fuse the fine-tuned subspace features to obtain a secondary feature vector.
[0013] The detection head is used to process the secondary feature vector to obtain the detection result.
[0014] The dual-branch spatiotemporal coding backbone network includes:
[0015] A coarse-grained branch is used to extract low-frequency global features from the electroencephalogram (EEG) signal;
[0016] Fine-grained branches are used to extract high-frequency transient detail features from the electroencephalogram (EEG) signal;
[0017] A cross-branch attention fusion module is used to fuse the low-frequency global features and the high-frequency transient detail features using a multi-head attention mechanism to obtain fused features;
[0018] The feature output module is used to concatenate the low-frequency global features and the fused features to obtain the initial feature vector; and,
[0019] A pre-trained head is used for pre-training detection based on the initial feature vector.
[0020] Based on the above technical solution, an EEG pain localization device was constructed, including a preprocessing module, a dual-branch spatiotemporal coding backbone network, a hybrid expert-weight decomposition low-rank adaptation module, and a detection head. The dual-branch spatiotemporal coding backbone network includes a coarse-grained branch for extracting low-frequency global features from EEG signals and a fine-grained branch for extracting high-frequency transient detail features from EEG signals. In this way, it can simultaneously capture the transient high-frequency features of acute pain and the continuous low-frequency oscillation features of chronic pain, solving the problem that a single-scale network cannot take into account the dynamic characteristics of different pain types.
[0021] In one possible design of the first aspect, the hybrid expert-weighted decomposition low-rank adaptor module includes:
[0022] The context compression module is used to generate a global context vector from the initial feature vector;
[0023] The feature segmentation module is used to uniformly segment the initial feature vector into several subspace feature blocks;
[0024] The subspace expert processing module is used to take the input feature block formed by concatenating the global context vector and the corresponding subspace feature block as input, and perform dynamic feature reweighting and weight decomposition low-rank adaptation processing on the input feature block to obtain the fine-tuned subspace features.
[0025] A gating network is used to generate the non-competitive gating weights; and,
[0026] The weighted fusion layer is used to perform weighted fusion of the fine-tuned subspace features using the non-competitive gating weights to obtain the secondary feature vector.
[0027] In one possible design of the first aspect, the subspace expert processing module includes:
[0028] A batch mean calculation unit is used to calculate the mean of the input feature blocks;
[0029] A multilayer perceptron layer is used to generate reweighted gating weights based on the mean;
[0030] The weight decomposition low-rank adaptation unit is used to perform weight decomposition low-rank adaptation processing on the reweighted input feature block to obtain the fine-tuned subspace features, wherein the weight decomposition low-rank adaptation processing decomposes the weight matrix into amplitude components and direction components.
[0031] In one possible design of the first aspect, the coarse-grained branches comprise sequentially connected:
[0032] The system comprises a first TSE module, a second TSE module, a first max-pooling layer, a third TSE module, a second max-pooling layer, and a first Transformer encoder. Each TSE module includes, in sequence, a temporal convolutional layer, a normalization layer, a Gaussian error linear unit activation layer, a spatial attention layer, and a random deactivation layer.
[0033] In one possible design of the first aspect, the fine-grained branch includes, in sequence: a fourth TSE module, a fifth TSE module, a third max-pooling layer, a sixth TSE module, a seventh TSE module, a fourth max-pooling layer, and a second Transformer encoder.
[0034] In one possible design of the first aspect, the preprocessing module is specifically used to: filter, downsample, rereference, perform empirical mode decomposition, channel expansion and tensor reconstruction on the electroencephalogram signal.
[0035] In one possible design of the first aspect, the pre-trained head includes a classification head and a projection head.
[0036] Secondly, a training method for the brainwave pain localization device is provided, the training method comprising:
[0037] Obtain training data; and,
[0038] The EEG pain localization device is pre-trained using the training data. After pre-training, the dual-branch spatiotemporal coding backbone network and the pre-training head are frozen, and subspace-based adaptive fine-tuning is performed through the hybrid expert-weight decomposition low-rank adaptation module.
[0039] Thirdly, an electronic device is provided, comprising: a processor, and a memory coupled to the processor, the memory for storing a computer program; the processor for executing the computer program stored in the memory, such that the electronic device performs the following process:
[0040] Preprocessing of EEG signals;
[0041] Feature extraction is performed on the preprocessed EEG signal to obtain an initial feature vector;
[0042] The initial feature vector is segmented to obtain several subspace feature blocks. Subspace experts are used to fine-tune the corresponding subspace feature blocks to obtain fine-tuned subspace features. Then, non-competitive gating weights are used to weight and fuse the fine-tuned subspace features to obtain secondary feature vectors; and...
[0043] The secondary feature vector is processed to obtain the detection result.
[0044] Feature extraction of the preprocessed EEG signals specifically includes:
[0045] Low-frequency global features are extracted from the electroencephalogram (EEG) signal;
[0046] High-frequency transient detail features are extracted from the electroencephalogram (EEG) signal;
[0047] The low-frequency global features and the high-frequency transient detail features are fused using a multi-head attention mechanism to obtain fused features; and,
[0048] The low-frequency global features and the fused features are concatenated to obtain the initial feature vector.
[0049] Fourthly, an electronic device is provided, comprising: a processor, and a memory coupled to the processor, the memory for storing a computer program; the processor is configured to execute the computer program stored in the memory, such that the electronic device performs the following process:
[0050] Obtain training data; and,
[0051] The EEG pain localization device is pre-trained using the training data. After pre-training, the dual-branch spatiotemporal coding backbone network and the pre-training head are frozen, and subspace-based adaptive fine-tuning is performed through the hybrid expert-weight decomposition low-rank adaptation module. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0053] Figure 1 This is a structural diagram of the EEG pain localization device provided in Embodiment 1 of this application;
[0054] Figure 2 This is a coarse-grained branching structure diagram provided in Embodiment 1 of this application;
[0055] Figure 3 This is a structural diagram of the TSE module provided in Embodiment 1 of this application;
[0056] Figure 4 This is a fine-grained branch structure diagram provided in Embodiment 1 of this application;
[0057] Figure 5 This is a structural diagram of the hybrid expert-weighted decomposition low-rank adaptor module provided in Embodiment 1 of this application;
[0058] Figure 6 This is an overall framework diagram of the training method provided in Embodiment 2 of this application;
[0059] Figure 7 This is a schematic diagram of the distribution of 30-channel EEG electrodes and the division of key functional areas based on the international 10-20 system provided in Embodiment 2 of this application;
[0060] Figure 8 This is a diagram of the dual-branch spatiotemporal coding backbone network structure provided in Embodiment 2 of this application;
[0061] Figure 9 This is a microstructure diagram of the TSE module provided in Embodiment 2 of this application;
[0062] Figure 10 This is a structural diagram of the MoDoRA fine-tuning module provided in Embodiment 2 of this application;
[0063] Figure 11 This is a microstructure diagram of the subspace expert module provided in Embodiment 2 of this application. Detailed Implementation
[0064] 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.
[0065] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0066] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0067] Example 1
[0068] like Figure 1 As shown, this embodiment provides a brainwave pain localization device, including:
[0069] Preprocessing module 101 is used to preprocess the electroencephalogram (EEG) signals;
[0070] A dual-branch spatiotemporal coding backbone network 102 is used to extract features from the preprocessed EEG signal to obtain an initial feature vector;
[0071] The hybrid expert-weighted decomposition low-rank adaptation module 103 is used to segment the initial feature vector to obtain several subspace feature blocks, fine-tune the corresponding subspace feature blocks using a subspace expert to obtain fine-tuned subspace features, and then use non-competitive gated weights to perform weighted fusion of the fine-tuned subspace features to obtain a secondary feature vector; and,
[0072] The detection head 104 is used to process the secondary feature vector to obtain the detection result.
[0073] The dual-branch spatiotemporal coding backbone network 102 includes:
[0074] Coarse-grained branch 1021 is used to extract low-frequency global features from the electroencephalogram signal;
[0075] Fine-grained branch 1022 is used to extract high-frequency transient detail features from the electroencephalogram signal;
[0076] The cross-branch attention fusion module 1023 is used to fuse the low-frequency global features and the high-frequency transient detail features using a multi-head attention mechanism to obtain fused features;
[0077] Feature output module 1024 is used to concatenate the low-frequency global features and the fused features to obtain the initial feature vector; and,
[0078] The pre-trained head 1025 is used for pre-training detection based on the initial feature vector.
[0079] Specifically, the preprocessing module 101 can be used to perform filtering, downsampling, rereference, empirical mode decomposition, channel expansion and tensor reconstruction on the electroencephalogram signal.
[0080] Empirical Mode Decomposition (EMD) is a data-driven adaptive signal processing method that mainly includes adaptive decomposition and spectral linearization. By using EMD, the interference of signal nonstationarity on model training can be reduced, and the accuracy of model detection can be improved.
[0081] The pre-trained head 1025 includes a classification head and a projection head. Both the classification head and the projection head can be implemented using a multilayer perceptron. The classification head is used to calculate the cross-entropy loss to ensure that the features are discriminative, while the projection head is used to calculate the supervised contrastive loss to bring similar samples closer together and push away dissimilar samples.
[0082] like Figure 2 As shown, the coarse-grained branch 1021 includes, in sequence: a first TSE module, a second TSE module, a first max-pooling layer, a third TSE module, a second max-pooling layer, and a first Transformer encoder, as follows: Figure 3 As shown, the TSE module consists of the following layers connected in sequence: a temporal convolutional layer, a normalization layer, a Gaussian error linear unit activation layer, a spatial attention layer, and a random deactivation layer.
[0083] like Figure 4 As shown, the fine-grained branch includes, in sequence: a fourth TSE module, a fifth TSE module, a third max-pooling layer, a sixth TSE module, a seventh TSE module, a fourth max-pooling layer, and a second Transformer encoder.
[0084] The cross-branch attention fusion module 1023 uses coarse-grained branch features as query vectors and fine-grained branch features as key and value vectors for fusion.
[0085] The feature output module 1024 can also be used to flatten the spliced features.
[0086] Based on the above technical solution, an EEG pain localization device was constructed, including a preprocessing module 101, a dual-branch spatiotemporal coding backbone network 102, a hybrid expert-weight decomposition low-rank adaptation module 103, and a detection head 104. The dual-branch spatiotemporal coding backbone network 102 includes a coarse-grained branch 1021 for extracting low-frequency global features from EEG signals and a fine-grained branch 1022 for extracting high-frequency transient detail features from EEG signals. In this way, it can simultaneously capture the transient high-frequency features of acute pain and the continuous low-frequency oscillation features of chronic pain, solving the problem that a single-scale network cannot take into account the dynamic characteristics of different pain types.
[0087] like Figure 5 As shown, the hybrid expert-weighted decomposition low-rank adaptation module 103 includes:
[0088] The context compression module is used to generate a global context vector from the initial feature vector;
[0089] The feature segmentation module is used to uniformly segment the initial feature vector into several subspace feature blocks;
[0090] The subspace expert processing module is used to take the input feature block formed by concatenating the global context vector and the corresponding subspace feature block as input, and perform dynamic feature reweighting and weight decomposition low-rank adaptation processing on the input feature block to obtain the fine-tuned subspace features.
[0091] A gating network is used to generate the non-competitive gating weights; and,
[0092] The weighted fusion layer is used to perform weighted fusion of the fine-tuned subspace features using the non-competitive gating weights to obtain a secondary feature vector.
[0093] Specifically, the subspace expert processing module includes:
[0094] A batch mean calculation unit is used to calculate the mean of the input feature blocks;
[0095] A multilayer perceptron layer is used to generate reweighted gating weights based on the mean;
[0096] The weight decomposition low-rank adaptation unit is used to perform weight decomposition low-rank adaptation processing on the reweighted input feature block to obtain the fine-tuned subspace features, wherein the weight decomposition low-rank adaptation processing decomposes the weight matrix into amplitude components and direction components.
[0097] Based on the above technical solutions, cross-subject robustness can be significantly improved. At the same time, the performance standard deviation is extremely low, which proves that the model can still maintain high stability when faced with huge differences in physiological signals among different individuals. It verifies the necessity of "non-competitive co-activation" for capturing pain EEG features (especially frontal-parietal synergy) and effectively overcomes the negative transfer problem of traditional MoE. Initializing subspace experts after partitioning the weight matrix, instead of random initialization, can accelerate the convergence speed of fine-tuning and retain the discriminative knowledge learned in the pre-training stage to the greatest extent, preventing performance collapse in the early stage of fine-tuning.
[0098] This application provides a training method for the EEG pain localization device, the training method comprising:
[0099] Obtain training data; and,
[0100] The EEG pain localization device is pre-trained using the training data. After pre-training, the dual-branch spatiotemporal coding backbone network and the pre-training head are frozen, and subspace-based adaptive fine-tuning is performed through the hybrid expert-weight decomposition low-rank adaptation module.
[0101] Example 2
[0102] This embodiment mainly illustrates the above training method by way of example. In this embodiment, the relevant content of the device and electronic equipment of this application is also involved.
[0103] like Figure 6 As shown, the training method in this embodiment mainly includes three stages:
[0104] Data construction phase: Construct a spatiotemporal-frequency joint tensor using Empirical Mode Decomposition (EMD) and channel stacking;
[0105] Phase I, Pre-training Phase: Multi-scale features are extracted using a dual-branch backbone network (DTSEFormer), and optimized using MixUp and contrastive learning. The pre-training head is a logical functional module, the specific structure of which is described in... Figure 9 This was elaborated upon in detail. In fact, the pre-trained head contains a parallel Classifier Head and a Projection Head.
[0106] Phase II, Fine-tuning Phase: Freeze the backbone network and perform subspace-based adaptive fine-tuning through the Hybrid Expert-Weight Decomposition Low-Rank Adaptation (MoDoRA) module.
[0107] (i) Data construction stage: Raw EEG data is acquired through EEG acquisition equipment and EMD-based data preprocessing and tensor construction are performed.
[0108] In this embodiment, based on the international 10-20 system, 30 scalp EEG electrodes covering key functional areas of the whole brain are preferably selected for signal acquisition. Figure 7 As shown, the spatial layout of these 30 channels is divided into five functional brain regions to ensure that the model can capture the distributed neural mechanisms involved in pain processing. The specific configuration includes: the frontal lobe (Fp1, Fp2, F3, F4, F7, F8, Fz, Fpz, FC1, FC2, FC5, FC6, etc.) responsible for cognitive assessment; the central lobe (C3, C4, Cz, CP1, CP2, CP5, CP6, etc.) responsible for sensorimotor processing; and the parietal lobe (P3, P4, P7, P8, Pz, POz, etc.) responsible for multimodal sensory integration, while also encompassing the temporal lobe (e.g., T7, T8) and occipital lobe (e.g., O1, O2, Oz) as supplementary reference channels. This specific spatial configuration provides the physical basis for the subsequent bibranched backbone network, enabling the network to effectively extract the synergistic features of the frontal cognitive network and the parietal sensory network through channel deployment strategies.
[0109] Preprocessing may include:
[0110] 1.1 Basic Preprocessing: To eliminate environmental noise and standardize data specifications, the following operations are performed on the acquired multi-channel raw EEG signals:
[0111] Filtering: A bandpass filter is used to remove irrelevant frequency components. In this embodiment, the preferred passband range is 0.1-100Hz.
[0112] Downsampling: To reduce computational load and adapt to model input, the signal sampling rate is reduced. In this embodiment, downsampling to 200Hz is preferred.
[0113] Rereference: In order to eliminate the influence of the reference electrode, the reference electrode normalization technique (REST) is used for rereference processing.
[0114] 1.2 Signal Decomposition: Empirical mode decomposition is performed on the original EEG signal of each channel (C channels in total, e.g., C=30) to decompose it into several intrinsic mode functions (IMFs). In this embodiment, it is preferable to retain the first M IMFs (e.g., M=6) that contain the energy of the main frequency band.
[0115] 1.3 Empirical Mode Decomposition (EMD):
[0116] Electroencephalogram (EEG) signals have significant non-stationary and non-linear characteristics. Traditional time-frequency analysis methods (such as Fourier transform) are based on fixed basis functions and are difficult to effectively analyze the complex dynamic characteristics of time changes caused by pain, such as the transient high-frequency response of acute pain and the continuous low-frequency oscillation of chronic pain. If the original signal is used directly, deep neural networks are unable to extract robust spectral features directly from highly chaotic and non-stationary time series.
[0117] Empirical Mode Decomposition (EMD) serves as the core preprocessing step. This is a data-driven adaptive signal processing method that involves:
[0118] Adaptive decomposition: EMD does not require preset basis functions, but rather adaptively decomposes the raw EEG signal based on the signal's own time-scale characteristics. It is decomposed into several intrinsic mode functions (IMFs) and a residual term. The formula is as follows:
[0119]
[0120] Where t is time, To retain the number of modes, Representing the The first channel Each intrinsic mode component This is the residual term.
[0121] Spectral linearization: Through this decomposition, the non-stationary fluctuations mixed in the original signal are "linearized" into a set of components with relatively stable frequency characteristics, each IMF representing a specific oscillation mode.
[0122] Empirical Mode Decomposition (EMD) goes beyond simply decomposing data; it innovatively employs a "channel unfolding and stacking strategy." Specifically, unlike traditional methods that treat IMFs as independent tensor dimensions, this embodiment unfolds and stacks the decomposed IMFs with spatial channels to construct a unified two-dimensional input tensor of dimension 1. This construction method enables subsequent Convolutional Neural Network (CNN) filters to simultaneously extract features across both space (different electrodes) and spectrum (different IMFs), thereby directly capturing the joint features of specific brain regions in specific frequency bands.
[0123] Compared to the original signal, the IMF components decomposed by EMD provide a more stable spectral basis, reducing the interference of signal non-stationarity on model training. Experimental validation shows that EMD-based data preprocessing is significantly better than using the original data directly. In comparative experiments, models using EMD (such as FBMSNet) showed a significant improvement in accuracy compared to variants that directly input the original data (e.g., FBMSNet improved from 67.54% to 82.35%), demonstrating the effectiveness of EMD in capturing pain-related neural features.
[0124] 1.4 Standardization Processing: In order to eliminate amplitude differences between different subjects and different modalities and accelerate network convergence, each "channel-IMF" pair was subjected to independent standard deviation (Z-score) standardization processing. More specifically, channel-by-channel and IMF-by-IMF standardization was performed.
[0125] 1.5 Channel Unfolding and Tensor Reconstruction: A channel unfolding strategy is adopted, which does not treat the IMF as an independent dimension, but rather as a channel dimension. and IMF dimensions Stacking and flattening are performed. Before constructing the input tensor, each expanded "channel-IMF" pair is individually Z-score normalized to eliminate amplitude differences between channels. The input tensor is then constructed. ,in For batch size, The number of channels after expansion (e.g.) ), This refers to a point in time.
[0126] This allows subsequent convolutional filters to simultaneously span different spatial channels and frequency components, directly capturing the joint features of specific frequency bands in specific brain regions.
[0127] In (I), a channel expansion tensor construction method based on EMD was proposed, which does not treat the IMF as an independent dimension, but rather flattens the channels and IMF stacks. By constructing a unified 2D input matrix, the problem of separating spatial and spectral features in traditional methods is solved, enabling single-layer convolutional filters to simultaneously capture joint features across space (different electrodes) and across frequency (different IMFs), effectively addressing the non-stationarity of EEG signals.
[0128] (II) Stage I, Pre-training Stage: Input the tensor data X obtained in (I) into... Figure 7 Feature extraction is performed in the dual-branch spatiotemporal coding backbone network (DTSEFormer) of the network to obtain pre-trained feature vectors.
[0129] like Figure 8 As shown, the backbone network employs an asymmetric dual-branch structure. The left side is a coarse-grained branch (large convolutional kernel k=15) used to capture global slow waves; the right side is a fine-grained branch (small convolutional kernel k=7) used to capture transient details. The outputs of both are encoded by Transformer and then fused through a multi-head attention (MHA) mechanism.
[0130] 2.1 Coarse-grained Branch (left side): This branch is used to extract low-frequency global features, with the input channel being... (Assuming the input is the number of channels after stacking). The data passes through the following channels in sequence:
[0131] First-layer TSE module: uses large convolutional kernel Step length ,filling The output channel remains at 128.
[0132] Second-layer TSE module: Convolutional kernel Step length ,filling This layer has a step size of 4, achieving initial time-dimension downsampling.
[0133] The first max pooling layer (MaxPool 1D) has a kernel size of 2 and a stride of 2, further halving the time dimension.
[0134] Third-layer TSE module: Convolutional kernel Step length ,filling .
[0135] The second max-pooling layer (MaxPool 1D): kernel size 2, stride 2. At this point, the time dimension is compressed to... .
[0136] Transformer encoder: Contains 6 layers and receives compressed feature sequences.
[0137] 2.2 Fine Branch (Right Side): This branch is used to extract high-frequency transient details. The input channel is... (Or segmented based on input). The data passes through the following steps in sequence:
[0138] First-layer time-compressed excitation module (TSE module): Convolutional kernel Step length ,filling , Output channel 64.
[0139] Second-layer TSE module: Convolutional kernel Step length ,filling .
[0140] First max pooling layer (MaxPool 1D): kernel size is 2, stride is 2.
[0141] Third-layer TSE module: Convolutional kernel Step length ,filling The output channels have been upgraded to 128.
[0142] Fourth layer TSE module: Convolutional kernel Step length ,filling .
[0143] The second max-pooling layer (MaxPool 1D): kernel size is 2, stride is 2. The time dimension is also compressed to... Align with the thick branch.
[0144] Transformer encoder: contains 6 layers.
[0145] 2.3 Integration and Output:
[0146] Cross-branch attention (MHA): coarse branch features are used as query vectors, and fine branch features are used as key and value vectors and fused together.
[0147] Concat & Flatten: The merged features are concatenated with the original features and then flattened.
[0148] Dual-head output (corresponding) Figure 6 (pre-trained head)
[0149] Classifier Head: A multilayer perceptron (MLP) structure used to calculate cross-entropy loss, ensuring that features are discriminative.
[0150] Projection Head: An MLP structure that maps features to a projection space to compute supervised contrastive loss (SCL), bringing similar samples closer together and pushing dissimilar samples further away.
[0151] 2.4. Dual-branch parallel processing: Data is processed in two parallel branches (coarse branch, ...). and fine-grained branching ).
[0152] Coarse-grained branching: Employs large convolution kernels (e.g., k=15) to capture global slow waves and low-frequency oscillations in the signal, which correspond to the persistent pain processing mechanism of chronic pain.
[0153] Fine-grained branching: Employing small convolution kernels (e.g., k=7) aims to capture transient details and high-frequency burst features in the signal, which correspond to the phase-locked response of acute pain.
[0154] 2.5 TSE Module Processing: Each branch consists of stacked TSE modules, such as... Figure 9 As shown:
[0155] like Figure 9As shown, each TSE module is a basic building block of the backbone network. Input features sequentially pass through a Temporal Convolutional layer, a BatchNorm normalization layer, and a Gaussian Error Linear Unit (GELU) activation layer. Crucially, the subsequent Spatial Attention Layer (SE Layer) reweights the channel-modality features using a squeeze-and-excitation mechanism. Subsequently, the features enter a Dropout layer. In this layer, the outputs of some neurons are randomly set to zero with a certain probability (e.g., p=0.3). This operation aims to break the co-adaptation relationship between neurons, preventing the model from overfitting on the training data and thus enhancing the model's generalization ability. Finally, the features processed by Dropout are residually connected to the module inputs to output the final features.
[0156] Each TSE module performs the following sequentially:
[0157] One-dimensional temporal convolution: extracting temporal features.
[0158] SE attention layer (Squeeze-and-Excitation): Adaptively calibrates the importance of the "channel-IMF" combination and suppresses noise modes.
[0159] Downsampling: Compressing the time dimension through max pooling (MaxPool1d) (e.g., eventually compressing to...) ).
[0160] To achieve the best results, the following specific parameter configurations are used in this example:
[0161] Coarse Branch: The first TSE module uses a large convolutional kernel. Step length ,filling The output channel is 128; then it undergoes max pooling (Kernel=2, Stride=2); the second layer uses... The third layer adopts Finally, features are extracted using a Transformer encoder (6 layers, 8-head attention, FFN dimension 512).
[0162] Fine Branch: The first layer uses a smaller convolutional kernel. The number of channels is 64; subsequent layers gradually increase the number of channels to 128, with the convolutional kernel configurations as follows: It also connects to a 6-layer Transformer encoder.
[0163] Feature dimension: After downsampling, the time dimension is compressed to The fused feature vector The dimension is (Batch size is B).
[0164] 2.6 Cross-branch attention fusion: Using coarse branch features as the query ( ), fine branch features as Key( ) and Value( The input is then fused into a multi-head attention mechanism.
[0165] 2.7 Feature Output: The fused features are concatenated and flattened to obtain a high-dimensional latent feature vector. .
[0166] In (II), a two-branch asymmetric structure with coarse-grained (large convolutional kernel, shallow layer) and fine-grained (small convolutional kernel, deep layer) was designed and combined with the SE attention mechanism. This structure can simultaneously capture the transient high-frequency features of acute pain (responsible for the fine branch) and the continuous low-frequency oscillation features of chronic pain (responsible for the coarse branch), thus solving the problem that a single-scale network cannot take into account the dynamic characteristics of different pain types.
[0167] (III) Stage II, Fine-tuning Stage: Input the feature vector obtained in (II) into... Figure 6 The final classification result is obtained by processing the data in the Mixture-of-DoRA (MoDoRA) adaptive fine-tuning module of the network.
[0168] During this stage, the backbone network parameters are frozen, and only the MoDoRA module is trained.
[0169] MoDoRA modules such as Figure 10 As shown, this module receives features output by the backbone network and includes three parallel paths: (1) Feature segmentation path: segments the features into Subspace; (2) Global context compression path: Extract global summary (3) Gated path: Generate non-competitive weights. The features of each subspace are concatenated with the global summary and then processed by the "subspace expert".
[0170] 3.1 Global Context Compression: Compressing feature vectors Input is fed into a lightweight network (linear layer + hyperbolic tangent activation function (Tanh activation function)) to generate a global context vector. It is used to preserve the overall signal structure.
[0171]
[0172] In the formula:
[0173] This represents the generated global context vector, used to preserve the structural information of the overall signal;
[0174] This represents the feature vector (or latent feature representation) output by the backbone network.
[0175] This represents the trainable weight matrix in the context compression layer;
[0176] This represents the trainable bias vector in the context compression layer;
[0177] This represents the hyperbolic tangent activation function.
[0178] 3.2 Feature Segmentation: The 6400-dimensional feature vector output by the backbone network is segmented... Cut evenly into An independent subspace feature block In this embodiment, it is preferable to set the number of segments. Therefore, each subspace feature block The dimension is 800. Simultaneously, the rank of the low-rank matrix is pre-set to be [value missing] for the weight decomposition low-rank adaptation (DoRA) module in subsequent processing steps. .
[0179] 3.3 Subspace Expert Processing (DoRA Adaptation): Each feature block With global context After concatenation, the data is input into the corresponding subspace expert module. Each expert contains a dynamically gated multilayer perceptron (MLP) and a weight-decomposed low-rank adaptation (DoRA) layer.
[0180] like Figure 11As shown, each subspace expert processes a feature block. Internally, it includes: (1) Dynamic feature modulation: a squeeze-and-excitation mechanism is adopted. First, the batch mean of the input feature block is calculated, then a two-layer MLP (structure: fully connected layer → GELU → fully connected layer → Sigmoid) is used to generate gated weights (excitation), and finally the input features are re-weighted (rescaled) to dynamically enhance the task-related features. (2) DoRA layer: receives the modulated features and processes them through a weight decomposition low-rank adaptation mechanism. Specifically, this layer decomposes the weight matrix into two independent components: amplitude and direction. Among them, the direction component is composed of frozen pre-trained weights. and trainable low-rank matrices ( The magnitude component is jointly determined by the trainable vectors. Decision. During the fine-tuning process, only updates will be made. and Thus, while maintaining pre-trained knowledge ( While splitting the weights from the pre-trained classifier head, it achieves parameter-efficient subspace feature adaptation.
[0181] The update formula for DORA is:
[0182]
[0183] in, For the frozen pre-trained weight matrix, and For trainable low-rank decomposition matrices ( ,rank ); This represents the normalization of the column norm of a matrix, which means calculating the 2-norm (Euclidean norm) of each column vector of the matrix and normalizing it to ensure the normalization of the directional components. It is a trainable magnitude vector; This indicates element-wise multiplication; This represents the dynamic gating coefficients calculated based on the concatenated features. This formula achieves efficient fine-tuning of the parameters by decoupling the direction and magnitude of the weight matrix. Initialization is derived from the partitioning of the classification head weights during the pre-training phase, rather than random initialization, in order to achieve knowledge inheritance.
[0184] 3.4. Use the Sigmoid activation function instead of Softmax to generate gate weights. :
[0185]
[0186] in, For the gated weight vector, Here is the weight matrix of the gated network. This represents the feature vector (or latent feature representation) output by the backbone network. This represents the trainable bias vector in a gated network.
[0187] The current activation function allows Independently approaching 1, thus allowing co-activation of experts from different subspaces, adapting to multi-brain region collaboration mechanisms in pain processing.
[0188] 3.5 Weighted Fusion and Output: Calculate the weighted sum to obtain the final predicted features, and input it into the classifier to obtain the pain location result (e.g., left hand / right hand, or specific brain region):
[0189]
[0190] in, This represents the secondary feature vector after weighted fusion. This vector will be used as the input to the detection head for final prediction. This indicates that the value generated by the gating network is for the first... Non-competitive gating weights for subspace experts This represents the subspace features after fine-tuning.
[0191] In section (III), high-dimensional features are divided into subspaces, low-rank fine-tuning is performed using DoRA, and the Sigmoid function is used as the gating activation instead of the traditional Softmax, which significantly improves cross-subject robustness: Experimental data show that in the most challenging cross-subject test for chronic pain, the localization accuracy of this embodiment reached 85.38%, which is significantly improved compared with mainstream baseline models (such as MedFormer at 51.96% and EEGNet at 63.04%). At the same time, the performance standard deviation is extremely low (only ±1.09%), which proves that the model can still maintain extremely high stability when faced with huge differences in physiological signals among different individuals. The necessity of the non-competitive mechanism is verified: Ablation experiments show that if the Sigmoid gating of this embodiment is replaced with the traditional Softmax gating (i.e., introducing a competitive mechanism), the accuracy will drop to 81.97%. This directly verifies the necessity of "non-competitive co-activation" for capturing pain EEG features (especially frontal-parietal synergy) and effectively overcomes the negative transfer problem of traditional MoE.
[0192] In (III), during the fine-tuning stage, the weight matrix of the pre-trained classification head is split and initialized with subspace experts instead of being randomly initialized. This accelerates the convergence speed of fine-tuning and preserves the discriminative knowledge learned in the pre-training stage to the greatest extent, preventing performance collapse in the early stages of fine-tuning.
[0193] The training method for the above network consists of two stages, including:
[0194] Phase 1: Backbone Network Pre-training
[0195] Step 1: Use the feature-level MixUp strategy to interpolate the samples in the latent feature space to generate enhanced samples. Calculate cross-entropy loss .
[0196] Step 2: Using supervised contrastive learning (SCL), bring similar subjects' features closer together and push dissimilar subjects' features further away in the projection space, and calculate the contrastive loss. .
[0197] Step 3: Calculate the total loss And update the parameters of the backbone network DTSEFormer.
[0198] About MixUp: Mixing coefficient Follows a Beta distribution In this embodiment, it is preferred that... (Data on chronic pain) or (Data on acute pain).
[0199] Regarding SCL: Temperature coefficient in supervised contrast loss The preferred setting is 0.2 or 0.15. Balance coefficient (To balance classification loss and contrast loss) It is preferred to set it to 0.1.
[0200] Phase Two: MoDoRA Adaptive Fine-Tuning
[0201] Step 1: Freeze all parameters of the DTSEFormer backbone network.
[0202] Step 2: Divide the pre-trained classifier head weights and initialize the MoDoRA experts. matrix.
[0203] Step 3: Only for low-rank matrices in the MoDoRA module The gating network parameters are updated to minimize the classification loss.
[0204] This application also provides an electronic device, comprising: a processor, and a memory coupled to the processor, the memory being used to store a computer program; the processor being used to execute the computer program stored in the memory, such that the electronic device performs the following process:
[0205] Preprocessing of EEG signals;
[0206] Feature extraction is performed on the preprocessed EEG signal to obtain an initial feature vector;
[0207] The initial feature vector is segmented to obtain several subspace feature blocks. Subspace experts are used to fine-tune the corresponding subspace feature blocks to obtain fine-tuned subspace features. Then, non-competitive gating weights are used to weight and fuse the fine-tuned subspace features to obtain secondary feature vectors; and...
[0208] The secondary feature vector is processed to obtain the detection result.
[0209] Feature extraction of the preprocessed EEG signals specifically includes:
[0210] Low-frequency global features are extracted from the electroencephalogram (EEG) signal;
[0211] High-frequency transient detail features are extracted from the electroencephalogram (EEG) signal;
[0212] The low-frequency global features and the high-frequency transient detail features are fused using a multi-head attention mechanism to obtain fused features; and,
[0213] The low-frequency global features and the fused features are concatenated to obtain the initial feature vector.
[0214] This application also provides an electronic device, comprising: a processor, and a memory coupled to the processor, the memory being used to store a computer program; the processor being used to execute the computer program stored in the memory, such that the electronic device performs the following process:
[0215] Obtain training data; and,
[0216] The EEG pain localization device is pre-trained using the training data. After pre-training, the dual-branch spatiotemporal coding backbone network and the pre-training head are frozen, and subspace-based adaptive fine-tuning is performed through the hybrid expert-weight decomposition low-rank adaptation module.
[0217] Electronic devices can be computing devices such as desktop computers, laptops, handheld computers, and cloud servers. These electronic devices may include, but are not limited to, processors and memory.
[0218] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the electronic device, connecting various parts of the device via various interfaces and lines.
[0219] The memory can be used to store the computer program, and the processor implements various functions of the electronic device by running or executing the computer program stored in the memory and calling the data stored in the memory.
[0220] The memory may primarily include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function, etc.; the data storage area may store data created based on the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0221] This application also provides a storage medium, which is a computer-readable storage medium. The computer program is stored in the computer-readable storage medium, and when executed by a processor, the computer program can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0222] This application also provides a computer program product, including: a computer program or instructions that, when the computer program or instructions are run on a computer, cause the computer to perform any of the above possible implementation methods.
[0223] The above description is the preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications are also considered to be within the scope of protection of this application.
Claims
1. A brainwave pain localization device, characterized in that, include: The preprocessing module is used to preprocess the EEG signals; A dual-branch spatiotemporal coding backbone network is used to extract features from the preprocessed EEG signal to obtain an initial feature vector; A hybrid expert-weighted decomposition low-rank adaptation module is used to segment the initial feature vector to obtain several subspace feature blocks. A subspace expert processing module is used to fine-tune the corresponding subspace feature blocks to obtain fine-tuned subspace features. Then, non-competitive gated weights are used to perform weighted fusion on the fine-tuned subspace features to obtain secondary feature vectors. as well as, The detection head is used to process the secondary feature vector to obtain the detection result. The dual-branch spatiotemporal coding backbone network includes: A coarse-grained branch is used to extract low-frequency global features from the electroencephalogram (EEG) signal; Fine-grained branches are used to extract high-frequency transient detail features from the electroencephalogram (EEG) signal; A cross-branch attention fusion module is used to fuse the low-frequency global features and the high-frequency transient detail features using a multi-head attention mechanism to obtain fused features; The feature output module is used to concatenate the low-frequency global features and the fused features to obtain the initial feature vector; and, A pre-trained head is used for pre-training detection based on the initial feature vector. The hybrid expert-weighted decomposition low-rank adaptation module includes: The context compression module is used to generate a global context vector from the initial feature vector; The feature segmentation module is used to uniformly segment the initial feature vector into several subspace feature blocks; The subspace expert processing module is used to take the input feature block formed by concatenating the global context vector and the corresponding subspace feature block as input, and perform dynamic feature reweighting and weight decomposition low-rank adaptation processing on the input feature block to obtain the fine-tuned subspace features. A gating network is used to generate the non-competitive gating weights; and, The weighted fusion layer is used to perform weighted fusion of the fine-tuned subspace features using the non-competitive gated weights to obtain the secondary feature vector. The subspace expert processing module includes: A batch mean calculation unit is used to calculate the mean of the input feature blocks; A multilayer perceptron layer is used to generate reweighted gating weights based on the mean; and, The weight decomposition low-rank adaptation unit is used to perform weight decomposition low-rank adaptation processing on the reweighted input feature block to obtain the fine-tuned subspace features. The weight decomposition low-rank adaptation processing decomposes the weight matrix into amplitude and direction components. The coarse-grained branch comprises sequentially connected: The system comprises a first TSE module, a second TSE module, a first max-pooling layer, a third TSE module, a second max-pooling layer, and a first Transformer encoder. Each TSE module includes, in sequence, a temporal convolutional layer, a normalization layer, a Gaussian error linear unit activation layer, a spatial attention layer, and a random deactivation layer. The fine-grained branch includes, in sequence: a fourth TSE module, a fifth TSE module, a third max-pooling layer, a sixth TSE module, a seventh TSE module, a fourth max-pooling layer, and a second Transformer encoder. The preprocessing module is specifically used to perform filtering, downsampling, rereference, empirical mode decomposition, channel expansion, and tensor reconstruction on the electroencephalogram (EEG) signal.
2. The EEG pain localization device as described in claim 1, characterized in that, The pre-trained head includes a classification head and a projection head.
3. A training method for the EEG pain localization device according to any one of claims 1-2, characterized in that, The training method includes: Obtain training data; and, The EEG pain localization device is pre-trained using the training data. After pre-training, the dual-branch spatiotemporal coding backbone network and the pre-training head are frozen, and subspace-based adaptive fine-tuning is performed through the hybrid expert-weight decomposition low-rank adaptation module.
4. An electronic device, characterized in that, The electronic device includes: a processor, and a memory coupled to the processor. The memory is used to store computer programs; The processor is configured to execute the computer program stored in the memory, causing the electronic device to perform the following process: Obtain training data; and, The brainwave pain localization device of claim 1 is pre-trained using the training data. After pre-training, the dual-branch spatiotemporal coding backbone network and the pre-training head are frozen, and subspace-based adaptive fine-tuning is performed through the hybrid expert-weight decomposition low-rank adaptation module.
Citation Information
Patent Citations
Pain detecting and positioning method and system based on brain waves and neural network
CN112957014A
Multi-mode postoperative child pain identification method
CN120661081A