Electroencephalogram signal classification method and system based on hierarchical pulse self-attention mechanism

CN122548437APending Publication Date: 2026-08-11BRAIN-COMPUTER INTERACTION & HUMAN-COMPUTER INTEGRATION HAIHE LAB +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-26
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0005]针对现有技术的不足,本发明拟解决的技术问题是,提供一种基于分层脉冲自注意力机制的脑电信号分类方法及系统,解决脑电信号的长程依赖性建模问题和引入脉冲自注意力机制带来的能耗增长问题,以轻量级、高效为目的,使用分层架构和轻量级脉冲自注意力算子,仅需少量的可训练参数即可实现强大的分类效果

Benefits of technology

本发明基于分层脉冲自注意力机制的脑电信号分类方法,用于脑电信号(EEG)分类,应用于脑机接口系统中,本发明使用轻量级脉冲自注意力算子Lightweight SSA,分层处理,以平衡能耗与模型复杂度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122548437A_ABST
    Figure CN122548437A_ABST
Patent Text Reader

Abstract

This invention relates to a method and system for classifying EEG signals based on a hierarchical spiking self-attention mechanism. The method constructs a hierarchical spiking neural network classification model (HLFormer), comprising two feature extraction stages: The first stage employs a spiking spatiotemporal encoder combined with a lightweight spiking self-attention operator (Lightweight SSA) to extract spatiotemporal features and perform global rhythm filtering on EEG signals at a lower feature dimension. A masking mechanism is used to perform dual attention calculations in both the time and feature domains, reducing computational complexity. The second stage utilizes a spiking vector embedding module (SPE) to extend the features to a high-dimensional space and combines this with the standard spiking self-attention operator (SSA) for refined long-range dependency modeling. This invention can effectively capture the global temporal dependencies of EEG signals while maintaining low energy consumption, significantly improving the classification accuracy of EEG tasks such as motor imagery.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of EEG signal classification technology, and in particular to an EEG signal classification method and system based on a hierarchical pulse self-attention mechanism. It addresses the problems of long-range dependence of EEG signals and high training energy consumption, and is particularly suitable for motor imagery intention recognition in low-power, portable brain-computer interface devices. Background Technology

[0002] With the deep integration of life sciences and artificial intelligence technologies, brain-computer interfaces have become the forefront of direct interaction between the brain and external devices. As a non-invasive electrophysiological recording method, electroencephalography (EEG) provides a key signal source for brain-computer interface systems by capturing electromagnetic waves (such as the delta, theta, alpha, beta, and gamma bands) generated by the activity of cortical neurons.

[0003] EEG signals exhibit high temporal correlation and are acquired at a high frequency, requiring models to possess the ability to model long-range dependencies. Self-attention mechanisms were first used in natural language processing and, thanks to their excellent modeling capabilities, have also been developed in the fields of images and videos. However, directly introducing self-attention mechanisms into the EEG signal domain presents the following problems: high computational complexity and insufficient feature extraction.

[0004] Existing methods (Chen Q, Sun C, Gao C, et al. Epilepsy seizure detection and prediction using an approximate spiking convolutional transformer[C] / / 2024 IEEE International Symposium on Circuits and Systems (ISCAS). IEEE,2024: 1-5.) directly introduce the standard Spiking Self-Attention (SSA) operator into a pure convolutional architecture. However, this approach results in extremely high energy consumption (as shown in Table 3 for Spiking Conformer-20 and Spiking Conformer-40), and its feature extraction capability remains limited. Summary of the Invention

[0005] To address the shortcomings of existing technologies, the technical problem this invention aims to solve is to provide a method and system for classifying EEG signals based on a hierarchical impulse self-attention mechanism. This method addresses the problems of long-range dependency modeling of EEG signals and the energy consumption increase caused by introducing the impulse self-attention mechanism. With the goal of being lightweight and efficient, this method uses a hierarchical architecture and a lightweight impulse self-attention operator, requiring only a small number of trainable parameters to achieve powerful classification results.

