EEG signal feature extraction method, system and device based on multi-scale local attention mechanism

By introducing a multi-scale local attention mechanism into the Transformer model, the problem of insufficient local dynamic perception in EEG signal processing by the traditional Transformer is solved, realizing refined cognitive state recognition of EEG signals and improving the accuracy of the model.

CN121694768BActive Publication Date: 2026-07-21INNER MONGOLIA UNIV OF TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INNER MONGOLIA UNIV OF TECH
Filing Date
2025-12-15
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Traditional Transformers ignore multi-frequency, multi-scale, and strong locality features when processing EEG signals, resulting in the loss of local pattern information and difficulty in capturing short-term cognitive fluctuations. Existing methods have problems such as scale uniformity, lack of frequency band differentiation, and insufficient perception of local dynamics in multi-band modeling of EEG signals.

Method used

A Transformer model based on a multi-scale local attention mechanism is adopted. By introducing a multi-scale local attention mechanism, feature extraction and attention calculation are performed on each frequency band of the EEG signal. Different convolution scales are used to adapt to the temporal dynamic features of each frequency band, and a mapping structure from frequency band to attention head is constructed.

Benefits of technology

It enhances the model's local perception capabilities and cross-frequency band feature collaborative modeling capabilities, improves the accuracy of EEG signals, and can take into account the temporal feature differences of different frequency components, thereby improving the accuracy of cognitive state recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121694768B_ABST
    Figure CN121694768B_ABST
Patent Text Reader

Abstract

The application discloses an EEG signal feature extraction method, system and device based on a multi-scale local attention mechanism, relates to the field of electroencephalogram signal processing, and comprises the following steps: inputting a multi-channel EEG signal segment into an EEG signal feature extraction model to obtain a corresponding risk cognitive level; the EEG signal feature extraction model is obtained by training a MALM-based Transformer model by using a training sample set, wherein the model comprises a frequency band embedding module, a local attention encoding module, a cross-frequency band fusion module and a decoding classification module which are sequentially arranged, a multi-scale local attention mechanism is introduced into the local attention encoding module, feature extraction and attention calculation are performed on each frequency band of the multi-channel EEG signal segment respectively, and different convolution scales are used to adapt to the time dynamic characteristics of each frequency band. The application can take into account the time characteristic differences of different frequency components and improve accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electroencephalogram (EEG) signal processing, and in particular to a method, system, and device for extracting EEG signal features based on a multi-scale local attention mechanism. Background Technology

[0002] Traditional Transformers rely on global attention to model the relationships between arbitrary positions in a sequence, but they have significant limitations when processing non-stationary temporal data such as electroencephalograms (EEGs). EEGs are characterized by multi-frequency, multi-scale, and strong locality; low-frequency components (such as delta and theta waves) reflect slowly varying cognitive rhythms, while high-frequency components (such as beta and gamma waves) represent instantaneous neural responses. Global attention ignores these temporal differences, easily leading to the loss of local pattern information, thus making it difficult to capture short-term cognitive fluctuations. In short, existing methods for multi-band modeling of EEG signals generally suffer from problems such as scale uniformity, lack of frequency band differentiation, and insufficient perception of local dynamics, making it difficult to simultaneously account for the temporal differences in different frequency components. Summary of the Invention

[0003] The purpose of this application is to provide a method, system, and device for EEG signal feature extraction based on a multi-scale local attention mechanism, which can take into account the temporal feature differences of different frequency components and improve accuracy.

[0004] To achieve the above objectives, this application provides the following solution: Firstly, this application provides a method for EEG signal feature extraction based on a multi-scale local attention mechanism, including: Acquire multi-channel EEG signal segments to be analyzed; The multi-channel EEG signal segment to be analyzed is input into the EEG signal feature extraction model to obtain the corresponding risk perception level; wherein, the EEG signal feature extraction model is obtained by training a MALM-based Transformer model using a training sample set; each training sample in the training sample set includes a multi-channel EEG signal sample and a corresponding risk perception level label; The MALM-based Transformer model includes a frequency band embedding module, a local attention coding module, a cross-frequency band fusion module, and a decoding and classification module arranged sequentially. In the local attention coding module, a multi-scale local attention mechanism is introduced to extract features and calculate attention for each frequency band of the multi-channel EEG signal segment, and different convolution scales are used to adapt to the temporal dynamic features of each frequency band.

