An electroencephalogram signal decoding method and system facing the edge side
Patent Information
- Application Number
- CN202511467656.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-14
- Publication Date
- 2026-09-25
AI Technical Summary
[0003]EEGNet等基于卷积神经网络的脑电信号解码模型采用浅层卷积结构,虽然模型参数规模相对较小,但在复杂的脑电信号模式识别任务中分类准确率有限,难以充分捕捉脑电信号的时空动态特征,特别是在多类别运动想象任务中的表现仍有改进空间
[0018]1、本发明公开了一种面向边缘侧的脑电图信号解码方法,内部设计公开了了一种脑电图信号解码模型,脑电图信号解码模型基于Transformer模型的构架设计,在脑电图信号解码模型中通过对局部注意力机制与动态窗口的设计,将Transformer模型的时间计算复杂度降低,满足边缘设备等嵌入式设备实时性需求,使得本发明中的脑电图信号解码模型具有高效的计算效率与低延迟的特点。
Smart Images

Figure CN122805293A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electroencephalography (EEG) decoding technology, and in particular to a method and system for decoding EEG signals oriented towards the limbic system. Background Technology
[0002] Traditional EEG signal decoding methods use conventional convolutional models for EEG signal decoding, but conventional convolutional models have the following limitations:
[0003] EEGNet and other convolutional neural network-based EEG signal decoding models employ shallow convolutional structures. Although the model parameters are relatively small, their classification accuracy is limited in complex EEG signal pattern recognition tasks, making it difficult to fully capture the spatiotemporal dynamic features of EEG signals. In particular, their performance in multi-class motor imagery tasks still has room for improvement.
[0004] Defects of global attention models: Although Transformer-based models such as EEGConformer have shown good performance in EEG signal classification tasks, the computational complexity brought about by their global self-attention mechanism increases twice, resulting in a large number of model parameters and high inference latency, making it difficult to meet the real-time and resource constraints of edge computing devices.
[0005] Therefore, there is an urgent need for a new method for decoding electroencephalogram (EEG) signals to solve the above-mentioned technical problems. Summary of the Invention
[0006] This invention provides a method and system for decoding electroencephalogram (EEG) signals oriented towards the limbic system, in order to solve the technical problems mentioned in the background art.
[0007] To achieve the above objectives, the technical solution of the present invention is implemented as follows:
[0008] This invention provides a method for decoding electroencephalogram (EEG) signals oriented towards the limbic side, comprising the following steps:
[0009] S1. Collect multiple sets of EEG signals and preprocess them; construct an EEG signal decoding model, which includes a spatiotemporal feature embedding module, a local attention encoding module, and a hierarchical feature decoder connected in sequence.
[0010] S2. Input a set of preprocessed EEG signals into the spatial feature embedding module to obtain the spatiotemporal feature matrix;
[0011] S3. Input the spatiotemporal feature matrix into the local attention encoding module to capture the EEG relationships in different time periods and obtain the local attention output features;
[0012] S4. Input the local attention output features into the hierarchical feature decoder to obtain the multi-class probability distribution, and then obtain the predicted label based on the multi-class probability distribution. Construct the total loss function based on the real label and predicted label of each annotation in the preprocessing process.
[0013] S5. Iterate through S2 to S4 to train the EEG signal decoding model, minimize the total loss, and obtain the trained EEG signal decoding model.
[0014] S6. The combined strategy of dynamic quantization and pruning is used to optimize the trained EEG signal decoding model to obtain the optimized EEG signal decoding model.
[0015] S7. Deploy the optimized EEG signal decoding model to the edge device, and use the EEG signal decoding model on the edge device to decode the actual EEG signal to obtain the decoding result.
[0016] In another aspect, the present invention provides a peripheral-oriented EEG signal decoding system, including a peripheral device configured to perform the above-described EEG signal decoding method.
[0017] The beneficial effects of this invention are:
[0018] 1. This invention discloses an edge-oriented EEG signal decoding method. The internal design discloses an EEG signal decoding model based on the Transformer model architecture. By designing a local attention mechanism and a dynamic window, the time computation complexity of the Transformer model is reduced, meeting the real-time requirements of embedded devices such as edge devices. This makes the EEG signal decoding model in this invention have high computational efficiency and low latency.
[0019] 2. This invention employs a combined strategy of dynamic quantization and pruning to optimize the trained EEG signal decoding model, thereby reducing the model's footprint while maintaining high-precision decoding capabilities. Attached Figure Description
[0020] Figure 1 This is a flowchart of the electroencephalogram (EEG) signal decoding method in this invention;
[0021] Figure 2 This is a structural block diagram of the attention encoding submodule of the present invention. Detailed Implementation
[0022] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Preferred embodiments of the invention are shown in the drawings. However, the invention can be implemented in many other different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to provide a thorough and complete understanding of the disclosure of the invention.
[0023] Reference Figure 1 This application provides a method for decoding electroencephalogram (EEG) signals oriented towards the limbic side, including the following steps:
[0024] S1. Collect multiple sets of EEG signals (such as 22-channel × 1000 sampling point EEG signals) and preprocess the multiple sets of EEG signals; construct an EEG signal decoding model, which includes a spatiotemporal feature embedding module, a local attention encoding module, and a hierarchical feature decoder connected in sequence.
[0025] S2. Input a set of preprocessed EEG signals into the spatial feature embedding module to obtain the spatiotemporal feature matrix;
[0026] S3. Input the spatiotemporal feature matrix into the local attention encoding module to capture the EEG relationships in different time periods and obtain the local attention output features;
[0027] S4. Input the local attention output features into the hierarchical feature decoder to obtain the multi-class probability distribution, and then obtain the predicted label based on the multi-class probability distribution. Construct the total loss function based on the real label and predicted label of each annotation in the preprocessing process.
[0028] S5. Iterate through S2 to S4 to train the EEG signal decoding model, minimize the total loss, and obtain the trained EEG signal decoding model.
[0029] S6. The combined strategy of dynamic quantization and pruning is used to optimize the trained EEG signal decoding model to obtain the optimized EEG signal decoding model.
[0030] S7. Deploy the optimized EEG signal decoding model to the edge device, and use the EEG signal decoding model on the edge device to decode the actual EEG signal to obtain the decoding result.
[0031] In some embodiments, S2 specifically includes the following steps:
[0032] S21. A set of EEG signals is input into the spatiotemporal feature embedding module. The spatial convolutional layer within the spatiotemporal feature embedding module first performs cross-channel feature fusion along the electrode dimensions of the EEG signals to obtain spatial features C. space ;
[0033] S22, Next, the temporal convolutional layer within the spatiotemporal feature embedding module is based on spatial feature C. space Generate a time-series token sequence T along the time axis time ;
[0034] S23, Spatial Features C space With time-series token sequence T time By integrating the results, a spatiotemporal feature matrix is obtained. in, Let N represent the set of real numbers. p N represents the total number of time-series tokens, obtained by segmenting the input signal through convolution; p =125, d is the embedding dimension, d=61.
[0035] In some embodiments, the spatial feature C in S21 space The specific calculation formula is as follows:
[0036] C space =Conv1D1(X; kernel=22×1, stride=1)
[0037] Where Conv1D1 represents the spatial convolutional layer; X represents the input EEG signal; kernel represents the one-dimensional convolutional kernel; and stride represents the number of steps.
[0038] The time-series token sequence T in S22 time The specific calculation formula is as follows:
[0039] T time =Conv1D2(C space (kernel = 1 × 64, stride = 8)
[0040] Here, Conv1D2 represents the temporal convolutional layer.
[0041] In some embodiments, refer to Figure 2 The local attention encoding module includes multiple (e.g., 6) attention encoding sub-modules connected in sequence;
[0042] Each attention encoding submodule includes a local attention mechanism, an activation function GeLU, a layer normalization layer 1, a feedforward network, and a layer normalization layer 2, which are connected in sequence. The input and output of the local attention mechanism are connected by residual connections. The local attention mechanism includes multiple (e.g., 8) attention encoders connected in sequence. The input and output of the feedforward network are connected by residual connections, and the dropout rate in the residual connections is set to 0.1.
[0043] The feedforward network is the second core module of the local attention encoding module, and its expansion factor is set to 4.
[0044] In some embodiments, S3 specifically includes the following steps:
[0045] S31. For the eigenvector Z of each time segment in the spatiotemporal feature matrix Z, t Perform average pooling to extract the global temporal statistical feature Fglobal;
[0046] S32. Parallel execution of max pooling with window sizes of 3, 5, and 7, on feature vector Z. t The sliding window is used to calculate the maximum value within each interval, and local high-response features are extracted based on the maximum value within each interval.
[0047] S33. Construct query vector Q, key vector K, and value vector V based on temporal statistical features and local high response features. Then, input query vector Q, key vector K, and value vector V into the local attention encoding module to finally obtain the local attention output features.
[0048] In some embodiments, the calculation formula for the time series statistical features in S31 is as follows:
[0049]
[0050] Where t represents the t-th time-series token;
[0051] The specific formula for calculating the local high-response features in S31 is as follows:
[0052]
[0053] Where i represents the window position and k represents the window size.
[0054] In some embodiments, S33 specifically includes the following steps:
[0055] S331. Construct query vector Q, key vector K, and value vector V based on temporal statistical features and local high-response features. Input query vector Q, key vector K, and value vector V into the local attention mechanism within the first attention encoding submodule of the local attention encoding module to obtain the attention matrix, as follows:
[0056]
[0057] Where Attentionlocal(Q, K, V) represents the attention matrix. represents the mask matrix, used to restrict the attention range to the k-neighborhood; Softmax represents the normalized exponential function; T represents the transpose; ⊙ represents element-wise multiplication (Hadamard product);
[0058] S332. Input the attention matrix into dropout layer 1, with dropout set to 0.1. Dropout layer 1 discards a portion of the data in the attention matrix, and after normalization by layer normalization layer 1, it is input into the feedforward network.
[0059] S333. The feedforward network combines the current output with the spatiotemporal feature matrix Z and inputs it into the dropout layer 2 and the normalization layer 2 to obtain the attention feature Z′ of the first attention encoding submodule. The specific formula for calculating the attention feature Z′ is as follows:
[0060] Z′=LayerNorm(Z+Dropout(GeLU(W Z+b)))
[0061] Where Dropout represents the dropout operation; GeLU represents the activation function; LayerNorm represents the normalized layer 2; W is the weight in the matrix multiplication operation in the local attention mechanism; and b is the bias of the weight W.
[0062] S334. Input the attention feature Z′ of the first attention encoding submodule into the other attention encoding submodules in sequence to finally obtain the local attention output feature.
[0063] In some embodiments, S4 specifically includes the following steps:
[0064] S41. Input the local attention output features into the hierarchical feature decoder, and use a three-layer fully connected classifier (where the first two layers use the ELU activation function) to classify the local attention output features to obtain a multi-class probability distribution, as follows:
[0065] P(y|X)=Soffmax(W3·ELU(W2·ELU(W1F+b1)+b2)+b3)
[0066] Where P(y|X) represents the multi-class probability distribution, Softmax represents the normalized exponential function; W1, W2, and W3 represent the weights in matrix multiplication in the local attention mechanism, and b1, b2, and b3 are the biases of W1, W2, and W3, respectively; F represents the output of the local attention encoding module; and ELU represents the activation function.
[0067] S42. Then, based on the multi-class probability distribution, the predicted labels are obtained, and the total loss function is constructed based on the real labels and predicted labels of each label in the preprocessing process.
[0068] In some embodiments, S6 specifically includes the following steps:
[0069] S61. A dynamic range calibration method based on KL (Kullback-Leibler) divergence is used to statistically analyze the weight data of the EEG signal decoding model to obtain a 32-bit floating-point weight distribution histogram. The optimal quantization interval is determined based on the 32-bit floating-point weight distribution histogram and by minimizing the KL divergence.
[0070] S62. Quantize the trained EEG signal decoding model according to the optimal quantization interval to obtain the quantized EEG signal decoding model.
[0071] S63. Calculate the importance score of the attention encoder in the local attention encoding module, and remove the attention encoders whose contribution is lower than the set threshold according to the importance score to obtain the optimized EEG signal decoding model.
[0072] This invention employs a combined strategy of dynamic quantization and pruning to optimize the trained EEG signal decoding model. This optimizes the model while maintaining high-precision decoding capabilities, reducing its size. After optimization (655.36KB memory, 47.9% compression), the classification accuracy remains at 83.42%, with a loss of only 0.34%, significantly better than the accuracy loss (>5.8%) of traditional quantization methods.
[0073] In some embodiments, the formula for calculating the optimal quantization interval in S61 is:
[0074]
[0075] Where Q(W) represents the optimal quantization interval; D KL (P(W)||Q(W)) represents the KL divergence loss, which measures the difference between the original weight distribution P(W) and the optimal quantization interval Q(W); P(W) represents the original weight distribution of the trained EEG signal decoding model;
[0076] The specific formula for calculating the importance score in S63 is as follows:
[0077]
[0078] Among them, Score h Indicates importance score; This represents the output matrix when the h-th attention encoder processes the i-th sample; ||*|| F represents the Frobenius norm, used to quantify the energy intensity of the matrix; N represents the total number of samples.
[0079] In this embodiment, the top 30% of attention encoders with the lowest importance scores are removed, compressing the model size from 1,368.35KB to 655.36KB.
[0080] In some embodiments, S7 specifically includes the following steps:
[0081] S71. Before deployment, the optimized EEG signal decoding model is optimized by using the RKNN Toolkit with INT8 quantization inference mode, implementing operator fusion optimization, and designing a memory reuse strategy to reduce the memory usage of the optimized EEG signal decoding model.
[0082] S72. Then, the latest EEG signal decoding model in S71 is deployed to the edge device, and the EEG signal decoding model on the edge device is used to decode the actual EEG signal to obtain the decoding result.
[0083] This invention discloses an edge-oriented EEG signal decoding method. The internal design discloses an EEG signal decoding model based on the Transformer model architecture. By designing a local attention mechanism and a dynamic window, the time computation complexity of the Transformer model is reduced, achieving an inference latency of 31ms. This meets the real-time requirements of embedded devices such as edge devices, making the EEG signal decoding model of this invention highly efficient in computation and low in latency.
[0084] To facilitate understanding, the following example illustrates the specific process of decoding electroencephalogram (EEG) signals:
[0085] Step S1: EEG signal acquisition and filtering;
[0086] Using 22-channel EEG signals (sampling rate 250Hz) from 9 subjects, a 6th-order Chebyshev Type II filter was applied for 4-40Hz bandpass filtering (60dB stopband attenuation). 1000 sampling points (4 seconds) were extracted from each test segment, and individual differences were eliminated through Z-score normalization to generate the input EEG signal. The data was split into a training set (5760 samples) and a test set (2880 samples), with the window overlap rate set to 50% to enhance temporal continuity;
[0087] Step S2: Parameter setting of the spatiotemporal feature embedding module and spatial feature C space Time-series token sequence T time Calculation;
[0088] Spatial convolutional layer: kernel size 22×1, number of output channels 22, captures cross-electrode spatial correlation;
[0089] Temporal convolutional layer: kernel size 1×64, stride 8, output channels 61, converting the temporal signal into 125 tokens (calculation: (1000-64) / 8+1=125(1000-64) / 8+1=125). Output embedding matrix. The total number of parameters is 3,742 (28.6% less than EEGNet);
[0090] A sample from the training set is input into the spatial convolutional layer and the temporal convolutional layer in the spatiotemporal feature embedding module to obtain the spatial feature C. space Time-series token sequence T time ;
[0091] Step S3, Configuration of Local Attention Encoding Module and
[0092] The number of attention encoders is set to 8, the spread factor of the feedforward network is set to 4, and the dropout rate of the residual connections is set to 0.1. The attention encoding submodules are stacked in 6 layers, and the computational complexity of each layer is:
[0093] FLOPS layer = 4 × 125 × 61 2 +2×125 2 ×61=2.17M
[0094] Among them, FLOPS layer Indicate complexity;
[0095] Total parameters: 1,368.35KB; inference latency: 44.7ms (RK NPU).
[0096] The spatiotemporal feature matrix is input into the local attention encoding module to capture the EEG relationships in different time periods and obtain the local attention output features.
[0097] Step S4: Iterate through steps S2 to S4 to train the EEG signal decoding model, minimize the total loss, and obtain the trained EEG signal decoding model.
[0098] Step S5: Quantization compression and pruning optimization of the trained EEG signal decoding model;
[0099] Dynamic range calibration: Quantization intervals are determined by minimizing the KL divergence of a statistical 256-bin histogram.
[0100] Symmetric quantization: Converts 32-bit floating-point numbers to 8-bit fixed-point numbers.
[0101] Structured pruning: Redundant attention encoders are removed based on importance scores. The compressed model size is 655.36KB (compression rate 47.9%), and the classification accuracy is 83.42% (loss 0.34%).
[0102] Step S6: Convert the optimized EEG signal decoding model to .rknn format using RKNN Tbolkit and enable INT8 quantization mode. Implement operator fusion optimization: merge the Conv1D-LayerNorm-Attention computation graph into a single NPU core. Configure a 4MB memory pool to achieve zero-copy data transmission, reducing peak memory usage from 12.3MB to 4.6MB. Receive Bluetooth EEG stream in real time (transmission latency <5ms), perform classification inference (latency 31.3ms ± 1.2ms), and output four-class distribution probabilities (i.e., multi-class distribution probabilities) to the exoskeleton controller (response cycle 40ms).
[0103] In another aspect, the present invention provides a peripheral-oriented EEG signal decoding system, including a peripheral device configured to perform the above-described EEG signal decoding method.
[0104] The EEG signal decoding system is implemented based on a hardware-software co-design concept. Through deep integration of edge devices (i.e., edge computing platforms) and optimized algorithms, a high-efficiency, low-latency EEG signal decoding system is constructed. The system uses a Rockchip NPU as its core computing unit, combined with a Bluetooth communication module and a real-time data processing engine, achieving end-to-end deployment from EEG signal acquisition to motor imagery classification. The hardware platform utilizes the RK NPU, which supports low-power parallel computing and integrates a 4MB on-chip memory pool. Zero-copy data transfer technology significantly reduces memory usage, decreasing peak memory from 12.3MB to 4.6MB, thus overcoming the resource constraints of embedded devices. A Bluetooth 5.0 low-power chip is responsible for real-time reception of 22-channel EEG signal streams, with transmission latency controlled within 5ms, ensuring temporal continuity between the signal acquisition end and the NPU. Classification results are transmitted to the exoskeleton controller via a standard UART / SPI interface, with a response cycle consistently within 40ms, meeting real-time control requirements.
[0105] In the deployment of the EEG signal decoding system, the optimized EEG signal decoding model was first converted into a .rknn format adapted for embedded hardware using the RKNN Toolkit. During this process, dynamic range calibration technology was employed, and the optimal quantization interval was determined by minimizing KL divergence. Symmetric quantization from 32-bit floating-point to 8-bit fixed-point was completed using a scaling factor, compressing the model size from 1,368.35KB to 655.36KB, achieving a compression rate of 47.9%. To further improve inference efficiency, 30% of low-contribution attention heads were removed through structured pruning. Combined with operator fusion technology, Conv1D, LayerNorm, and local attention calculations were merged into a single NPU core, reducing intermediate data transfer overhead. The final inference latency was optimized from 44.7ms to 31ms. The synergistic optimization of quantization and pruning allowed the model to maintain 83.42% classification accuracy after compression, with an accuracy loss of only 0.34%.
[0106] In the data processing flow of the EEG signal decoding system, the input signal is 22-channel × 1000-sampling-point EEG data (4 seconds duration, 250Hz sampling rate). After denoising using a 6th-order Chebyshev Type II bandpass filter (4-40Hz, 60dB stopband attenuation), individual differences are eliminated through Z-score normalization to generate the input matrix. Data segmentation employs a 50% overlapping sliding window strategy to enhance temporal continuity and generate a training set (5760 samples) and a test set (2880 samples). In the real-time inference stage, the final output is a multi-class distribution probability. The EEG signal decoding system supports continuous EEG stream processing, with an average inference latency of 31.3ms ± 1.2ms, significantly lower than the 50ms real-time threshold for brain-computer interfaces.
[0107] In terms of EEG signal decoding system integration, the system employs Dynamic Voltage Frequency Scaling (DVFS) technology to dynamically adjust the NPU operating frequency (0.8GHz-1.5GHz) based on the computational load, with typical power consumption controlled at 1.2W, making it suitable for battery-powered scenarios. Furthermore, the system incorporates a watchdog timer and anomaly detection module. When EEG signals are interrupted or noise levels exceed limits, it automatically switches to historical data caching mode, ensuring robustness in complex environments. In practical applications, the system can be deployed on portable brain-computer interface terminals to interpret users' motor intentions (such as left hand, right hand, foot, and tongue) in real time, and drive the mechanical structure to complete the corresponding movements via an exoskeleton controller. The modular design of the system also supports the expansion of multimodal sensors (such as electromyography signals and inertial measurement units), further enhancing environmental adaptability and application scenario diversity. Through the above design, the EEG signal decoding system achieves a balance between high accuracy (83.42%), low latency (31ms), and low resource consumption (4.6MB memory, 655.36KB model) on an embedded platform, providing a practical hardware implementation solution for edge computing-driven brain-computer interface systems.
[0108] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Furthermore, the technical solutions of the various embodiments of the present invention can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for decoding electroencephalogram (EEG) signals oriented towards the limbic side, characterized in that, Includes the following steps: S1. Collect multiple sets of EEG signals and preprocess them; construct an EEG signal decoding model, which includes a spatiotemporal feature embedding module, a local attention encoding module, and a hierarchical feature decoder connected in sequence. S2. Input a set of preprocessed EEG signals into the spatial feature embedding module to obtain the spatiotemporal feature matrix; S3. Input the spatiotemporal feature matrix into the local attention encoding module to capture the EEG relationships in different time periods and obtain the local attention output features; S4. Input the local attention output features into the hierarchical feature decoder to obtain the multi-class probability distribution, and then obtain the predicted label based on the multi-class probability distribution. Construct the total loss function based on the real label and predicted label of each annotation in the preprocessing process. S5. Iterate through S2 to S4 to train the EEG signal decoding model, minimize the total loss, and obtain the trained EEG signal decoding model. S6. The combined strategy of dynamic quantization and pruning is used to optimize the trained EEG signal decoding model to obtain the optimized EEG signal decoding model. S7. Deploy the optimized EEG signal decoding model to the edge device, and use the EEG signal decoding model on the edge device to decode the actual EEG signal to obtain the decoding result.
2. The method for decoding EEG signals oriented towards the limbic side according to claim 1, characterized in that, S2 specifically includes the following steps: S21. A set of EEG signals is input into the spatiotemporal feature embedding module. The spatial convolutional layer within the spatiotemporal feature embedding module first performs cross-channel feature fusion along the electrode dimensions of the EEG signals to obtain spatial features C. space ; S22, Next, the temporal convolutional layer within the spatiotemporal feature embedding module is based on spatial feature C. space Generate a time-series token sequence T along the time axis time ; S23, Spatial Features C space With time-series token sequence T time By integrating the results, a spatiotemporal feature matrix is obtained. in, Let N represent the set of real numbers. p d represents the total number of time-series tokens, and d represents the embedding dimension.
3. The method for decoding EEG signals oriented towards the limbic side according to claim 2, characterized in that, The spatial feature C in S21 space The specific calculation formula is as follows: C space =Conv1D1(X;kernel=22×1,stride=1) Where Conv1D1 represents the spatial convolutional layer; X represents the input EEG signal; kernel represents the one-dimensional convolutional kernel; and stride represents the number of steps. The time-series token sequence T in S22 time The specific calculation formula is as follows: T time =Conv1D2(C space ;kernel=1×64,stride=8) Here, Conv1D2 represents the temporal convolutional layer.
4. The method for decoding EEG signals oriented towards the limbic side according to claim 3, characterized in that, The local attention coding module includes multiple attention coding sub-modules connected in sequence; Each attention encoding submodule includes a local attention mechanism, an activation function GeLU, a layer normalization layer 1, a feedforward network, and a layer normalization layer 2, which are connected in sequence. The input and output of the local attention mechanism are connected by residuals. The local attention mechanism includes multiple attention encoders connected in sequence, and the input and output of the feedforward network are connected by residuals.
5. The method for decoding EEG signals oriented towards the limbic side according to claim 4, characterized in that, S3 specifically includes the following steps: S31. For the eigenvector Z of each time segment in the spatiotemporal feature matrix Z, t Perform average pooling to extract global temporal statistical features F. global ; S32. Parallel execution of max pooling with window sizes of 3, 5, and 7, on feature vector Z. t The sliding window is used to calculate the maximum value within each interval, and local high-response features are extracted based on the maximum value within each interval. S33. Construct query vector Q, key vector K, and value vector V based on temporal statistical features and local high response features. Then, input query vector Q, key vector K, and value vector V into the local attention encoding module to finally obtain the local attention output features.
6. The method for decoding EEG signals oriented towards the limbic side according to claim 5, characterized in that, The specific formula for calculating the time series statistical features in S31 is as follows: Where t represents the t-th time-series token; The specific formula for calculating the local high-response features in S31 is as follows: Where i represents the window position and k represents the window size.
7. The method for decoding EEG signals oriented towards the limbic side according to claim 6, characterized in that, S4 specifically includes the following steps: S41. Input the local attention output features into the hierarchical feature decoder, and use a three-layer fully connected classifier to classify the local attention output features to obtain multi-class probability distributions, as follows: P(y|X)=Softmax(W3·ELU(W2·ELU(W1F+b1)+b2)+b3) Where P(y|X) represents the multi-class probability distribution, Softmax represents the normalized exponential function; W1, W2, and W3 represent the weights in matrix multiplication in the local attention mechanism, and b1, b2, and b3 are the biases of W1, W2, and W3, respectively; F represents the output of the local attention encoding module; and ELU represents the activation function. S42. Then, based on the multi-class probability distribution, the predicted labels are obtained, and the total loss function is constructed based on the real labels and predicted labels of each label in the preprocessing process.
8. The method for decoding EEG signals oriented towards the limbic side according to claim 7, characterized in that, S6 specifically includes the following steps: S61. A dynamic range calibration method based on KL divergence is used to statistically analyze the weight data of the EEG signal decoding model to obtain a 32-bit floating-point weight distribution histogram. The optimal quantization interval is determined based on the 32-bit floating-point weight distribution histogram and by minimizing the KL divergence. S62. Quantize the trained EEG signal decoding model according to the optimal quantization interval to obtain the quantized EEG signal decoding model. S63. Calculate the importance score of the attention encoder in the local attention encoding module, and remove the attention encoders whose contribution is lower than the set threshold according to the importance score to obtain the optimized EEG signal decoding model.
9. The method for decoding EEG signals oriented towards the limbic side according to claim 8, characterized in that, The formula for calculating the optimal quantization interval in S61 is: Where Q(W) represents the optimal quantization interval; D KL (P(W)||Q(W)) represents the KL divergence loss, which measures the difference between the original weight distribution P(W) and the optimal quantization interval Q(W); P(W) represents the original weight distribution of the trained EEG signal decoding model; The specific formula for calculating the importance score in S63 is as follows: Among them, Score h Indicates importance score; This represents the output matrix when the h-th attention encoder processes the i-th sample; ||*|| F represents the Frobenius norm, used to quantify the energy intensity of the matrix; N represents the total number of samples.
10. A peripheral EEG signal decoding system, characterized in that, Includes an edge device, which is configured to perform the electroencephalogram (EEG) signal decoding method according to any one of claims 1 to 9.