[0006] The technical solution adopted by the present invention to solve the aforementioned technical problem is as follows: In a first aspect, the present invention provides a method for classifying electroencephalogram (EEG) signals based on a hierarchical impulse self-attention mechanism, the method comprising the following: Acquire electroencephalogram (EEG) signal data; A hierarchical spiking neural network classification model HLFormer is constructed, which includes a first feature extraction stage (Stage 1), a second feature extraction stage (Stage 2), and a classifier connected sequentially. The EEG signal is input into the first feature extraction stage, and the initial spatiotemporal feature is extracted using a pulse spatiotemporal encoder. The low-dimensional global feature is then filtered using a lightweight pulse self-attention operator (Lightweight SSA), and the first-stage pulse features are output. The first-stage pulse features are input into the second feature extraction stage, the dimensionality is expanded using the pulse vector embedding module, and long-range dependency modeling is performed using the standard pulse self-attention operator SSA, outputting the second-stage pulse features. The second-stage pulse features are input into the classifier, and the classification result is output. The lightweight impulse self-attention operator includes parallel Token-dimensional self-attention branches and Feature-dimensional self-attention branches: The token-dimensional self-attention branch is used to calculate the attention mask in the time dimension to filter moments containing key information; The Feature dimension self-attention branch is used to calculate the attention mask of the feature dimension and to filter the feature dimensions with discriminative power. The mask results of the two branches are added together and then passed through a spiking neuron to emit a pulse sequence, thus obtaining the output of a lightweight spiking self-attention operator.

[0007] The specific calculation process of the lightweight pulse self-attention operator is as follows: Define the input as Token-dimensional self-attention query matrices are generated using linear and LIF neurons, respectively. Bond matrix And the query matrix of self-attention in the Feature dimension. Bond matrix ; right Summing in the Token dimension yields... ,right Summing along the Feature dimension yields... ; Sum result , Inputting each LIF neuron into it yields a pulse mask. and ; Perform a token-level masking operation on the token-level impulse mask and the corresponding key matrix to obtain the output of the token-level self-attention branch. The specific calculation is as follows: ; Perform a feature-level masking operation on the impulse mask and the corresponding key matrix in the feature dimension to obtain the output of the feature-level self-attention branch. The specific calculation is as follows: ; The final output O of the lightweight impulse self-attention operator is: Here, LIF represents LIF neuron operation.

[0008] Furthermore, the classifier includes time step dimension accumulation, feature dimension accumulation, and a fully connected layer. By accumulating pulse signals in the time step dimension, the dynamic pulse sequence is transformed into a feature vector. After accumulating pulse signals in the feature dimension, the classification probability is calculated using the fully connected layer, and the classification result is output.

[0009] Furthermore, the pulse spatiotemporal encoder includes a temporal convolution, a spatial convolution, a batch normalization, a max pooling layer, a copy operation, and a LIF neuron connected in sequence.

[0010] Secondly, the present invention provides an EEG signal classification system based on a hierarchical pulse self-attention mechanism, wherein the system performs the method comprising: The EEG signal acquisition module is used to acquire raw EEG signals; The data augmentation module is used to generate new EEG data from the EEG signals obtained by the EEG signal acquisition module through time-domain segmentation and reconstruction, and to build a dataset. The HLFormer, a hierarchical spiking neural network classification model, is used to classify EEG signals from EEG data. The display module is used to show the processing results of each module.

[0011] Furthermore, the specific processing procedure of the data amplification module is as follows: for any two EEG signal test segments Trial 1 and Trial 2 of the same category and the same individual, they are respectively divided into several segments at the same time interval. Then, while ensuring that the original time order remains unchanged, they are randomly spliced ​​together. The number of segments spliced ​​together is consistent with the number of test segments that were divided.

