Motor Imagery EEG Signal Classification Method and System
By building a convolutional network model of channel and temporal attention mechanism, combining channel and temporal attention mechanism, the problem of deep learning methods ignoring the spatiotemporal structure of EEG signals is solved, and a more efficient classification of EEG signals is achieved through the motion imagination.
Patent Information
- Application Number
- CN202510354253.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-03-25
AI Technical Summary
Existing deep learning methods tend to ignore the complex spatial and temporal structure of the signal when processing EEG signals, resulting in low classification accuracy and efficiency of EEG signals for motor imagination.
Convolutional network model of channel and time attention mechanism is built, combined with channel attention convolution module, deep feature extraction module and time attention module, and through convolution processing and feature extraction, the spatio-temporal feature fusion capability of EEG signals is improved.
It significantly improves the classification performance of motor imaginary EEG signals, can more accurately capture the local and global characteristics of EEG signals, and improves classification accuracy and efficiency.
Smart Images

Figure CN119884841B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and particularly relates to a method and system for classifying motor imagery electroencephalogram (EEG) signals. Background Art
[0002] Brain-Computer Interface (BCI) has shown great potential in the rehabilitation of patients with stroke, spinal cord injury, or amyotrophic lateral sclerosis, helping patients restore certain motor abilities or the ability to interact with the outside world. With the continuous progress of neuroscience, artificial intelligence, and hardware technology, BCI is developing towards a more efficient, accurate, and popular direction; traditional machine learning methods for processing electroencephalogram (EEG) signals usually focus on extracting neurophysiological features. This process generally follows a multi-step framework, and traditional feature extraction methods are task-specific, that is, they require specific prior knowledge for different BCI paradigms and have limited generalization ability.
[0003] In recent years, deep learning methods, especially Convolutional Neural Network (CNN), have shown excellent performance in many fields including image recognition, natural language processing, and EEG signal classification; however, existing deep learning models usually lack sufficient modeling of the multi-level dependencies between signal channels and in time, and are prone to ignoring the complex spatio-temporal structure hidden in EEG signals, resulting in inaccurate extraction of features of motor imagery EEG signals, and thus low accuracy and low efficiency in classifying motor imagery EEG signals. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide a method and system for classifying motor imagery EEG signals, which can solve the technical problem that existing deep learning methods in the prior art are prone to ignoring the complex spatio-temporal structure hidden in EEG signals.
[0005] To solve the above technical problem, this application is implemented as follows:
[0006] In a first aspect, the embodiments of this application provide a method for classifying motor imagery EEG signals, and the method includes:
[0007] Obtain a data set, and preprocess the data set to obtain a target data set;
[0008] Construct a channel and time attention mechanism convolutional network model, and the channel and time attention mechanism convolutional network model includes a channel attention convolutional module, a deep feature extraction module, a time attention module, and a classification module;
[0009] Construct a loss function, and train and test the channel and temporal attention mechanism convolutional network model according to the loss function and the target data set;
[0010] Input the motion imagination EEG signal to be classified into the tested channel and temporal attention mechanism convolutional network model, and output the classification result of the motion imagination EEG signal data.
[0011] As an optional implementation manner of the first aspect of this application, the step of inputting the motion imagination EEG signal to be classified into the tested channel and temporal attention mechanism convolutional network model and outputting the classification result of the motion imagination EEG signal data is specifically:
[0012] Input the motion imagination EEG signal to be classified into the channel attention convolutional module of the tested channel and temporal attention mechanism convolutional network model. The channel attention convolutional module performs convolutional processing on the motion imagination EEG signal to be classified and outputs a group of channel-weighted convolutional feature maps;
[0013] Input the group of channel-weighted convolutional feature maps into the deep feature extraction module. The deep feature extraction module performs deep feature extraction on the group of channel-weighted convolutional feature maps to obtain a group of deep convolutional feature maps;
[0014] Input the group of deep convolutional feature maps into the temporal attention module. The temporal attention module performs temporal attention weighting processing on the group of deep convolutional feature maps to obtain a group of temporally weighted convolutional feature maps;
[0015] Input the group of temporally weighted convolutional feature maps into the classification module. The classification module performs classification processing on the group of temporally weighted feature maps to obtain the category corresponding to the motion imagination EEG signal to be classified, and completes the classification of the motion imagination EEG signal to be classified.
[0016] As an optional implementation manner of the first aspect of this application, the step that the channel attention convolutional module performs convolutional processing on the motion imagination EEG signal to be classified and outputs a group of channel-weighted convolutional feature maps is specifically:
[0017] The motion imagination EEG signal to be classified is input into the channel attention convolutional module. The first temporal convolutional layer in the channel attention convolutional module performs temporal convolutional processing on the motion imagination EEG signal to be classified to obtain an initial group of feature maps, and performs normalization processing on the initial group of feature maps according to the first batch normalization layer;
[0018] Perform spatial convolution processing on the initial feature map group after the normalization processing according to the spatial convolution layer pair to obtain a spatial feature map group; then perform normalization processing and non-linear activation processing on the spatial feature map group according to the second batch of normalization layers and the first non-linear activation layer in sequence;
[0019] Perform average pooling processing on the spatial feature map group after the non-linear activation processing according to the average pooling layer, and then perform dropout processing on the spatial feature map group after the average pooling processing according to the dropout layer;
[0020] Perform channel attention weighting processing on the spatial feature map group after the dropout processing according to the channel attention layer to obtain a channel weighted feature map group;
[0021] Perform temporal convolution processing on the channel weighted feature map group according to the second temporal convolution layer, and then perform normalization processing and non-linear activation processing on the spatial feature map group according to the third batch of normalization layers and the second non-linear activation layer in sequence to obtain the channel weighted convolution feature map group.
[0022] As an optional implementation manner of the first aspect of the present application, input the channel weighted convolution feature map group into the deep feature extraction module, and the deep feature extraction module performs deep feature extraction on the channel weighted convolution feature map group to obtain a deep convolution feature map group; specifically:
[0023] Use time window division M Simultaneously perform windowing processing on each channel weighted convolution feature map in the channel weighted convolution feature map group along the time dimension using M feature windows, and divide each channel weighted convolution feature map into
[0024] window sub-feature maps with equal widths; M Calculate the variance of each window sub-feature map in each feature window according to the variance layer to obtain
[0025] the variances of each window sub-feature map in each of the
[0026] feature windows; M Perform natural logarithm operation on the variance of each window sub-feature map to obtain the variance feature of each window sub-feature map;
[0027] Construct each deep convolution feature map corresponding to each channel weighted convolution feature map according to the
[0028] M variance features corresponding to each channel weighted convolution feature map;
[0027] Construct the deep convolution feature map group according to each deep convolution feature map.
[0028] As an alternative implementation of the first aspect of the present application, the temporal attention module performs temporal attention weighting processing on the depth convolution feature map group to obtain a temporally weighted convolution feature map group; specifically:
[0029] Equalize the variance features in each of the feature windows into h variance feature groups;
[0030] Perform multi-head attention processing on each of the h variance feature groups corresponding to each feature window through a one-dimensional convolutional layer to obtain each attention feature corresponding to each variance feature;
[0031] For each of the M attention features in the feature windows, splice them along the time dimension to obtain each temporally weighted convolution feature map corresponding to each depth convolution feature map;
[0032] Construct the temporally weighted convolution feature map group according to each temporally weighted convolution feature map.
[0033] In a second aspect, an embodiment of the present application provides a motor imagery electroencephalogram signal classification system, the system includes:
[0034] An acquisition module: acquires a data set, preprocesses the data set to obtain a target data set;
[0035] A construction module: constructs a channel and temporal attention mechanism convolutional network model, the channel and temporal attention mechanism convolutional network model includes a channel attention convolutional module, a depth feature extraction module, a temporal attention module, and a classification module;
[0036] A training module: constructs a loss function, and trains and tests the channel and temporal attention mechanism convolutional network model according to the loss function and the data set;
[0037] A classification module: inputs the motor imagery electroencephalogram signal to be classified into the tested channel and temporal attention mechanism convolutional network model, and outputs the classification result of the motor imagery electroencephalogram signal data.
[0038] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device includes a processor, a memory, and a program or instruction stored on the memory and executable on the processor, and when the program or instruction is executed by the processor, the steps of the method described in the first aspect are implemented.
[0039] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by the processor, the steps of the method described in the first aspect are implemented.
[0040] Compared with the prior art, the present application has the following innovative points and beneficial effects:
[0041] (1) The present application combines a convolutional neural network with a channel attention mechanism, which can not only extract local temporal features of electroencephalogram (EEG) signals, but also capture the global temporal correlation of EEG signals, contributing to the extraction of discriminative features;
[0042] (2) The present application combines a variance layer with a temporal attention mechanism, which can not only reduce the temporal dimension of feature maps, but also extract more statistically significant features, greatly improving the feature representation of EEG signals based on motor imagery;
[0043] (3) The present application effectively extracts and fuses spatio-temporal-frequency features by intelligently integrating a channel attention convolutional module, a deep feature extraction module, and a temporal attention module, significantly enhancing the classification performance of motor imagery-based brain-computer interface tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 is a flowchart of a method for classifying motor imagery EEG signals provided by some embodiments of the present application;
[0045] Figure 2 is a structural diagram of a channel and temporal attention mechanism convolutional network model in a method for classifying motor imagery EEG signals provided by some embodiments of the present application;
[0046] Figure 3 is a structural diagram of a channel attention convolutional module in a method for classifying motor imagery EEG signals provided by some embodiments of the present application;
[0047] Figure 4 is a structural diagram of a channel attention layer in a method for classifying motor imagery EEG signals provided by some embodiments of the present application;
[0048] Figure 5 is a structural diagram of a temporal attention module in a method for classifying motor imagery EEG signals provided by some embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0049] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art without creative efforts based on the embodiments of the present application belong to the scope of protection of the present application.
[0050] The terms "first", "second", etc. in the description and claims of this application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of this application can be implemented in an order other than those illustrated or described herein. In addition, "and / or" in the description and claims means at least one of the connected objects, and the character " / " generally indicates an "or" relationship between the associated objects before and after.
[0051] The following will combine the accompanying drawings and, through specific embodiments and their application scenarios, provide a detailed description of a method and system for classifying motor imagery electroencephalogram (EEG) signals according to an embodiment of this application.
[0052] Embodiment
[0053] A method for classifying motor imagery EEG signals includes the following steps:
[0054] S100: Obtain a data set, preprocess the data set to obtain a target data set;
[0055] It should be noted that S100 specifically is:
[0056] S110: Obtain a data set, where the data set includes four types of motor imagery EEG signals;
[0057] S120: Preprocess the data set to obtain a target data set;
[0058] Furthermore, the data set in S110 comes from a four-class motor imagery EEG signal data set provided by the fourth International BCI Competition; the data set includes MI-EEG (motor imagery EEG signal) data from 9 healthy subjects; each subject conducted experiments in two sessions. Each session contains 288 experiments, including four motor imagery tasks of left hand, right hand, foot, and tongue, and each task has 72 experiments. The EEG signals are recorded using 22 electrode channels located in the motor cortex area, and the sampling rate is 250 Hz; the EEG signals of all these electrodes are used for decoding the motor imagery tasks, that is, it shows that the data set contains motor imagery EEG signal data of two sessions;
[0059] It should be noted that in S120, preprocess the data set to obtain a target data set; specifically:
[0060] S121: Segment each motor imagery EEG signal in the data set, and intercept the single motor imagery EEG signal in each motor imagery EEG signal from 0 s to 4 s after the task prompt;
[0061] S122: Perform band-pass filtering and sampling rate processing on each single-trial motor imagery EEG signal according to a fourth-order Butterworth filter;
[0062] S123: Construct a target dataset based on each single-trial motor imagery EEG signal in the dataset after the band-pass filtering and sampling rate processing;
[0063] Furthermore, in S122, the working frequency of the fourth-order Butterworth filter for performing band-pass filtering on each single-trial motor imagery EEG signal is 4 Hz - 40 Hz, and the sampling rate of each single-trial motor imagery signal is processed to 250 Hz; Similarly, the target dataset obtained in S123 corresponds to the dataset and contains single-trial motor imagery EEG signal data in two time periods.
[0064] S200: Construct a channel and temporal attention mechanism convolutional network model, where the channel and temporal attention mechanism convolutional network model includes a channel attention convolutional module, a deep feature extraction module, a temporal attention module, and a classification module;
[0065] S300: Construct a loss function, and train and test the channel and temporal attention mechanism convolutional network model according to the loss function and the target dataset;
[0066] It should be noted that in S300, the channel and temporal attention mechanism convolutional network model is trained and tested according to the loss function and the target dataset; specifically:
[0067] S310: Construct a loss function and divide the target dataset into a training set and a test set;
[0068] S320: Train the channel and temporal attention mechanism convolutional network model according to the loss function and the training set;
[0069] S330: Test the trained channel and temporal attention mechanism convolutional network model according to the test set.
[0070] Furthermore, in S310, dividing the target data set into a training set and a test set means using the data of two time periods in the target data set as the training set and the test set respectively; in S320, for model training, the PyTorch library in Python 3.7 is used as the software environment for model construction and training, and the hardware environment includes an Intel Core i5-12400F CPU and an NVIDIA GeForce RTX 3080 GPU; cross-entropy loss is used for network optimization. The Adam optimizer is used with default settings. The initial learning rate is set to 0.001, and if the training loss does not improve for 20 consecutive epochs, the learning rate will be reduced by 0.6 times. The dropout rate is set to 0.5. The batch size for each epoch is 64. The training process of the model is divided into the following two stages. In the first stage, all the weights in the network are initialized using the Glorot initializer, and the biases are set to zero. Early stopping is enabled, and the maximum number of training epochs and the maximum patience are set to 500 and 50 respectively, which means that if the validation accuracy does not improve for 50 consecutive epochs, the training in the first stage will be terminated, and the current network weight parameters will be saved; in the second stage, the weight parameters of the first stage are inherited, and the number of training epochs is set to 200.
[0071] S400: Input the motion imagination EEG signal to be classified into the channel and time attention mechanism convolutional network model after testing, and output the classification result of the motion imagination EEG signal data.
[0072] It should be noted that S400 specifically is:
[0073] S410: Input the motion imagination EEG signal to be classified into the channel attention convolutional module of the channel and time attention mechanism convolutional network model after testing. The channel attention convolutional module performs convolutional processing on the motion imagination EEG signal to be classified, and outputs a group of channel-weighted convolutional feature maps;
[0074] S420: Input the group of channel-weighted convolutional feature maps into the deep feature extraction module. The deep feature extraction module performs deep feature extraction on the group of channel-weighted convolutional feature maps to obtain a group of deep convolutional feature maps;
[0075] S430: Input the group of deep convolutional feature maps into the time attention module. The time attention module performs time attention weighting processing on the group of deep convolutional feature maps to obtain a group of time-weighted convolutional feature maps;
[0076] S440: Input the group of time-weighted convolutional feature maps into the classification module. The classification module performs classification processing on the group of time-weighted feature maps to obtain the category corresponding to the motion imagination EEG signal to be classified, and completes the classification of the motion imagination EEG signal to be classified.
[0077] It should be noted that in S410, the channel attention convolution module performs convolution processing on the motion imagination EEG signals to be classified, and outputs a group of channel-weighted convolution feature maps; specifically:
[0078] S411: The motion imagination EEG signals to be classified are input into the channel attention convolution module. The first temporal convolution layer in the channel attention convolution module performs temporal convolution processing on the motion imagination EEG signals to be classified, obtains an initial group of feature maps, and normalizes the initial group of feature maps according to the first batch normalization layer;
[0079] S412: Perform spatial convolution processing on the initial group of feature maps after normalization according to the spatial convolution layer to obtain a group of spatial feature maps; then, perform normalization processing and non-linear activation processing on the group of spatial feature maps in sequence according to the second batch normalization layer and the first non-linear activation layer;
[0080] S413: Perform average pooling processing on the group of spatial feature maps after non-linear activation processing according to the average pooling layer, and then perform dropout processing on the group of spatial feature maps after average pooling processing according to the dropout layer;
[0081] S414: Perform channel attention weighting processing on the group of spatial feature maps after dropout processing according to the channel attention layer to obtain a group of channel-weighted feature maps;
[0082] S415: Perform temporal convolution processing on the group of channel-weighted feature maps according to the second temporal convolution layer, and then perform normalization processing and non-linear activation processing on the group of spatial feature maps in sequence according to the third batch normalization layer and the second non-linear activation layer to obtain a group of channel-weighted convolution feature maps.
[0083] Furthermore, the first temporal convolution layer in S411 is used to capture frequency information above 4 Hz, and this layer uses filters of size . Among them is set to 32, is set to 64. At the same time, the padding parameter is set to to ensure that the dimension of the EEG signal remains unchanged after the convolution operation; the initial group of feature maps output by this layer includes initial features; then, use the first batch normalization (BN) layer to normalize the initial group of feature maps output by the first temporal convolution layer to maintain the stability of the data distribution.
[0084] The spatial convolution layer in S412 contains filters of size , where S is the number of electrode channels used for decoding the motion imagination task, and the number of filter groups is set to , which means there are D filters for each feature channel; among them, , the group of spatial feature maps output by this layer includes spatial feature maps, which are successively followed by a second BN layer and a first non-linear (ELU) activation layer, respectively used for normalizing and non-linearly activating the group of spatial feature maps.
[0085] In S413, through an average pooling (Avg. Pool) layer with a size of and a dropout layer (dropout rate is 0.5), average pooling processing and dropout processing are performed. In the average pooling layer, K2 is set to 8. The average pooling processing is used to reduce the sampling rate of the group of spatially feature maps after non-linear activation processing from 250 Hz to about 32 Hz, and reduce the length of the spatial feature maps to 1000 / 8 = 125. The dropout processing is to reduce the overfitting of the group of spatial feature maps.
[0086] In S414, global average pooling (GAP) is performed on the group of spatial feature maps after dropout processing, and its dimension is compressed from ( N , C , S , T ) to ( N , C , 1, 1), where N , C , S , T respectively represent the batch size, the number of feature channels, the spatial dimension size, and the time dimension size. Global average pooling is used to capture the global information of the entire group of spatial feature maps; then one-dimensional convolution (C1D) is used to calculate the channel weights of the group of spatial feature maps after GAP , as shown in the following formula:
[0087] ,
[0088] Among them, represents the spatial feature map after GAP processing, represents one-dimensional convolution with a convolution kernel size of ;
[0089] According to the number of feature channels C it is adaptively determined, as shown in the following formula:
[0090] ,
[0091] Among them, represents the odd number closest to , and Used to change the ratio of channels to convolutional kernels, the default setting is 2, the default setting is 1;
[0092] Using channel weights weight the channels of the spatial feature map to obtain a channel-weighted feature map, as shown in the following formula:
[0093] ,
[0094] where, represents the channel-weighted feature map, represents the spatial feature map, represents the product in the element direction.
[0095] In S415, the second temporal convolutional layer uses filters of size , where is empirically set to 16 for decoding 500 ms of MI activity, aiming to further extract temporal features. It is followed by a third BN layer and a second ELU activation layer in sequence, which are used to normalize and non-linearly activate the output of the second temporal convolutional layer respectively, to obtain a group of channel-weighted convolutional feature maps.
[0096] It should be noted that in S420, the group of channel-weighted convolutional feature maps is input into the deep feature extraction module, and the deep feature extraction module performs deep feature extraction on the group of channel-weighted convolutional feature maps to obtain a group of deep convolutional feature maps; specifically:
[0097] S421: Divide the time window and use M feature windows to perform windowing processing on each channel-weighted convolutional feature map in the group of channel-weighted convolutional feature maps along the time dimension, and divide each channel-weighted convolutional feature map into M window sub-feature maps with equal widths;
[0098] S422: Calculate the variance of each window sub-feature map in each feature window according to the variance layer to obtain M the variances of each window sub-feature map in each of the
[0099] S423: Perform natural logarithm operation on the variance of each window sub-feature map to obtain the variance feature of each window sub-feature map;
[0100] S424: Construct each deep convolutional feature map corresponding to each channel-weighted convolutional feature map according to the M variance features corresponding to each channel-weighted convolutional feature map;
[0101] S425: Construct a group of deep convolutional feature maps according to each of the deep convolutional feature maps.
[0102] Further, in S421, each channel weighted convolution feature map is divided into M weighted window sub-feature maps with equal widths, where , represents the length of each channel weighted convolution feature map, represents that the width of each weighted window sub-feature map is, set to 20.
[0103] In S422, the variance of the th window sub-feature map in the th feature window is calculated as follows:
[0104] ,
[0105] where represents the th channel weighted convolution feature map, represents the average value of the th window sub-feature map in the th feature window, represents the value at the th time sampling point.
[0106] It should be noted that in S430, the time attention module performs time attention weighting processing on the depth convolution feature map group to obtain the time weighted convolution feature map group; specifically:
[0107] S431: The variance features in each feature window are equally divided into h variance feature groups;
[0108] S432: Each of the h variance feature groups corresponding to each feature window is subjected to multi-head attention processing through a one-dimensional convolutional layer to obtain each attention feature corresponding to each variance feature;
[0109] S433: The attention features in each of the M feature windows are concatenated along the time dimension to obtain each time weighted convolution feature map corresponding to each depth convolution feature map;
[0110] S434: According to each time weighted convolution feature map, a time weighted convolution feature map group is constructed.
[0111] Further, the th time weighted convolution feature map in S432 is expressed as follows:
[0112] ,
[0113] Among them, represents the weight of the one-dimensional convolution, and mod represents the modulo operation. represents the th attention feature in the
[0114] According to a method for classifying motor imagery electroencephalogram signals in this embodiment, by constructing a network structure including a channel attention convolution module, a deep feature extraction module, a temporal attention module, and a classification module, this method can capture features in motor imagery electroencephalogram signals more precisely, thereby improving the accuracy of classification; the channel attention mechanism can automatically adjust the importance of different channels, which helps to highlight key signal features. The temporal attention mechanism can focus on the changes in the signal in the time dimension, further enhancing the capture of dynamic features. The deep feature extraction module effectively reduces the feature dimension and the complexity of subsequent processing by dividing time windows and calculating variance features. The multi-head attention processing in the temporal attention module allows parallel computing, improving the processing speed. This method can process different types of motor imagery electroencephalogram signals, whether there are four or two types, and can adapt by adjusting the model parameters and structure.
[0115] It should be noted that for a method for classifying motor imagery electroencephalogram signals provided in an embodiment of this application, the execution subject can be a system for classifying motor imagery electroencephalogram signals, or a control module in the system for classifying motor imagery electroencephalogram signals that is used to execute and load a method for classifying motor imagery electroencephalogram signals. In an embodiment of this application, taking a system for classifying motor imagery electroencephalogram signals that executes and loads a method for classifying motor imagery electroencephalogram signals as an example, a method for classifying motor imagery electroencephalogram signals provided in an embodiment of this application is described.
[0116] A system for classifying motor imagery electroencephalogram signals includes:
[0117] An acquisition module: acquires a data set, preprocesses the data set, and obtains a target data set;
[0118] A construction module: constructs a convolutional network model with channel and temporal attention mechanisms, and the convolutional network model with channel and temporal attention mechanisms includes a channel attention convolution module, a deep feature extraction module, a temporal attention module, and a classification module;
[0119] A training module: constructs a loss function, and trains and tests the convolutional network model with channel and temporal attention mechanisms according to the loss function and the data set;
[0120] A classification module: inputs the motor imagery electroencephalogram signals to be classified into the tested convolutional network model with channel and temporal attention mechanisms, and outputs the classification result of the motor imagery electroencephalogram signal data.
[0121] A motor imagery electroencephalogram signal classification system in an embodiment of the present application may be a device, or a component, an integrated circuit, or a chip in a terminal. The device may be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a handheld computer, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc., and the non-mobile electronic device may be a server, a network attached storage (NAS), a personal computer (PC), etc. The embodiment of the present application does not make specific limitations.
[0122] A motor imagery electroencephalogram signal classification system in an embodiment of the present application may be a device with an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems. The embodiment of the present application does not make specific limitations.
[0123] A motor imagery electroencephalogram signal classification system provided by an embodiment of the present application can implement Figures 1 to 5 each process implemented by a motor imagery electroencephalogram signal classification method in the method embodiment. To avoid repetition, it will not be elaborated here.
[0124] A motor imagery electroencephalogram (EEG) signal classification system according to this embodiment obtains a data set, providing rich data resources for subsequent preprocessing and classification, and preprocesses the data set to obtain a target data set, ensuring data consistency and quality, and laying a solid foundation for subsequent feature extraction and classification. The designed channel and temporal attention mechanism convolutional network model in the construction module can make full use of the channel and temporal dimension information in EEG signals to achieve efficient feature extraction. The channel attention convolutional module can automatically adjust the importance of different channels and highlight key signal features; the deep feature extraction module further extracts the dynamic features of the signal through time window division and variance calculation; the temporal attention module focuses on the changes in the signal in the temporal dimension and enhances the feature expression ability. The training module constructs a loss function and uses the target data set to train and test the model, ensuring the accuracy and generalization ability of the model. The classification module can input the motor imagery EEG signal to be classified into the tested model to obtain accurate classification results. By combining mechanisms such as channel attention, temporal attention, and deep feature extraction, the system can capture the features in EEG signals more comprehensively, thereby improving the classification accuracy. The system provides an effective solution for the classification of motor imagery EEG signals, contributing to the development and application of brain-computer interface technology. By accurately classifying motor imagery EEG signals, the system provides strong support for fields such as motion control and rehabilitation assistance in brain-computer interface systems.
[0125] Optionally, an embodiment of the present application further provides an electronic device, including a processor, a memory, and a program or instruction stored on the memory and executable on the processor. When the program or instruction is executed by the processor, it implements each process of the above embodiment of the method for classifying motor imagery EEG signals and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0126] An embodiment of the present application further provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, it implements each process of the above embodiment of the method for classifying motor imagery EEG signals and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0127] Wherein, the processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes computer-readable storage media such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disc.
[0128] It should be noted that in this text, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including that element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, but may also include performing functions in a substantially simultaneous manner or in a reverse order according to the functions involved. For example, the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, the features described with reference to certain examples may be combined in other examples.
[0129] From the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions for causing a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present application.
[0130] The embodiments of the present application have been described above with reference to the accompanying drawings. However, the present application is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them fall within the protection scope of the present application.
Claims
1. A method for classifying motor imagery electroencephalogram signals, characterized in that, The method includes: Obtaining a data set, preprocessing the data set to obtain a target data set; Constructing a channel and temporal attention mechanism convolutional network model, where the channel and temporal attention mechanism convolutional network model includes a channel attention convolutional module, a deep feature extraction module, a temporal attention module, and a classification module; wherein: The depth feature extraction module performs depth feature extraction on the channel-weighted convolution feature map group to obtain a depth convolution feature map group; specifically: divide the time window and use M feature windows to perform windowing processing on each channel-weighted convolution feature map in the channel-weighted convolution feature map group along the time dimension, and divide each channel-weighted convolution feature map into M window sub-feature maps with equal widths; calculate the variance of each window sub-feature map in each feature window according to the variance layer to obtain M the variances of each window sub-feature map in each of the feature windows; perform natural logarithm operations on the variances of each window sub-feature map to obtain the variance features of each window sub-feature map; according to the M variance features corresponding to each channel-weighted convolution feature map, construct each depth convolution feature map corresponding to each channel-weighted convolution feature map; construct the depth convolution feature map group according to each depth convolution feature map; The time attention module performs time attention weighting processing on the depth convolution feature map group to obtain a time-weighted convolution feature map group; specifically: equally divide the variance features in each of the feature windows into h variance feature groups; perform multi-head attention processing on each of the h variance feature groups corresponding to each feature window through a one-dimensional convolutional layer to obtain each attention feature corresponding to each variance feature; splice each of the attention features in each of the M feature windows along the time dimension to obtain each time-weighted convolution feature map corresponding to each depth convolution feature map; construct the time-weighted convolution feature map group according to each time-weighted convolution feature map; Constructing a loss function, and training and testing the channel and temporal attention mechanism convolutional network model according to the loss function and the target data set; Inputting the motion imagination EEG signal to be classified into the tested channel and temporal attention mechanism convolutional network model, and outputting the classification result of the motion imagination EEG signal data.
2. The method for classifying motor imagery EEG signals according to claim 1, wherein, The step of inputting the motion imagination EEG signal to be classified into the tested channel and temporal attention mechanism convolutional network model and outputting the classification result of the motion imagination EEG signal data; specifically: Inputting the motion imagination EEG signal to be classified into the channel attention convolutional module of the tested channel and temporal attention mechanism convolutional network model, and the channel attention convolutional module performs convolutional processing on the motion imagination EEG signal to be classified, and outputs a group of channel-weighted convolutional feature maps; Inputting the group of channel-weighted convolutional feature maps into the deep feature extraction module, and the deep feature extraction module performs deep feature extraction on the group of channel-weighted convolutional feature maps to obtain a group of deep convolutional feature maps; Inputting the group of deep convolutional feature maps into the temporal attention module, and the temporal attention module performs temporal attention weighting processing on the group of deep convolutional feature maps to obtain a group of temporally weighted convolutional feature maps; Inputting the group of temporally weighted convolutional feature maps into the classification module, and the classification module performs classification processing on the group of temporally weighted convolutional feature maps to obtain the category corresponding to the motion imagination EEG signal to be classified, and completes the classification of the motion imagination EEG signal to be classified.
3. A method for classifying motor imagery EEG signals according to claim 2, characterized in that, The channel attention convolutional module performs convolutional processing on the motion imagination EEG signal to be classified and outputs a group of channel-weighted convolutional feature maps; specifically: Inputting the motion imagination EEG signal to be classified into the channel attention convolutional module, and the first temporal convolutional layer in the channel attention convolutional module performs temporal convolutional processing on the motion imagination EEG signal to be classified to obtain an initial group of feature maps, and performs normalization processing on the initial group of feature maps according to the first batch normalization layer; Performing spatial convolutional processing on the initial group of feature maps after the normalization processing according to the spatial convolutional layer to obtain a group of spatial feature maps; then performing normalization processing and non-linear activation processing on the group of spatial feature maps according to the second batch normalization layer and the first non-linear activation layer in sequence; Performing average pooling processing on the group of spatial feature maps after the non-linear activation processing according to the average pooling layer, and then performing dropout processing on the group of spatial feature maps after the average pooling processing according to the dropout layer; Performing channel attention weighting processing on the group of spatial feature maps after the dropout processing according to the channel attention layer to obtain a group of channel-weighted feature maps; Perform temporal convolution processing on the channel-weighted feature map group according to the second temporal convolution layer, and then perform normalization processing and non-linear activation processing on the spatial feature map group according to the third batch normalization layer and the second non-linear activation layer in sequence to obtain the channel-weighted convolution feature map group.
4. A motor imagery EEG signal classification system that implements a motor imagery EEG signal classification method according to any one of claims 1-3, characterized in that, The system includes: An acquisition module: acquire a data set, preprocess the data set to obtain a target data set; A construction module: construct a channel and temporal attention mechanism convolutional network model, the channel and temporal attention mechanism convolutional network model includes a channel attention convolutional module, a depth feature extraction module, a temporal attention module, and a classification module; where: The depth feature extraction module performs depth feature extraction on the channel-weighted convolution feature map group to obtain a depth convolution feature map group; specifically: divide the time window and use M feature windows to perform windowing processing on each channel-weighted convolution feature map in the channel-weighted convolution feature map group along the time dimension, and divide each channel-weighted convolution feature map into M window sub-feature maps with equal widths; calculate the variance of each window sub-feature map in each feature window according to the variance layer to obtain M the variances of each window sub-feature map in each of the feature windows; perform natural logarithm operations on the variances of each window sub-feature map to obtain the variance features of each window sub-feature map; according to the M variances features corresponding to each channel-weighted convolution feature map, construct each depth convolution feature map corresponding to each channel-weighted convolution feature map; construct the depth convolution feature map group according to each depth convolution feature map; The time attention module performs time attention weighting processing on the deep convolutional feature map group to obtain a time-weighted convolutional feature map group; specifically: equally divide the variance features in each of the feature windows into h variance feature groups; perform multi-head attention processing on each of the h variance feature groups corresponding to each feature window through a one-dimensional convolutional layer to obtain each attention feature corresponding to each variance feature; splice each of the attention features in each of the M feature windows along the time dimension to obtain each time-weighted convolutional feature map corresponding to each deep convolutional feature map; construct the time-weighted convolutional feature map group according to each time-weighted convolutional feature map; A training module: construct a loss function, and train and test the channel and temporal attention mechanism convolutional network model according to the loss function and the target data set; A classification module: input the motion imagination EEG signal to be classified into the tested channel and temporal attention mechanism convolutional network model, and output the classification result of the motion imagination EEG signal data.
5. An electronic device, characterized in that, It includes a processor, a memory, and a program or instruction stored on the memory and executable on the processor. When the program or instruction is executed by the processor, the steps of a motion imagination EEG signal classification method according to any one of claims 1-3 are implemented.
6. A readable storage medium, characterized in that, A program or instruction is stored on the readable storage medium. When the program or instruction is executed by a processor, the steps of a motion imagination EEG signal classification method according to any one of claims 1-3 are implemented.
Citation Information
Patent Citations
Nervous system disease electroencephalogram diagnosis method and device based on space-time attention
CN118121210A