{'fraction_non_alphanumeric': 0.03134666941637451, 'fraction_numerical': 0.007836667354093628, 'mean_word_length': 4.920879120879121, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
MutualGraphNet: A novel model for motor imagery classification

Motor imagery classification is of great significance to humans with mobility impairments, and how to extract and utilize the effective features from motor imagery electroencephalogram(EEG) channels has always been the focus of attention. There are many different methods for the motor imagery classification, but the limited understanding on human brain requires more effective methods for extracting the features of EEG data. Graph neural networks(GNNs) have demonstrated its effectiveness in classifying graph structures; and the use of GNN provides new possibilities for brain structure connection feature extraction. In this paper we propose a novel graph neural network based on the mutual information of the raw EEG channels called MutualGraphNet. We use the mutual information as the adjacency matrix combined with the spatial temporal graph convolution network(ST-GCN) could extract the transition rules of the motor imagery electroencephalogram(EEG) channels data more effectively. Experiments are conducted on motor imagery EEG data set and we compare our model with the current state-of-the-art approaches and the results suggest that MutualGraphNet is robust enough to learn the interpretable features and outperforms the current state-of-the-art methods.


Introduction
Brain-computer-interface(BCI) technology has received much attention globally because of its significant meaning [29]. It enables their users to interact with a machine via the brain singals [32], such as the motor imagery task which translates the mental imagination of movement into commands [2] can be utilized to help disabled people as a rehabilitation device [33], which could be considered as being the only way of communication for people with motor disabilities [16]. The motor imagery classification based on the features extracted from the EEG imagination data of moving the body parts without actual movement, but the feature extraction process often rely too much on prior knowledge to exclude some features [26], so the more robust feature extraction techniques will continue to promote the development of BCI technologies. A complete BCI system generally contains four main processes [22]: EEG raw data collection, data pre-processing, feature extraction and feature classification. The classification phase is crucial since a good classifier can utilize the extracted features as great as possible and greatly improve the accuracy of classification. The motor imagery classification is a EEG-based task mainly focus on the feature extraction and classification, and a big number of researchers have made great contributions to this task. The two most common types of features are frequency band power features and time point features [25], both types of features benefit from being extracted after spatial filtering [6]. Principal com-ponent analysis(PCA) and independent component analysis(ICA) are two classical unsupervised spatial filter manners [14], supervised spatial filters include the common spatial patterns(CSP) and filter bank common spatial patterns(FBCSP) [17]. As for the classifiers for Motor imagery task, there are some state-of-the-art methods that have been proven to have good performance, such as linear discriminant analysis(LDA), passive-aggressive(PA) and support vector machine(SVM) [31].
In recent years, deep learning methods have achieved remarkable performances in many fields, and many recent works have explored the application of deep learning to EEG-based tasks [28]. Deep learning has largely alleviated the need for manual feature extraction and provided end-to-end learning for EEG based tasks, such as sleep stage detection, anomaly detection, motor imagery classification and so on [19]. Although the convolution nets could learn from the raw data without manual feature extraction, but they still have their own limitations including that they generally require large dataset to train the model, which may be a drawback for EEG based tasks since that the collection of EEG data often cost a lot. In addition, the EEG data has its own unique characteristics, it's collected from different areas of the brain, so the spatial connection among the EEG data shouldn't be ignored, however, neither the state-of-theart methods nor the recent deep learning methods can effectively learn the connections between different brain regions [13].
Graphs are the most appropriate data structure to indicate brain connection, and graph neural networks(GNNs) has been demonstrated to be effective in classifying graph structures [35], the core idea of GNNs is to update each node's embedding iteratively through aggregating the representations of its neighbors and itself. The EEG channels could be represented as nodes in the graph and the connections among the channels correspond to the edges of the graph, but the graph convolutional networks need adjacency matrix to be given in advance which is the representation of the graph connection [3], since the limitations of cognition of brain structure, so it's still a challenge to determine a suitable graph structure of the brain. Moreover, the collection of EEG data is usually in chronological order, so it also has temporal characteristics in addition to spatial characteristics which also need to be taken into account.
In this paper, we proposed a novel model called MutualGraphNet, combined the spatial-temporal filter and graph convolutional networks to learn the temporal and spatial characteristics, as for the graph connection, we use the mutual inforamtion between different channels as the degree of the association between channels, which achieved robust performance on the motor imagery classification tasks. The contributions of this paper are as follows: • A novel model is proposed, which could realize end-to-end learning. Furthermore, the model is specially designed to adapt to the characteristics of EEG data, so it could be able to utilize the features to the great extend.
• For the first time, we try to use mutual information as the adjacent matrix of graph convolution input, and achieve good performance.
• Experimental results demonstrate that our method achieves better performance in the motor imagery classification task.

Related Work
A motor imagery classification task is of great significance for disabled people. Numerous work has been proposed to improve the classification performance. In the earlier research, traditional machine learning methods are generally used for motor imagery classification task, such as support vector machine(SVM), K-Nearest-Neighbor(KNN) and artificial neural network(ANN) are frequently used [10], but these traditional methods have limited performance on EEG-based classification tasks. Thus, Common Spatial Patterns(CSP) [27] algorithm was proposed specially for motor imagery classification tasks, and it has been used for many EEG-based classification tasks successfully. Based on the CSP, the Filter bank common spatial pattern(FBCSP) [15] was proposed, which bandpass-filtered the EEG data into multiple frequency bands, then CSP features were extracted from each of these bands. The FBCSP algorithm achieved better performance than CSP on the motor imagery classification task.
Currently, the deep learning methods are utilized in EEG-based classification tasks, Deep Belief Network(DBN) [23] was proposed that extracted features manually from the channels then feed the features into the network. Convolutional Neural Networks(CNN) could learn features from EEG data automatically and have better performance than DBN due to its regularization structure and degree of translation invariance [1]. Two CNN models were specially designed for motor imagery classification called Shallow ConvNets and Deep ConvNets [28], both of them have better performance than the state-of-theart methods. Then another CNN model called EEGNet [19] was proposed, which utilizes the Depthwise and Separable convolutions to replace the traditional convolutions for the motor imagery task. Besides, the novel deep learning method based on Multi-Task Learning framework called DMTL-BCI [29] was proposed for EEG-based classification, which enhanced the generalization ability of the model and improve the performance of classification with limited data.
The CNN models can effectively extract the local patterns of data, but it can only be applied for the standard grid data [9], graph convolutional networks have been proven to have better performance on the graph structure data. Many works have been done to improve the performance of the graph convolutional networks. For example, The GraphSAGE model [11] could leverage node feature information to efficiently generate node embeddings for unseen data, the graph attention networks(GATs) [30] through stacking layers in which nodes are able to attend over their neighborhoods' features, could specify different weights to different nodes in a neighborhood. So far, GCNs have been applied in many fields, the spatialtemporal graph convolution network(ST-GCN) [20] is proposed to learn the dynamic graphs for the human action recognition tasks, the spatiotemporal multi-graph convolution network(ST-MGCN) [8] is proposed for ride-hailing demand forecasting which encodes the non-Euclidean correlations among regions into multiple graphs, GraphSleepNet [13] based on spatial-temporal convolution network(ST-GCN) is proposed for automatic sleep stage classification.
Motivated by the studies mentioned above, considering the graph structure and the dynamic spatialtemporal characteristic of the EEG data, also the graph structure of different motor imagery may be different, the traditional GCNs models may be not optimal for EEG-based motor imagery classification task. we propose the novel model to best suit to the characteristics of EEG data.

Methodology
The overall framework of the model proposed in this paper is presented in Fig. 1, it includes three main parts: feature extraction and mutual information computation part, spatial-temporal attention part and spatial-temporal graph convolution part. Spatial-temporal attention part puts more attention on the more valuable spatial-temporal information, spatial-temporal graph convolution part extracts both spatial and temporal features.

Mutual information computation
Mutual Information(MI) [24] is used to indicate wether there is a relationship between two variables and the strength of the relationship. The mutual information of two variables X and Y can be defined as: Figure 1: The overall structure of the proposed model, consists of three parts : the feature extraction and mutual information computation part, the spatial-temporal attention mechanism part and spatialtemporal graph convolution part.
Mutual information is related to entropy, which is the expected or mean value of the information of all variables. The entropy of X is defined as: Then MI of X and Y can be computed by the equations: H(X, Y ) is the joint entropy of X and Y : H(Y |X) is the conditional entropy that X is given in advanced: Thus, I(X, Y ) is the reduction in the uncertainty of the variable X by the knowledge of another variable Y, equivalently, it represents the amount of information that B contains about A. Considering the features of EEG data X = x 1 , x 2 , ..., x N ∈ R N ×F , we could compute the mutual information m i j of x i , x j and use it as the weight of the connection of x i , x j , then we could generate a N × N weight matrix which could be used as the input adjacency matrix of the graph convolution networks as Fig. 2 shown.

Spatial-temporal attention
The spatial-temporal attention mechanism could capture the dynamic spatial and temporal correlations of the motor imagery network. In the spatial dimension, the activities of one brain region has influence on other brain regions and generally different brain activities convey different information, so the dynamic spatiotemporal capture mechanism is required. We use a spatial attention mechanism [7], which could be represented as: Figure 2: The process of calculating the mutual information between channels and obtaining the adjacency matrix, N represents the number of channels.
Where S denotes the spatial attention matrix, which is computed by current layer. V p , b p ∈ R N ×N , χ ( r −1) = (X 1 , X 2 , ..., X Tr−1 ∈ R N ×Cr−1×Tr−1 C r−1 is the number of channels of the input data in the r t h layer. W 1 ∈ R Tr−1 , W 2 ∈ R Cr−1×Tr−1 , W 3 ∈ R Cr−1 , S i,j in S represents the correlation strength between node i and j, then a softmax function is used to normalize the attention weights. Combine the adjacency matrix and the spatial attention matrix, the model could adjust the impacting weights between nodes dynamically.
In the temporal dimension, there are correlations during each motor imagery trial, since that the brain waves are transmitted in the cerebral cortex and the active areas of the brain will change over time, so the collected EEG data also changes over time. Therefore, a temporal attention is utilized to capture dynamic temporal information. The temporal attention mechanism is defined as: Where V e , b q ∈ R T l−1 ×T l−1 , M 1 ∈ R N , M 2 ∈ R C l−1 ×N , M 3 ∈ R C l−1 , E m,n denotes the strength of the correlation between motor imagery network m, n, and E is normalized by the softmax function, so the temporal attention matrix can be directly applied to the input.

Spatial-temporal graph convolution
The spatial-temporal convolution consists of a graph convolution in the spatial dimension and a normal convolution in the temporal dimension, which could extract both the spatial features and the temporal features.
The spatial features are extracted by aggregating information from neighbor nodes, we use graph convolution to extract the spatial features. The graph convolution is based on laplacian matrix and fourier transform, the graph laplacian can be defined as: Where A ∈ R N ×N is the adjacency matrix associated with the graph, D ∈ R N ×N is the diagonal degree matrix, I ∈ R N ×N is the identity matrix. L is a real symmetric positive semidefinite matrix, it can be decomposed as L = U ΛU T and Λ ∈ R N ×N is the diagonal matrix of eigenvalues that represent the frequencies of their associated eigenvectors. Let x ∈ R n be a signal defined on the vertices of a graph G, the graph fourier transform of the signal is defined asx = U T x. The graph convolution uses the linear operators that diagonalize in the flourier domain to replace the classical convolution operator, the graph convolution can be defined as: Where θ is a vector of fourier coefficients to be learned, g θ is the filter, to reduce the computational complexity, g θ can be approximated by a truncated expansion in the terms of Chebyshev polynomials [5]: Where k is the order of the Chebyshev polynomials, θ p ∈ R k is the vector of Chebyshev coefficients, T p (Λ) ∈ R N ×N is the Chebyshev polynomial of order k andΛ = 2Λ/λ max − I ranges in [−1, 1]. Then the j − th output feature can be calculated as: x i denotes the i − th row of input matrix, F in equals to the input dimension, the outputs are collected into a feature matrix Y = [y 1 , y 2 , ..., y Fout ] ∈ R N ×Fout . In this work, we generalize the above definition to the nodes with multiple channels, the l − th layer's input is X (l−1) = (x 1 , x 2 , ..., x (T l−1 ) ) ∈ R N ×C l−1 ×T l−1 , C (l−1) denotes the channel's number and T l−1 denotes the l − th layer's temporal dimension.
After the graph convolution having captured the neighboring information for each node in the spatial dimension, a standard convolution layer is used in the temporal dimension, we use a standard twodimension convolution layer to extract the temporal information, the r − th convolution layer could be defined as: χ where Φ is the parameter of the temporal dimension convolution kernel, and * represents the convolution operation, ReLU is the activation function.

Experiment
In order to evaluate the effectiveness of our model, we carried out the comparative experiments on a public dataset BCI Competition IV dataset 2a(SMR) for motor imagery task.

Dataset description
The BCI Competition IV dataset 2a consists of EEG data from nine subjects, there are two sessions recorded, one for training and the other one for testing. Each session includes 288 trials, which are recorded with 22 EEG electrodes and 3 electrooculogram channels, and we only utilize the 22 EEG channels in this experiment. There are four type of labels in this dataset, corresponding to movements of the left hand, right hand, feet and tongue. The original dataset is sampled at 250Hz and bandpass-filtered between 0.5Hz and 100Hz, and we low-pass filter the dataset to 4-40Hz. Also in our experiment, we set the length of each trial to 4.5s which starts from 500ms before the start cue of each trial until to the end cue, then extract 11 differential entropy features(DE) for each channel then double fold the features to make it have the same shape as the adjacency matrix, and combine the two as the input of the graph convolutional network, then we standard scale the data to make it suit for the machine learning model. To show the effectiveness of our model learning from the raw data and ensure the model could be used for wider range of task , we don't do much more preprocessing on the raw EEG data.

Experiment settings
To show the effectiveness of our model, we compare our model with some state-of-the-art methods, the baseline methods are listed as follows: 1. Filter Bank Common Spatial Patterns(FBCSP) [18]: It extracted the band power features of EEG ,then use the features to train the classifier to predict the labels.
2. Shallow ConvNet [28]: An end-to-end learn method, which use convolutional networks to do all the computations.
3. Deep ConvNet [28]: It has more convolution-pooling blocks and is much deeper than Shallow Con-vNet.
In addition to the above baseline methods, we also compared traditional machine learning methods, support vector machine(SVM) [4] and random forest(RF) [21].
In order to prove that the model can effectively extract features and have the ability to eliminate the influence of individual differences, we no longer conduct experiments on each subject separately, we mixed the experimental data of nine subjects, and a total 2592 training trials and 2592 testing trials, and we use four-fold cross-validation to evaluate the performance. We use Adam optimizer and the loss rate is set to 7.6e-4, and dropout rate is 0.5, the batch size is 32 and the we train the model 500 epochs. For the graph convolutional layers, and since the training set is not big enough, so in order to reduce the impact of overfitting, we adopt a loss flooding strategy [12], which is defined as:R(g) = |R(g) − b| + b andR(g) is the loss of the model, b is a constant called loss flooding level, here we set b as 0.5. As for the baseline methods, in order to evaluate the performance of the models more reasonably, we use 250Hz sampling 4.5s EEG data for all experiments. Since that the EEGNet [19] used the 128Hz resampled data to conduct experiment in the original paper, so we double the lengths of temporal kernels and average pooling size of the original model for double sampling rate to better adapt the input which proven to have better performance than the original model. In response to changes in the length of the sampling time, we also adjusted the parameters of each model accordingly and conducted experiments and we selected the best model performance. The training parameter of other baseline methods are the same as in the paper [19].

Results and discussion
We compare our model with the six baseline methods on SMR, we use the accuracy, f1-score and precision as the evaluation metrics to evaluate the performance of the models. Tabel 1 shows the performance of the different models on the SMR dataset, the results show that our model have better performance compared to the other baseline methods. For the traditional methods, the random tree(RF) has better performance In order to evaluate the effect of the depth of network, we study the impact of the layers of ST-GCN in Fig. 3. The horizonal axis in Fig. 3 represents the layers of ST-GCN and the vertical axis represents the corresponding performance of the model. The results show that the MutualGraphNet with more ST-GCN layers doesn't work better, the best performance is achieved when the layers is 4 and with the number of layers increases the performance gets worse, which is caused by the increase in the number of layers leads to an increase in training parameters, but the training data set is too small to train the model with more parameters. In this paper, we extract differential entropy(DE) feature as the input of the model, and in EEG-based tasks there are other five different features [34]: power spectral density(PSD), differential asymmetry (DASM), rational asymmetry(RASM), asymmetry(ASM) and differential caudality(DACU) features from EEG. The DASM and RASM can be expressed as: ASM features are the direct concatenation of DASM and RASM features. DCAU features are the difference between DE features of frontal-posterior electrodes, which can be defined as: We also evaluate the performance of our model on these features. The comparison of the performance of model on different features is shown in Table.2. All the experiments are performed with 4-fold crossvalidation and the training settings are the same as above. The results presented in Table.2 show that indicate that there exists some kind asymmetry of the brain which has discriminative information and our knowledge of the human brain is still very limited, the deeper understanding of brain is still required to obtain more effective and valuable information from EEG data. Moreover, in order to evaluate the effectiveness of mutual information(MI), we also design several different ways to generate adjacency matrix: 1. KNN: For each channel, select the nearest N channels to establish a connection.
2. Euclidean distance(ED): According to the actual distance of each electrode on the brain, select adjacent points to establish a connection.
3. Random: Randomly select channels and establish connections between channels.
4. Mul KNN: Use KNN to establish connections and calculate mutual information between connected channels.
5. Mul ED: Use euclidean distance to conform connection and calculate mutual information between connected channels The results of classification with different kind of adjacency matrix are shown in Fig. 4. It can be seen that the MI adjacency matrix has best performance, Mul KNN and Mul ED is better than KNN and ED which means that mutual information could provide valuable information for ST-GCN. Furthermore, the adjacency matrix surly could effect the performance of classification.

Conclusion
In this paper, we propose a novel attention based spatial-temporal graph convolution model for motor imagery classification task, the model combines the spatial-temporal attention mechanism and the spatialtemporal convolution. The main advantage of the proposed model is to extract attentive spatial-temporal features of EEG data and experiment results demonstrate that our model outperforms the state-of-the-art methods. Our model is designed to extract spatial-temporal features of EEG, so it can also be applied to other EEG-based tasks. Actually, the current understanding of brain mechanisms is still limited, as the understanding of the brain gradually increase, more influencing factors will be taken into account to further improve the forecasting accuracy. Moreover, motor imagery EEG data presents individual differences, such as FBCSP has different performance when experimenting with EEG data from different subjects, and it can achieve good results when using the same subject's data for training and testing, but it does not perform well in mixed data of multiple subjects. Individual difference also affected the development of solutions for the classification task of motor imagery, eliminating individual differences and extract valuable features is still key for wider application of EEG-based tasks.