[0012] Compared with the prior art, the beneficial effects of the present invention are: This invention presents a hierarchical pulse self-attention mechanism-based EEG signal classification method for EEG signal classification and application in brain-computer interface systems. This invention uses a lightweight pulse self-attention operator, Lightweight SSA, for hierarchical processing to balance energy consumption and model complexity.

[0013] This invention constructs a hierarchical spiking neural network classification model (HLFormer), comprising two feature extraction stages: The first stage employs a spiking spatiotemporal encoder combined with a lightweight spiking self-attention operator (LightweightSSA) to extract spatiotemporal features and perform global rhythm filtering on EEG signals at a lower feature dimension. A masking mechanism is used to perform dual attention calculations in both the time and feature domains, reducing computational complexity. The second stage utilizes a spiking vector embedding module (SPE) to extend the features to a high-dimensional space and combines this with the standard spiking self-attention operator (SSA) for refined long-range dependency modeling. This invention effectively captures the global temporal dependencies of EEG signals while maintaining low energy consumption, significantly improving the classification accuracy of EEG tasks such as motor imagery.

[0014] In this invention, the Lightweight SSA operator can perform attention calculations in both the Token and Feature dimensions, which can significantly reduce the energy consumption of spiking neural networks. Attached Figure Description

[0015] Figure 1 This is a schematic diagram of the time-domain data enhancement process in this invention.

[0016] Figure 2 This is an overall framework diagram of HLFormer in this invention, showing the connection relationship between Stage 1, Stage 2 and the classifier.

[0017] Figure 3 This is a schematic diagram of the Lightweight SSA, a lightweight pulse self-attention operator proposed in this invention, illustrating the parallel dual-branch structure of Token Attention and Feature Attention, as well as the mask calculation process.

[0018] Figure 4 This is a comparison chart of the test accuracy of the HLFormer model of this invention with other existing SNN models on the BCI IV-2a dataset.

[0019] Figure 5 This is a comparison chart of the test accuracy of the HLFormer model of this invention with other existing SNN models on the BCI IV-2b dataset. Detailed Implementation

[0020] The present invention will be further explained below with reference to the embodiments and accompanying drawings, but this is not intended to limit the scope of protection of this application.

[0021] This invention relates to a brainwave signal classification method based on a hierarchical pulse self-attention mechanism, comprising the following steps: S1: Acquire raw EEG signals and perform data augmentation, then divide them into training and testing sets; S2: Construct a hierarchical spiking neural network classification model (HLFormer), which includes a first feature extraction stage (Stage 1), a second feature extraction stage (Stage 2), and a classifier connected in sequence; S3: Input the EEG signal into the first feature extraction stage, use the pulse spatiotemporal encoder to perform preliminary spatiotemporal feature extraction, and use the Lightweight SSA pulse self-attention operator to perform low-dimensional global feature filtering, and output the first stage pulse features; The lightweight impulse self-attention operator includes parallel Token-dimensional self-attention branches and Feature-dimensional self-attention branches: The token-dimensional self-attention branch is used to calculate the attention mask in the time dimension to filter moments containing key information; The Feature dimension self-attention branch is used to calculate the attention mask of the feature dimension and to filter the feature dimensions with discriminative power. The mask results of the two branches are added together and then passed through a spiking neuron to emit a pulse sequence, thus obtaining the output of a lightweight spiking self-attention operator. S4: Input the first-stage impulse features into the second feature extraction stage, expand the dimensions using the impulse vector embedding module (SPE), and perform long-range dependency modeling using the standard impulse self-attention operator (SSA) to output the second-stage impulse features; S5: Input the second-stage pulse features into the classifier and output the classification result through a fully connected layer; S6: Train the model using the training set and verify the model performance using the test set, then use the trained model to classify EEG signals.

[0022] Furthermore, the specific calculation process of the lightweight pulse self-attention operator (see...) Figure 3 )as follows: Define the input as Token-dimensional self-attention query matrices are generated using linear layers and LIF (Spike) neurons, respectively. Bond matrix And the query matrix of self-attention in the Feature dimension. Bond matrix ; right The summation operation on the token dimension yields... ,right Summing along the Feature dimension yields... ; Sum result , Inputting each LIF neuron into it yields a pulse mask. and ; Perform a token-dimensional masking operation on the token-dimensional impulse mask and the corresponding key matrix. ), obtain the output of the self-attention branch in the Token dimension. The specific calculation is as follows: ; Perform a feature-dimensional masking operation on the pulse mask and the corresponding key matrix in the feature dimension. ), obtain the output of the self-attention branch in the Feature dimension. The specific calculation is as follows: ; The final output is: The specific process here is as follows: the mask results of the two branches are added together → the result is activated by LIF neurons → the resulting pulse sequence is used as input to the next module; Here, LIF represents LIF neuron operation.

[0023] Furthermore, the specific processing flow of the first feature extraction stage (Stage 1) is as follows: First, the input signal is converted into low-dimensional pulse characteristics using a pulse space-time encoder (SST). Then, the input is fed into the lightweight impulse self-attention operator, and the output of the lightweight impulse self-attention operator is added using a residual connection. Finally, the pulse characteristics of the first stage are output through a pulse multilayer perceptron (SMLP) and the residual connection is used again.

[0024] Furthermore, the specific processing flow of the second feature extraction stage (Stage 2) is as follows: First, the feature dimension is expanded to the target dimension through the impulse vector embedding module (SPE), which includes convolutional layers, batch normalization layers, max pooling layers, and LIF neurons; Then it enters the standard pulse self-attention module (SSA), and uses residual connections to add the input to the SSA output; Finally, the pulse multilayer perceptron (SMLP) is used to output the second-stage pulse features (discriminative features) by utilizing residual connections again.

[0025] Furthermore, the classifier accumulates pulse signals along the time step dimension, transforming the dynamic pulse sequence into a feature vector, and then calculates the classification probability by accumulating pulse signals along the feature dimension and passing them through a fully connected layer.

[0026] Example 1 This embodiment uses a hierarchical pulse self-attention mechanism-based EEG signal classification method, which includes the following steps: S1: The time-consuming acquisition of EEG signals limits the size of the available dataset, making the model highly susceptible to overfitting during training. Data augmentation methods are employed to provide the model with sufficient samples, generating new data through temporal segmentation and reconstruction. Figure 1 This is a schematic diagram of the time-domain data augmentation method used in this invention to expand the original dataset.

[0027] For any two EEG signal test segments Trial 1 and Trial 2 of the same category and the same individual, they are decomposed into... and Then, while keeping the original time sequence unchanged, the pieces are randomly spliced ​​together, that is... .

[0028] S2: Figure 2 This paper presents the overall framework diagram of the hierarchical spiking neural network classification model HLFormer based on the present invention, which includes a first feature extraction stage (Stage 1), a second feature extraction stage (Stage 2), and a classifier connected sequentially. For the input... Stage 1 can be described as: SST stands for Pulse Spatiotemporal Encoder. It is a lightweight impulse self-attention operator, and SMLP is an impulse multilayer perceptron. This is an intermediate form of the characteristic matrix in Stage 1. It is the output feature matrix of Stage 1.

[0029] Subsequently, in Stage 2, the feature dimension is expanded to the full feature space using the impulse vector embedding module (SPE). Furthermore, SSA (Spiritual Assistive Modeling) is used for refined long-range dependency modeling, ensuring that the attention mechanism can focus on highly abstract physiological patterns and avoiding the feature degradation risk that single-layer models are prone to when processing long-sequence high-dimensional data. After dynamic calibration of two levels of attention, the impulse representation transmitted to the classifier has a high signal-to-noise ratio and class separability, thus maintaining excellent generalization performance even in low-sample-volume environments. For input Stage 2 can be described as: The structure of SPE is Conv→BN→MP→LIF. This is an intermediate form of the characteristic matrix in Stage 2. It is the output feature matrix of Stage 2.

[0030] O2 is then transmitted to the classifier, which ultimately outputs the classification result.

[0031] Furthermore, the pulse spatiotemporal encoder SST in the first feature extraction stage can be described as:

[0032]

[0033]

[0034]

[0035]

[0036] in, X1 is the output of the intermediate layer of the pulse-space-time encoder SST; X2 is the output pulse sequence of the pulse-space-time encoder; LIF is the spiking neuron layer; It is the time step. It is the feature extraction dimension. It refers to the number of electrodes for EEG signals. It represents the sequence length of the EEG signal in the time dimension. Repest indicates that the data is copied in the T dimension. TemporalConv indicates that the input is convolved in the temporal dimension. SpatialConv indicates spatial convolution. BatchNorm indicates batch normalization. MaxPool indicates max pooling operation.

[0037] The encoded features are then input into a lightweight impulse self-attention operator (Lightweight SSA) for low-dimensional global feature filtering. Figure 3 The diagram illustrates the structure of a lightweight impulsive self-attention operator (SA), a lightweight self-attention mechanism operating in both the time and feature dimensions. This achieves lower energy consumption for long-range dependency modeling and reduces computational complexity. Lightweight SSA consists of two independent self-attention branches: token-level self-attention and feature-level self-attention. For a time step of... The number of tokens is And the feature dimension is Input Lightweight SSA can be described as:

[0038]

[0039]

[0040]

[0041]

[0042] in, , , and These are the Query and Key for Token Attention and Feature Attention, respectively, and are computed using different linear layers and LIF neuron layers. yes The sum of all Feature dimensions of each Token is obtained by adding them together. yes The sum of all token dimensions for each Feature; and They are and Pulse mask after passing through LIF neurons; yes and The attention matrix obtained by performing a token-level masking operation. yes and The attention matrix obtained by performing a feature dimension masking operation. It is the output pulse matrix of the Lightweight SSA.

[0043] The pulse vector embedding module in the second feature extraction stage consists of convolutional layers, batch normalization layers, max pooling layers, and LIF neuron layers, which increases the feature dimension to a deeper target dimension. Subsequently, the standard pulse self-attention operator (SSA) is used for long-range dependency modeling to output the second-stage pulse features.

[0044] The second-stage pulse features are input into the classifier, which accumulates the time step dimension and feature dimension of the pulse features respectively, and then outputs the classification result after passing through a fully connected layer.

[0045] To verify the effectiveness of the method of the present invention, training and testing were conducted in the following experimental environment: 1. Experimental Environment and Setup: The model was implemented using the PyTorch library in a Python 3.9 environment, with an NVIDIA A30 GPU. The spiking neurons used were LIF neurons provided in the SpikingJelly framework. Individual-dependent experiments were conducted on several representative public datasets, with each individual undergoing 10 training iterations, each lasting 500 epochs. The model was trained using the Adam optimizer with a learning rate of 0.0002. It is 0.5. The value is 0.999. The model uses a two-layer hierarchical architecture. The first layer, SST, increases the Feature dimension from 1 to 20, and the Token dimension from... Down to The second-layer SPE increases the Feature dimension from 20 to 40, and the Token dimension from... Down to .

[0046] 2. Experimental verification: Experimental validation was performed on the publicly available motion imagery datasets BCI IV-2a and BCI IV-2b.

[0047] (1) Dataset description BCI IV-2a is currently the most widely used motor imagery dataset, containing four motor imagery tasks: left hand, right hand, both feet, and tongue. Experimental data came from nine subjects, each participating in two data collections (training and testing), with each collection containing 288 trials. The experiment used a 10-20 system with 22 Ag / AgCl electrodes (plus 3 unipolar EOG channels for noise reduction), with an electrode spacing of 3.5 cm and a sampling rate of 250 Hz.

