CN118228129B - Motor imagery electroencephalogram signal classification method based on deep migration learning - Google Patents
Motor imagery electroencephalogram signal classification method based on deep migration learning Download PDFInfo
- Publication number
- CN118228129B CN118228129B CN202410635143.3A CN202410635143A CN118228129B CN 118228129 B CN118228129 B CN 118228129B CN 202410635143 A CN202410635143 A CN 202410635143A CN 118228129 B CN118228129 B CN 118228129B
- Authority
- CN
- China
- Prior art keywords
- data
- model
- network
- deep
- electroencephalogram
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 25
- 238000013508 migration Methods 0.000 title claims abstract 5
- 230000005012 migration Effects 0.000 title claims abstract 5
- 238000013526 transfer learning Methods 0.000 claims abstract description 23
- 230000006978 adaptation Effects 0.000 claims abstract description 22
- 210000004556 brain Anatomy 0.000 claims abstract description 13
- 238000013145 classification model Methods 0.000 claims abstract description 8
- 238000007781 pre-processing Methods 0.000 claims abstract description 7
- 238000013528 artificial neural network Methods 0.000 claims abstract description 6
- 238000005259 measurement Methods 0.000 claims abstract description 5
- 230000006870 function Effects 0.000 claims description 19
- 230000007246 mechanism Effects 0.000 claims description 19
- 238000012549 training Methods 0.000 claims description 13
- 238000013507 mapping Methods 0.000 claims description 9
- 238000009826 distribution Methods 0.000 claims description 8
- ORILYTVJVMAKLC-UHFFFAOYSA-N Adamantane Natural products C1C(C2)CC3CC1CC2C3 ORILYTVJVMAKLC-UHFFFAOYSA-N 0.000 claims description 6
- 238000005457 optimization Methods 0.000 claims description 6
- 230000008569 process Effects 0.000 claims description 5
- 238000012360 testing method Methods 0.000 claims description 5
- 230000003044 adaptive effect Effects 0.000 claims 1
- 230000036624 brainpower Effects 0.000 claims 1
- 238000010276 construction Methods 0.000 claims 1
- 238000010801 machine learning Methods 0.000 abstract description 6
- 238000012545 processing Methods 0.000 abstract description 3
- 230000036541 health Effects 0.000 abstract description 2
- 238000000537 electroencephalography Methods 0.000 description 54
- 238000000605 extraction Methods 0.000 description 7
- 238000011176 pooling Methods 0.000 description 6
- 238000013527 convolutional neural network Methods 0.000 description 5
- 230000003993 interaction Effects 0.000 description 4
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 3
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 230000008447 perception Effects 0.000 description 3
- 238000011160 research Methods 0.000 description 3
- 230000002411 adverse Effects 0.000 description 2
- 230000015556 catabolic process Effects 0.000 description 2
- 238000002790 cross-validation Methods 0.000 description 2
- 238000006731 degradation reaction Methods 0.000 description 2
- 230000009977 dual effect Effects 0.000 description 2
- 230000004927 fusion Effects 0.000 description 2
- 238000005070 sampling Methods 0.000 description 2
- 230000017105 transposition Effects 0.000 description 2
- 101100012902 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) FIG2 gene Proteins 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007177 brain activity Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000008034 disappearance Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000003058 natural language processing Methods 0.000 description 1
- 238000004904 shortening Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
- G06F18/2413—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on distances to training or reference patterns
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/213—Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/243—Classification techniques relating to the number of classes
- G06F18/2431—Multiple classes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/25—Fusion techniques
- G06F18/253—Fusion techniques of extracted features
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/0464—Convolutional networks [CNN, ConvNet]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/096—Transfer learning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2218/00—Aspects of pattern recognition specially adapted for signal processing
- G06F2218/08—Feature extraction
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2218/00—Aspects of pattern recognition specially adapted for signal processing
- G06F2218/12—Classification; Matching
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02T—CLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
- Y02T10/00—Road transport of goods or passengers
- Y02T10/10—Internal combustion engine [ICE] based vehicles
- Y02T10/40—Engine management systems
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- General Engineering & Computer Science (AREA)
- Life Sciences & Earth Sciences (AREA)
- General Physics & Mathematics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Computational Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Evolutionary Biology (AREA)
- General Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Molecular Biology (AREA)
- Computational Linguistics (AREA)
- Biophysics (AREA)
- Biomedical Technology (AREA)
- Health & Medical Sciences (AREA)
- Measurement And Recording Of Electrical Phenomena And Electrical Characteristics Of The Living Body (AREA)
Abstract
Description
技术领域Technical Field
本发明领域属于神经网络、机器学习进行脑机接口数据分类处理领域,更具体地,涉及一种基于深度迁移学习的运动想象脑电信号分类方法。The field of the present invention belongs to the field of brain-computer interface data classification and processing using neural networks and machine learning, and more specifically, to a motor imagery EEG signal classification method based on deep transfer learning.
背景技术Background technique
脑机接口为人们创造了一种新的人机通信方式,它将大脑的想法转化为实际的命令来控制外部设备。运动想象是经典的脑机接口范式之一,是一种想象运动行为。通过运动想象或者某些运动意图,大脑活动可以转化为控制信号,其可以通过脑电图(electroencephalography, EEG)进行捕捉和识别。据目前研究表明,当人们想象自己身体运动时,受运动想象任务的影响,脑信号会显著发生变化,同时运动想象脑电信号的解码具有潜在的应用价值。Brain-computer interface has created a new way of human-computer communication for people. It converts the brain's thoughts into actual commands to control external devices. Motor imagery is one of the classic brain-computer interface paradigms and is an imaginary movement behavior. Through motor imagery or certain movement intentions, brain activity can be converted into control signals, which can be captured and identified through electroencephalography (EEG). According to current research, when people imagine their body movements, brain signals will change significantly due to the influence of motor imagery tasks. At the same time, the decoding of motor imagery EEG signals has potential application value.
在当前基于运动想象的脑机接口研究中,存在三大挑战:低信噪比、记录脑电信号中固有的非平稳性、不同受试者间存在的特异性,针对上述的三个挑战有很多基于机器学习的方法被提出,机器学习的良好使用需要大量的数据来学习数据的分布。然而,在脑机接口的应用中,重新收集所需要的训练数据是既费时又麻烦的,因此,想要使用较少的训练样本来精确处理个体间的差异问题,仅仅使用传统的机器学习方法是远远不够的。迁移学习是机器学习中的一种方法,专注于存储解决一个问题时所获得的知识,并将其应用于不同但相关的问题中。There are three major challenges in the current research on brain-computer interfaces based on motor imagery: low signal-to-noise ratio, inherent non-stationarity in recording EEG signals, and specificity between different subjects. Many machine learning-based methods have been proposed to address the above three challenges. The good use of machine learning requires a large amount of data to learn the distribution of data. However, in the application of brain-computer interfaces, it is time-consuming and troublesome to re-collect the required training data. Therefore, if you want to use fewer training samples to accurately deal with the problem of differences between individuals, it is far from enough to use traditional machine learning methods alone. Transfer learning is a method in machine learning that focuses on storing the knowledge gained when solving a problem and applying it to different but related problems.
在图像处理和自然语言处理领域,乃至脑机接口的研究中,迁移学习都显露出了其至关重要的价值与影响力。迁移学习能够将来自不同领域的特征映射到统一的特征空间,增加数据量,克服数据量有限的问题,解决分布差异问题。迁移学习既能够解决数据不足而导致的过拟合问题,又可以提高脑电信号识别模型的泛化能力。尽管现在有许多成熟的算法能精准地解码运动想象脑电信号,但其分类精度仍有提升空间。对于需要在医疗康复中应用的患者而言,分类精度在不同个体之间的显著差异,实际上限制了其成熟度和应用范围。In the fields of image processing and natural language processing, and even in the research of brain-computer interfaces, transfer learning has shown its vital value and influence. Transfer learning can map features from different fields to a unified feature space, increase the amount of data, overcome the problem of limited data, and solve the problem of distribution differences. Transfer learning can not only solve the overfitting problem caused by insufficient data, but also improve the generalization ability of EEG signal recognition models. Although there are many mature algorithms that can accurately decode motor imagery EEG signals, there is still room for improvement in their classification accuracy. For patients who need to be used in medical rehabilitation, the significant differences in classification accuracy between different individuals actually limit its maturity and scope of application.
发明内容Summary of the invention
为了克服现有技术中存在的不足,针对运动想象脑电信号分类领域存在的训练时间长,跨受试者分类效果差的问题,本发明目的是提供一种基于深度迁移学习的运动想象脑电信号分类方法,设计了一种基于EEGNet-Attention-ResNet模型的深度迁移学习算法,使得迁移模块能够集成到EEGNet-Attention-ResNet模型上,从而利用源域信息帮助目标域训练一个可靠的分类模型,达到减少目标域受试者训练样本数量,缩短目标域受试者训练时间的效果。In order to overcome the shortcomings of the prior art, and to address the problems of long training time and poor cross-subject classification effect in the field of motor imagery EEG signal classification, the present invention aims to provide a motor imagery EEG signal classification method based on deep transfer learning, and designs a deep transfer learning algorithm based on the EEGNet-Attention-ResNet model, so that the transfer module can be integrated into the EEGNet-Attention-ResNet model, thereby using the source domain information to help the target domain train a reliable classification model, thereby reducing the number of training samples for subjects in the target domain and shortening the training time for subjects in the target domain.
为实现上述目的,本发明提供了如下技术方案:一种基于深度迁移学习的运动想象脑电信号分类方法,包括:To achieve the above object, the present invention provides the following technical solution: a motor imagery EEG signal classification method based on deep transfer learning, comprising:
步骤S1:获取运动想象脑电信号的数据集,并进行预处理。Step S1: Obtain a data set of motor imagery EEG signals and perform preprocessing.
预处理模块,使用带通滤波器对脑电信号进行预处理,去除脑电信号的伪迹,得到预处理后的数据集,基于所述源域受试者数据集划分为训练集和测试集。The preprocessing module uses a bandpass filter to preprocess the EEG signal to remove artifacts of the EEG signal to obtain a preprocessed data set, which is divided into a training set and a test set based on the source domain subject data set.
步骤S11:假定来自不同主体的EEG数据被认为是不同的域。给定一个标记的源域 表示为和未标记的目标域,这里是n通道和m个采 样点表示多通道EEG数据。表示第i个样本的源标签。本发明所建立一个基于深度迁移学 习模型,可以从源域Ds中吸取知识,以增强对目标域Dt上更准确的预测分类能力,有效减轻 数据域之间的分布漂移。 Step S11: Assume that EEG data from different subjects are considered to be different domains. Given a labeled source domain represented as and the unlabeled target domain ,here n channels and m sampling points represent multi-channel EEG data. Represents the source label of the i-th sample. The deep transfer learning model established in the present invention can absorb knowledge from the source domain Ds to enhance the more accurate prediction and classification capabilities on the target domain Dt , effectively reducing the distribution drift between data domains.
步骤S12:将步骤S11中的脑电源域数据集使用带通滤波器对脑电信号进行预处理,去除脑电信号的伪迹,得到预处理后的脑电数据。Step S12: Use a bandpass filter to preprocess the EEG signal in the EEG source domain data set in step S11 to remove artifacts of the EEG signal and obtain preprocessed EEG data.
步骤S13:在步骤S12中,本发明将预处理后的脑电数据集进行划分,形成训练集、测试集。Step S13: In step S12, the present invention divides the preprocessed EEG data set into a training set and a test set.
步骤S2:通过应用EEGNet-Attention-ResNet算法训练分类模型,本发明对预处理后的运动想象脑电信号的源域数据集执行特征提取,并通过全连接层进一步处理,最终获得并输出分类结果。其中,所述分类模型,是在EEGNet神经网络的基础上增加了一个空间、通道注意力机制和ResNet残差网络,即EEGNet-Attention-ResNet模型,其通过训练集对基于EEGNet的模型进行训练,并通过测试集对训练后的模型进行性能评估,得到卷积神经网络模型。Step S2: By applying the EEGNet-Attention-ResNet algorithm to train the classification model, the present invention performs feature extraction on the source domain data set of the preprocessed motor imagery EEG signal, and further processes it through the fully connected layer, and finally obtains and outputs the classification result. Wherein, the classification model is based on the EEGNet neural network, adding a spatial, channel attention mechanism and a ResNet residual network, that is, the EEGNet-Attention-ResNet model, which trains the EEGNet-based model through the training set, and evaluates the performance of the trained model through the test set to obtain a convolutional neural network model.
步骤S21:基于EEGNet神经网络层增加一个双自注意力机制即空间、通道注意力机制。由于脑电信号中蕴含着丰富的空间和脑电通道方面的信息,故提取更有用的信息会大幅度提升分类的准确率。Step S21: Add a dual self-attention mechanism, namely, spatial and channel attention mechanism, based on the EEGNet neural network layer. Since EEG signals contain rich spatial and EEG channel information, extracting more useful information will greatly improve the classification accuracy.
步骤S211:输入经过EEGNet网络所提取的脑电特征,经ECA模块学习脑电信号中通道的重要性,学习到的通道权重与输入特征相乘得到通道注意力特征。其中,ECA通道注意力模块首先使用全局平均池化层聚合卷积特征,获得特征向量,然后自适应确定核K的大小,使用一维卷积学习通道权重,完成跨通道间的信息交互。此模块不降维的局部跨通道交互策略,有效避免所产生的不良影响。Step S211: Input the EEG features extracted by the EEGNet network, learn the importance of channels in the EEG signals through the ECA module, and multiply the learned channel weights with the input features to obtain channel attention features. Among them, the ECA channel attention module first uses the global average pooling layer to aggregate the convolution features to obtain the feature vector, then adaptively determines the size of the kernel K, uses one-dimensional convolution to learn the channel weights, and completes the information interaction across channels. This module does not reduce the local cross-channel interaction strategy of dimensionality, which effectively avoids the adverse effects caused.
步骤S212:以通道注意力输出特征作为输入,送入CBAM模块学习空间位置的重要性,学习到的空间位置权重与通道注意力特征相乘以得到最终结果。其中,CBAM注意力模块首先对特征信息分别做最大池化与平均池化操作,其次对生成的不同特征图连接后进行卷积操作,经过Sigmoid函数使权重归一化,最终将权重和输入特征图相乘得到最终的结果。通过学习空间注意力权重,关注重要空间特征信息,抑制重复和非关键的信息,提升整个网络的性能和泛化能力。Step S212: Take the channel attention output feature as input and send it to the CBAM module to learn the importance of spatial position. The learned spatial position weight is multiplied by the channel attention feature to obtain the final result. Among them, the CBAM attention module first performs maximum pooling and average pooling operations on the feature information, and then connects the generated different feature maps and performs convolution operations. The weights are normalized by the Sigmoid function, and finally the weights are multiplied by the input feature map to obtain the final result. By learning the spatial attention weights, we focus on important spatial feature information, suppress repeated and non-critical information, and improve the performance and generalization ability of the entire network.
上述双通道子注意力机制权重具有特征自适应性,加强了通道之间的关联性及空间位置的重要性,抑制了非关键信息,提升了脑电数据的表征能力和网络感知能力的准确性。The weights of the above-mentioned dual-channel sub-attention mechanism are feature-adaptive, which strengthens the correlation between channels and the importance of spatial positions, suppresses non-critical information, and improves the representation ability of EEG data and the accuracy of network perception.
步骤S22:在步骤S21的基础上增加ResNet残差网络,随着网络模型层数的增加会出现识别率大幅度下降、计算资源消耗增大以及梯度消失或爆炸等问题。通过引入了ResNet残差网络,使用shortcut直接进行连接,学习从注意力机制提取的特征映射以及输出的残差映射,并不需要完整的映射,解决相关的梯度消失和网络退化问题。Step S22: Adding the ResNet residual network on the basis of step S21, as the number of network model layers increases, there will be problems such as a sharp drop in recognition rate, increased consumption of computing resources, and gradient vanishing or exploding. By introducing the ResNet residual network, using shortcuts to directly connect, learning the feature mapping extracted from the attention mechanism and the output residual mapping, it does not require a complete mapping, and solves the related gradient vanishing and network degradation problems.
步骤S23:通过上述模型对脑电信号的特征提取,经过全连接层进行分类。Step S23: Extract the features of the EEG signal through the above model and classify it through the fully connected layer.
步骤S24:最后,基于Adam优化算法更新网络权重。Step S24: Finally, update the network weights based on the Adam optimization algorithm.
步骤S3:构建迁移学习模型。Step S3: Build a transfer learning model.
进行模型适配,构建深度迁移学习模型,使得源域脑电信号的模型能够应用到目标域的运动想象脑电信号上,进而完成运动想象脑电信号的精确特征提取、分类。Perform model adaptation and build a deep transfer learning model so that the model of the source domain EEG signal can be applied to the motor imagery EEG signal in the target domain, thereby completing the accurate feature extraction and classification of the motor imagery EEG signal.
步骤S31:首先输入源域、目标域预处理后的通道数据和目标域的脑电信号数据。Step S31: First, input the source domain, the preprocessed channel data of the target domain and the EEG signal data of the target domain.
步骤S32:在较浅的网络层次中,脑电信号的特征往往是领域通用的,通过欧氏对齐方法来实现通用特征的对齐,即在EEGNet的时间、空间滤波器后加入特征对齐模块,由滤波器和特征对齐模块组成,即欧氏对齐模块,实现数据对齐在步骤S2中训练好的特征提取模型实现源域数据的浅层参数和目标域数据的参数共享。执行欧氏对齐表达式如下:Step S32: In the shallow network layer, the features of EEG signals are often universal in the field. The universal features are aligned by the Euclidean alignment method, that is, a feature alignment module is added after the time and space filters of EEGNet. The module is composed of filters and feature alignment modules, namely the Euclidean alignment module, to achieve data alignment. The feature extraction model trained in step S2 realizes the sharing of shallow parameters of source domain data and parameters of target domain data. The expression for executing Euclidean alignment is as follows:
,, , ,
表示n个协方差矩阵的均值,表示协方差函数,表示一段EEG信号样 本,表示对EEG信号样本数据的转置,n表示总的信号样本数,表示执行完中心对齐后 的样本表示。 represents the mean of n covariance matrices, represents the covariance function, represents a sample of EEG signal, represents the transposition of EEG signal sample data, n represents the total number of signal samples, Represents the sample representation after center alignment.
步骤S33:随着网络深度增加,不同受试者特征表示变得更加特殊,本发明通过加入一个领域自适应模块,实现对特征提取器输出特征更精细的领域自适应。Step S33: As the network depth increases, the feature representations of different subjects become more specific. The present invention achieves more refined domain adaptation of the feature extractor output features by adding a domain adaptation module.
在源域数据和目标域数据特征提取器输出特征之间加入适配层,在适配层之间加入最大均值差异MMD的度量函数,来度量源域数据和目标域数据输出特征的差异,多核最大均值差异MK-MMD通过多个高斯核函数将源域数据和目标域数据映射到再生核希尔伯特空间,在再生核希尔伯特空间度量两个分布p和q的距离,多个核定义的核函数K通过公式进行描述如下:An adaptation layer is added between the output features of the source domain data and the target domain data feature extractor, and the maximum mean difference MMD measurement function is added between the adaptation layers to measure the difference in the output features of the source domain data and the target domain data. The multi-core maximum mean difference MK-MMD maps the source domain data and the target domain data to the reproducing kernel Hilbert space through multiple Gaussian kernel functions, and measures the distance between the two distributions p and q in the reproducing kernel Hilbert space. The kernel function K defined by multiple kernels is described by the formula as follows:
, ,
其中为不同高斯核贡献的权重,贡献大的高斯核权重大,贡献小的高斯核权重 小,ku是第u个高斯核,并将其加入网络的损失中继续训练,m表示高斯核的数量,k表示不同 核{ku}函数的组合,MK-MMD可以通过下式表达: in is the weight of different Gaussian kernels. The weight of Gaussian kernels with large contributions is large, and the weight of Gaussian kernels with small contributions is small. Ku is the uth Gaussian kernel, and it is added to the loss of the network to continue training. m represents the number of Gaussian kernels, and k represents the combination of different kernel { ku } functions. MK-MMD can be expressed by the following formula:
, ,
式中,表示再生核希尔伯特空间Hk的距离,其中的,分别表示 源域数据Ds和目标域数据Dt在可再生核希尔伯特空间的映射,Ep、Eq分别表示源域数据和目 标域数据的特征输出数学期望。 In the formula, represents the distance of the reproducing kernel Hilbert space H k , where , They represent the mapping of source domain data Ds and target domain data Dt in the reproducible kernel Hilbert space respectively, and Ep and Eq represent the mathematical expectations of the feature outputs of source domain data and target domain data respectively.
整个深度迁移学习模型由两个主要部分组成:一方面,在浅层网络中采用加入欧式对齐方法进行参数共享;另一方面,在深层网络中采用最大均值差异MMD实现域适应,从而最大限度减少域偏移。The entire deep transfer learning model consists of two main parts: on the one hand, the Euclidean alignment method is used in the shallow network for parameter sharing; on the other hand, the maximum mean difference (MMD) is used in the deep network to achieve domain adaptation, thereby minimizing domain shift.
步骤S34:最后,采用Adam优化算法更新网络权重。Step S34: Finally, the Adam optimization algorithm is used to update the network weights.
本发明具有以下有益效果:The present invention has the following beneficial effects:
本发明构建了一种EEGNet-Attention-ResNet模型,将EEGNet、Attention、ResNet串行设置,EEGNet继承了CNN优点的同时,解决了同一CNN不能处理不同实验范式信号的缺点,可以获得更加精确的频域特征;通过引入双通道Attention机制和ResNet残差网络分别进行特征提取和融合,最终令脑电信号的分类结果充分考虑时频域以及空间域的因素,使得分类结果更加精确;引入深度迁移学习模块,分别从浅层网络的微调、共享参数以及深层网络的域适应进行模型适配,所搭建的深度迁移学习模型,能够完成不同受试者良好的分类任务。进一步理解人脑的运作机理,并在医疗健康、生物医学工程都具有重要的实际意义。The present invention constructs an EEGNet-Attention-ResNet model, which sets EEGNet, Attention, and ResNet in series. EEGNet inherits the advantages of CNN while solving the disadvantage that the same CNN cannot process signals of different experimental paradigms, and can obtain more accurate frequency domain features; by introducing a dual-channel Attention mechanism and a ResNet residual network for feature extraction and fusion, the classification results of EEG signals finally take into full consideration the factors of the time-frequency domain and the spatial domain, making the classification results more accurate; introducing a deep transfer learning module, respectively, from the fine-tuning of the shallow network, shared parameters and the domain adaptation of the deep network to perform model adaptation, the constructed deep transfer learning model can complete good classification tasks for different subjects. Further understand the operating mechanism of the human brain, and have important practical significance in medical health and biomedical engineering.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚的说明本发明的实施方式或现有技术中的技术方案,下面将对实施方式或现有技术所描述中所需要使用的附图作简单地介绍。In order to more clearly illustrate the implementation modes of the present invention or the technical solutions in the prior art, the drawings required for describing the implementation modes or the prior art are briefly introduced below.
图1为本发明MI-EEG信号的分类方法的流程图。FIG1 is a flow chart of the classification method of MI-EEG signals of the present invention.
图2为本发明注意力模块架构图。FIG2 is a diagram showing the architecture of the attention module of the present invention.
具体实施方式Detailed ways
为使本发明的目的、技术方案和优点更加清楚,下面结合附图及具体实施例对本发明作进一步说明。In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described below in conjunction with the accompanying drawings and specific embodiments.
参见附图1为本发明实施的整体流程图,本发明提供了一种基于深度迁移学习的运动想象脑电信号分类方法,具体包括以下流程:数据采集及预处理;采用EEGNet、Attention机制、Resnet残差网络训练的分类模型;基于欧式距离和最大均值MMD的度量函数实现目标域数据的迁移学习。Referring to FIG1 , which is an overall flow chart of the implementation of the present invention, the present invention provides a method for classifying motor imagery EEG signals based on deep transfer learning, which specifically includes the following processes: data acquisition and preprocessing; a classification model trained using EEGNet, Attention mechanism, and Resnet residual network; and transfer learning of target domain data based on the metric function of Euclidean distance and maximum mean MMD.
参见附图2为本发明的双自注意力机制,由通道注意力模块和空间注意力模块,分别学习通道和空间位置的重要信息,抑制非关键信息,用于提高网络对关键目标的感知能力,提高分类的准确性。See Figure 2 for the dual self-attention mechanism of the present invention, which consists of a channel attention module and a spatial attention module, which respectively learn important information of the channel and spatial position and suppress non-critical information, so as to improve the network's perception of key targets and improve classification accuracy.
如图1所示,一种基于深度迁移学习的运动想象脑电信号分类方法,包括以下步骤:As shown in FIG1 , a motor imagery EEG signal classification method based on deep transfer learning includes the following steps:
步骤S1:获取运动想象数据集,并对数据集进行预处理。Step S1: Obtain a motor imagery dataset and preprocess the dataset.
步骤S11:假定来自不同受试者的EEG数据被认为是不同的域。给定一个标记的源 域表示为和未标记的目标域,这里是n通道和m个 采样点表示多通道EEG数据。表示第i个样本的源标签。本发明所建立一个基于深度迁移 学习模型,可以从源域Ds中吸取知识,以增强对目标域Dt上更准确的预测分类能力,有效减 轻数据域之间的分布漂移。 Step S11: Assume that EEG data from different subjects are considered to be different domains. Given a labeled source domain represented as and the unlabeled target domain ,here n channels and m sampling points represent multi-channel EEG data. Represents the source label of the i-th sample. The deep transfer learning model established in the present invention can absorb knowledge from the source domain Ds to enhance the more accurate prediction and classification capabilities on the target domain Dt , effectively reducing the distribution drift between data domains.
步骤S12:将步骤S11中的脑电源域数据集使用带通滤波器对脑电信号进行预处理,去除脑电信号的伪迹,得到预处理后的脑电数据。Step S12: Use a bandpass filter to preprocess the EEG signal in the EEG source domain data set in step S11 to remove artifacts of the EEG signal and obtain preprocessed EEG data.
步骤S13:在步骤S12中,本发明将预处理后的脑电数据集进行划分,形成训练集和测试集。Step S13: In step S12, the present invention divides the preprocessed EEG data set into a training set and a test set.
步骤S2:特征提取、分类。Step S2: Feature extraction and classification.
基于EEGNet模型,EEGNet继承了CNN优点的同时,解决了同一CNN不能处理不同实验范式信号的缺点,可以获得更加精确的频域特征。通过引入双通道Attention机制和ResNet残差网络,双通道注意力机制包括通道注意力机制和空间注意力机制,ResNet残差网络,构建脑电信号的特征提取和分类模型,构建的模型由源域数据输入,特征提取和分类输出层组成,具体包括以下步骤:Based on the EEGNet model, EEGNet inherits the advantages of CNN while solving the shortcoming that the same CNN cannot process signals of different experimental paradigms, and can obtain more accurate frequency domain features. By introducing the dual-channel Attention mechanism and ResNet residual network, the dual-channel attention mechanism includes the channel attention mechanism and the spatial attention mechanism, and the ResNet residual network, a feature extraction and classification model of EEG signals is constructed. The constructed model consists of source domain data input, feature extraction and classification output layers, and specifically includes the following steps:
步骤S21:基于EEGNet神经网络层增加了一个双通道Attention机制即空间、通道注意力机制,如图2所示。由于脑电信号中蕴含着丰富的通道、空间方面的信息,故提取更有用的信息会大幅度提升分类的准确率。Step S21: A dual-channel Attention mechanism, namely, spatial and channel attention mechanism, is added based on the EEGNet neural network layer, as shown in Figure 2. Since EEG signals contain rich channel and spatial information, extracting more useful information will greatly improve the classification accuracy.
步骤S211:首先,输入经过EEGNet网络所提取的脑电特征,经ECA模块学习脑电信号中通道的重要性,学习到的通道权重与输入特征相乘得到通道注意力特征。其中的ECA通道注意力模块首先使用全局平均池化层聚合卷积特征,获得特征向量。然后自适应确定核K的大小,使用一维卷积学习通道权重,完成跨通道间的信息交互。同时此模块不降维的局部跨通道交互策略,有效避免所产生的不良影响。Step S211: First, input the EEG features extracted by the EEGNet network, learn the importance of channels in the EEG signal through the ECA module, and multiply the learned channel weights by the input features to obtain channel attention features. The ECA channel attention module first uses the global average pooling layer to aggregate the convolution features to obtain the feature vector. Then the size of the kernel K is adaptively determined, and the channel weights are learned using one-dimensional convolution to complete the information interaction across channels. At the same time, this module does not reduce the local cross-channel interaction strategy of dimensionality, which effectively avoids the adverse effects.
步骤S212:然后,以通道注意力输出特征作为输入,送入CBAM模块学习空间位置的重要性,学习到的空间位置权重与通道注意力特征相乘以得到最终结果。其中的CBAM注意力模块首先对特征信息分别做最大池化与平均池化操作,其次对生成的不同特征图连接后进行卷积操作,经过Sigmoid函数使权重归一化,最终将权重和输入特征图相乘得到最终的结果。通过学习空间注意力权重,关注重要特征信息,抑制重复和非关键的信息,提升整个网络的性能和泛化能力。Step S212: Then, the channel attention output feature is used as input and sent to the CBAM module to learn the importance of spatial position. The learned spatial position weight is multiplied by the channel attention feature to obtain the final result. The CBAM attention module first performs maximum pooling and average pooling operations on the feature information, and then connects the generated different feature maps and performs convolution operations. The weights are normalized by the Sigmoid function, and finally the weights are multiplied by the input feature map to obtain the final result. By learning the spatial attention weights, focusing on important feature information, suppressing repeated and non-critical information, and improving the performance and generalization ability of the entire network.
通过双通道Attention机制权重具有特征自适应性,加强了通道之间的关联性及空间位置的重要性,抑制了非关键信息,提升了脑电数据的表征能力和网络感知能力的准确性。The dual-channel Attention mechanism weights are feature-adaptive, which strengthens the correlation between channels and the importance of spatial positions, suppresses non-critical information, and improves the representation ability of EEG data and the accuracy of network perception.
步骤S22:在步骤S21的基础上增加ResNet残差网络,随着网络模型层数的增加不仅会出现识别率大幅度下降、计算资源消耗增大以及梯度消失或爆炸等问题。便通过引入了ResNet残差网络,通过shortcut直接进行连接,学习从注意力机制提取的特征映射以及输出的残差映射,并不需要完整的映射,能够解决相关的梯度消失和网络退化问题。Step S22: Based on step S21, a ResNet residual network is added. As the number of network model layers increases, not only will the recognition rate drop significantly, the computing resource consumption increases, and the gradient disappears or explodes. By introducing the ResNet residual network, the shortcut is used to directly connect, learn the feature mapping extracted from the attention mechanism and the output residual mapping, and the complete mapping is not required, which can solve the related gradient disappearance and network degradation problems.
步骤S23:通过上述模型对脑电信号的特征提取经过全连接层进行分类。Step S23: extract the features of the EEG signal through the above model and classify it through the fully connected layer.
步骤S24:基于Adam优化算法更新网络权重。Step S24: Update network weights based on the Adam optimization algorithm.
步骤S25:基于以上步骤为一次交叉验证,按照步骤S21~S24重复进行。Step S25: Based on the above steps as a cross-validation, repeat steps S21 to S24.
步骤S3:模型适配,构建深度迁移学习模型,使得源域脑电信号的分类模型可以应用到目标域的脑电信号上,具体包括以下步骤:Step S3: Model adaptation, building a deep transfer learning model so that the classification model of the source domain EEG signal can be applied to the target domain EEG signal, specifically including the following steps:
步骤S31:首先输入源域、目标域预处理后的通道数据。Step S31: First, input the pre-processed channel data of the source domain and the target domain.
步骤S32:在较浅的网络层次中,特征往往是领域通用的,通过欧氏对齐方法来实现通用特征的对齐,即在EEGNet网络的第二个卷积滤波器后加入特征对齐模块进行融合,即欧氏对齐模块,实现数据对齐在步骤S2中训练好的模型实现源域数据的浅层参数和目标域数据的参数共享。执行欧氏对齐表达式如下:Step S32: In the shallow network layer, features are often universal in the field. The universal feature alignment is achieved through the Euclidean alignment method, that is, a feature alignment module is added after the second convolution filter of the EEGNet network for fusion, that is, the Euclidean alignment module, to achieve data alignment. The model trained in step S2 realizes the sharing of shallow parameters of source domain data and parameters of target domain data. The expression for executing Euclidean alignment is as follows:
,, , ,
表示n个协方差矩阵的均值,表示协方差函数,表示一段EEG信号样 本,表示对EEG信号样本数据的转置,n表示总的信号样本数,表示执行完中心对齐后 的样本表示。 represents the mean of n covariance matrices, represents the covariance function, represents a sample of EEG signal, represents the transposition of EEG signal sample data, n represents the total number of signal samples, Represents the sample representation after center alignment.
步骤S33:随着网络深度增加,不同受试者的特征表示变得更加特殊,本发明针对特征提取器的输出特征进行了更精细的领域自适应。Step S33: As the network depth increases, the feature representations of different subjects become more specific, and the present invention performs more sophisticated domain adaptation on the output features of the feature extractor.
在源域数据和目标域数据特征提取器输出特征之间加入适配层,在适配层之间加入最大均值差异MMD的度量函数,来度量源域数据和目标域数据输出特征的差异,多核最大均值差异MK-MMD通过多个高斯核函数将源域数据和目标域数据映射到再生核希尔伯特空间,在再生核希尔伯特空间度量两个分布p和q的距离,多个核定义的核函数K通过公式进行描述如下:An adaptation layer is added between the output features of the source domain data and the target domain data feature extractor, and the maximum mean difference MMD measurement function is added between the adaptation layers to measure the difference in the output features of the source domain data and the target domain data. The multi-core maximum mean difference MK-MMD maps the source domain data and the target domain data to the reproducing kernel Hilbert space through multiple Gaussian kernel functions, and measures the distance between the two distributions p and q in the reproducing kernel Hilbert space. The kernel function K defined by multiple kernels is described by the formula as follows:
, ,
其中为不同高斯核贡献的权重,贡献大的高斯核权重大,贡献小的高斯核权重 小,ku是第u个高斯核,并将其加入网络的损失中继续训练,m表示高斯核的数量,k表示不同 核{ku}函数的组合,MK-MMD可以通过下式表达: in is the weight of different Gaussian kernels. The weight of Gaussian kernels with large contributions is large, and the weight of Gaussian kernels with small contributions is small. Ku is the uth Gaussian kernel, and it is added to the loss of the network to continue training. m represents the number of Gaussian kernels, and k represents the combination of different kernel { ku } functions. MK-MMD can be expressed by the following formula:
, ,
式中,表示再生核希尔伯特空间Hk的距离,其中的,分别表示 源域数据Ds和目标域数据Dt在可再生核希尔伯特空间的映射,Ep、Eq分别表示源域数据和目 标域数据的特征输出数学期望。 In the formula, represents the distance of the reproducing kernel Hilbert space H k , where , They represent the mapping of source domain data Ds and target domain data Dt in the reproducible kernel Hilbert space respectively, and Ep and Eq represent the mathematical expectations of the feature outputs of source domain data and target domain data respectively.
整个深度迁移学习模型主要是由两个部分组成:在浅层网络中采用欧式对齐方法进行参数共享,在深层网络中采用最大均值差异MMD实现域适应,最大限度减少域偏移。The entire deep transfer learning model mainly consists of two parts: the Euclidean alignment method is used for parameter sharing in the shallow network, and the maximum mean difference (MMD) is used in the deep network to achieve domain adaptation and minimize domain shift.
步骤S34:最后,采用Adam优化算法更新网络权重。Step S34: Finally, the Adam optimization algorithm is used to update the network weights.
步骤S35:基于以上步骤为一次交叉验证,按照步骤S31~S34重复进行。Step S35: Based on the above steps as a cross-validation, repeat steps S31 to S34.
Claims (2)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410635143.3A CN118228129B (en) | 2024-05-22 | 2024-05-22 | Motor imagery electroencephalogram signal classification method based on deep migration learning |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410635143.3A CN118228129B (en) | 2024-05-22 | 2024-05-22 | Motor imagery electroencephalogram signal classification method based on deep migration learning |
Publications (2)
Publication Number | Publication Date |
---|---|
CN118228129A CN118228129A (en) | 2024-06-21 |
CN118228129B true CN118228129B (en) | 2024-07-16 |
Family
ID=91501173
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410635143.3A Active CN118228129B (en) | 2024-05-22 | 2024-05-22 | Motor imagery electroencephalogram signal classification method based on deep migration learning |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118228129B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113303814A (en) * | 2021-06-13 | 2021-08-27 | 大连理工大学 | Single-channel ear electroencephalogram automatic sleep staging method based on deep transfer learning |
CN115105076A (en) * | 2022-05-20 | 2022-09-27 | 中国科学院自动化研究所 | EEG emotion recognition method and system based on dynamic convolution residual multi-source transfer |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113627518B (en) * | 2021-08-07 | 2023-08-08 | 福州大学 | Method for realizing neural network brain electricity emotion recognition model by utilizing transfer learning |
CN117332300A (en) * | 2023-10-16 | 2024-01-02 | 安徽大学 | Motor imagery electroencephalogram classification method based on self-attention improved domain adaptation network |
CN117520891A (en) * | 2023-11-08 | 2024-02-06 | 山东大学 | A motor imagery EEG signal classification method and system |
-
2024
- 2024-05-22 CN CN202410635143.3A patent/CN118228129B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113303814A (en) * | 2021-06-13 | 2021-08-27 | 大连理工大学 | Single-channel ear electroencephalogram automatic sleep staging method based on deep transfer learning |
CN115105076A (en) * | 2022-05-20 | 2022-09-27 | 中国科学院自动化研究所 | EEG emotion recognition method and system based on dynamic convolution residual multi-source transfer |
Also Published As
Publication number | Publication date |
---|---|
CN118228129A (en) | 2024-06-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110069958B (en) | Electroencephalogram signal rapid identification method of dense deep convolutional neural network | |
CN113693613B (en) | Electroencephalogram signal classification method, electroencephalogram signal classification device, computer equipment and storage medium | |
CN110555468A (en) | Electroencephalogram signal identification method and system combining recursion graph and CNN | |
CN112001306A (en) | Electroencephalogram signal decoding method for generating neural network based on deep convolution countermeasure | |
CN109711383A (en) | Time-frequency domain-based convolutional neural network motor imagery EEG signal recognition method | |
CN112766355B (en) | A method for EEG emotion recognition under label noise | |
Zhang et al. | Human identification driven by deep CNN and transfer learning based on multiview feature representations of ECG | |
CN112307996A (en) | A fingertip electrocardiographic identification device and method | |
CN117473303B (en) | Personalized dynamic intention feature extraction method and related device based on electroencephalogram signals | |
CN117523202A (en) | A fundus blood vessel image segmentation method based on visual attention fusion network | |
CN114548262A (en) | A Feature-Level Fusion Method for Multimodal Physiological Signals in Affective Computing | |
Chen et al. | Patient emotion recognition in human computer interaction system based on machine learning method and interactive design theory | |
CN117398084A (en) | Physiological signal real-time quality assessment method based on light-weight mixed model | |
Guo et al. | Convolutional gated recurrent unit-driven multidimensional dynamic graph neural network for subject-independent emotion recognition | |
CN114861731B (en) | A myoelectric pattern recognition method that can be used across scenarios | |
CN114492560A (en) | Electroencephalogram emotion classification method based on transfer learning | |
CN118228129B (en) | Motor imagery electroencephalogram signal classification method based on deep migration learning | |
Li et al. | Joint hybrid recursive feature elimination based channel selection and ResGCN for cross session MI recognition | |
CN114611556B (en) | Multi-category motor imagery task identification method based on graph neural network | |
CN117034030A (en) | Electroencephalo-gram data alignment algorithm based on positive and negative two-way information fusion | |
CN114052734B (en) | Electroencephalogram emotion recognition method based on progressive graph convolution neural network | |
CN116662782A (en) | MSFF-SENET-based motor imagery electroencephalogram decoding method | |
CN114626405A (en) | Real-time identity recognition method and device based on electromyographic signals and electronic equipment | |
CN117493963B (en) | A cross-subject EEG emotion recognition method and device based on multi-scale hyperbolic contrastive learning | |
CN117311516B (en) | Motor imagery electroencephalogram channel selection method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |