Brain electrical signal classification method, keyboard control method, electronic device and medium

Through the fusion of time domain and frequency domain features and the weighted average integration of multi-dimensional attention mechanisms, the problem of low accuracy of EEG signal classification for people with limb dysfunction is solved, and high-accuracy classification of EEG signals of fine motor imagination is achieved.

CN118427694BActive Publication Date: 2024-09-24XIANGJIANG LAB
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410888941.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-09-24
Estimated Expiration
2044-07-04

AI Technical Summary

Technical Problem

In the existing technology, the classification accuracy of the EEG signals of people with limb dysfunction is low, and they are greatly affected by the interference of electromyography and eye movement noise, making it difficult to accurately identify the EEG signals of fine motor imagination.

Method used

The extraction method of time domain spatial domain fusion features and frequency domain spatial domain fusion features is adopted, and feature fusion and weighted average integration are performed through a multi-dimensional attention mechanism to reduce noise interference and highlight features related to the classification task.

Benefits of technology

It improves the accuracy and robustness of EEG signal classification, enhances the expressiveness of classification results, can more effectively identify and process noise interference, and improves the classification accuracy of fine motor imagination EEG signals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118427694B
    Figure CN118427694B
Patent Text Reader

Abstract

The embodiment of the present invention provides an EEG signal classification method, a keyboard control method, an electronic device and a medium, and relates to the field of feature classification technology. The method includes: obtaining an EEG signal data set, the EEG signal data set is obtained by real-time collection of the user's EEG signal; adopting a first feature extraction strategy to extract features from the EEG signal data set to obtain time domain and spatial domain fusion features; adopting a second feature extraction strategy to extract features from the EEG signal data set to obtain frequency domain and spatial domain fusion features; splicing the time domain and spatial domain fusion features and the frequency domain and spatial domain fusion features according to preset dimensions to obtain spliced ​​features, the spliced ​​features include time domain features, frequency domain features and spatial domain features; performing feature fusion on the spliced ​​features through a multi-dimensional attention mechanism, and outputting weighted features; performing weighted average integration on the weighted features, and outputting classification results. Through the present invention, the classification accuracy of EEG signals can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of feature classification, and in particular, to an electroencephalogram signal classification method, a keyboard control method, an electronic device and a medium. Background Art

[0002] Motor Imagery (MI) is a paradigm in brain-computer interface that can spontaneously generate EEG signal data. When imagining different MI tasks, the rhythm in the corresponding motor sensory area of ​​the brain will change. By detecting this change, the subject's intention can be inferred. At present, people with limb dysfunction have many inconveniences in their lives. Therefore, with the rapid development of artificial intelligence, EEG signals can be collected, classified and converted into keyboard input commands to help them chat and socialize online, thereby improving their sense of happiness.

[0003] However, in the existing technology, the classification accuracy of EEG signals is not high because the movements imagined by individuals with limb dysfunction are more detailed and relatively small in amplitude, and because of noise interference such as electromyography and eye movements. Summary of the invention

[0004] The embodiments of the present invention provide an electroencephalogram signal classification method, a keyboard control method, an electronic device and a medium to improve the classification accuracy of electroencephalogram signals.

[0005] According to an embodiment of the present invention, there is provided a method for classifying electroencephalogram signals, comprising:

[0006] Acquire an EEG signal data set, where the EEG signal data set is obtained by collecting EEG signals of a user in real time;

[0007] Using a first feature extraction strategy, extracting features from the EEG signal data set to obtain time-domain and space-domain fusion features;

[0008] Using the second feature extraction strategy, extracting features from the EEG signal data set to obtain frequency domain and spatial domain fusion features;

[0009] The time domain and spatial domain fusion features and the frequency domain and spatial domain fusion features are spliced ​​according to a preset dimension to obtain spliced ​​features, wherein the spliced ​​features include time domain features, frequency domain features and spatial domain features;

[0010] Performing feature fusion on the concatenated features through a multi-dimensional attention mechanism and outputting weighted features;

[0011] The weighted features are weighted averaged and integrated, and a classification result is output.

[0012] In an exemplary embodiment, after acquiring the EEG signal dataset, the following steps are included:

[0013] The EEG signal dataset is amplified to obtain an amplified EEG signal dataset, wherein the size of the amplified EEG signal dataset is n times the size of the original EEG signal dataset, where n is an integer greater than or equal to 2.

[0014] In an exemplary embodiment, the EEG signal data set includes time domain information and spatial domain information, and the second feature extraction strategy is used to extract features from the EEG signal data set to obtain frequency domain and spatial domain fusion features, including:

[0015] Inputting the EEG signal data set into an FFT module to obtain a frequency domain signal data set, wherein the EEG signal is a time domain signal, and the FFT module is used to convert the EEG signal into the frequency domain signal, and the frequency domain signal data set includes frequency domain information;

[0016] Inputting the frequency domain signal data set into a SAC module to obtain a first fusion feature, wherein the SAC module is used to weight and integrate the spatial domain information into the frequency domain information;

[0017] Inputting the first fused feature into the mDAC module to obtain a second weighted fused feature;

[0018] The second weighted fusion feature is input into the SC module to obtain the frequency domain and spatial domain fusion feature.

[0019] In an exemplary embodiment, the first feature extraction strategy is used to extract features from the EEG signal dataset to obtain time domain and space domain fusion features, including:

[0020] The EEG signal data set is sequentially input into the SAC module, the mDAC module and the SC module to obtain the time domain and spatial domain fusion features.

[0021] In an exemplary embodiment, the concatenated features are subjected to feature fusion through a multi-dimensional attention mechanism, and weighted features are output, including:

[0022] Performing a linear transformation on the concatenated features to obtain a plurality of attention heads, each of which includes a Q vector, a K vector, and a V vector;

[0023] For each attention head, performing a dot product calculation on the Q vector and the K vector to obtain a first result, and scaling the first result to obtain an attention distribution of each attention head, where the attention distribution is used to characterize the similarity of the attention heads;

[0024] Multiply the attention distribution of each attention head by the corresponding V vector to obtain the weighted features of each attention head.

[0025] In an exemplary embodiment, after multiplying the attention distribution of each of the attention heads by the corresponding V vector to obtain the weighted features of each of the attention heads, the method further includes:

[0026] Merging the weighted features of the multiple attention heads to obtain weighted features of the multiple attention heads;

[0027] Expanding the longitudinal dimension of the weighted features of the plurality of attention heads, wherein the longitudinal dimension includes spatial information and frequency information;

[0028] Use the convolution calculation formula to calculate the vertical dimension attention score;

[0029] Each of the longitudinal dimension attention scores is used as a weight to multiply the weighted features of the corresponding attention head to obtain the weighted features of each of the attention heads after the multiplication, and the steps of weighted average integration of the weighted features and outputting the classification results are performed.

[0030] In an exemplary embodiment, performing weighted average integration on the weighted features and outputting a classification result includes:

[0031] Randomly generate a vector parameter V;

[0032] Performing a dot product calculation on the weighted feature and the vector parameter V to obtain a second result, where the second result is used to characterize the similarity between the weighted feature and the vector parameter V;

[0033] According to the second result, calculating the weight coefficient w;

[0034] Multiplying the weight coefficient w by the weighted feature to obtain a weighted average feature representation value;

[0035] Using a multi-level residual connection to add the weighted feature and the feature representation value after the weighted average to obtain a third result, so that the output classification result and the numerical value of the weighted feature are in the same dimension;

[0036] A classification result is obtained according to the third result.

[0037] According to another embodiment of the present invention, a keyboard control method is provided, which is applied to an electronic device, wherein the electronic device includes an electroencephalogram signal acquisition device, and the electronic device is connected to a display screen and a keyboard, and includes:

[0038] The electronic device generates a sliding window of a preset number of key positions on the display screen, wherein the sliding window is used to move horizontally at a preset time interval;

[0039] Within the preset time interval, the EEG signal acquisition device executes the above-mentioned EEG signal classification method to obtain a classification result;

[0040] The electronic device converts the classification result into an operation instruction to control the keys of the keyboard to execute the operation instruction.

[0041] According to yet another embodiment of the present invention, there is further provided an electronic device, including:

[0042] EEG signal acquisition device;

[0043] a memory configured to store instructions; and

[0044] The processor is configured to call the instructions from the memory and implement the above keyboard control method when executing the instructions.

[0045] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned keyboard control method when running.

[0046] Through the above technical scheme, since the time-domain spatial fusion features and the frequency-domain spatial fusion features are first extracted, and then the time-domain spatial fusion features and the frequency-domain spatial fusion features are spliced ​​according to the preset dimensions, the features of the EEG signal can be obtained more comprehensively, thereby improving the accuracy of the classification results; in addition, the multi-dimensional attention mechanism is used to fuse the spliced ​​features, which can automatically learn the association and importance between the features, effectively reduce the influence of noise and redundant features, and extract the most useful features for the classification task; secondly, the weighted average integration of the weighted features can enhance the local features of the features. The weighted average integration takes into account the importance of different feature dimensions, making the important feature dimensions more prominent after integration, thereby enhancing the expression ability of the classification results. In summary, in the case of interference from noise such as electromyography and eye movement in the classification of refined motor imagery EEG signals, feature fusion and weighted average integration can reduce the influence of noise, highlight the features related to the classification task, and thus improve the accuracy of classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 is a flow chart of a method for classifying EEG signals according to an embodiment of the present invention;

[0048] Figure 2is a schematic diagram of a one-dimensional dynamic attention convolution structure in an mDAC module according to an embodiment of the present invention;

[0049] Figure 3 is a schematic diagram of multiple attention heads in a MAM module according to an embodiment of the present invention;

[0050] Figure 4 is a schematic flow chart of a method for classifying EEG signals according to an embodiment of the present invention;

[0051] Figure 5 is a flow chart of a keyboard control method according to an embodiment of the present invention;

[0052] Figure 6 is a schematic diagram of a sliding window according to an embodiment of the present invention. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0054] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0055] The following is a detailed description of the EEG signal classification method provided in the embodiment of the present application through specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0056] The embodiment of the present application discloses a method for classifying EEG signals.

[0057] Reference Figure 1 , a method for classifying EEG signals comprises the following steps:

[0058] S101, obtaining an EEG signal dataset, where the EEG signal dataset is obtained by collecting the user's EEG signals in real time.

[0059] The EEG signal data set is obtained by collecting the user's EEG signals in real time. In this embodiment, the EEG signal data in the EEG signal data set is time series data.

[0060] EEG signals are obtained by recording brain activity through electrodes placed on the scalp and can be used to analyze and study brain function.