[0005] Secondly, this application provides an EEG signal feature extraction system based on a multi-scale local attention mechanism, which applies an EEG signal feature extraction method based on a multi-scale local attention mechanism, including: The data acquisition module is used to acquire multi-channel EEG signal segments to be analyzed. The model building and application module is used to input the multi-channel EEG signal segment to be analyzed into the EEG signal feature extraction model to obtain the corresponding risk perception level; wherein, the EEG signal feature extraction model is obtained by training a MALM-based Transformer model using a training sample set; each training sample in the training sample set includes a multi-channel EEG signal sample and a corresponding risk perception level label; The MALM-based Transformer model includes a frequency band embedding module, a local attention coding module, a cross-frequency band fusion module, and a decoding and classification module arranged sequentially. In the local attention coding module, a multi-scale local attention mechanism is introduced to extract features and calculate attention for each frequency band of the multi-channel EEG signal segment, and different convolution scales are used to adapt to the temporal dynamic features of each frequency band.

[0006] Thirdly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement an EEG signal feature extraction method based on a multi-scale local attention mechanism.

[0007] According to the specific embodiments provided in this application, the following technical effects are disclosed: The EEG signal feature extraction model used in this application is obtained by training a Transformer model based on MALM (Multi-scale Locality-aware Attention Mechanism) using a training sample set. This model introduces a multi-scale local attention mechanism, performing feature extraction and attention calculation on each frequency band of the multi-channel EEG signal segment within the Transformer structure, and using different convolution scales to adapt to the temporal dynamic features of each frequency band. This mechanism uses each typical frequency band of EEG as an independent attention head for parallel modeling, thereby enhancing the model's local perception ability and cross-frequency band feature collaborative modeling ability while maintaining temporal causality, providing a new technical path for refined cognitive state recognition of EEG signals. Furthermore, after training is complete, directly inputting the multi-channel EEG signal segment to be analyzed yields the corresponding risk cognition level, taking into account the temporal feature differences of different frequency components and improving accuracy. Attached Figure Description

[0008] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0009] Figure 1 This is an application environment diagram of the EEG signal feature extraction method based on multi-scale local attention mechanism in one embodiment of this application.

[0010] Figure 2 This is a flowchart illustrating an EEG signal feature extraction method based on a multi-scale local attention mechanism in one embodiment of this application.

[0011] Figure 3 is a schematic diagram of the timing characteristics of EEG signals; where (a) is a schematic diagram of the instantaneous fluctuation of EEG signals, and (b) is a schematic diagram of EEG signals at different frequencies.

[0012] Figure 4 shows the confusion matrix under different distraction states; where (a) is the confusion matrix, (b) is the low distraction state, (c) is the medium distraction state, and (d) is the high distraction state.

[0013] Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0014] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0015] This application constructs a multi-scale local attention mechanism, realizing the mapping relationship of attention mechanism on the time and frequency scales, effectively making up for the shortcomings of existing methods.

[0016] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0017] The EEG signal feature extraction method based on a multi-scale local attention mechanism provided in this application can be applied to, for example... Figure 1In the application environment shown, terminal 101 communicates with server 102 via a network. A data storage system can store the data that server 102 needs to process. The data storage system can be set up independently, integrated into server 102, or placed in the cloud or on another server. Terminal 101 can send multi-channel EEG signal segments to be analyzed to server 102. After receiving the data, server 102 inputs it into the EEG signal feature extraction model to obtain the corresponding risk perception level. Server 102 can then feed back the obtained risk perception level to terminal 101. Furthermore, in some embodiments, the EEG signal feature extraction method based on a multi-scale local attention mechanism can also be implemented independently by server 102 or terminal 101.

[0018] The terminal 101 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. The server 102 can be implemented using a standalone server or a server cluster consisting of multiple servers, or it can be a cloud server.

[0019] In one exemplary embodiment, such as Figure 2 As shown, a method for EEG signal feature extraction based on a multi-scale local attention mechanism is provided. This method is executed by a computer device, specifically by a terminal or server alone, or by both a terminal and a server. In this embodiment, the method is applied to... Figure 1 Taking server 102 as an example, the explanation includes the following steps 201 to 202.

[0020] Step 201: Acquire the multi-channel EEG signal segment to be analyzed.

[0021] In a specific application, a multi-channel EEG signal segment to be analyzed is acquired, including: (11) In the application of driving braking, the moment when the target person presses the brake pedal is taken as the event moment, and the brain activity signals detected by multiple electrode channels within a preset time period starting from the event moment are collected to obtain the original multi-channel EEG signal segment.

[0022] The process involves acquiring raw multi-channel EEG signal fragments using a multi-channel EEG acquisition device. The preferred sampling rate is 500Hz, with a resolution of 24 bits. Electrodes are deployed in multiple brain regions, including the frontal, central, parietal, and occipital regions, according to a 10⁻¹⁰ system, to obtain comprehensive EEG activity data. During the acquisition process, key events (such as the trigger moment of a driving braking action) are used as time markers to ensure that the EEG signals are synchronized with external behavioral data.

[0023] (12) The original multi-channel EEG signal segments are filtered, artifacts are removed, baselines are corrected and normalized to obtain the multi-channel EEG signal segments to be analyzed.

[0024] The acquired raw multi-channel EEG signal segments were input into a computer for preprocessing. Preprocessing included: filtering the signal with a finite impulse response bandpass filter in the range of 0.5 Hz to 45 Hz to remove low-frequency drift and high-frequency electrical noise; and performing baseline correction on each channel to eliminate DC offset. Secondly, the original EEG signal was rereferenced using the Common Average Reference (CAR) method to reduce common-mode interference. To further improve data stability, statistical parameters such as variance, peak-to-peak value, and bandgap energy of each channel were detected, and bad signals were automatically identified and removed. The removed portions were reconstructed using spherical spline interpolation. Subsequently, independent component analysis was used to separate the sources of the preprocessed signal, and automated algorithms (such as ADJUST) were used to identify and remove artifacts related to eye movement, electromyography, and power line interference, preserving pure brain-source signals.

[0025] After artifact removal, a threshold detection is performed on the amplitude of all channel signals. If the potential amplitude at any sampling point exceeds ±100... At that time, the corresponding segments are marked as contaminated regions and removed or repaired by interpolation. After denoising, using the trigger time of the behavioral event as a reference point, a target time window is extracted from the cleaned continuous signal, resulting in a length of... The EEG segments were then processed. Finally, the EEG segments of each channel were zero-mean or unit variance normalized to reduce individual differences, and organized into a three-dimensional tensor structure (B, T, C), where B is the batch size, T is the time step, and C is the number of channels, which served as the input for subsequent model processing.

[0026] As shown in Figures 3(a) and (b), when the driver perceives the vehicle in front braking, the amplitude of the Pz channel suddenly increases, the FP2 channel drops sharply, while the FP1 channel shows a gradual upward trend. These significant local temporal changes reflect the dynamic fluctuations in the driver's cognitive alertness level and should therefore not be ignored in driver state detection.

[0027] To address the non-stationary nature of EEG signals in the time domain and the insufficient local context awareness in traditional Transformers, this application introduces a multi-scale local attention mechanism in the feature encoding stage. Unlike the multi-head attention mechanism of conventional Transformers, MLAM utilizes various typical frequency bands of EEG signals (… , , , , , , , Each frequency band signal corresponds to an attention head, forming a "frequency band to attention head mapping" structure. Feature extraction and attention computation are performed in an independent subspace for each frequency band signal, and different convolution scales are used to adapt to the temporal dynamic features of each frequency band, as detailed in step 202 below.

[0028] Step 202: Input the multi-channel EEG signal segment to be analyzed into the EEG signal feature extraction model to obtain the corresponding risk perception level; wherein, the risk perception level includes three probabilities of low, medium and high distraction level; the EEG signal feature extraction model is obtained by training a MALM-based Transformer model using a training sample set; each training sample in the training sample set includes a multi-channel EEG signal sample and a corresponding risk perception level label.

[0029] The MALM-based Transformer model comprises a frequency band embedding module, a local attention coding module, a cross-frequency band fusion module, and a decoding and classification module arranged sequentially. The entire network is built according to the approach of "frequency band embedding—local attention coding—cross-frequency band fusion—classification and decoding," realizing multi-scale mapping from raw time-series signals to high-level semantic features. The local attention coding module introduces a multi-scale local attention mechanism to extract features and calculate attention for each frequency band of the multi-channel EEG signal segment separately, using different convolution scales to adapt to the temporal dynamic features of each frequency band.

[0030] The frequency band embedding module is used to: decompose the multi-channel EEG signal segment to obtain multiple EEG frequency band feature sequences, respectively. , , ..., , Where h is the number of frequency bands; each EEG frequency band feature is mapped to the latent representation space through a linear transformation to obtain the corresponding embedded frequency band feature. The calculation formula for the frequency band embedding module is: .

[0031] in, For the embedded frequency band features corresponding to the i-th EEG frequency band feature, This represents the i-th EEG band characteristic of a multi-channel EEG signal segment. This is the frequency band mapping matrix corresponding to the i-th EEG frequency band feature. This is the temporal position encoding corresponding to the i-th EEG frequency band feature; Let be the dimension of the potential representation space.

[0032] The local attention encoding module includes multiple attention heads, convolutional units, attention units, and feedforward fully connected units; wherein, considering the scale dependence of different EEG frequency bands in time dynamics, different convolutional kernel sizes are set between each attention head. It follows the design principle of "larger convolution kernels for low frequency and smaller convolution kernels for high frequency".

[0033] The attention head is used to extract and map the embedded frequency band features output by the frequency band embedding module to obtain initial attention features; the convolutional unit is used to combine the convolutional kernel size A one-dimensional causal convolution is introduced into the initial attention features along the time dimension to generate the attention query vector. Key vector AND value vector This allows for the simultaneous consideration of temporal causality and local contextual relationships when calculating attention; the attention unit is used based on the attention query vector. Key vector AND value vector The local attention result is obtained; the feedforward fully connected unit is used to process the local attention result to obtain the final attention feature.

[0034] The calculation formula for the convolutional unit is: .

[0035] .

[0036] .

[0037] in, Indicates the kernel size One-dimensional causal convolution with a stride of 1; value vector Use 1×1 convolution to reduce computational overhead; , and The feature obtained after embedding and position coding of the i-th EEG frequency band feature is: t represents the time step, and j represents the coding layer index.

[0038] The calculation formula for the attention unit is: ; in, For the softmax function, The local attention result corresponding to the i-th EEG band feature, Let K be the dimension of the matrix in the attention mechanism; After obtaining the local attention results, to maintain stable feature flow, this application adds residual connections, layer normalization, and feedforward networks to each frequency band sub-layer to form a complete local coding unit, namely the feedforward fully connected unit. The calculation formula is as follows: .

[0039] .

[0040] in, This represents the intermediate feature of the i-th EEG band in the feedforward fully connected unit. This is a feedforward sublayer, containing two fully connected mapping layers; For attention features, For normalization processing, For the local attention results corresponding to the i-th EEG frequency band feature, It is a feedforward fully connected layer.

[0041] After local attention coding is completed in all frequency bands, the cross-band fusion module concatenates the multiple attention features output by the local attention coding module along the channel dimension, and then obtains the cross-band comprehensive features through encoding processing; the calculation formula of the cross-band fusion module is as follows: .

[0042] .

[0043] in, For the cross-band synthesis features of the j-th encoder layer, For the attention features corresponding to the first EEG band feature, To correspond to the attention features of the second EEG band, The attention feature corresponding to the h-th EEG band feature; The projection matrix is ​​a linear transformation. It is a feedforward fully connected layer. Let j be the output matrix of the j-th encoder layer. This is for normalization purposes.

[0044] The output after encoding processing in the cross-band fusion module is .right Average pooling is performed to aggregate the EEG time-series features into a single global feature vector. : .

[0045] The decoding and classification module is used to convert the cross-band integrated features into a fixed-dimensional representation. The decoding and classification module comprises L fully connected layers connected sequentially, and the calculation formula is as follows: .

[0046] .

[0047] .

[0048] in, For the first L The weights of each fully connected layer For the first L- The bias of a fully connected layer; The weights of the first fully connected layer. This is the bias for the first fully connected layer; The weights of the second fully connected layer. This is the bias for the second fully connected layer; The ReLU function is used; a single global feature vector Z is used as the input to the fully connected layer. This is the output of the first fully connected layer. This is the output of the second fully connected layer. This is the output of the Lth fully connected layer.

[0049] The output of the decoding and classification module is: ;in, The weight matrix for the decoding and classification module. The bias matrix for the decoding and classification module. This represents the number of categories.

[0050] During the training phase, high-performance computing equipment was used for model training. Training hardware included a workstation equipped with an NVIDIA RTX 5090 graphics card, an Intel i9 series CPU, 128 GB of memory, and an Ubuntu operating system. All deep learning models were implemented in the PyTorch framework, employing GPU parallel computing to accelerate backpropagation and parameter optimization. EEG signals were filtered, artifact removed, baseline corrected, and normalized before being processed according to... (0.5–4 Hz) (4–8 Hz) (8–10 Hz) (10–13 Hz) (13–20 Hz) (20–30 Hz) (30–40 Hz) and The model is decomposed into eight typical frequency bands (>40 Hz). Each band signal is linearly mapped and position-encoded before being input into a multi-layer MLAM-Transformer encoder. Finally, a Softmax layer outputs three probabilities (low, medium, and high) of the driver's distraction level. Model training uses a cross-entropy loss function and the Adam optimization algorithm to update parameters, with a learning rate set to 1×10⁻⁶. -4 The batch size was 128, and the iterations were performed for 500 rounds. After training, the optimal weight file and standardized parameters were saved. Key hyperparameters are shown in Table 1.

[0051] Table 1

[0052] As shown in Figure 4, in a state of moderate distraction Nine false negatives were observed, indicating that the model employed a more conservative strategy in predicting this state. While this strategy reduced the number of false positives, it also resulted in a higher number of false negatives. The samples were missed. Figure 4(a) shows that 9 of them were missed. The sample was misclassified as This is the main reason for the decline in recall rates. Overall, the proposed model performs satisfactorily in detecting driver cognitive alertness, achieving an overall accuracy of 0.9325.

[0053] Based on the same inventive concept, this application also provides a system. The solution provided by this system is similar to the solution described in the above method. Therefore, the specific limitations of one or more system embodiments provided below can be found in the limitations of the method above, and will not be repeated here.

[0054] In an exemplary embodiment, an EEG signal feature extraction system based on a multi-scale local attention mechanism is provided, which applies the above-described EEG signal feature extraction method based on a multi-scale local attention mechanism. The system includes: The data acquisition module is used to acquire multi-channel EEG signal segments to be analyzed.

[0055] The model building and application module is used to input the multi-channel EEG signal segments to be analyzed into the EEG signal feature extraction model to obtain the corresponding risk perception level; wherein, the EEG signal feature extraction model is obtained by training a MALM-based Transformer model using a training sample set; each training sample in the training sample set includes a multi-channel EEG signal sample and a corresponding risk perception level label.

[0056] The MALM-based Transformer model includes a frequency band embedding module, a local attention coding module, a cross-frequency band fusion module, and a decoding and classification module arranged sequentially. In the local attention coding module, a multi-scale local attention mechanism is introduced to extract features and calculate attention for each frequency band of the multi-channel EEG signal segment, and different convolution scales are used to adapt to the temporal dynamic features of each frequency band.

[0057] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 5 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and databases. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media to run. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements an EEG signal feature extraction method based on a multi-scale local attention mechanism.

[0058] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0059] In one exemplary embodiment, a computer device is also provided, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps in the above-described method embodiments.

[0060] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0061] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0062] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0063] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

[0064] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0065] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0066] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for extracting EEG signal features based on a multi-scale local attention mechanism, characterized in that, The method includes: Acquire multi-channel EEG signal segments to be analyzed; The multi-channel EEG signal segment to be analyzed is input into the EEG signal feature extraction model to obtain the corresponding risk perception level; wherein, the EEG signal feature extraction model is obtained by training a MLAM-based Transformer model using a training sample set; each training sample in the training sample set includes a multi-channel EEG signal sample and a corresponding risk perception level label; The MLAM-based Transformer model includes a frequency band embedding module, a local attention coding module, a cross-frequency band fusion module, and a decoding and classification module arranged sequentially. In the local attention coding module, a multi-scale local attention mechanism is introduced to extract features and calculate attention for each frequency band of the multi-channel EEG signal segment, and different convolution scales are used to adapt to the temporal dynamic features of each frequency band. The local attention encoding module includes multiple attention heads, convolutional units, attention units, and feedforward fully connected units; wherein, different convolutional kernel sizes are set between the attention heads. The attention head is used to extract and map the embedded frequency band features output by the frequency band embedding module to obtain initial attention features; the convolutional unit is used to combine the convolutional kernel size A one-dimensional causal convolution is introduced into the initial attention features in the time dimension to generate an attention query vector. Key vector AND value vector The attention unit is used to determine the attention query vector. Key vector AND value vector The local attention result is obtained; the feedforward fully connected unit is used to process the local attention result to obtain the final attention feature; The calculation formula for the convolutional unit is: ; ; ; in, Indicates the kernel size One-dimensional causal convolution; For the i-th EEG frequency band feature and the (j-1)-th layer embedded frequency band feature; The calculation formula for the attention unit is: ; in, For the softmax function, For the local attention results corresponding to the i-th EEG frequency band feature, Let K be the dimension of the matrix in the attention mechanism; The calculation formula for the feedforward fully connected unit is: ; ; in, This represents the intermediate feature of the i-th EEG band in the feedforward fully connected unit. This is a feedforward sublayer, containing two fully connected mapping layers; For attention features, For normalization processing, The local attention result corresponding to the i-th EEG band feature, It is a feedforward fully connected layer.