[0048] Unlike BCI IV-2a, BCI IV-2b focuses more on binary classification tasks and introduces an online feedback mechanism. BCIIV-2b includes two motor imagery tasks: left hand and right hand. Experimental data also came from 9 subjects. A unique feature of BCI IV-2b is that the first three acquisitions were without feedback, while the last two acquisitions included visual feedback, simulating a real BCI control scenario. The experiment used only three EEG electrode channels: C3, C2, and C4, located in the core of the motor cortex.

[0049] (2) Model The model used in this experiment is the HLFormer model proposed in this invention, which is implemented using a hierarchical architecture and a spurious attention mechanism.

[0050] (3) Comparison Algorithm The HLFormer of this invention was compared with five artificial neural network methods (ANN) and three spiking neural network algorithms (SNN). These algorithms are FBCSP, ConvNet, EEGNet, DRDA, Conformer, SCNet, Spiking Conformer, and LENet. They share the same focus as the HLFormer of this invention: to efficiently encode and decode EEG signals, and include pure convolutional architectures and attention architectures.

[0051] (4) Experimental results and analysis The comparative experimental results on the two datasets BCI IV-2a and BCI IV-2b are as follows: Table 1 shows the experimental results of HLFormer of this invention and other comparative algorithms on the BCI IV-2a dataset. Conformer adopts a general EEG model that first encodes and then performs global modeling, introducing the Transformer architecture from the fields of natural language and vision to the field of EEG signal processing. This makes it possible to perform long-range dependency modeling of EEG signals within a global time window. Conformer, with its hybrid architecture of CNN and Transformer, performs best in the field of artificial neural networks.

[0052] In the field of spiking neural networks, Spiking Conformer, by combining the Conformer architecture with spiking self-attention operators, significantly reduces the computational energy consumption of the Conformer architecture. However, the accuracy drops considerably (by about 16 percentage points). This is because it does not consider the limited information representation ability of spiking neurons. Directly replacing neurons in artificial neural network models with spiking neurons (such as LIF) is the most common model transformation method. However, this often leads to a sharp drop in performance due to the 0 / 1 characteristics of spiking, which in turn significantly reduces computational energy consumption.

[0053] The HLFormer proposed in this invention employs a hierarchical architecture and a lightweight spurious self-attention operator. On one hand, the hierarchical architecture reduces the high energy consumption of single-layer encoding; on the other hand, it enables the model to perform global temporal segment attention calculations at an earlier stage, thus solving the problem of long-range dependency of EEG signals. Furthermore, the lightweight spurious self-attention operator of this invention possesses richer attention calculation capabilities, while its computational and spatial complexity is lower than that of SSA, resulting in lower energy consumption compared to SSA.

[0054] Table 1. Comparative experiments of the HLFormer model on BCI IV-2a (%)

[0055] Table 2 shows the experimental results of the HLFormer model of this invention and other comparison algorithms on the BCI IV-2b dataset. The experimental results show that the HLFormer model also performs well on binary classification tasks.

[0056] Table 2 Comparative experiments of the HLFormer model on BCI IV-2b (%)

[0057] Kappa is a metric that measures the accuracy of a model's predictions, ranging from -1 to 1. A higher Kappa value indicates a more accurate prediction.

[0058] Table 3 shows the energy consumption performance of several ANN models and directly trainable SNN models compared on the BCI IV-2b dataset. Experiments were conducted for two configurations with 20 and 40 feature dimensions. Experimental results show that, with the same feature dimensions, this invention, compared to the direct introduction of the Spiking Conformer, more effectively incorporates the attention mechanism, maintaining superior performance in terms of accuracy, energy consumption, and parameter count. This invention benefits from the advantages of its hierarchical architecture; the introduction of the attention mechanism does not lead to a doubling of model parameters, and with the support of sparse impulse features, the increase in model energy consumption is minimal.

[0059] Table 3 Energy consumption performance of the model on BCI IV-2b

[0060] Any aspects not covered in this invention are applicable to existing technologies.

Claims