[0061] An EEG signal can be extracted into time domain features and frequency domain features. EEG signals are voltage signals sampled in time, so they can be analyzed from the perspective of time domain. Time domain features usually include the amplitude, amplitude change, waveform shape, etc. of the signal.

[0062] At the same time, EEG signals can also be converted into frequency domain representation by applying spectrum analysis methods such as FFT, thereby extracting frequency domain features. Frequency domain features usually include the energy distribution of different frequency components, the power spectrum density of the frequency band, etc.

[0063] On the other hand, EEG signal datasets can extract spatial features. EEG signal datasets usually contain signal records from multiple electrodes or sensors, and the position of each electrode or sensor can be regarded as spatial information. By considering the spatial distribution relationship between different electrodes or sensors, the spatial features of the EEG signal dataset can be extracted.

[0064] S102: adopt the first feature extraction strategy to extract features from the EEG signal data set to obtain time-domain and spatial-domain fusion features.

[0065] The time-domain and space-domain fusion features refer to the features obtained by combining the time-domain features and the space-domain features, which are used to comprehensively consider the information in the time domain and the space-domain. Among them, the time-domain features refer to the analysis of EEG signals in the time domain, such as the mean value, variance, etc.; the space-domain features refer to the analysis of EEG signals in the space domain, such as the correlation between different electrodes.

[0066] S103, using the second feature extraction strategy to extract features from the EEG signal data set to obtain frequency domain and spatial domain fusion features.

[0067] Frequency domain and spatial domain fusion features refer to the features obtained by combining frequency domain features and spatial domain features, which are used to comprehensively consider the information in frequency domain and spatial domain.

[0068] Among them, frequency domain features refer to the analysis of EEG signals in the frequency domain, such as using Fourier transform to convert time domain signals into frequency domain and extract spectral features therefrom.

[0069] Since the EEG signal data is time series data, when using the second feature extraction strategy, the EEG signal needs to be converted into a frequency domain signal first.

[0070] S104, splicing the time domain and spatial domain fusion features and the frequency domain and spatial domain fusion features according to a preset dimension to obtain spliced ​​features, where the spliced ​​features include time domain features, frequency domain features and spatial domain features.

[0071] Splicing is used to link the output feature information of time-domain spatial-domain fusion features and frequency-domain spatial-domain fusion features. Inspired by the idea of ​​data augmentation, the splicing does not perform the fusion operation of time-domain-frequency-domain spatial-domain features, but instead performs the splicing operation of feature data in a shuffled stacking manner while ensuring the integrity of the features, which is conducive to retaining complete detail information, as shown below:

[0072] ;

[0073] The specific approach is to splice the time domain and spatial domain fusion features and the frequency domain and spatial domain fusion features according to the b dimension and then randomly shuffle them.

[0074] Specifically, in this embodiment, the dimension of the electroencephalogram signal (hereinafter referred to as EEG signal) is .in:

[0075] b represents the batch size, that is, the number of samples input at one time;

[0076] d represents the number of data channels, usually 1, indicating an EEG signal with only one channel;

[0077] c represents the number of channels, which indicates the number of channels for EEG signal acquisition, usually 16;

[0078] t represents the number of time points, which indicates the time length of the EEG signal, usually 1250 time points.

[0079] The preset dimension in this embodiment is the b dimension, that is, the time domain and spatial domain fusion features and the frequency domain and spatial domain fusion features are spliced ​​according to the b dimension, so that the features of different samples input in the same batch can be spliced, and the spliced ​​features can include the time domain features, frequency domain features and spatial domain features of each sample.

[0080] S105, perform feature fusion on the concatenated features through a multi-dimensional attention mechanism and output weighted features.

[0081] In the multi-dimensional attention mechanism, by introducing multiple attention heads, multiple different attention weight matrices can be learned simultaneously to capture different focus points and feature representations. Each attention head can learn a different set of weights to calculate the relevance and importance between different features.

[0082] Specifically, the multi-dimensional attention mechanism linearly maps the input sequence into multiple different query, key, and value spaces, and then performs attention calculations on each space. The outputs of multiple attention heads can be obtained, and they can be concatenated or weighted summed to obtain the final multi-dimensional attention representation, namely the weighted feature.

[0083] The multidimensional attention mechanism can automatically learn the relationship and importance between features and weight the features according to the relationship between them. By applying the multidimensional attention mechanism, the importance of features that contribute to the classification task can be increased, and the impact of noise or irrelevant features can be reduced.

[0084] S106: Perform weighted average integration on the weighted features and output the classification result.

[0085] Weighted features are weighted averaged according to their importance. This can balance the contributions of different features, reduce the differences between features, and generate the final classification results. Weighted average integration can improve the accuracy and robustness of classification while reducing the dependence on a single feature.

[0086] In this embodiment, since the time-domain spatial-domain fusion features and the frequency-domain spatial-domain fusion features are first extracted, and then the time-domain spatial-domain fusion features and the frequency-domain spatial-domain fusion features are spliced ​​according to the preset dimensions, the features of the EEG signals can be obtained more comprehensively, thereby improving the accuracy of the classification results; in addition, the spliced ​​features are fused through the multi-dimensional attention mechanism, which can automatically learn the association and importance between the features, effectively reduce the influence of noise and redundant features, and extract the most useful features for the classification task; secondly, the weighted average integration of the weighted features can enhance the local features of the features, and the weighted average integration takes into account the importance of different feature dimensions, so that the important feature dimensions are more prominent after integration, thereby enhancing the expressive power of the classification results. In summary, in the case of interference from noise such as electromyography and eye movement in the classification of refined motor imagery EEG signals, feature fusion and weighted average integration can reduce the influence of noise, highlight the features related to the classification task, and thus improve the accuracy of classification.