2. The EEG signal feature extraction method based on multi-scale local attention mechanism according to claim 1, characterized in that, The frequency band embedding module is used to: decompose the multi-channel EEG signal segment to obtain multiple EEG frequency band feature sequences; and map each EEG frequency band feature to a latent representation space through a linear transformation to obtain the corresponding embedded frequency band feature. The cross-band fusion module is used to: concatenate multiple attention features output by the local attention encoding module in the channel dimension, and then obtain cross-band integrated features through encoding processing; The decoding and classification module is used to convert the cross-band integrated features into a fixed-dimensional representation.

3. The EEG signal feature extraction method based on multi-scale local attention mechanism according to claim 1, characterized in that, The calculation formula for the frequency band embedding module is as follows: ; in, For the embedded frequency band features corresponding to the i-th EEG frequency band feature, This represents the i-th EEG band characteristic of a multi-channel EEG signal segment. This is the frequency band mapping matrix corresponding to the i-th EEG frequency band feature. This is the temporal position encoding corresponding to the i-th EEG frequency band feature; The calculation formula for the cross-band fusion module is as follows: ; ; Where j is the coding layer index, For the cross-band synthesis characteristics of the j-th encoder layer, For the attention features corresponding to the first EEG band feature, To correspond to the attention features of the second EEG band, The attention feature corresponding to the h-th EEG band feature; The projection matrix is ​​a linear transformation. It is a feedforward fully connected layer. For normalization processing, This represents the normalized cross-band fusion attention feature of the j-th layer.

4. The EEG signal feature extraction method based on multi-scale local attention mechanism according to claim 1, characterized in that, The decoding and classification module comprises L fully connected layers connected sequentially, and the calculation formula is as follows: ; ; ; in, For the first L The weights of each fully connected layer For the first L- The bias of a fully connected layer; The weights of the first fully connected layer. This is the bias for the first fully connected layer; The weights of the second fully connected layer. This is the bias for the second fully connected layer; Z is the ReLU function; Z is the input to the fully connected layer. This is the output of the first fully connected layer. This is the output of the second fully connected layer. This is the output of the Lth fully connected layer; The output of the decoding and classification module is: ; in, The weight matrix for the decoding and classification module. This is the bias matrix for the decoding and classification module.

5. The EEG signal feature extraction method based on multi-scale local attention mechanism according to claim 1, characterized in that, Acquire multi-channel EEG signal segments to be analyzed, including: In the application of driving braking, the moment when the target person presses the brake pedal is taken as the event moment. Brain activity signals detected by multiple electrode channels within a preset time period starting from the event moment are collected to obtain the original multi-channel EEG signal segment. The original multi-channel EEG signal segments are filtered, artifact removed, baseline corrected, and normalized to obtain the multi-channel EEG signal segments to be analyzed.

6. The EEG signal feature extraction method based on multi-scale local attention mechanism according to claim 1, characterized in that, The risk perception level includes three categories of probability: low, medium, and high; The EEG signal feature extraction model is trained using the cross-entropy loss function.

7. A feature extraction system for EEG signals based on a multi-scale local attention mechanism, employing the EEG signal feature extraction method based on a multi-scale local attention mechanism as described in any one of claims 1-6, characterized in that, The system includes: The data acquisition module is used to acquire multi-channel EEG signal segments to be analyzed. The model building and application module is used to input the multi-channel EEG signal segments to be analyzed into the EEG signal feature extraction model to obtain the corresponding risk perception level; wherein, the EEG signal feature extraction model is obtained by training a MLAM-based Transformer model using a training sample set; each training sample in the training sample set includes a multi-channel EEG signal sample and a corresponding risk perception level label; The MLAM-based Transformer model includes a frequency band embedding module, a local attention coding module, a cross-frequency band fusion module, and a decoding and classification module arranged sequentially. In the local attention coding module, a multi-scale local attention mechanism is introduced to extract features and calculate attention for each frequency band of the multi-channel EEG signal segment, and different convolution scales are used to adapt to the temporal dynamic features of each frequency band.

8. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the EEG signal feature extraction method based on a multi-scale local attention mechanism as described in any one of claims 1-6.