A movement disorder rehabilitation training method and system based on electroencephalogram signal recognition
By combining global self-attention modules with multi-temporal focus and self-distillation learning with frequency and spatial filtering, the EEG signal recognition model is optimized, solving the problems of noise interference and model complexity, and realizing efficient and real-time EEG signal recognition and rehabilitation training.
Patent Information
- Application Number
- CN202311605799.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-24
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-11-24
AI Technical Summary
Existing technologies struggle to effectively remove noise interference in EEG signal recognition, and deep learning models are complex and time-consuming to train, failing to meet the real-time requirements of rehabilitation training for movement disorders, and feature extraction and recognition are slow.
We employ a global self-attention module group with multiple temporal attention and self-distillation learning, combined with frequency domain and spatial domain filtering, to extract the spatiotemporal features of EEG signals through a self-attention convolutional neural network. We then optimize the model through feature distillation and logistic distillation to reduce training costs and recognition time.
It achieves efficient and real-time EEG signal recognition, can quickly respond to and drive exoskeleton devices for rehabilitation training, improves recognition accuracy and reduces model complexity, and meets the real-time requirements of rehabilitation training for movement disorders.
Smart Images

Figure CN117694903B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electroencephalogram (EEG) signal processing technology, and in particular to a method and system for rehabilitation training of movement disorders based on EEG signal recognition. Background Technology
[0002] Limb movement disorders are symptoms caused by neurological diseases or injuries that result in limited or uncontrollable muscle movement, affecting patients' daily lives and causing numerous problems for their families. Traditional limb rehabilitation involves patients passively receiving mechanical training, lacking active brain involvement, resulting in limited effectiveness in repairing motor nerves and requiring long-term training to achieve the desired results.
[0003] EEG signals from motor imagery contain information about motor-related neural activity. Collecting and classifying these signals using brain-computer interface (BCI) technology is a good solution to help patients efficiently recover their motor abilities. However, current rehabilitation training for motor disorders based on EEG signal recognition faces two main challenges: 1. The inherently weak nature of EEG signals, coupled with their non-stationary, non-linear, non-Gaussian, and non-short-form characteristics, complicates feature extraction and signal analysis; 2. EEG signal recognition in rehabilitation training for motor disorders has high real-time requirements, necessitating maximizing recognition speed and accuracy.
[0004] Existing technologies for EEG signal recognition do not adequately address the aforementioned problems: Traditional EEG signal decoding is based on machine learning, involving manual feature extraction. The accuracy depends on the effectiveness of feature selection, and the data features are limited and susceptible to noise interference. While deep learning technology can extract effective features from complex EEG signals, the resulting network model structure is complex and cannot meet the real-time requirements of rehabilitation training. Furthermore, it requires a certain amount of training data, and prolonged training can cause patient fatigue, leading to poor data performance. How to extract more representative features across multiple ranges and scales from a small EEG signal dataset is a major challenge in the current application of deep learning in motor disorder rehabilitation.
[0005] Therefore, how to design a scientific EEG signal recognition model that can efficiently filter EEG signals to remove noise interference, extract deep spatial and temporal features from multiple dimensions and scales using limited data, and reduce the network structure as much as possible to speed up the recognition rate while improving classification accuracy is a key problem that must be faced and solved in the current research and application of multi-category EEG signal recognition for motor imagery in rehabilitation training for limb movement disorders. Summary of the Invention
[0006] To address the problems existing in the prior art, this invention provides a method and system for rehabilitation training of motor disorders based on electroencephalogram (EEG) signal recognition. The purpose is to filter out irrelevant noise interference from complex EEG signals, and to extract features that can better represent motor imagery from a small amount of data in both time and space dimensions using a global self-attention module group with multiple temporal attention, thereby further improving the signal recognition accuracy. At the same time, the established recognition model is self-distilled to reduce the model training cost, accelerate the model formation speed, and ensure the rate of EEG signal recognition of motor imagery, thus achieving high-speed and efficient rehabilitation training for motor disorders.
[0007] To achieve the above objectives, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for rehabilitation training of movement disorders based on electroencephalogram (EEG) signal recognition, comprising: S1, offline training is conducted on the patient to collect training phase data, wherein the training phase data is multimodal EEG signals of the patient with movement disorder when imagining different types of movement; S2, preprocessing the multimodal EEG signal, including establishing a frequency domain filter based on bandpass filtering, normalization processing, and improving the co-space mode algorithm to establish a spatial domain filter. S3, using the preprocessed EEG signal to establish a self-attention convolutional neural network to extract the spatiotemporal features of the EEG signal, and determining a first loss function based on the predicted classification and the true classification of the self-attention convolutional neural network, and determining a second loss function based on the distance between the spatiotemporal features and the corresponding spatiotemporal feature center; S4, using the deep network layers of the self-attention convolutional neural network as the teacher model and the shallow network layers as the student model, perform feature distillation and logistic distillation on the self-attention convolutional neural network to optimize the model and obtain a third loss function; the third loss function includes the feature similarity loss function in the feature distillation process and the classification loss function in the logistic distillation process; S5, construct the total loss function of the model based on the linear combination of the first loss function, the second loss function, and the third loss function, and iteratively train the self-attention convolutional neural network to obtain the EEG signal recognition model; S6. Collect the patient's EEG signals from online training as rehabilitation stage data, and input the patient's rehabilitation stage data into the EEG signal recognition model established during the patient's most recent offline training to obtain the classification and recognition results. S7. The classification and recognition results are converted into control commands that can be recognized by external devices. Based on the control commands, the corresponding limb movements are driven to complete the rehabilitation training for the patient with movement disorders.
[0008] Preferably, in step S2, the bandpass filtering uses a Type II Chebyshev filter to filter the data to remove irrelevant high-frequency and low-frequency noise; the normalization process uses Z-score normalization to reduce the volatility and non-stationarity of the data.
[0009] Preferably, step S2, which improves the co-space mode algorithm to establish a spatial filter, includes: S231, the multimodal EEG signals are grouped according to motion type to form n types of EEG signals, where n is the total number of motion types of EEG signals; S232, calculate the normalized covariance matrix of each type of EEG signal. i represents different motion types; and based on the normalized covariance matrix The mixture spatial covariance matrix R of the multimodal EEG signals is obtained; S233, perform principal component decomposition on the mixed spatial covariance matrix R of the multimodal EEG signal; S234, Based on the normalized covariance matrix of the various types of EEG signals The common eigenvector matrix S is obtained from the principal component decomposition. i And for the common feature vector matrix S i The principal component decomposition method in step S233 is used to obtain the eigenvalue diagonal matrix V of various EEG signals. i Sum and eigenvalue diagonal matrix V i The corresponding eigenvector matrix U i ; S235, for all the aforementioned common eigenvector matrices S i Approximate joint diagonalization is performed to obtain the correlation diagonal matrices corresponding to various EEG signals, and the eigenvalues in each of the correlation diagonal matrices are calculated. Importance; the importance is the feature value. and the characteristic value The larger of the two inverse proportional functions; S236, in each of the relevant diagonal matrices, the eigenvalues are assigned according to their importance. Sort the data in descending order and record the eigenvalue corresponding to the maximum importance value in each relevant diagonal matrix. The number of identical values; S237, if the eigenvalue corresponding to the maximum importance value in each of the relevant diagonal matrices is... If all values are the same, then the eigenvalues of the top n eigenvalues in each of the relevant diagonal matrices, ranked by importance, are used. Spatial filtering is performed on the corresponding eigenvectors; If the eigenvalue corresponding to the maximum importance value in each of the relevant diagonal matrices is m, where m<n, the eigenvectors corresponding to the first m+1 eigenvalues ranked by importance in each of the relevant diagonal matrices are adopted to construct a spatial filter.
[0010] Preferably, the self-attention convolutional neural network in step S3 includes: a feature extraction layer: a two-dimensional convolution operator is divided into two one-dimensional convolutions to extract temporal features and spatial features respectively, including a four-layer structure, wherein the first layer extracts temporal features of EEG signals through a convolution operation; the second layer learns the interaction between different lead channels to extract spatial features, the third layer is a pooling layer in the temporal dimension, and the fourth layer uses a self-attention module to obtain the correlation of global temporal positions; a center loss layer: a center loss function is defined as a second loss function based on the distance between the spatiotemporal features and the corresponding spatiotemporal feature centers, which is used to minimize the Euclidean distance between the center of class features and sample features; a classification layer: a fully connected layer classifier is used to predict and classify the spatiotemporal features of the EEG signal extracted by the feature extraction layer, and a cross-entropy loss function between the predicted classification result and a real EEG signal classification label is calculated as a first loss function.
[0011] Preferably, the self-attention module is a global self-attention module group formed by parallelly connecting multiple self-attention units with different temporal attention degrees through concatenation normalization layers, wherein the self-attention unit adopts a multi-head scaled dot-product attention mechanism, including: S51, determining temporal attention degrees of the multiple self-attention units based on the time series length of the spatiotemporal features and the number of the self-attention units, and establishing a global self-attention module group formed by parallelly connecting the multiple self-attention units with different temporal attention degrees; S52, performing linear mapping on the spatiotemporal features based on the self-attention units with different temporal attention degrees to obtain an attention matrix under the corresponding temporal attention degree: a Q matrix, a K matrix, and a V matrix; the attention matrix has the same matrix dimension as the spatiotemporal features; S53, calculating cumulative eigenvalues of each feature vector in the K matrix under the same time frame in the corresponding self-attention unit, and extracting a key representation vector from the K matrix; S54, calculating a first attention weight matrix based on the key representation vector and the Q matrix, and performing a compression operation on the Q matrix according to the weight magnitude in the first attention weight matrix to obtain a compressed Q matrix; S55, supplementing the dimension of the compressed Q matrix to be the same as the dimension of the K matrix by using a zero vector to obtain a key Q matrix; S56, calculate the second attention weight matrix based on the K matrix and the key Q matrix, and use the second attention weight matrix to weight and sum the V matrix to obtain the output of the corresponding self-attention unit; S57, the output of the self-attention unit is averaged by using the mean of the V matrix of the spatiotemporal features within the corresponding time attention range; S58, Perform the above steps S52-S57 on each self-attention unit with different time attention in the global self-attention module group; S59, the outputs of each self-attention unit with different time attention are spliced and normalized to obtain the output of the global self-attention module group. The output of the global self-attention module group is the global relevant information at the time position of the EEG signal.
[0012] Preferably, step S53, which calculates the cumulative feature values of each feature vector in the K matrix at the same time frame in the corresponding self-attention unit to extract key representation vectors from the K matrix, includes: S531, obtain the K matrix of each head in the multi-head self-attention mechanism, and calculate the average and variance of the eigenvalues of each feature vector in the K matrix of all heads under the same time frame; S532, based on the average value, sort the eigenvalues of each feature vector in the same time frame of all heads in descending order, and select the first feature value whose variance satisfies the variance threshold from top to bottom in each time frame to obtain the key representation vector.
[0013] Preferably, step S54 calculates a first attention weight matrix based on the key representation vector and the Q matrix, and compresses the Q matrix according to the weights in the first attention weight matrix to obtain a compressed Q matrix, including: S541, Calculate the first attention weight matrix based on the key representation vector and the Q matrix; S542, sort the first attention weight matrix in descending order according to the weight size, select the time frames corresponding to the top p weights as key time frames, extract the Q values of the key time frames from the Q matrix to form a compressed Q matrix, where p is a trainable parameter.
[0014] Preferably, step S4, which involves performing feature distillation on the self-attention convolutional neural network to obtain the feature similarity loss function, includes: S81, each feature extraction layer and intermediate layer of the self-attention convolutional neural network are used as candidate distillation layers; the intermediate layer is its respective attention unit. S82, add a suitable classification structure to each of the candidate distillation layers, the classification structure being used to output a weak classification result for each candidate distillation layer; S83, obtain the mean accuracy of the classification structure of each candidate distillation layer, and calculate the distillation correlation value between any candidate distillation layers based on the mean accuracy; the distillation correlation value is the quotient of the product of the mean accuracy between two candidate distillation layers and the square of the number of layers between them. S84, based on the distillation correlation value and the preset interval number between the teacher layer and the student layer, assign a single other candidate distillation layer to each candidate distillation layer to form multiple pairs of teacher-student groups; S85, for the same EEG signal, calculate the feature similarity between two feature vectors of the EEG signal in each teacher-student pair; the feature similarity uses Euclidean distance to measure the degree of difference between candidate distillation layers at different depths; S86, calculate the feature similarity for all EEG signals to obtain the similarity matrix for each pair of teacher-student groups, then the feature similarity loss function is to minimize the similarity matrix.
[0015] Preferably, step S4, which involves performing logistic distillation on the self-attention convolutional neural network to obtain the classification loss function, includes: S91, the classification layer of the self-attention convolutional neural network is used as the teacher layer, and a shallow fully connected classifier is added after the second layer of the feature extraction layer of the self-attention convolutional neural network as the student layer. S92, the classification loss function is obtained by calculating the outputs of the student layer and the teacher layer using KL divergence.
[0016] Secondly, the present invention provides a motor disorder rehabilitation training system based on electroencephalogram (EEG) signal recognition, comprising: The EEG signal acquisition module is used to acquire EEG signals when a patient imagines different types of movement. The signal processing module is used to perform preprocessing operations on the acquired EEG signals, including a frequency domain filtering unit and a standardization unit. The frequency domain filtering unit is used to establish a frequency domain filter to filter out irrelevant noise in the frequency domain of the EEG signals. The standardization unit is used to reduce the volatility and non-stationarity of the data. The spatial domain filtering unit is used to establish a spatial domain filter to maximize the difference in variance values of multiple types of EEG signals. The recognition network establishment module is used to establish a self-attention convolutional neural network to extract the spatiotemporal features of preprocessed EEG signals; The distillation module is used to optimize the self-attention convolutional neural network from both feature distillation and logistic distillation perspectives using a self-distillation method. The loss function calculation module is used to determine the first loss function based on the predicted classification and the true classification of the self-attention convolutional neural network, determine the second loss function based on the distance between the spatiotemporal features and the corresponding spatiotemporal feature center, determine the third loss function based on the distillation module, and construct the total loss function of the model based on the linear combination of the first loss function, the second loss function, and the third loss function. The model training module is used to iteratively train the self-attention convolutional neural network based on the total loss function of the model to obtain an EEG signal recognition model. The classification and recognition module is used to classify and recognize brain signals based on the brain signal recognition model and convert them into control commands that can be recognized by external devices. The motion execution module is used to execute the control commands and drive the corresponding exoskeleton device to perform rehabilitation training for the corresponding limb.
[0017] The present invention provides a method and system for rehabilitation training of movement disorders based on electroencephalogram (EEG) signal recognition, which has the following beneficial effects: 1. This invention filters and standardizes acquired EEG signals in both the frequency and spatial domains, effectively reducing the influence of irrelevant noise. The improved co-space pattern algorithm extends the binary classification algorithm to a multi-class range, maximizing the difference in variance values among multiple signal classes. Compared to the one-to-one and one-to-many strategies in existing technologies, this significantly reduces the overall algorithm's complexity and time cost. Considering the potential for identical feature values in different classes within the co-space patterns obtained from multiple classification tasks, this invention selects as few feature vectors as possible based on the similarity of feature values while maximizing importance. This ensures the projection space requirement of maximizing energy differences among multiple EEG signals while effectively reducing the dimensionality of feature vectors. Compared to existing technologies that directly use the magnitude of feature values for selection, this invention is more accurate in filtering and classifying EEG signals of different movement types.
[0018] 2. This invention employs a multi-head self-attention mechanism with multiple temporal focuses to establish a global self-attention module group. While considering the relationships between all data in the spatiotemporal feature sequence of EEG signals, it expresses the input data from different dimensions, capturing different attention information and improving the expressive power of globally relevant information. Considering that feature changes between adjacent time frames of EEG signals are relatively slow and there are no clear boundaries between adjacent frames, this invention compresses the attention weight matrix globally through the mean of key representation vectors and spatiotemporal features within the temporal focus range. This focuses more on the more effective features of some key time frames, reduces the number of matrix dot product operations, and accelerates feature extraction. The mean feature and the fusion of multiple self-attention units with different temporal focuses compensate for the aforementioned compression process's focus on only important information. Compared to existing self-attention mechanisms that directly ignore secondary information during weighted averaging calculations, this improves the completeness of EEG signal feature extraction.
[0019] 3. This invention considers the complex characteristics of EEG signals themselves and the multi-head self-attention mechanism with multiple temporal attention involved in volume feature extraction, which makes the feature extraction process more complex. Therefore, this invention optimizes the EEG signal recognition model through self-distillation training, performing feature distillation and logistic distillation respectively. This refines the more parameterized and structurally complex network (teacher model) into a smaller, less latency target network (student model), reducing the complexity of the network structure while ensuring it meets the complexity and real-time requirements of EEG signals. In feature distillation, a self-matching, self-selecting teacher student model is used, allowing shallow features (student layer) to select suitable deep features (teacher layer) and gravitate towards them, performing knowledge-supervised training based on feature similarity. In logistic distillation, the difference between classification results from two different depths is obtained through classification loss, which can better guide the shallow network in learning spatial features.
[0020] 4. This invention provides a method and system for rehabilitation training of movement disorders based on electroencephalogram (EEG) signal recognition. Before feature extraction, the signals undergo multi-faceted preprocessing to effectively filter noise and better separate different signals. During feature extraction, the established model has low complexity and can respond at the millisecond level, extracting EEG signal features from both temporal and spatial dimensions. It incorporates a multi-temporal attention mechanism to capture the correlation of global temporal positions of features. Self-distillation learning is also included to accelerate network fitting, reduce training costs, and greatly improve the system's real-time performance. Before the classification layer, multiple loss functions are introduced to optimize and limit classification capabilities. This invention has a small overall model parameter count, enabling real-time recognition and rapid control of exoskeleton devices, achieving zero-delay interaction between patients with movement disorders and external devices, and completing an efficient and accurate rehabilitation training process. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating a method for rehabilitation training of movement disorders based on electroencephalogram (EEG) signal recognition according to the present invention. Figure 2 This is a schematic diagram of the preprocessing process for the acquired electroencephalogram (EEG) signals according to the present invention; Figure 3 This is a schematic diagram of the improved co-space mode algorithm of the present invention for spatial filtering; Figure 4 This is a schematic diagram of the self-attention convolutional neural network structure established in this invention; Figure 5 This is a block diagram of the decomposed structure of the global self-attention module group with multiple time attention in this invention; Figure 6 This is a flowchart illustrating the process of establishing a global self-attention module group according to the present invention; Figure 7 This is a schematic diagram of the process of extracting key representation vectors from the K matrix by accumulating eigenvalues according to the present invention; Figure 8 This is a schematic diagram of the process of compressing the Q matrix based on the weights of the first attention weight matrix to obtain the compressed Q matrix according to the present invention; Figure 9 This is a schematic diagram of the characteristic distillation process in the self-distillation training of the present invention; Figure 10 This is a schematic diagram of the logic distillation process in the self-distillation training of this invention; Figure 11 This is a structural block diagram of a motor disorder rehabilitation training system based on electroencephalogram (EEG) signal recognition according to the present invention. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] To facilitate understanding of this embodiment, a detailed description of a motor disorder rehabilitation training method based on electroencephalogram (EEG) signal recognition disclosed in this embodiment of the invention will be provided first, such as... Figure 1 As shown, it includes: S1, offline training is conducted on the patient to collect training phase data, wherein the training phase data is multimodal EEG signals of the patient with movement disorder when imagining different types of movement; The patient's rehabilitation training consists of two parts: the training phase and the rehabilitation phase.
[0024] During the training phase, it is necessary to collect patients' EEG data to create a labeled motor imagery EEG signal dataset for training the EEG signal recognition model. Specifically, offline training is conducted for patients. The user wears an electrode cap, sits in front of a screen, and activates the EEG-based motor disorder rehabilitation training system of this invention. A 10-second countdown appears in the center of the screen before the data collection begins. The patient visualizes the gestures shown on the screen, including the left hand, right hand, and both feet. The amount of data collected is the same for each category. Each gesture image lasts for 4 seconds, followed by a 6-second rest period before the next image appears. The collection process lasts approximately 20 minutes. After collection, the collected EEG signal data from each stage are tagged and stored.
[0025] S2, preprocessing the multimodal EEG signal, including establishing a frequency domain filter based on bandpass filtering, normalization processing, and improving the co-space mode algorithm to establish a spatial domain filter. S3, using the preprocessed EEG signal to establish a self-attention convolutional neural network to extract the spatiotemporal features of the EEG signal, and determining a first loss function based on the predicted classification and the true classification of the self-attention convolutional neural network, and determining a second loss function based on the distance between the spatiotemporal features and the corresponding spatiotemporal feature center; S4, using the deep network layers of the self-attention convolutional neural network as the teacher model and the shallow network layers as the student model, perform feature distillation and logistic distillation on the self-attention convolutional neural network to optimize the model and obtain a third loss function; the third loss function includes the feature similarity loss function in the feature distillation process and the classification loss function in the logistic distillation process; S5, construct the total loss function of the model based on the linear combination of the first loss function, the second loss function, and the third loss function, and iteratively train the self-attention convolutional neural network to obtain the EEG signal recognition model; S6. Collect the patient's EEG signals from online training as rehabilitation stage data, and input the patient's rehabilitation stage data into the EEG signal recognition model established during the patient's most recent offline training to obtain the classification and recognition results. During the rehabilitation phase, patients use the motor disorder rehabilitation training system based on EEG signal recognition of this invention for rehabilitation testing.
[0026] Specifically, patients can plan their own motor imagery, such as their left hand, right hand, and feet. For example, when a patient imagines their right hand, electrodes on their scalp record the imagery. The data acquisition module transmits the EEG data to the classification and recognition module, which then calls the trained EEG recognition model to predict the results and displays the imagery on the screen.
[0027] Considering that EEG signals can vary over time, it is necessary to load the recognition model established during the patient's most recent offline training.
[0028] S7. The classification and recognition results are converted into control commands that can be recognized by external devices. Based on the control commands, the corresponding limb movements are driven to complete the rehabilitation training for the patient with movement disorders.
[0029] Preferred, refer to Figure 2 The preprocessing operation in step S2 includes: The bandpass filtering uses a Type II Chebyshev filter to filter the data to remove irrelevant high-frequency and low-frequency noise; the normalization process uses Z-score normalization to reduce data volatility and non-stationarity; and the common space mode algorithm is improved to establish a spatial filter.
[0030] Specifically, in S21, bandpass filtering is performed using a Type II Chebyshev filter to filter the data from 4 to 40 Hz. This frequency range contains the main rhythmic components related to motion; that is, frequency components below 4 Hz and above 40 Hz are filtered out by bandpass filtering. The transfer function is: ; in To achieve an effective bandpass cutoff frequency, It is a parameter related to passband ripple. Large, large ripples, 0< <1, Given an Nth-order Chebyshev polynomial, this invention uses a 6th-order Chebyshev filter to preserve the rhythm relevant to the motion imagery task.
[0031] S22, standardization processing is performed. Z-score standardization is used for normalization to balance and normalize non-standardized EEG signals, achieving objectivity, reliability, and comparability, and eliminating fluctuation interference that occurs during the acquisition process: ; in and These represent the bandpass filtered data and the normalized output, respectively. and These represent the mean and variance of the training data, respectively.
[0032] Beneficial effects: Preprocessing multimodal EEG signals can reduce the impact of noise and other non-research factors on the feature extraction and decoding process, thereby extracting useful signal components. Bandpass filtering can remove irrelevant high-frequency and low-frequency noise, while standardization can reduce data volatility and non-stationarity, facilitating model training.
[0033] S23, Spatial filter design using improved common-space mode algorithm, see [link / reference] Figure 3 The specific steps are as follows: S231, the multimodal EEG signals are grouped according to motion type to form n types of EEG signals, where n is the total number of motion types of EEG signals; The multimodal EEG signals were all labeled with corresponding movement types during acquisition, such as left hand, right hand, and both feet.
[0034] S232, calculate the normalized covariance matrix of each type of EEG signal. i represents different motion types; and based on the normalized covariance matrix The mixture spatial covariance matrix R of the multimodal EEG signals is obtained; Specifically, the covariance matrix Ri of various EEG signals is calculated as follows: ; in These represent EEG signals for different types of movement, where T denotes the transpose of the matrix. This represents the sum of the elements on the diagonal of the matrix; The normalized covariance matrix is obtained by averaging the covariance matrix Ri of various EEG signals. ; The mixed space covariance matrix R is: ; S233, perform principal component decomposition on the mixed spatial covariance matrix R of the multimodal EEG signal; Specifically, principal component decomposition is performed on the mixture space covariance matrix R of the multimodal EEG signals: ; Where V is the eigenvalue diagonal matrix, and U is the eigenvector matrix formed by the eigenvectors corresponding to the eigenvalues in V; S234, Based on the normalized covariance matrix of the various types of EEG signals The common eigenvector matrix S is obtained from the principal component decomposition. i And for the common feature vector matrix S i The principal component decomposition method in step S233 is used to obtain the eigenvalue diagonal matrix V of various EEG signals. i Sum and eigenvalue diagonal matrix V i The corresponding eigenvector matrix U i ; Specifically, obtain the common eigenvector matrix S. i include: Calculate the whitening matrix P. Then the common eigenvector matrix S i for ; For the common eigenvector matrix S i The principal component decomposition method in step S233 is used to obtain the eigenvalue diagonal matrix V of various EEG signals. i and the corresponding eigenvector matrix U i : ; in = = = , =I, where I is the identity matrix.
[0035] In this embodiment, the three-class classification of electroencephalogram (EEG) signals is used as an example. Steps S231-S234 are used to obtain... = = , =I.
[0036] The co-space pattern algorithm maximizes the difference in variance between two types of signals, resulting in a feature vector with high discriminative power while retaining the most spatially separable features. Since the classic co-space pattern algorithm is a spatial filtering method for binary classification tasks, and this invention involves multiple types of motion, it needs to be extended.
[0037] S235, for all the aforementioned common eigenvector matrices S i Approximate joint diagonalization is performed to obtain the correlation diagonal matrices corresponding to various EEG signals, and the eigenvalues in each of the correlation diagonal matrices are calculated. Importance; the importance is the feature value. and the characteristic value The larger of the two inverse proportional functions; It should be understood that the approximate joint diagonalization of the matrix uses existing techniques, which will not be elaborated here.
[0038] Specifically, the importance is an eigenvalue. and The larger value in; among which Eigenvalues The inverse proportional function, Determined based on the number of tasks categorized.
[0039] S236, in each of the aforementioned related diagonal matrices, the eigenvalues are sorted according to their importance. Sort the data in descending order and record the eigenvalues corresponding to the maximum importance values in each relevant diagonal matrix. The number of identical values; The existing common spatial pattern algorithm selects the largest eigenvalues to construct filters after sorting the eigenvalues. However, considering that the eigenvalues of different classifications in the common spatial pattern spatial filtering obtained by multiple classification tasks may be the same, the present invention utilizes the importance of eigenvalues to select appropriate eigenvalues.
[0040] S237, if the eigenvalues corresponding to the maximum importance in each of the relevant diagonal matrices have the same value, the eigenvectors corresponding to the top n eigenvalues sorted by importance in each of the relevant diagonal matrices are used for spatial filtering; In this embodiment, n=3, and if the eigenvalues with the highest importance are all the same, the first three columns of the relevant eigenvector matrix corresponding to the relevant diagonal matrix are selected.
[0041] If the number of eigenvalues corresponding to the maximum importance in each of the relevant diagonal matrices with the same value is m, m<n, the eigenvectors corresponding to the top m+1 eigenvalues sorted by importance in each of the relevant diagonal matrices are used to construct a spatial filter.
[0042] According to the method of the present invention, sorting based on the importance of eigenvalues can avoid the problem that eigenvalues for different motor imagery classifications may be the same and correspond to the same eigenvectors, solving the problem that the classic common spatial pattern is only applicable to binary classification problems for finding the largest and smallest eigenvalues.
[0043] In this embodiment, the first m+1 columns of the relevant eigenvector matrix corresponding to the relevant diagonal matrix are selected.
[0044] The matrix composed of the eigenvectors corresponding to the eigenvalues is denoted as the relevant eigenvector matrix. In this embodiment, n=3, that is, m can be 0 or 1 (when m=2, all are the same); If m=0, that is, the eigenvalues corresponding to the maximum importance in each of the relevant diagonal matrices have different values, at this time, the eigenvectors corresponding to the top m+1=1 column sorted by importance in each of the relevant diagonal matrices, that is, the eigenvectors corresponding to the eigenvalue with the highest importance, are used for spatial filtering, that is, the first column of the relevant eigenvector matrix is selected.
[0045] If m=1, that is, two of the eigenvalues corresponding to the maximum importance in each of the relevant diagonal matrices have the same value, at this time, the eigenvectors corresponding to the top m+1=2 columns of eigenvalues sorted by importance in each category are used for spatial filtering, that is, the first two columns of the relevant eigenvector matrix are selected.
[0046] The spatial filtering steps after feature value selection in this invention are the same as those in the co-space mode algorithm in the prior art, and will not be described again here.
[0047] Beneficial Effects: By maximizing the variance differences among multiple signal classes using a co-space pattern algorithm, a feature vector with high discriminative power is obtained. Considering the limitation on the number of classes and the potential for identical feature values in different classes during spatial filtering of co-space patterns obtained from multiple classification tasks, this invention improves the co-space pattern algorithm by considering the importance of feature values and whether selected feature values are identical. This extends the two-class co-space pattern algorithm to a multi-class range. Compared to the one-to-one and one-to-many strategies in existing technologies, it significantly reduces the overall algorithm's complexity and time overhead. Furthermore, by maximizing importance and then selecting as few feature vectors as possible based on the similarity of feature values, the requirement of maximizing the projection space of energy differences among multiple EEG signals is ensured, while also effectively reducing the dimensionality of the feature vectors. Compared to existing technologies that directly use the magnitude of feature values for selection, this method is more accurate in filtering and classifying EEG signals of different movement types.
[0048] Preferred, such as Figure 4 As shown, the self-attention convolutional neural network structure in step S3 is as follows: Feature extraction layer: Performs temporal and spatial convolutions along the time and lead channel dimensions to extract spatiotemporal features, and then uses a self-attention module to extract global relevant information at the temporal location of the EEG signal. Specifically, it includes a four-layer structure: The first layer uses k convolution kernels of size (1,25) with a stride of (1,1) to perform convolution operations and extract the temporal features of the EEG signal. The second layer uses a kernel of size (N,1) with a stride of (1,1) to learn the interaction between different lead channels and extract spatial features; The third layer is a time-dimensional pooling layer with a kernel size of (1, 75) and a stride of (1, 15). Average pooling along the time dimension smooths out the temporal features, avoiding overfitting and reducing computational complexity.
[0049] The fourth layer uses a self-attention module to obtain the correlation of global temporal location.
[0050] It can effectively make up for the shortcomings of convolution operations that focus on local receptive fields, and the resulting features are more discriminative.
[0051] Center loss layer: The initial center point of each EEG signal category is set as a zero vector or a random vector. The spatiotemporal feature output of the fourth layer of the feature extraction layer of the convolutional neural network is used as the sample feature vector. The Euclidean distance between each sample feature vector and its corresponding category center point is calculated as the second loss function.
[0052] The center loss layer is used to indent the distance between EEG signals of the same category and increase the distance between EEG signals of different categories, thereby improving the performance of the EEG signal recognition model. Specifically, EEG signals are mapped to fixed center points in the feature space, and similar samples are placed close to these center points, with a center point defined for each category. The center loss measures the proximity of the EEG signal feature vector to its corresponding category center point.
[0053] Classification layer: The fully connected layer classifier is used to predict and classify the spatiotemporal features of the EEG signal extracted by the feature extraction layer, and the cross-entropy loss function between the predicted classification result and the actual EEG signal classification label is calculated as the first loss function; Preferably, the self-attention module is a global self-attention module group, wherein the self-attention unit adopts a multi-head scaling dot product attention mechanism, and each self-attention unit with temporal attention includes a multi-head self-attention mechanism and a fully connected network. Residual connections and normalization modules are connected after the multi-head self-attention mechanism and the fully connected network. Multiple self-attention units with different temporal attention are connected in parallel through a concatenated normalization layer. For the specific structure of the global self-attention module group of this invention, please refer to [link to specific details]. Figure 5 As shown.
[0054] The output of the global self-attention module group of the present invention is ; in For layer normalization operation, This represents the output of a self-attention unit with a time attention level of T.
[0055] Beneficial effects: Multi-head self-attention mechanisms consider the relationships between all data in the spatiotemporal feature sequence while representing the input data from different dimensions, capturing different attention information, and improving the expressive power of globally relevant information. Residual connections can provide cross-layer connections for feature information, thereby reducing the training difficulty of deep neural networks; by normalizing layers, the output of each self-attention module follows the same distribution, enabling the global self-attention module group to adapt to changes in the compression of the attention matrix due to different levels of attention at different times, thus allowing the model to converge faster.
[0056] like Figure 6 As shown, the global self-attention module group established in this invention is as follows: S51, based on the time series length of the spatiotemporal features and the number of self-attention units, determine the time attention of multiple self-attention units, and establish multiple self-attention units with different time attention in parallel connection to form a global self-attention module group. The global self-attention module group contains multiple self-attention units. These units have the same internal structure but different temporal attention, meaning that each self-attention unit focuses on a different temporal receptive field.
[0057] Specifically, the spatiotemporal features collected above are represented as follows: , Let be the time series length of the spatiotemporal feature sequence. Indicates the first The spatiotemporal features of EEG signals in a time frame are analyzed. In this embodiment, three self-attention units with different time attention levels are used, namely T, T / 2, and T / 4, and the time receptive fields are the entire / half / quarter of the spatiotemporal feature sequence, respectively. That is, when processing the sequence, each element is associated with other elements in the entire / half / quarter sequence. The relative importance between elements is calculated by adaptively capturing the long-range dependencies between elements.
[0058] S52, the spatiotemporal features are linearly mapped based on the self-attention units with different time attention levels to obtain the attention matrices under the corresponding time attention levels: Q matrix, K matrix, and V matrix; the attention matrices have the same matrix dimension as the spatiotemporal features. Specifically, the spatiotemporal features are linearly mapped using the dot product attention method in existing technologies to obtain the attention matrix, which includes three matrices: Q (Query) matrix, K (Key) matrix, and V (Value) matrix.
[0059] The linear mapping formula is: , , .in The input is the spatiotemporal feature sequence of each self-attention module. , , They are respectively to Linear mapping is , , The required learnable weight matrix.
[0060] Considering that EEG signals often exhibit periodic changes in the time domain, and that the changes between adjacent time frames are relatively slow with inconspicuous feature changes, it is necessary to compress the length of the time series and extract important time frames.
[0061] S53, calculate the cumulative feature values of each feature vector in the K matrix under the same time frame in the corresponding self-attention unit to extract the key representation vector of the K matrix; S54, calculate the first attention weight matrix based on the key representation vector and the Q matrix, and compress the Q matrix according to the weight size in the first attention weight matrix to obtain the compressed Q matrix; S55, use the zero vector to pad the dimensions of the compressed Q matrix to be the same as the dimensions of the K matrix, and obtain the key Q matrix; Since the attention weights need to perform a dot product operation on the K and Q matrices, and the dimensions of the two matrices must be the same, zero vectors are filled into the time frames corresponding to the Q values removed during compression.
[0062] S56, calculate the second attention weight matrix based on the K matrix and the key Q matrix, and use the second attention weight matrix to weight and sum the V matrix to obtain the output of the corresponding self-attention unit; ; in To compress the Q matrix, d is the dimension of the K matrix, and T denotes the transpose of the matrix. Then the output of the self-attention unit is: ; ; in, This indicates a splicing operation. This represents the second weight matrix of the h-th self-attention head. This represents the h-th self-attention head. It is a learnable parameter matrix used to fuse multi-head self-attention information.
[0063] S57, The output of the self-attention unit is mean-filled using the V matrix of the spatiotemporal features; Specifically, S571, calculate the mean of the V matrix of the spatiotemporal features within the corresponding time attention range; When the time attention level is T, the formula for calculating the mean is: ; Where T represents time-based attention. Let V be the i-th V value of the spatiotemporal features of the EEG signal in the T-th time frame of the V matrix.
[0064] When the time focus is T / 2 or T / 4, simply replace T in the above formula with T / 2 or T / 4.
[0065] S572, replace the data 0 in the output of the self-attention unit with the mean.
[0066] S58, Perform the above steps S52-S57 on the self-attention units of the global self-attention module group with different time attention levels. S59, the outputs of each self-attention unit with different time attention are spliced and normalized to obtain the output of the global self-attention module group. The output of the global self-attention module group is the global relevant information at the time position of the EEG signal.
[0067] Beneficial effects: By compressing the attention weight matrix globally through the mean of key representation vectors and spatiotemporal features within the time focus range, this approach reduces the computational frequency and complexity of self-attention in existing technologies while minimizing the loss of spatiotemporal features, thus focusing more on the more effective features of key time frames. Simultaneously, using multiple self-attention units with different time focus levels ensures that data at each time point focuses on other data within different time range windows. By fusing the results of multiple self-attention units, the correlation between data within both global and local time ranges can be obtained simultaneously. This compensates for the aforementioned compression process focusing only on the "most important information." Compared to existing self-attention mechanisms that directly ignore "secondary information" during weighted averaging calculations, this approach improves the completeness of EEG signal feature extraction.
[0068] Preferred, such as Figure 7 As shown, step S53 calculates the cumulative feature values of each feature vector in the K matrix at the same time frame in the corresponding self-attention unit to extract key representation vectors from the K matrix, including: S531, obtain the K matrix of each head in the multi-head self-attention mechanism, and calculate the average and variance of the eigenvalues of each feature vector in the K matrix of all heads under the same time frame; This invention employs a multi-head self-attention mechanism, where each head mines representational information in different subspaces at different time frames. When processing sequence data, the self-attention mechanism allows each element to establish a relationship with other elements in the sequence. The K matrix, as key information of the features, is used to match the Q matrix. In order to compress the attention matrix, this invention needs to find the key time, that is, only consider the K value where the key information in each self-attention head is relatively large.
[0069] S532, based on the average value, sort the eigenvalues of each feature vector in the same time frame of all heads in descending order, and select the first feature value whose variance satisfies the variance threshold from top to bottom in each time frame to obtain the key representation vector.
[0070] Specifically, for each feature vector in the same time frame, a K value is calculated under the self-attention mechanism. The average and variance of the K values calculated by all heads for this feature vector are calculated. Only the K value with the larger average and smaller variance is selected from each head as the key representation K value. The key representation K values of multiple heads in each time frame are combined to obtain the key representation vector.
[0071] ; in Represents the key representation vector. The K value represents the K matrix of the i-th head of the spatiotemporal features under time frame T, where the mean is large and the variance meets the variance threshold. Beneficial effects: This invention takes into account the relatively slow feature changes between adjacent time frames of EEG signals, the lack of clear boundaries between adjacent frames, and the difficulty in calculating the similarity between each pair of time frames when using attention. By selecting feature values with relatively large key information in each self-attention head from the original K matrix, key information is extracted, thereby making the self-attention mechanism pay more attention to key time frame information.
[0072] Preferred, such as Figure 8 As shown, step S54 calculates a first attention weight matrix based on the key representation vector and the Q matrix, and compresses the Q matrix according to the weights in the first attention weight matrix to obtain a compressed Q matrix, including: S541, Calculate the first attention weight matrix based on the key representation vector and the Q matrix; Specifically, the formula for calculating the weight of the first attention is: ;
[0073] S542, sort the first attention weight matrix in descending order according to the weight size, select the time frames corresponding to the top p weights as key time frames, extract the Q values of the key time frames from the Q matrix to form a compressed Q matrix, where p is a trainable parameter.
[0074] The key representation vector is composed of K values that have relatively high weights in multiple self-attention heads. Time frames with smaller weights in the first attention weight matrix calculated from the key representation vector and the original Q matrix do not require much attention; therefore, the original Q matrix is compressed by adjusting the weights. The number of selected time frames can be adjusted during training based on the results of the self-attention module.
[0075] Beneficial effects: By compressing the original Q matrix through the first attention weight matrix, only the time frames with high weights are selected as key time frames, while other time frames with low weights are ignored, and the self-attention weights of these time frames are assigned to 0, thereby reducing the number of dot product operations and speeding up the model formation.
[0076] Beneficial effects: The aforementioned compression of the original Q matrix allows for the direct ignoring of the weights of non-critical time frames in the attention weight matrix. However, due to the weakness and complexity of EEG signals, direct ignoring may result in the loss of some signal features and lead to deviations in the results. Therefore, replacing the zero feature vectors in the mean V matrix before the self-attention output splicing, that is, replacing the relatively unimportant time frame signals with global average features, can improve the completeness of EEG signal feature extraction.
[0077] Due to the complex characteristics of EEG signals and the addition of a multi-head self-attention mechanism with multiple time attention, the feature extraction process is more complex and the recognition model network has more layers. However, EEG signal recognition in motor disorder rehabilitation training requires high real-time performance. Therefore, this invention uses a self-distillation method to optimize the EEG signal recognition model.
[0078] Beneficial effects: By using feature distillation and logistic distillation, a network with more parameters and a more complex structure (teacher model) can be refined into a smaller target network (student model) with lower latency. This reduces the complexity of the network structure, achieving lightweight training and high feature transfer efficiency. At the same time, it effectively improves the performance of the neural network to ensure that it meets the complexity and real-time requirements of EEG signals.
[0079] Preferred, such as Figure 9 As shown, the characteristic distillation steps in step S4 are as follows: S81, each feature extraction layer and intermediate layer of the self-attention convolutional neural network are used as candidate distillation layers; the intermediate layer is its respective attention unit. S82, add a suitable classification structure to each of the candidate distillation layers, the classification structure being used to output a weak classification result for each candidate distillation layer; It should be noted that the classification structure added to each candidate distillation layer can be deleted after the network training is completed, and the final EEG signal recognition model does not add any additional response time.
[0080] S83, obtain the mean accuracy of the classification structure of each candidate distillation layer, and calculate the distillation correlation value between any candidate distillation layers based on the mean accuracy; the distillation correlation value is the quotient of the product of the mean accuracy between two candidate distillation layers and the square of the number of layers between them. By calculating the distillation correlation value, the middle layer of the original network is autonomously selected for teacher learning, realizing cross-layer knowledge learning. Compared with the existing technology that uses the last layer structure as the teacher layer for manual selection, this method effectively improves the knowledge transfer effect, ensures that the deep layer contains as much knowledge as possible that the shallow layer does not yet have, and ensures that the distance between the two layers is neither too close nor too far through the layer interval, so that the deep knowledge is as suitable as possible for the shallow learning.
[0081] S84, based on the distillation correlation value and the preset interval number between the teacher layer and the student layer, assign a single other candidate distillation layer to each candidate distillation layer to form multiple teacher-student groups; Among all candidate distillation layers whose interval between the two is no greater than the preset interval, the other candidate distillation layer whose distillation correlation value is greater than the correlation threshold and is closest to the current candidate distillation layer is assigned to the current candidate distillation layer as a teacher-student pair, where the shallow candidate distillation layer is the student layer and the deep candidate distillation layer is the teacher layer.
[0082] S85, for the same EEG signal, calculate the feature similarity between two feature vectors of the EEG signal in each teacher-student pair; the feature similarity uses Euclidean distance to measure the degree of difference between candidate distillation layers at different depths; In neural networks, the deeper the network layer, the closer it is to the real features. As the number of layers increases, the features gradually approach the features of the deepest layer. By calculating the similarity of the features extracted by the student layer and the teacher layer for the same signal, the feature extraction of the (n+1)th layer can be made to approximate that of the nth layer.
[0083] S86, calculate the feature similarity for all EEG signals to obtain the similarity matrix for each pair of teacher-student groups, then the feature similarity loss function is to minimize the similarity matrix; Beneficial effects: By bringing shallow features closer to deep features, knowledge-supervised training on feature similarity is performed. Deeper branches are used to extract deep knowledge, and global feature information from deep features is introduced into shallow features to balance the feature differences between deep and shallow layers. Deep information is used to feed back and optimize shallow layers, refining the similarity of shallow layers, so that more accurate information from the original deep layers can be learned in shallow layers. In this way, shallow convolutions can better match the results of deep layers when predicting spatial classification results.
[0084] Preferred, such as Figure 10 As shown, the logical distillation steps in step S4 are as follows: S91, the classification layer of the self-attention convolutional neural network is used as the teacher layer, and a shallow fully connected classifier is added after the second layer of the feature extraction layer of the self-attention convolutional neural network as the student layer. It should be understood that, unlike the aforementioned classification structure, the shallow fully connected classifier added after the second layer of the feature extraction layer can be removed after the network training is completed, without increasing the complexity of the final model.
[0085] S92, the classification loss function is obtained by calculating the outputs of the student layer and the teacher layer using KL divergence.
[0086] Beneficial effects: During logistic distillation, the deepest classifier is used as the teacher classifier to guide the learning of the second-layer classifier, which is used as the student classifier for feature extraction. The classification loss can be used to obtain the difference between the classification results of two different deep and shallow layers, which can better guide the shallow network in learning spatial features.
[0087] This invention also provides a motor disorder rehabilitation training system based on electroencephalogram (EEG) signal recognition, such as... Figure 11 As shown, it includes: The EEG signal acquisition module is used to acquire EEG signals when a patient imagines different types of movement. The signal processing module is used to perform preprocessing operations on the acquired EEG signals, including a frequency domain filtering unit and a standardization unit. The frequency domain filtering unit is used to establish a frequency domain filter to filter out irrelevant noise in the frequency domain of the EEG signals. The standardization unit is used to reduce the volatility and non-stationarity of the data. The spatial domain filtering unit is used to establish a spatial domain filter to maximize the difference in variance values of multiple types of EEG signals. The recognition network establishment module is used to build a self-attention convolutional neural network to extract spatiotemporal features; A distillation module is used to optimize the self-attention convolutional neural network using a self-distillation method. The loss function calculation module is used to determine the first loss function based on the predicted classification and the true classification of the self-attention convolutional neural network, determine the second loss function based on the distance between the spatiotemporal features and the corresponding spatiotemporal feature center, determine the third loss function based on the distillation module, and construct the total loss function of the model based on the linear combination of the first loss function, the second loss function, and the third loss function. The model training module is used to iteratively train the self-attention convolutional neural network based on the total loss function of the model to obtain an EEG signal recognition model. The classification and recognition module is used to classify and recognize brain signals based on the brain signal recognition model and convert them into control commands that can be recognized by external devices. The motion execution module is used to drive the corresponding exoskeleton device to perform rehabilitation training for the corresponding limb.
[0088] This invention is not limited to the specific embodiments described above. Any modifications made by those skilled in the art based on the above concept without creative effort are within the scope of protection of this invention.
Claims
1. A method for rehabilitation training of movement disorders based on electroencephalogram (EEG) signal recognition, characterized in that, Includes the following steps: S1, offline training is conducted on the patient to collect training phase data, wherein the training phase data is multimodal EEG signals of the patient with movement disorder when imagining different types of movement; S2, preprocessing the multimodal EEG signal, including establishing a frequency domain filter based on bandpass filtering, normalization processing, and improving the co-space mode algorithm to establish a spatial domain filter. The improvement to the common space mode algorithm for establishing spatial filters includes: S231, the multimodal EEG signals are grouped according to motion type to form n types of EEG signals, where n is the total number of motion types of EEG signals; S232, calculate the normalized covariance matrix of each type of EEG signal. i represents different motion types; and based on the normalized covariance matrix The mixture spatial covariance matrix R of the multimodal EEG signals is obtained; S233, perform principal component decomposition on the mixture space covariance matrix R of the multimodal EEG signal; S234, Based on the normalized covariance matrix of the various types of EEG signals The common eigenvector matrix S is obtained from the principal component decomposition. i And for the common feature vector matrix S i The principal component decomposition method in step S233 is used to obtain the eigenvalue diagonal matrix V of various EEG signals. i Sum and eigenvalue diagonal matrix V i The corresponding eigenvector matrix U i ; S235, for all the aforementioned common eigenvector matrices S i Approximate joint diagonalization is performed to obtain the correlation diagonal matrices corresponding to various EEG signals, and the eigenvalues in each of the correlation diagonal matrices are calculated. Importance; the importance is the feature value. and the characteristic value The larger of the two inverse proportional functions; S236, in each of the relevant diagonal matrices, the eigenvalues are assigned according to their importance. Sort the data in descending order and record the eigenvalue corresponding to the maximum importance value in each relevant diagonal matrix. The number of identical values; S237, if the eigenvalue corresponding to the maximum importance value in each of the relevant diagonal matrices is... If all values are the same, then the eigenvalues of the top n eigenvalues in each of the relevant diagonal matrices, ranked by importance, are used. Spatial filtering is performed on the corresponding eigenvectors; if the number of identical values among the eigenvalues corresponding to the maximum importance values in the relevant diagonal matrices is m, where m<n, then the eigenvectors corresponding to the top m+1 eigenvalues in the importance ranking of each relevant diagonal matrix are used to construct a spatial filter S3, using the preprocessed EEG signal to establish a self-attention convolutional neural network to extract the spatiotemporal features of the EEG signal, and determining a first loss function based on the predicted classification and the true classification of the self-attention convolutional neural network, and determining a second loss function based on the distance between the spatiotemporal features and the corresponding spatiotemporal feature center; The self-attention convolutional neural network includes: Feature extraction layer: The two-dimensional convolution operator is divided into two one-dimensional convolutions to extract temporal and spatial features respectively. It includes a four-layer structure. The first layer extracts the temporal features of the EEG signal through convolution operation; the second layer learns the interaction between different lead channels to extract spatial features; the third layer is a pooling layer in the time dimension; and the fourth layer uses a self-attention module to obtain the correlation of global temporal location. Center loss layer: Based on the distance between the spatiotemporal feature and the center of the corresponding spatiotemporal feature, the center loss function is defined as the second loss function, which is used to minimize the Euclidean distance between the center of the category feature and the sample feature; Classification layer: The fully connected layer classifier is used to predict and classify the spatiotemporal features of the EEG signal extracted by the feature extraction layer, and the cross-entropy loss function between the predicted classification result and the actual EEG signal classification label is calculated as the first loss function; The self-attention module is a global self-attention module group formed by connecting multiple self-attention units with different attention levels at different times through a concatenation and normalization layer. The self-attention units employ a multi-head scaling dot product attention mechanism, including: S51, based on the time series length of the spatiotemporal features and the number of self-attention units, determine the time attention of multiple self-attention units, and establish multiple self-attention units with different time attention in parallel connection to form a global self-attention module group. S52, the spatiotemporal features are linearly mapped based on the self-attention units with different time attention levels to obtain the attention matrices under the corresponding time attention levels: Q matrix, K matrix, and V matrix; the attention matrices have the same matrix dimension as the spatiotemporal features. S53, calculate the cumulative feature values of each feature vector in the K matrix under the same time frame in the corresponding self-attention unit to extract the key representation vector of the K matrix; S54, calculate the first attention weight matrix based on the key representation vector and the Q matrix, and compress the Q matrix according to the weight size in the first attention weight matrix to obtain the compressed Q matrix; S55, use the zero vector to pad the dimensions of the compressed Q matrix to be the same as the dimensions of the K matrix, and obtain the key Q matrix; S56, calculate the second attention weight matrix based on the K matrix and the key Q matrix, and use the second attention weight matrix to weight and sum the V matrix to obtain the output of the corresponding self-attention unit; S57, the output of the self-attention unit is averaged by using the mean of the V matrix of the spatiotemporal features within the corresponding time attention range; S58, Perform the above steps S52-S57 on each self-attention unit with different time attention in the global self-attention module group; S59, the output of each self-attention unit with different time attention is spliced and normalized to obtain the output of the global self-attention module group. The output of the global self-attention module group is the global relevant information in the time position of the EEG signal. S4, using the deep network layers of the self-attention convolutional neural network as the teacher model and the shallow network layers as the student model, perform feature distillation and logistic distillation on the self-attention convolutional neural network to optimize the model and obtain a third loss function; the third loss function includes the feature similarity loss function in the feature distillation process and the classification loss function in the logistic distillation process; The feature distillation process performed on the self-attention convolutional neural network to obtain the feature similarity loss function includes: S81, each feature extraction layer and intermediate layer of the self-attention convolutional neural network are used as candidate distillation layers; the intermediate layer is its respective attention unit. S82, add a suitable classification structure to each of the candidate distillation layers, the classification structure being used to output a weak classification result for each candidate distillation layer; S83, obtain the mean accuracy of the classification structure of each candidate distillation layer, and calculate the distillation correlation value between any candidate distillation layers based on the mean accuracy; the distillation correlation value is the quotient of the product of the mean accuracy between two candidate distillation layers and the square of the number of layers between them. S84, based on the distillation correlation value and the preset interval number between the teacher layer and the student layer, assign a single other candidate distillation layer to each candidate distillation layer to form multiple teacher-student groups; S85, for the same EEG signal, calculate the feature similarity between two feature vectors of the EEG signal in each teacher-student pair; the feature similarity uses Euclidean distance to measure the degree of difference between candidate distillation layers at different depths; S86, calculate the feature similarity for all EEG signals to obtain the similarity matrix for each pair of teacher-student groups, then the feature similarity loss function is to minimize the similarity matrix; Logical distillation of the self-attention convolutional neural network yields the classification loss function, which includes: S91, the classification layer of the self-attention convolutional neural network is used as the teacher layer, and a shallow fully connected classifier is added after the second layer of the feature extraction layer of the self-attention convolutional neural network as the student layer. S92, the classification loss function is obtained by calculating the outputs of the student layer and the teacher layer using KL divergence; S5, construct the total loss function of the model based on the linear combination of the first loss function, the second loss function, and the third loss function, and iteratively train the self-attention convolutional neural network to obtain the EEG signal recognition model; S6. Collect the patient's EEG signals from online training as rehabilitation stage data, and input the patient's rehabilitation stage data into the EEG signal recognition model established during the patient's most recent offline training to obtain the classification and recognition results. S7. The classification and recognition results are converted into control commands that can be recognized by external devices. Based on the control commands, the corresponding limb movements are driven to complete the rehabilitation training for the patient with movement disorders.
2. The method for rehabilitation training of movement disorders based on electroencephalogram (EEG) signal recognition according to claim 1, characterized in that, In step S2, the bandpass filtering uses a Type II Chebyshev filter to filter the data to remove irrelevant high-frequency and low-frequency noise; the normalization process uses Z-score normalization to reduce the volatility and non-stationarity of the data.
3. The method for rehabilitation training of movement disorders based on electroencephalogram (EEG) signal recognition according to claim 1, characterized in that, Step S53 calculates the cumulative eigenvalues of each feature vector in the K matrix at the same time frame in the corresponding self-attention unit to extract key representation vectors from the K matrix, including: S531, obtain the K matrix of each head in the multi-head self-attention mechanism, and calculate the average and variance of the eigenvalues of each feature vector in the K matrix of all heads under the same time frame; S532, based on the average value, sort the eigenvalues of each feature vector in the same time frame of all heads in descending order, and select the first feature value whose variance satisfies the variance threshold from top to bottom in each time frame to obtain the key representation vector.
4. The method for rehabilitation training of movement disorders based on electroencephalogram (EEG) signal recognition according to claim 1, characterized in that, Step S54 calculates a first attention weight matrix based on the key representation vector and the Q matrix, and compresses the Q matrix according to the weights in the first attention weight matrix to obtain a compressed Q matrix, including: S541, Calculate the first attention weight matrix based on the key representation vector and the Q matrix; S542, sort the first attention weight matrix in descending order according to the weight size, select the time frames corresponding to the top p weights as key time frames, extract the Q values of the key time frames from the Q matrix to form a compressed Q matrix, where p is a trainable parameter.
5. A rehabilitation training system for movement disorders based on electroencephalogram (EEG) signal recognition, characterized in that, The method for implementing the motor disorder rehabilitation training method based on electroencephalogram (EEG) signal recognition as described in any one of claims 1 to 4 includes: The EEG signal acquisition module is used to acquire EEG signals when a patient imagines different types of movement; The signal processing module is used to perform preprocessing operations on the acquired EEG signals, including a frequency domain filtering unit, a normalization unit, and a spatial domain filtering unit. The frequency domain filtering unit is used to establish a frequency domain filter to filter out irrelevant noise in the frequency domain of the EEG signals. The normalization unit is used to reduce the volatility and non-stationarity of the data. The spatial domain filtering unit is used to improve the co-space pattern algorithm to establish a spatial domain filter to maximize the difference in variance values of multiple types of EEG signals. The improvement to the common space mode algorithm for establishing spatial filters includes: S231, the multimodal EEG signals are grouped according to motion type to form n types of EEG signals, where n is the total number of motion types of EEG signals; S232, calculate the normalized covariance matrix of each type of EEG signal. i represents different motion types; and based on the normalized covariance matrix The mixture spatial covariance matrix R of the multimodal EEG signals is obtained; S233, perform principal component decomposition on the mixed spatial covariance matrix R of the multimodal EEG signal; S234, Based on the normalized covariance matrix of the various types of EEG signals The common eigenvector matrix S is obtained from the principal component decomposition. i And for the common feature vector matrix S i The principal component decomposition method in step S233 is used to obtain the eigenvalue diagonal matrix V of various EEG signals. i Sum and eigenvalue diagonal matrix V i The corresponding eigenvector matrix U i ; S235, for all the aforementioned common eigenvector matrices S i Approximate joint diagonalization is performed to obtain the correlation diagonal matrices corresponding to various EEG signals, and the eigenvalues in each of the correlation diagonal matrices are calculated. Importance; the importance is the feature value. and the characteristic value The larger of the two inverse proportional functions; S236, in each of the relevant diagonal matrices, the eigenvalues are assigned according to their importance. Sort the data in descending order and record the eigenvalue corresponding to the maximum importance value in each relevant diagonal matrix. The number of identical values; S237, if the eigenvalue corresponding to the maximum importance value in each of the relevant diagonal matrices is... If all values are the same, then the eigenvalues of the top n eigenvalues in each of the relevant diagonal matrices, ranked by importance, are used. Spatial filtering is performed on the corresponding eigenvectors; if the number of identical values among the eigenvalues corresponding to the maximum importance degree in each of the relevant diagonal matrices is m, where m<n, the eigenvectors corresponding to the first m+1 eigenvalues sorted by importance degree in each of the relevant diagonal matrices are used to construct a spatial filter; The recognition network establishment module is used to establish a self-attention convolutional neural network to extract the spatiotemporal features of preprocessed EEG signals; The self-attention convolutional neural network includes: Feature extraction layer: The two-dimensional convolution operator is divided into two one-dimensional convolutions to extract temporal and spatial features respectively. It includes a four-layer structure. The first layer extracts the temporal features of the EEG signal through convolution operation; the second layer learns the interaction between different lead channels to extract spatial features; the third layer is a pooling layer in the time dimension; and the fourth layer uses a self-attention module to obtain the correlation of global temporal location. Center loss layer: Based on the distance between the spatiotemporal feature and the center of the corresponding spatiotemporal feature, the center loss function is defined as the second loss function, which is used to minimize the Euclidean distance between the center of the category feature and the sample feature; Classification layer: The fully connected layer classifier is used to predict and classify the spatiotemporal features of the EEG signal extracted by the feature extraction layer, and the cross-entropy loss function between the predicted classification result and the actual EEG signal classification label is calculated as the first loss function; The self-attention module is a global self-attention module group formed by connecting multiple self-attention units with different attention levels at different times through a concatenation and normalization layer. The self-attention units employ a multi-head scaling dot product attention mechanism, including: S51, based on the time series length of the spatiotemporal features and the number of self-attention units, determine the time attention of multiple self-attention units, and establish multiple self-attention units with different time attention in parallel connection to form a global self-attention module group. S52, the spatiotemporal features are linearly mapped based on the self-attention units with different time attention levels to obtain the attention matrices under the corresponding time attention levels: Q matrix, K matrix, and V matrix; the attention matrices have the same matrix dimension as the spatiotemporal features. S53, calculate the cumulative feature values of each feature vector in the K matrix under the same time frame in the corresponding self-attention unit to extract the key representation vector of the K matrix; S54, calculate the first attention weight matrix based on the key representation vector and the Q matrix, and compress the Q matrix according to the weight size in the first attention weight matrix to obtain the compressed Q matrix; S55, use the zero vector to pad the dimensions of the compressed Q matrix to be the same as the dimensions of the K matrix, and obtain the key Q matrix; S56, calculate the second attention weight matrix based on the K matrix and the key Q matrix, and use the second attention weight matrix to weight and sum the V matrix to obtain the output of the corresponding self-attention unit; S57, the output of the self-attention unit is averaged by using the mean of the V matrix of the spatiotemporal features within the corresponding time attention range; S58, Perform the above steps S52-S57 on each self-attention unit with different time attention in the global self-attention module group; S59, the output of each self-attention unit with different time attention is spliced and normalized to obtain the output of the global self-attention module group. The output of the global self-attention module group is the global relevant information in the time position of the EEG signal. The distillation module is used to perform feature distillation and logistic distillation on the self-attention convolutional neural network, using the deep network layers as the teacher model and the shallow network layers as the student model, to optimize the model. The loss function calculation module is used to determine a first loss function based on the predicted classification and the true classification of the self-attention convolutional neural network; determine a second loss function based on the distance between the spatiotemporal features and the corresponding spatiotemporal feature centers; determine a third loss function based on the distillation module, the third loss function including the feature similarity loss function in the feature distillation process and the classification loss function in the logistic distillation process; and construct the total loss function of the model based on the linear combination of the first loss function, the second loss function, and the third loss function. The step of obtaining the feature similarity loss function includes: S81, each feature extraction layer and intermediate layer of the self-attention convolutional neural network are used as candidate distillation layers; the intermediate layer is its respective attention unit. S82, add a suitable classification structure to each of the candidate distillation layers, the classification structure being used to output a weak classification result for each candidate distillation layer; S83, obtain the mean accuracy of the classification structure of each candidate distillation layer, and calculate the distillation correlation value between any candidate distillation layers based on the mean accuracy; the distillation correlation value is the quotient of the product of the mean accuracy between two candidate distillation layers and the square of the number of layers between them. S84, based on the distillation correlation value and the preset interval number between the teacher layer and the student layer, assign a single other candidate distillation layer to each candidate distillation layer to form multiple teacher-student groups; S85, for the same EEG signal, calculate the feature similarity between two feature vectors of the EEG signal in each teacher-student pair; the feature similarity uses Euclidean distance to measure the degree of difference between candidate distillation layers at different depths; S86, calculate the feature similarity for all EEG signals to obtain the similarity matrix for each pair of teacher-student groups, then the feature similarity loss function is to minimize the similarity matrix; The steps for obtaining the classification loss function include: S91, the classification layer of the self-attention convolutional neural network is used as the teacher layer, and a shallow fully connected classifier is added after the second layer of the feature extraction layer of the self-attention convolutional neural network as the student layer. S92, the classification loss function is obtained by calculating the outputs of the student layer and the teacher layer using KL divergence; The model training module is used to iteratively train the self-attention convolutional neural network based on the total loss function of the model to obtain an EEG signal recognition model. The classification and recognition module is used to classify and recognize brain signals based on the brain signal recognition model and convert them into control commands that can be recognized by external devices. The motion execution module is used to execute the control commands and drive the corresponding exoskeleton device to perform rehabilitation training for the corresponding limb.
Citation Information
Patent Citations
Key technology method for brain-computer interface of strokerehabilitation system
CN109620223A
Pure idea control intelligent rehabilitation method based on distillation learning and deep learning and application
CN111544855A