[0087] In one implementation of this embodiment, after obtaining the EEG signal data set, the following steps are included:

[0088] S201. Amplify the EEG signal dataset to obtain an amplified EEG signal dataset, wherein the size of the amplified EEG signal dataset is n times the size of the original EEG signal dataset, where n is an integer greater than or equal to 2.

[0089] In this embodiment, the EEG signal dataset can be The data is input to the preset amplification module to amplify the EEG signal dataset by segmenting and recombining the time domain.

[0090] Specifically, the input EEG signal data set can be amplified n-fold , wherein n is an integer greater than or equal to 2. In this embodiment, n=2, d=1, c=16, t=1250.

[0091] Specifically, the amplification method is as follows:

[0092] ;

[0093] Wherein, m is the number of samples, x is the amplified EEG signal data set, n represents the nth EEG signal data in the EEG signal data set, i represents the i-th time domain data, in this embodiment, 0.5S is used as a time period, r represents a random time domain data in the m-1 EEG signal data except the nth EEG signal data, t is a data structure for temporary storage, Xr represents the EEG signal data set, and f represents the reconstruction function. The EEG signal data set can be split and inserted into t through the reconstruction function f, and the amplified EEG signal data set can be obtained by calculating the union.

[0094] This implementation method can increase the number of samples in the EEG signal dataset and introduce more differences between samples by amplifying the EEG signal dataset. This is beneficial to improving the generalization ability of the classification model, reducing overfitting, and increasing the robustness to different changes and noises. This improves the generalization ability and robustness of the model.

[0095] In one implementation of this embodiment, the EEG signal dataset includes time domain information and spatial domain information. The second feature extraction strategy is used to extract features from the EEG signal dataset to obtain frequency domain and spatial domain fusion features, including the following steps:

[0096] S301. Input the EEG signal data set into the FFT module to obtain a frequency domain signal data set, wherein the EEG signal is a time domain signal, and the FFT module is used to convert the EEG signal into a frequency domain signal, and the frequency domain signal data set includes frequency domain information.

[0097] The FFT module (Fast Fourier Transform) is used to resolve the time domain signal into a frequency domain signal and keep the dimensions consistent. Specifically, the FFT module can decompose a time domain signal into a series of spectral components of sine and cosine functions to reveal the frequency information in the signal and keep the input and output dimensions consistent. The FFT module used in this embodiment uses a pure frequency domain analysis method to directly convert the time domain signal into a frequency domain signal.

[0098] S302: Input the frequency domain signal data set into the SAC module to obtain the first fusion feature, wherein the SAC module is used to weight and integrate the spatial domain information into the frequency domain information.

[0099] The SAC module (Spatial Attention Convolution) is used to weight the spatial information of the EEG signal into the frequency domain signal and output the fused features, namely the first fused features. The spatial information refers to the spatial distribution of the EEG signal in different brain regions. The first fused feature not only reflects the frequency characteristics, but also takes into account the spatial distribution of the EEG signal, thus enhancing the expressiveness of the feature.

[0100] Specifically, the SAC module can generate a learnable parameter of size 8×1×c to act on the spatial dimension and perform 8-dimensional diffusion to integrate the spatial information, as shown below:

[0101] ;

[0102] In the formula, Represents input data, represents the learnable parameters, and After the vector product, the spatial information is adaptively weighted and integrated into , and diffuse from dimension 1 to dimension 8, and get the result .

[0103] S303: Input the first fusion feature into the mDAC module to obtain a second weighted fusion feature.

[0104] Inputting the first fused features into the mDAC module (Multi-branch Dynamic Attention Convolution) can further weight and optimize the fused features, enhance the distinguishability of the data, and improve the accuracy of classification.

[0105] Specifically, the mDAC module designs a multi-branch one-dimensional dynamic attention convolution, which enhances the expressiveness by aggregating multiple parallel convolution kernels in each branch, and solves the problem of differences in reaction speed by linking convolution kernels of different receptive fields between branches. The one-dimensional dynamic attention convolution in the branch where the FFT is located acts on the frequency dimension to highlight more important frequency segments.

[0106] like Figure 2As shown, the mDAC module in this embodiment designs a one-dimensional dynamic attention convolution structure containing three parallel branches, each of which contains n one-dimensional convolution kernels, and n is preset to 6. The parallel branches are composed of three one-dimensional dynamic attention convolution kernels with different lengths acting on the time dimension. In order to compensate for the differences in reaction speed, the parallel branch structure learns the characteristics of motor imagery EEG signal data from time lengths of 0.1s, 0.2s, and 0.3s respectively. In order to facilitate the unification of the size of the output feature maps of different branches, the 0.2s time window is fine-tuned respectively, and finally three one-dimensional convolution kernels of different sizes are obtained, namely (1,25), (1,51), and (1,75).

[0107] In each parallel branch, 6 convolution kernels are adaptively weighted averaged by learnable weights w. Batch normalization is used in each branch to speed up network training. The normalized results are then activated using the ELU activation function to enhance nonlinear expression capabilities. Finally, a Dropout layer with a dropout rate of 0.5 is used to reduce overfitting. The output of each branch is concatenated according to the channel dimension to obtain a set of features that mix different details. Finally, an average pooling operation of size (1,4) is used to blur noise and smooth temporal features.