1. A layered pulse self-attention mechanism-based electroencephalogram signal classification method, characterized in that, The method includes the following: Acquire electroencephalogram (EEG) signal data; A hierarchical spiking neural network classification model HLFormer is constructed, which includes a first feature extraction stage (Stage 1), a second feature extraction stage (Stage 2), and a classifier connected in sequence. The EEG signal is input into the first feature extraction stage, and the initial spatiotemporal feature is extracted using a pulse spatiotemporal encoder. The low-dimensional global feature is then filtered using a lightweight pulse self-attention operator (Lightweight SSA), and the first-stage pulse features are output. The first-stage pulse features are input into the second feature extraction stage, the dimensionality is expanded using the pulse vector embedding module, and long-range dependency modeling is performed using the standard pulse self-attention operator SSA, outputting the second-stage pulse features. The second-stage pulse features are input into the classifier, and the classification result is output. The lightweight impulse self-attention operator includes parallel Token-dimensional self-attention branches and Feature-dimensional self-attention branches: The token-dimensional self-attention branch is used to calculate the attention mask in the time dimension to filter moments containing key information; The Feature dimension self-attention branch is used to calculate the attention mask of the feature dimension and to filter the feature dimensions with discriminative power. The mask results of the two branches are added together and then passed through a spiking neuron to emit a pulse sequence, thus obtaining the output of a lightweight spiking self-attention operator.

2. The method of claim 1, wherein, The specific calculation process of the lightweight pulse self-attention operator is as follows: Define the input as Token-dimensional self-attention query matrices are generated using linear and LIF neurons, respectively. Bond matrix And the query matrix of self-attention in the Feature dimension. Bond matrix ; On Summing up on Token dimension gets , on Summing up on Feature dimension gets ; sum the results , input the LIF neurons respectively, respectively get pulse masks and ; performing a token dimension mask operation on the pulse mask of the token dimension and the corresponding key matrix to obtain an output of the token dimension self-attention branch , and the specific calculation is: ; performing a Feature dimension mask operation on the pulse mask of the Feature dimension and the corresponding key matrix to obtain an output of the Feature dimension self-attention branch , and the specific calculation is ; The final output O of the lightweight pulse self-attention operator is: ​ Here, LIF represents LIF neuron operation.

3. The method of claim 1, wherein, The classifier includes time step dimension accumulation, feature dimension accumulation, and a fully connected layer. By accumulating pulse signals in the time step dimension, the dynamic pulse sequence is transformed into a feature vector. After accumulating pulse signals in the feature dimension, the fully connected layer is used to calculate the classification probability and output the classification result.

4. The method of claim 1, wherein, The pulse spatiotemporal encoder comprises temporal convolution, spatial convolution, batch normalization, max pooling layer, copy operation, and LIF neuron connected in sequence.

5. A layered pulse self-attention mechanism-based electroencephalogram signal classification system, characterized in that, The system performs the method according to any one of claims 1-4, including: The EEG signal acquisition module is used to acquire raw EEG signals; The data augmentation module is used to generate new EEG data from the EEG signals obtained by the EEG signal acquisition module through time-domain segmentation and reconstruction, and to build a dataset. The HLFormer, a hierarchical spiking neural network classification model, is used to classify EEG signals from EEG data. The display module is used to show the processing results of each module.

6. The system of claim 5, wherein, The specific processing procedure of the data amplification module is as follows: For any two EEG signal test segments Trial 1 and Trial 2 of the same category and the same individual, they are respectively divided into several segments at the same time interval. Then, while ensuring that the original time order remains unchanged, they are randomly spliced ​​together. The number of segments spliced ​​together is consistent with the number of test segments that were divided.

7. The system of claim 5, wherein, The pulse neural network classification model HLFormer based on a hierarchical architecture is trained by using a public motor imagery dataset, and electroencephalogram signal classification is performed by using the trained model, so that the effects of precision and energy consumption can be considered, and the parameter quantity is low.