BCI Optimization Method Based on Deep Neural Networks
By constructing an EEG classification model based on deep neural networks, combining convolutional neural networks and self-attention modules, and using Fisher's ratio to screen significant channels, the problems of imperfect global optimization and reliance on human experience in EEG channel selection are solved, achieving efficient channel combination and classification accuracy, and is suitable for portable EEG devices.
Patent Information
- Application Number
- CN202410254396.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-06
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2044-03-06
AI Technical Summary
Existing EEG channel selection methods suffer from imperfect global optimization, low efficiency, reliance on human experience, and low accuracy in multi-classification. Furthermore, research on EEG channel optimization algorithms based on artificial intelligence deep learning is limited, making it difficult to effectively utilize the correlation of EEG signals.
We employ a deep neural network-based approach, combining deep learning and statistics. By using an improved convolutional neural network, a self-attention module, and a graph convolutional neural network, we construct an EEG classification model. We utilize Fisher's ratio to screen significant channels, optimize channel combinations, and reduce channel redundancy.
It achieves a significant reduction in the number of channels in multi-classification tasks while maintaining high classification accuracy, improves data processing efficiency, reduces reliance on professional knowledge, and is suitable for the design of portable EEG devices.
Smart Images

Figure CN118070124B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a technique in the field of electroencephalogram (EEG) signal analysis, specifically a brain-computer interface (BCI) optimization method based on deep neural networks. Background Technology
[0002] Existing methods for EEG channel selection can be broadly categorized into filtering, wrapping, and embedding techniques. These traditional methods, which optimize feature selection and classifiers separately, may lead to imperfect global optimization. Furthermore, they suffer from low efficiency, reliance on human experience, and room for improvement in multi-classification accuracy. Currently, research on EEG channel optimization algorithms based on deep learning in artificial intelligence remains limited, facing numerous challenges in introducing models and decoding EEG semantic features. Studies have shown that when subjects perform a specific task, the task-related channels should contain common information, and this correlation between channels exists across multiple tasks. Summary of the Invention
[0003] To address the aforementioned shortcomings of existing technologies, this invention proposes a BCI optimization method based on deep neural networks. By combining deep learning with statistics, this method can significantly reduce the number of channels used in multi-classification tasks of EEG signals caused by visual images, while maintaining a certain classification accuracy, thus solving the channel redundancy problem and providing new ideas for the design of portable EEG devices.
[0004] This invention is achieved through the following technical solution:
[0005] This invention relates to a BCI optimization method based on deep neural networks. In a multi-classification task of EEG signals caused by visual images, an improved EEG classification model is constructed and trained. The influence of a single channel is determined by the accuracy obtained from the classification, and then channel combinations are constructed, i.e., significant channel selection based on correlation, to achieve BCI optimization.
[0006] The improved EEG classification model includes: an improved convolutional neural network module, a self-attention module, and a classifier module based on fully connected layers. Specifically: the improved convolutional neural network module learns the spatial convolutional layers of the EEG input signal and low-level local features throughout one-dimensional time; the self-attention module learns the global temporal dependence of EEG features, supplements the limited receptive field in the convolutional neural network module, and extracts global correlations within local temporal features, inputting the spatiotemporal characteristics obtained by the convolutional neural network module into the self-attention module; and the classifier module based on fully connected layers predicts the category of the EEG signal based on the embedding vector obtained by the self-attention module.
[0007] The improved convolutional neural network module includes: a graph convolutional neural network (GCNnet), a serialized neural network (Shallownet), and a rearrangement unit (Projection). Specifically: the GCNnet constructs graph-structured data based on the channel nodes of the EEG cap and the physical positions between channels, and performs a three-layer graph convolution operation based on the positional information of the EEG channels to obtain the spatial features of the region surrounding the EEG channels; the serialized neural network expands the output of the GCNnet by one dimension as a convolutional channel, i.e., (1, c). h ,s p The system performs two convolutional layers to obtain one-dimensional low-level local features of the EEG signal in time; the rearrangement unit rearranges the output of the serialized neural network to adapt to the needs of subsequent processing or learning tasks.
[0008] The graph structure data includes nodes and edges, where: a node refers to the value of the corresponding channel at all time points (EEG channel c). h Time sample s p An edge is a connection between nodes based on the physical distance between channels.
[0009] The aforementioned correlation-based significant channel selection refers to: filtering out channels weakly related to the task by calculating the Fisher ratio, retaining only channels that are strongly correlated and closely related to the task, and optimizing the final channel combination. Specifically, the two categories of data have a mean (μ1, μ2) and a variance, respectively. Fisher's ratio Where: (μ1-μ2) 2 It is the inter-class variance, which is the difference between data points of different classes. It is the intra-class variance, which represents the degree of dispersion of data within each class.
[0010] The aforementioned correlation-based salient channel selection specifically includes:
[0011] i) Determine the influence of a single channel: Train an EEG classification model and record the classification accuracy (acc) when all channels are removed. Then, remove channels one by one, recording the accuracy (acc) when removing the i-th channel. i This is used to measure the importance of each channel. Reduce the magnitude Δacc. i The larger the value, the greater the influence of this channel on the classification task. Sort all channels from high to low according to their influence and calculate the average influence, which is the average of all the decreases. Select the EEG channels with [influence > average value] as the initial candidate channels.
[0012] ii) Determine the specific channel combination: Calculate the Fisher ratio between any two channels in the initial candidate channels in turn. Then calculate the average Fisher ratio between all pairs of channels, retain the channels with higher rankings based on the average, and remove the channels with lower rankings.
[0013] Preferably, the classification accuracy of the output EEG channel combination is acc. * And compare acc * The classification accuracy (acc) of all channels is compared with that of the full-channel system to verify the scientific validity of the final retained channel combination. Technical effect
[0014] This invention constructs a deep neural network model driven by a classification task based on convolutional neural networks and a self-attention mechanism. This model determines the influence of each channel and, combined with statistical knowledge, selects significant channel combinations based on Fisher's ratio correlation. Considering the low spatial resolution of EEG signals and the susceptibility of specific channel nodes to the influence of surrounding areas, this invention introduces a graph convolutional neural network, which can directly act on the EEG channel map and utilize its structural information, solving the problem of limited local receptive fields in traditional convolutional neural networks. Considering the high temporal resolution of EEG signals, which can capture minute changes in brain activity within very short time intervals, this invention introduces a self-attention mechanism to learn the global temporal dependence of EEG. Given that existing channel selection methods rely on EEG expertise, the method proposed in this invention enables end-to-end channel selection.
[0015] Compared to existing technologies, the channel selection algorithm of this invention does not rely on the researcher's experience and knowledge, eliminating subjective initiative and requiring researchers to possess domain knowledge of EEG signals, making it user-friendly for non-specialists. The innovation of the algorithm proposed in this invention lies in introducing a graph convolutional neural network to directly act on the EEG channel map, enabling accurate extraction of spatial features. This invention not only considers the individual contribution of each channel but also analyzes the interactions between channels through Fisher's ratio correlation coefficient, thereby optimizing channel combinations and improving data processing efficiency. Using a publicly available dataset to train the channel selection algorithm of this invention, the ten-class classification accuracy reached 94% after training. After channel selection, the number of channels was reduced by half, and the classification accuracy decreased by only 2%. Attached Figure Description
[0016] Figure 1a and Figure 1b This is a flowchart of the present invention;
[0017] Figure 2a and Figure 2b A structural diagram of the improved EEG classification model;
[0018] Figures 3-5 This is a schematic diagram illustrating the effect of an example. Detailed Implementation
[0019] like Figure 1a and Figure 1b As shown, this embodiment involves a method for selecting EEG channels based on a deep neural network model and Fisher ratio correlation. It is implemented using toolkits such as PyTorch, NumPy, Matplotlib, and einops, and employs the Thoughtviz-EEG dataset. The specific steps include:
[0020] Step 1: Set up the CUDA environment by specifying the GPU to use via os.environ["CUDA_VISIBLE_DEVICES"] = "1"; initialize the number of channels n_channels = 14, class labels n_classes = 10, and feature dimension feature_dim = 64.
[0021] Step 2: Load EEG data and corresponding labels from the file as the training set and test set, respectively, and perform standardization and image adjustment on the EEG data.
[0022] The dimensions of the EEG data in the training and test sets are (45390,14,32,1) and (5706,14,32,1), respectively, which represent (number of samples, number of channels, time dimension, 1). The EEG labels are set to 0-9, i.e., a ten-class problem.
[0023] The standardization process described above uses the preprocess_data function to standardize the data and transform its shape to fit the model input. Specifically, it involves: first, normalizing the data: X = (X - max_val) / max_val, where max_val is the maximum value of all elements in data X, so that the data range falls between [-1, 1]; then, rearranging the dimensions of X and converting the data type to float32.
[0024] The image adjustment described above uses the rand_brightness, rand_saturation, and rand_contrast functions to randomly adjust the brightness, saturation, and contrast of the image, thereby increasing the model's generalization ability.
[0025] Step 3: Use the `np.delete` function to sequentially delete the channels of the EEG data and construct a graph-structured data. The data after deleting the i-th channel is named `eegdata`. i (Sample count, 13, 32, 1). At this point, eegdata... i This dataset contains only 13 channels and is used to calculate the impact of deleting channel i on the classification task, i.e., the reduction in classification accuracy. The `eegdata` is removed using the `np.squeeze` function. iIt has a dimension of length 1 and is converted into a tensor.
[0026] The aforementioned construction of the graph data structure refers to: utilizing the location information of EEG channels, calculating the distances between channels, and constructing a graph data structure based on channel nodes and distances. Specifically, this involves: first, reading the Cartesian coordinates of the EEG channels from the chanlocs_14.csv file (relevant data is shown in Table 1); then calculating the Euclidean distances between all channels, filtering out all valid edges, and obtaining the indices of these edges; traversing the training and test set samples, creating a graph data structure for each sample: Data(x, edge_index, y), where x represents the sample's feature vector, edge_index represents the edge index, and y represents the sample label; and then using the load_complete_data function to perform batch processing on the training and test set data.
[0027] Table 1 Cartesian coordinates of EEG channels
[0028] The batch processing operation refers to: storing all sample graph data (Data) in graph_data_list, importing it from torch_geometric.data into DataLoader, and merging multiple Data into a single batch_size object: DataLoader(graph_data_list, batch_size, shuffle = True).
[0029] Step four involves building an improved EEG classification model using PyTorch, specifically including:
[0030] 4.1) A series of graph convolutional layers are used to build the GCNnet module, specifically: three graph convolutional layers GCNConv, ReLU activation function and Dropout.
[0031] 4.2) A series of convolutional layers are used to build the PatchEmbedding module, specifically: two convolutional layers nn.Conv2d, batch normalization BatchNorm2d, ELU activation function, average pooling AvgPool2d, and Dropout.
[0032] 4.3) Construct a TransformerEncoderBlock module with multi-head self-attention (MultiHeadAttention) and a feedforward network (FeedForwardBlock), and add a residual connection (ResidualAdd) to each part.
[0033] The TransformerEncoder module forms the encoder part of the model by stacking multiple TransformerEncoderBlocks, which is used to handle global dependencies of sequence data.
[0034] 4.4) Build a ClassificationHead module that uses global average pooling Reduce to reduce the number of parameters, and output the final ten-class results through a series of linear layers and activation functions.
[0035] The improved EEG classification model includes: an improved convolutional neural network module, a self-attention module, and a classifier module based on fully connected layers. The improved convolutional neural network module learns the spatial convolutional layers of the EEG input signal and the low-level local features of the entire one-dimensional time. The self-attention module extracts the global correlation within the local temporal features and inputs the spatiotemporal features obtained by the convolutional module into the self-attention module. The classifier module based on fully connected layers is used to predict the category of the EEG signal.
[0036] The improved convolutional neural network module introduces a graph convolutional neural network (GCN). Based on the location information of the EEG channels, it performs a three-layer graph convolution operation to capture the spatial features of the area surrounding the channels. Subsequently, the convolutional neural network (CNN) uses temporal convolution to obtain low-level local features in one dimension. Then, an average pooling layer is used to slice the temporal feature segments to suppress noise interference. This not only reduces the model complexity but also removes redundant information and improves the model's generalization ability.
[0037] The improved convolutional neural network module includes: graph convolutional neural network GCNnet, serialized neural network Shallownet, and rearrangement unit Projection.
[0038] The graph convolutional neural network GCNnet includes three graph convolutional layers, a ReLU activation function, and a Dropout layer. The three graph convolutional layers process the channel node features sequentially, and each layer increases the network's nonlinearity and generalization ability through activation functions and Dropout regularization.
[0039] The first graph convolutional layer transforms the node features from 32 to 128 features.
[0040] The second graph convolutional layer further reduces the node features to 64 dimensions.
[0041] The third convolutional layer restores the node features to their original 32 dimensions.
[0042] The Dropout layer is activated only in training mode.
[0043] The serialized neural network Shallownet includes: two convolutional layers, a batch normalization layer, an ELU (Exponential Linear Unit) activation function, an average pooling layer, and a Dropout layer. The first convolutional layer performs convolution processing in the time dimension, the second convolutional layer acts as a spatial filter to learn the closer relationships between different EEG channels, the batch normalization layer and the ELU activation function help the model learn and speed up the training process, and the average pooling layer operates along the time dimension.
[0044] The first convolutional layer comprises k kernels of size (1,4) with a stride of (1,1).
[0045] The second convolutional layer retains k elements of size (c h The kernel is (1,1), with a step size of (1,1), where c h This is equal to the number of electrode channels in the EEG data.
[0046] The average pooling layer kernel size is (1,2) and the step size is (1,4). This pooling layer smooths out time characteristics, which not only avoids overfitting but also reduces computational complexity.
[0047] The Dropout layer has a dropout rate of 0.5 to prevent overfitting.
[0048] The aforementioned rearrangement refers to compressing the EEG channel dimension and transposing the convolutional channel dimension with the temporal dimension. In this way, all feature channels at each time point are input as tokens into the next module.
[0049] The self-attention module learns global time dependencies through a self-attention layer. This module includes a multi-head attention mechanism unit, a residual connection unit, a feedforward network unit, and multiple stacked encoder blocks. Specifically: the multi-head attention mechanism unit, during initialization, creates linear transformations of keys, queries, and values for each head and defines the projections of attention and output; the residual connection unit encapsulates functions (e.g., multi-head attention or feedforward network) that allow input to be processed through these functions and the result added to the original input, thus achieving residual connections; the feedforward network performs complex feature transformations through four steps: dimensionality expansion, non-linear activation, regularization, and dimensionality reduction. This approach improves the model's ability to handle complex data. The feedforward network unit includes two linear layers, a GELU activation function, and a Dropout layer. Encoder blocks are constructed by concatenating residual connections with LayerNorm and multi-head attention, and residual connections with LayerNorm and feedforward network; the encoder blocks can perform complex feature extraction and information integration based on the input information, ultimately yielding results with rich representational capabilities.
[0050] The classifier module includes a global average pooling layer and two fully connected layer sequences (fc1, fc2). The global average pooling layer uses a Reduce operation to reduce the size of the embedding vector from (batch_size, num_tokens, emb_size) to (batch_size, emb_size). This step reduces the dimensionality of each sample by aggregating multiple features into a fixed-size vector. The fully connected layer sequences fc1 and fc2 further process the data and finally output the classification result. Both use the ELU activation function and Dropout to prevent overfitting.
[0051] Step 5: Train the EEG classification model, which includes:
[0052] 5.1) Set the learning rate lr = 0.0002, batch size batch_size = 256, loss function to torch.nn.CrossEntropyLoss, optimizer to Adam with betas = (0.7, 0.5), and maximum training epochs max_epochs = 500. Initialize the early stopping parameter patience = 10. If the accuracy on the test set does not improve within 10 consecutive epochs, training is stopped to prevent overfitting.
[0053] 5.2) Instantiate the classification model and move it to the GPU. Continuously train the model and save the optimal model state. After training, save the classification accuracy (acc = 0.9398) for all channels.
[0054] 5.3) Remove channels one by one and record the accuracy (acc) when removing the i-th channel. i i = [1, 14], accuracy results are as follows Figure 3 As shown.
[0055] Step 6: Determine the impact of each channel on the classification task. Specifically, calculate the decrease in classification accuracy Δacc after removing each channel. i =acc-acc i i = [1, 14], decrease the magnitude Δacc i The larger the value, the greater the influence of this channel on the classification task. All channels are sorted from highest to lowest according to their influence, as shown below. Figure 4 As shown. Calculate Δacc. i average Pick The EEG channel was used as the initial candidate channel, and the results were 8, 4, 14, 1, 11, 7, and 9.
[0056] Step 7: Extract the EEG features of the initial candidate channels. Specifically, based on the optimal model state saved in Step 5, extract the 64-dimensional features of channels 8, 4, 14, 1, 11, 7, and 9 in sequence. These features refer to the features before processing by the fully connected layer, that is, the feature vector after global average pooling and layer normalization.
[0057] Step 8: Determine the optimal channel combination, which involves calculating the Fisher ratio among the features of the initial candidate channels. Specifically: fisher_ratio = np.square(mean1 - mean2) / (var1 + var2), where: mean i Let var be the mean of the i-th feature. i Let be the variance of the i-th feature, and the calculation result is as follows: Figure 5 As shown, the average Fisher ratio between all pairs of channels according to The channels with the highest order are retained: 11, 9, 1, 8, 7, 14, 4, which is the final optimal channel combination: FC6, P8, AF3, O2, O1, AF4, FC5. The result is as follows: Figure 2b As shown.
[0058] Through practical experiments, the data dimension was expanded to 14 channels to avoid errors caused by the reduction in data volume. An EEG classification model was trained, and the classification accuracy of the selected channel combination was calculated to be 0.9127. Compared to the full-channel approach, the number of channels was reduced to 7, but the accuracy only decreased by 0.0271.
[0059] Compared to existing technologies, this invention introduces a graph convolutional neural network, which can directly act on the EEG channel map and utilize its structural information to solve the problem of limited local receptive fields in traditional convolutional neural networks. It not only considers the individual contribution of each channel but also analyzes the interactions between channels using Fisher's ratio correlation coefficient, thereby optimizing channel combinations and improving data processing efficiency. Using a publicly available dataset to train the channel selection algorithm of this invention, the ten-class classification accuracy reached 94% after training. After channel selection, the number of channels was reduced by half, and the classification accuracy decreased by only 2%.
[0060] The above-described specific implementations can be partially adjusted by those skilled in the art in different ways without departing from the principles and purpose of the present invention. The scope of protection of the present invention is defined by the claims and is not limited to the above-described specific implementations. All implementation schemes within the scope of the claims are bound by the present invention.
Claims
1. A BCI optimization method based on deep neural networks, characterized in that, In a multi-classification task of EEG signals induced by visual images, an improved EEG classification model is constructed and trained. The influence of a single channel is determined by the accuracy obtained from the classification, and then channel combinations are constructed, i.e., significant channel selection based on correlation, to achieve optimization of BCI. The improved EEG classification model includes: an improved convolutional neural network module, a self-attention module, and a classifier module based on fully connected layers. Specifically: the improved convolutional neural network module learns the spatial convolutional layers of the EEG input signal and low-level local features throughout one-dimensional time; the self-attention module learns the global temporal dependence of EEG features, supplements the limited receptive field in the convolutional neural network module, and extracts global correlations within local temporal features, inputting the spatiotemporal characteristics obtained from the convolutional neural network module into the self-attention module; the classifier module based on fully connected layers predicts the category of the EEG signal based on the embedding vector obtained from the self-attention module. The improved convolutional neural network module includes: a graph convolutional neural network, a serialized neural network, and a rearrangement unit. The graph convolutional neural network constructs graph structure data based on the channel nodes of the EEG cap and the physical positions between channels. Based on the positional information of the EEG channels, it performs a three-layer graph convolution operation to obtain the spatial features of the region surrounding the EEG channels. The serialized neural network expands the output of the graph convolutional neural network by one dimension to serve as the convolutional channel. Two convolutional layers are performed to obtain one-dimensional low-level local features of the EEG signal in time; the rearrangement unit rearranges the output of the serialized neural network to adapt to the needs of subsequent processing or learning tasks. The graph structure data includes: node features, i.e., the values of the corresponding channels at all time points. And edges, which connect nodes based on the physical distance between channels; The aforementioned correlation-based significant channel selection refers to: through calculation Instead of filtering out channels that are weakly relevant to the task, only retaining channels that are strongly relevant and closely related to the task, the final channel combination is optimized. Specifically, the data distributions of the two categories are respectively the mean... and variance ,but Compare It is the inter-class variance, which is the difference between data points of different classes. It is the intra-class variance, which represents the degree of dispersion of data within each class.
2. The BCI optimization method based on deep neural networks according to claim 1, characterized in that, The graph convolutional neural network includes: three graph convolutional layers, Activation function and The three graph convolutional layers process the channel node features sequentially, with each layer using an activation function and... Regularization is used to increase the nonlinearity and generalization ability of the network.
3. The BCI optimization method based on deep neural networks according to claim 1, characterized in that, The serialized neural network includes: two convolutional layers, a batch normalization layer, and... Activation function, average pooling layer and The layers consist of a first convolutional layer that performs convolutional processing in the temporal dimension, a second convolutional layer that acts as a spatial filter to learn smaller, closer relationships between different EEG channels, and a batch normalization layer. Activation functions help the model learn and speed up the training process, while average pooling layers operate along the time dimension.
4. The BCI optimization method based on deep neural networks according to claim 1, characterized in that, The self-attention module learns global temporal dependencies through a self-attention layer. This module includes a multi-head attention mechanism unit, a residual connection unit, a feedforward network unit, and multiple stacked encoder blocks. During initialization, the multi-head attention mechanism unit creates a key for each head. Query Sum The linear transformation is defined, and the attention and projection of the output are defined; the residual connection unit encapsulates a function that allows the input to be processed through the function and the result is added to the original input to realize the residual connection; the feedforward network unit performs complex feature transformation processing through dimension expansion, nonlinear activation, regularization and dimension reduction; the encoder block performs complex feature extraction and information integration based on the input information, and finally obtains a result with rich representation capabilities.
5. The BCI optimization method based on deep neural networks according to claim 4, characterized in that, The feedforward network unit includes: two linear layers, Activation function and Layers, connected in series with Residual connections with multi-head attention and having The encoder block is constructed by connecting the residuals of the feedforward network to the network.
6. The BCI optimization method based on deep neural networks according to claim 1, characterized in that, The classifier module includes: a global average pooling layer and two fully connected layers. Sequence, where: global average pooling uses The operation changes the size of the embedding vector from Reduce to This step reduces the dimensionality of each sample by aggregating multiple features into a fixed-size vector. (Fully connected layer sequence) and Both further process the data and ultimately output the classification results using [method / method]. Activation function and Prevent overfitting.
7. The BCI optimization method based on deep neural networks according to claim 1, characterized in that, The aforementioned correlation-based salient channel selection specifically includes: i) Determine the influence of individual channels: Train the EEG classification model and record the classification accuracy across all channels. Then, while removing channels one by one, record the removal of each channel (the first one). Accuracy at (number) This is used to measure the importance of each channel and reduce the magnitude. The larger the value, the greater the influence of this channel on the classification task. Sort all channels from high to low according to their influence and calculate the average influence, which is the average of all the decreases. Select the EEG channels with [influence > average value] as the initial candidate channels. ii) Determine the specific channel combination: Calculate the relationship between any two channels in the initial candidate channels sequentially. Compare And calculate the pairs of channels. The average value of the ratio is used to retain the channels that rank higher and remove the channels that rank lower.
8. The BCI optimization method based on deep neural networks according to claim 7, characterized in that, Classification accuracy of output EEG channel combination And compare and This verifies the scientific validity of the final retained channel combination.
Citation Information
Patent Citations
Electroencephalogram channel selection method based on extrusion and activation graph convolutional neural network
CN114818823A
EEG channel selection method based on Fisher score
CN116756643A