[0108] The number of parallel convolution kernels in the mDAC module is p, where p can be any positive integer.

[0109] Specifically, the one-dimensional dynamic attention convolution of the mDAC module can be expressed as:

[0110] ;

[0111] ;

[0112] In the formula, According to The weight coefficient of the generated k-th convolution kernel, represents the kth parallel convolution kernel. avg represents the average arithmetic operation on the input data, gelu represents the activation function to enhance the nonlinear expression ability, and Softmax is used to calculate the attention weight coefficient.

[0113] S304: Input the second weighted fusion feature into the SC module to obtain frequency domain and spatial domain fusion features.

[0114] The SC module (Spatial Convolution) is used to aggregate all channel information. The preset convolution includes C×1, where C represents the number of channels. The multi-dimensional spatial information is compressed and fused into one dimension. In the branch where the FFT is not located, the time domain and spatial domain fusion features are obtained.

[0115] The SC module is used to learn the representation of the interaction between different electrode channels. In order to reduce the complexity of the model, this embodiment does not expand the input data, but uses a fixed-size convolution kernel (c, 1), where c represents the number of motor imagery EEG signal channels 16. After the convolution, batch normalization and ELU activation function are performed, and then an average pooling operation of size (1, 8) is used to further reduce the data dimension, and finally a dropout layer with a dropout rate of 0.5 is used to reduce overfitting. The output of this module is a time series with high-level representation.

[0116] This implementation method effectively improves the richness and expression ability of EEG signal features by gradually integrating frequency domain and spatial domain information. Through this multi-dimensional fusion, the complexity and dynamic changes of EEG signals can be better captured, thereby improving the accuracy and efficiency of EEG signal classification.

[0117] In one implementation of this embodiment, a first feature extraction strategy is adopted to extract features from an EEG signal data set to obtain time-domain and space-domain fusion features, including the following steps:

[0118] S401, input the EEG signal data set into the SAC module, the mDAC module and the SC module in sequence to obtain the time domain and spatial domain fusion features.

[0119] Since EEG signals are time domain signals, time domain analysis can be performed directly on the EEG signals.

[0120] Similar to S301 to S304, the functions of the SAC module, mDAC module and SC module in this embodiment are the same as those of the SAC module, mDAC module and SC module in S301 to S304. The difference is that, in this embodiment, the SAC module is used to weightedly integrate the spatial domain information of the EEG signal into the time domain information and output the fused features.

[0121] This implementation method effectively improves the richness and expression ability of EEG signal features by gradually integrating time domain and spatial domain information. Through this multi-dimensional fusion, the complexity and dynamic changes of EEG signals can be better captured, thereby improving the accuracy and efficiency of EEG signal classification.

[0122] In one implementation of this embodiment, the concatenated features are fused through a multi-dimensional attention mechanism, and weighted features are output, including the following steps:

[0123] S501. Perform linear transformation on the concatenated features to obtain multiple attention heads, each of which includes a Q vector, a K vector and a V vector.

[0124] S502. For each attention head, perform a dot product calculation on the Q vector and the K vector to obtain a first result, and scale the first result to obtain an attention distribution of each attention head, where the attention distribution is used to characterize the similarity of the attention heads.

[0125] S503: Multiply the attention distribution of each attention head by the corresponding V vector to obtain the weighted features of each attention head.

[0126] In this embodiment, the spliced ​​features can be passed through a MAM module (Multidimensional Attention Mechanism) to achieve feature fusion of the spliced ​​features through a multidimensional attention mechanism and output weighted features.

[0127] Specifically, the MAM module designs an attention mechanism suitable for high-dimensional EEG signal decoding, which performs weighted integration of input features from multiple dimensions of time, frequency and space.

[0128] The MAM module is multi-dimensionally enhanced based on the multi-head attention mechanism. The multi-head attention mechanism is used to perceive important time segments in the time dimension so as to obtain more distinguishing time features, so that the attention acting on the time dimension lacks attention to features in other dimensions. Therefore, in this embodiment, the attention module is improved to facilitate the integration and highlighting of important time-frequency-space features.

[0129] In this embodiment, the MAM module linearly transforms the input data to obtain multiple attention heads, each of which includes a Q vector, a K vector, and a V vector (hereinafter referred to as Q, K, V). The vector product between Q and K is used to obtain the weighted features of each attention head. That is, for each attention head, the Q vector and the K vector are dot-producted to obtain a first result, and the first result is scaled to obtain the attention distribution of each attention head, which is used to characterize the similarity of the attention heads. The attention distribution of each attention head is multiplied by the corresponding V vector to obtain the weighted features of each attention head.

[0130] Specifically, for each attention head, the Q vector and the K vector can be dot-producted to calculate the similarity, i.e., the first result, and then the first result is scaled (usually divided by the square root of the dimension of the K vector) to obtain the attention distribution of each attention head.

[0131] This implementation can effectively identify and extract the most critical information from the spliced ​​features through a multi-dimensional attention mechanism, effectively improving the flexibility and efficiency of feature processing.

[0132] In one implementation of this embodiment, after multiplying the attention distribution of each attention head by the corresponding V vector to obtain the weighted feature of each attention head, the following steps are included:

[0133] S601: Merge the weighted features of multiple attention heads to obtain the weighted features of multiple attention heads.

[0134] The weighted features of multiple attention heads are merged to obtain the weighted features of multiple attention heads, which are used to merge the weighted features of different attention heads into a unified feature representation, which helps to capture features extracted from different aspects.

[0135] S602: Expand the longitudinal dimension of the weighted features of the multiple attention heads, where the longitudinal dimension includes spatial information and frequency information.

[0136] The vertical dimension of the weighted features of multiple attention heads is expanded, where the vertical dimension includes spatial information and frequency information to increase the dimension of the features and introduce more information (such as spatial information and frequency information) for more in-depth analysis.

[0137] Specifically, the expansion of the vertical dimension involves the reconstruction or expansion of the feature space, and additional layers or channels can be added to represent the spatial position and frequency characteristics. This is conducive to more effectively considering the spatial or temporal relationships and dynamic changes when processing EEG signals.

[0138] S603. Calculate the vertical dimension attention score using the convolution calculation formula.

[0139] The vertical dimension attention score is used to reflect the relative importance of each vertical dimension in the current task.

[0140] S604: multiply the attention score of each vertical dimension as a weight with the weighted feature of the corresponding attention head to obtain the weighted feature of each attention head after the multiplication, perform weighted average integration of the weighted features, and output the classification result.

[0141] Using the calculated vertical dimension attention score, each feature is further weighted and then integrated to enhance the expression of local features.

[0142] Reference Figure 3 , and combined with S501 to S503, the MAM module linearly transforms the input data to obtain multiple attention heads, each of which includes a Q vector, a K vector and a V vector (hereinafter referred to as Q, K, V). The vector product between Q and K is used to obtain the weighted features of each attention head, and applied to the V vector to obtain the weighted feature representation .at this time It is expressed as a weighted change value in the time domain, and the proportion of the time-frequency-spatial features in the result is calculated. In this embodiment, a (5,1) size convolution kernel is used to iteratively deduce the appropriate weight size and scale it proportionally.

[0143] Specifically, the MAM module linearly transforms the input data to obtain vectors Q, K, and V, and uses the Q, K, and V vectors to perform a multi-head attention mechanism to obtain the feature representation after weighting the horizontal time domain information. . Then extract other dimensional features, the specific method is as follows:

[0144] 1. For each attention head, calculate the attention distribution, where the similarity between Q and K determines the degree of attention to the value, which is calculated here by the scaled dot product method. Then multiply the attention distribution of each attention head by the corresponding value, and finally combine these results to obtain the output of the multi-head attention That is, for each attention head, the Q vector and the K vector are dot-producted to obtain the first result, and the first result is scaled to obtain the attention distribution of each attention head. The attention distribution is used to characterize the similarity of the attention heads. The attention distribution of each attention head is multiplied by the corresponding V vector to obtain the weighted feature of each attention head. Among them, the output of multi-head attention is It is obtained by combining the weighted features of each attention head.

[0145] 2. In order to facilitate calculation, the input data Expand the vertical dimension.

[0146] ;

[0147] ;

[0148] In the formula, first The dimension is expanded to , where b represents the batch size, 1 represents the added dimension, d represents the vertical dimension size, and n represents the time series dimension. Finally, for ease of calculation, the dimension is converted to .

[0149] 3. Use convolution calculation The correlation between the vertical dimensions and the fusion of input data, the convolution calculation formula is as follows:

[0150] ;

[0151] The convolution calculation formula uses the convolution dynamic learning vertical dimension feature representation, which contains spatial and frequency information, divided by It is used to avoid polarization of the output of the Softmax function. Finally, the vertical dimension attention score is applied to the input That is, the attention score of each vertical dimension is used as a weight and multiplied with the weighted feature of the corresponding attention head to obtain the weighted feature of each attention head after the multiplication.

[0152] After obtaining the weighted features of each attention head after multiplication, execute S106.

[0153] This embodiment can more accurately identify and utilize key information in the data by refining and strengthening feature processing. By multi-level weighting and integration of features, it can not only capture global information, but also focus on local details with decisive influence, thereby improving the accuracy of EEG signal classification.

[0154] In one implementation of this embodiment, weighted average integration is performed on the weighted features, and a classification result is output, including the following steps:

[0155] S701. Randomly generate a vector parameter V.

[0156] The vector parameter V is used to evaluate the importance of the weighted features, and its dimension matches that of the weighted features.

[0157] S702: Perform a dot product calculation on the weighted feature and the vector parameter V to obtain a second result, where the second result is used to characterize the similarity between the weighted feature and the vector parameter V.

[0158] S703. Calculate a weight coefficient w according to the second result.

[0159] S704: Multiply the weight coefficient w by the weighted feature to obtain a weighted average feature representation value.

[0160] S705. Use a multi-level residual connection to add the weighted feature and the feature representation value after weighted average to obtain a third result, so that the output classification result and the numerical value of the weighted feature are in the same dimension.

[0161] This embodiment combines the original weighted features and the feature representation values ​​after weighted averaging, and uses residual connections to enhance the learning process.

[0162] S706. Obtain a classification result according to the third result.

[0163] The third result may be input into a classifier to obtain a classification result.

[0164] Specifically, in this embodiment, the weighted features may be input into an AP module (Attention Pooling) to highlight local features to enhance the network expression capability.

[0165] This embodiment designs a weighted average pooling module based on attention scores to replace the global average pooling to integrate the weighted average of input information, which can effectively highlight local features to enhance the network's expression ability.

[0166] First, a learnable vector parameter v is randomly generated, then the similarity between the input y and the learnable parameter v is calculated by dot product, and finally the weight coefficient w is calculated by the Softmax function. In order to solve the gradient problem and keep the final output and the input y in the same dimension, a multi-level residual connection is used, as shown below:

[0167] ;

[0168] ;

[0169] ;

[0170] In the formula, the similarity between the input y and the learnable vector parameter v is calculated by the dot product, and the weight coefficient w is calculated by the Softmax function; the ep function is used to align y and w. represents matrix multiplication operation; fc represents linear mapping operation.

[0171] This implementation can dynamically adjust the influence of different features through dot product and weight calculation, while the residual connection is conducive to increasing the depth while maintaining stability, thereby optimizing the overall performance, so as to effectively identify and utilize key features and improve classification accuracy.

[0172] In summary, if Figure 4 The overall flow chart of the EEG signal classification method of the present embodiment is shown. The EEG signal classification method of the present embodiment can obtain the EEG signal data set in real time, and obtain frequency domain information through the FFT module; integrate the time domain and spatial domain fusion features and the frequency domain and spatial domain fusion features through the SAC module; compensate for the difference in reaction speed through the mDAC module, and improve the expression ability by adaptive integration of multiple convolution kernels; aggregate all channel information through the SC module; highlight the most important feature information under multi-dimensional features through the MAM module; further enhance the network expression ability through the AP module instead of the global average pooling; and finally obtain the classification result.

[0173] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of various embodiments of the present invention.

[0174] Reference Figure 5 In this embodiment, a keyboard control method is also provided, which is applied to an electronic device, wherein the electronic device includes an electroencephalogram signal acquisition device, and the electronic device is connected to a display screen and a keyboard, and includes:

[0175] S801. The electronic device generates a sliding window of a preset number of key positions on a display screen, wherein the sliding window is used to move horizontally at a preset time interval.

[0176] In this embodiment, the preset number is 3, that is, this embodiment can initialize and generate a sliding window covering the size of 3 keys and highlight them, wherein the sliding window can move horizontally at a preset time interval, that is, the sliding window can automatically move horizontally from one key position to another key position according to the preset time interval.

[0177] Specifically, in the embodiment, a 16-lead EEG cap is used to collect data at 250Hz, including five categories: thumb bending downward, middle finger bending downward, pinky finger bending downward, wrist bending downward, and wrist lifting upward. Since the ring finger bending downward will cause interference with the middle finger and pinky finger, not all finger data are collected, and the categories are controlled to the above five categories in order to improve the accuracy.

[0178] like Figure 6 As shown, the sliding window concept is used to solve the problem of multiple key positions. Initialize and generate sliding windows of three key sizes (indicated by the dotted rectangular box), and match the thumb, middle finger, and little finger from left to right in turn. As you imagine the corresponding finger movements, the corresponding keys in the sliding window will be triggered. The sliding window is preset to slide once every 1s, sliding horizontally by one window size each time and highlighting the next key in the window in real time. The highlight setting in this embodiment can be adjusted to match people with different reaction speeds. The sliding window is set to slide only horizontally. At this time, you can control the longitudinal movement of the sliding window by imagining two wrist movements. For example, imagine that the wrist is bent downward, which will move the sliding window vertically downward from the current position by one key position to the next row of keys.

[0179] S802: Within a preset time interval, the EEG signal acquisition device executes the above-mentioned EEG signal classification method to obtain a classification result.

[0180] The EEG signal acquisition device monitors the user's EEG activity in real time. When the sliding window stops at a certain key position, the user can express the intention to select the key position through a specific EEG signal pattern (such as imaginary movement, visual attention, etc.). Through the EEG signal classification method, the classification result can be obtained, that is, the key position that the user intends to select can be identified.

[0181] S803: The electronic device converts the classification result into an operation instruction to control the keys of the keyboard to execute the operation instruction.

[0182] The electronic device generates corresponding keyboard operation instructions according to the classification results of the EEG signals, such as pressing a key, releasing a key, etc. The keyboard performs corresponding actions according to these operation instructions, such as inputting characters, executing commands, etc.

[0183] In this embodiment, by combining the EEG signal classification method, the user can control the keyboard only through EEG activity, thereby performing text input or other keyboard-related operations. This not only improves the accessibility of interaction, but also provides an effective communication method for people who cannot use traditional keyboards due to physical conditions, effectively improving the quality of life of users.

[0184] In this embodiment, an electronic device is also provided, including:

[0185] EEG signal acquisition device;

[0186] a memory configured to store instructions; and

[0187] The processor is configured to call instructions from the memory and implement the above keyboard control method when executing the instructions.

[0188] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0189] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned keyboard control method when running.

[0190] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0191] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0192] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0193] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for classifying electroencephalogram signals, characterized in that: include: Acquire an EEG signal data set, where the EEG signal data set is obtained by collecting EEG signals of a user in real time; Using a first feature extraction strategy, extracting features from the EEG signal data set to obtain time-domain and space-domain fusion features; Using the second feature extraction strategy, extracting features from the EEG signal data set to obtain frequency domain and spatial domain fusion features; The time domain and spatial domain fusion features and the frequency domain and spatial domain fusion features are spliced ​​according to a preset dimension to obtain spliced ​​features, wherein the spliced ​​features include time domain features, frequency domain features and spatial domain features; Performing feature fusion on the concatenated features through a multi-dimensional attention mechanism and outputting weighted features; Performing weighted average integration on the weighted features and outputting a classification result; Wherein, after obtaining the EEG signal data set, the following steps are included: Amplifying the EEG signal dataset to obtain an amplified EEG signal dataset, wherein the size of the amplified EEG signal dataset is n times the size of the EEG signal dataset, where n is an integer greater than or equal to 2; The step of fusing the concatenated features through a multi-dimensional attention mechanism and outputting weighted features includes: Performing a linear transformation on the concatenated features to obtain a plurality of attention heads, each of which includes a Q vector, a K vector, and a V vector; For each attention head, performing a dot product calculation on the Q vector and the K vector to obtain a first result, and scaling the first result to obtain an attention distribution of each attention head, where the attention distribution is used to characterize the similarity of the attention heads; Multiply the attention distribution of each attention head by the corresponding V vector to obtain the weighted feature of each attention head; After multiplying the attention distribution of each of the attention heads by the corresponding V vector to obtain the weighted features of each of the attention heads, the method further comprises: Merging the weighted features of the multiple attention heads to obtain weighted features of the multiple attention heads; Expanding the longitudinal dimension of the weighted features of the plurality of attention heads, wherein the longitudinal dimension includes spatial information and frequency information; Use the convolution calculation formula to calculate the vertical dimension attention score; Multiplying each of the longitudinal dimension attention scores as a weight with the weighted features of the corresponding attention head to obtain the weighted features of each of the attention heads after the multiplication, and performing the steps of weighted average integration of the weighted features and outputting the classification results; The vertical dimension attention score is used to reflect the relative importance of each vertical dimension in the current task; The step of calculating the vertical dimension attention score using the convolution calculation formula includes: Input Data Expand vertical dimension ; Use convolution to calculate the correlation between the vertical dimensions and fuse the input data In the formula In order to avoid polarization of the output of the Softmax function, the vertical dimension attention score is applied to the input .

2. The method according to claim 1, characterized in that The EEG signal data set includes time domain information and spatial domain information. The second feature extraction strategy is used to extract features from the EEG signal data set to obtain frequency domain and spatial domain fusion features, including: Inputting the EEG signal data set into an FFT module to obtain a frequency domain signal data set, wherein the EEG signal is a time domain signal, and the FFT module is used to convert the EEG signal into the frequency domain signal, and the frequency domain signal data set includes frequency domain information; Inputting the frequency domain signal data set into a SAC module to obtain a first fusion feature, wherein the SAC module is used to weight and integrate the spatial domain information into the frequency domain information; Inputting the first fused feature into the mDAC module to obtain a second weighted fused feature; Inputting the second weighted fusion feature into the SC module to obtain frequency domain and spatial domain fusion features; The SAC module refers to Spatial Attention Convolution, spatial attention convolution; Wherein, the mDAC module refers to Multi-branch Dynamic Attention Convolution, multi-branch dynamic attention convolution; The SC module refers to Spatial Convolution, spatial convolution.

3. The method according to claim 2, characterized in that The first feature extraction strategy is adopted to extract features from the EEG signal data set to obtain time domain and space domain fusion features, including: The EEG signal data set is sequentially input into the SAC module, the mDAC module and the SC module to obtain the time domain and spatial domain fusion features.

4. The method according to claim 1, characterized in that: The weighted average integration of the weighted features and outputting the classification results include: Randomly generate a vector parameter; Performing a dot product calculation on the weighted feature and the vector parameter to obtain a second result, where the second result is used to characterize the similarity between the weighted feature and the vector parameter; According to the second result, calculating the weight coefficient w; Multiplying the weight coefficient w by the weighted feature to obtain a weighted average feature representation value; Using a multi-level residual connection to add the weighted feature and the feature representation value after the weighted average to obtain a third result, so that the output classification result and the numerical value of the weighted feature are in the same dimension; A classification result is obtained according to the third result.

5. A keyboard control method, characterized in that: Applied to electronic equipment, the electronic equipment includes an electroencephalogram signal acquisition device, the electronic equipment is connected to a display screen and a keyboard, and includes: The electronic device generates a sliding window of a preset number of key positions on the display screen, wherein the sliding window is used to move horizontally at a preset time interval; Within the preset time interval, the EEG signal acquisition device executes the EEG signal classification method according to any one of claims 1 to 4 to obtain a classification result; The electronic device converts the classification result into an operation instruction to control the keys of the keyboard to execute the operation instruction.

6. An electronic device, characterized in that: include: EEG signal acquisition device; a memory configured to store instructions; as well as A processor is configured to call the instructions from the memory and implement the keyboard control method according to claim 5 when executing the instructions.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the keyboard control method of claim 5 when executed.

Citation Information

Patent Citations

  • Electroencephalogram recognition method based on CWT and MLMSFFCNN

    CN111582041A

  • EEG signal representation method, classification method and visualization method and medium

    CN111671423A

  • Electroencephalogram visual classification method based on time-frequency domain fusion Transform

    CN114298216A

  • Space-time convolution electroencephalogram decoding method based on multi-head self-attention mechanism fusion

    CN117131356A

  • Classification method for motor imagery electroencephalogram signals

    CN117860271A