An electroencephalogram artifact removal method and system based on deep learning and decision denoising
Patent Information
- Application Number
- CN202410658818.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2044-05-27
AI Technical Summary
然而,现有的结构设计中没有充分考虑到伪影信号时间分布的随机性和波形多样性,忽略了肌电伪影在长期分布上与脑电图的时变重叠以及长短期伪影之间的相互干扰,大多数网络结构直接在受混合伪影干扰的样本上进行处理,增加了模型的训练难度,进而导致在长短期分布伪影的去除上出现一定的失真
[0068](1)本发明构建了新型脑电伪影去除方法RLANET,通过对长期分布和短期分布的伪影进行判别处理,根据分割网络输出所得到的样本位置编码将易产生时变重叠的长期伪影样本与短期伪影样本分离开来,解决了长短期伪影时变重叠加大模型训练难度的技术问题,相较于现有的伪影去除方法,在半模拟数据集上达到了最优的去噪性能,其中相关系数(CC)和信噪比(SNR)高达90.88%和9.9008。
Smart Images

Figure CN118535858B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of signal processing technology, specifically to a method and system for removing EEG artifacts based on deep learning and decision denoising. Background Technology
[0002] EEG, a widely used neuroimaging technique, plays a crucial role in research fields such as brain-computer interfaces and mental health assessment. While collecting EEG data is relatively easy, its practical application presents challenges due to artifacts that complicate data analysis. Various types of artifacts introduce noise into EEG signals; for example, electrooculography (EOG), electrocardiography (ECG), and electromyography (EMG) result in low signal-to-noise ratios, limiting further research and development. Therefore, researching effective methods to remove artifacts from EEG sequences has become a vital research topic.
[0003] Currently, commonly used artifact removal methods include traditional methods and deep learning-based methods. Traditional methods are typically based on signal processing techniques and mathematical models, including filters and Independent Component Analysis (ICA). Filter methods can adjust filter parameters according to the dynamic characteristics of the signal to remove artifacts. The drawback is that the optimal parameter values for the filter are difficult to determine; excessively large or small parameter values may lead to filter instability or a slow adaptive process. ICA is a commonly used blind source separation technique that can decompose a mixed signal into multiple independent components. By removing the components corresponding to artifact signals, a clean EEG signal can be reconstructed. The disadvantages of ICA are that it is limited by sufficient data volume and number of channels, and the signals decomposed by ICA require further interpretation of their origins by professionals.
[0004] In contrast, deep learning-based artifact removal methods have greater potential and flexibility, and can better adapt to different types of artifacts. However, existing architectures do not fully consider the randomness and waveform diversity of artifact signal temporal distribution, ignore the time-varying overlap between EMG artifacts and EEG artifacts in the long-term distribution, and the mutual interference between long-term and short-term artifacts. Most network structures process samples directly affected by mixed artifacts, increasing the training difficulty of the model and leading to some distortion in the removal of artifacts in both long-term and short-term distributions. Summary of the Invention
[0005] To overcome the defects and shortcomings of existing technologies, this invention provides a method and system for removing EEG artifacts based on deep learning and decision denoising. This invention guides short-term and long-term denoising networks to remove artifacts of short-term and long-term distributions by making decisions on the position codes obtained by the segmentation network, thereby achieving efficient removal of mixed artifacts.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] This invention provides a method for removing EEG artifacts based on deep learning and decision denoising, comprising the following steps:
[0008] A semi-simulated dataset was constructed by generating contaminated EEG signals containing both long-term and short-term artifacts.
[0009] A network model for removing EEG artifacts is constructed, which includes a segmentation network, a short-term denoising network, and a long-term denoising network.
[0010] The location coding labels for adding noise artifacts to the contaminated EEG signals are input into the segmentation network for pre-training to obtain the location codes corresponding to the EEG signals interfered with by long-term and short-term artifacts.
[0011] The short-term denoising network includes an LSTM layer, a weight-initialized convolutional layer, and a TCN layer. The EEG signal affected by short-term artifacts is input into the LSTM layer to extract the state features of the EEG signal. The state features of the EEG signal are then input into the weight-initialized convolutional layer. Based on the new weight parameters generated by the weight-initialized convolutional layer, a one-dimensional convolution operation is performed on the state features of the EEG signal to output local temporal features. The TCN layer captures the features of short-term artifacts based on the local temporal features and smooths out the short-term artifacts.
[0012] The long-term denoising network includes an auxiliary network and a generator network. The EEG signal affected by long-term artifact interference is input into the auxiliary network to obtain a preliminarily denoised EEG signal, which serves as the conditional information for the generator network. The generator network generates EEG signal data that matches the conditional information based on the attention mechanism, and aggregates it with the temporal features to output the reconstructed EEG signal.
[0013] A network model for removing EEG artifacts was trained using a semi-simulated dataset.
[0014] The test set of contaminated EEG signals is input into the trained EEG artifact removal network model, and the output is a denoised signal.
[0015] As a preferred technical solution, constructing a semi-simulated dataset involves the following steps:
[0016] Acquire clean EEG signals, short-term distributed EOG signals in the time domain, and randomly distributed EMG signals;
[0017] Based on wavelet transform processing of ECG signals, all signals are standardized. EOG, EMG, and ECG signals are introduced as artifacts into the clean EEG signal to synthesize the contaminated EEG signal, represented as:
[0018] X N=S+λN
[0019] Among them, X N S represents the synthesized contaminated EEG signal, S represents the clean EEG signal, N represents artifact noise, and λ represents the weighting coefficient.
[0020] The signal-to-noise ratio (SNR) is calculated, and weighting coefficients are set based on the SNR to control the degree of contamination of clean EEG signals by artifact noise. The formula for calculating the SNR is expressed as follows:
[0021]
[0022] Among them, s i For the amplitude of a clean EEG signal, n i The amplitude of the artifact noise.
[0023] As a preferred technical solution, the segmentation network adopts a one-dimensional residual U-shaped network, including an encoder, skip connections and a decoder;
[0024] In the encoder, a one-dimensional convolutional layer is used to extract features from the contaminated EEG signal to obtain a convolutional feature map. Max pooling is performed on each convolutional feature map. By stacking convolutional layers and pooling layers, a feature map of high-dimensional features is obtained.
[0025] After each pooling operation, the encoder saves the convolutional feature map of the current layer and passes it to the decoder via skip connections.
[0026] The decoder performs deconvolution on the convolutional feature maps. At the same time, in each layer of the decoder, the feature maps of the same layer as the encoder are merged through skip connections. The merged feature maps are input into the convolutional layer of the decoder and perform one-dimensional convolution with the features extracted by the original encoder. The outputs of the same layer of the encoder and decoder are added through residual connections.
[0027] As a preferred technical solution, the short-term denoising network includes an LSTM layer, a weight-initialized convolutional layer, and a TCN layer, and the specific processing procedure includes:
[0028] The EEG signal affected by short-term artifacts is input into the LSTM layer to extract the state features of the EEG signal. The hidden state and cell state of the LSTM layer are initialized as zero vectors. For each time step of the EEG signal affected by short-term artifacts, the LSTM layer receives the current input and the hidden state of the previous time step as input, and outputs the hidden state and cell state of the current time step. The hidden state is used as the state feature of the EEG signal extracted by the LSTM layer, which includes long-term dependencies and contextual information. The feature space output by the LSTM layer is mapped to the same dimension space as the weight-initialized convolutional layer through a linear connection layer.
[0029] As a preferred technical solution, the new weight parameters generated by the weight initialization convolutional layer are specifically expressed as follows:
[0030]
[0031] Among them, normalized ij This represents the new weight parameters, where mean represents the mean of the weight matrix, var represents the variance of the weight matrix, and w ij Let represent the element in the i-th row and j-th column of the weight matrix, where ∈ represents a constant.
[0032] As a preferred technical solution, the TCN layer includes a residual module, a connection layer, and a corrected linear unit. The residual module includes multiple sets of residual layers, each connected to a corresponding input stream and output stream. The first and last residual layers use a skip output method. The intermediate residual layers include dilated convolutional layers and 1×1 convolutional layers. The dilated convolutional layers initialize the local temporal features of the output of the convolutional layers according to the weights to capture the features of short-term artifacts. Holes are inserted in the middle of the convolutional kernels to increase the receptive field of the convolutional kernels and smooth out short-term artifacts. The 1×1 convolutional layers perform dimensionality reduction and regularize the output. The connection layer integrates the features of different layers and maps high-dimensional features to a low-dimensional space. The corrected linear unit introduces nonlinear features to fit the data distribution of clean EEG signals and outputs clean EEG signals.
[0033] As a preferred technical solution, the generative network generates EEG signal data that matches conditional information based on an attention mechanism, and aggregates it with temporal features to output a reconstructed EEG signal, specifically including:
[0034] The generative network performs EEG reconstruction including forward diffusion and reverse denoising processes.
[0035] The generative network includes a residual layer, a conditional attention layer, a downsampling layer, a temporal embedding layer, and an upsampling layer;
[0036] Time steps and Gaussian random noise are generated and a forward diffusion process is performed. Gaussian white noise is randomly generated at each time step and added to the EEG signal to obtain a data sequence of T time steps.
[0037] The time vector T is obtained after normalizing the time step. en , time vector T en The input is fed into the time embedding layer for time embedding encoding, specifically as follows:
[0038]
[0039] Where d represents half the dimension of the embedding vector, and i represents the dimension index of the embedding vector;
[0040] The reverse denoising process will denoise the data X at time step T. T Denoising and restoring the original sample X0, specifically, is expressed as follows:
[0041]
[0042] in, μ θ and Σ θ Let represent the mean and covariance matrix of the posterior distribution of the network parameter θ, respectively;
[0043] EEG signals affected by long-term artifacts are processed through a residual layer to extract high-dimensional feature representations, which are then input into a conditional attention layer along with conditional information. The conditional information S is then queried and projected using an attention mechanism to obtain Q. s The input features are projected onto keys and values to obtain K and V. Attention weights are then calculated, and the attention calculation formula is expressed as:
[0044]
[0045] Where softmax is the activation function. This is the scaling factor;
[0046] By using attention mechanisms to filter out long-term artifacts that do not match the conditional information, EEG signal data that matches the conditional information is generated.
[0047] After reducing the data dimensionality through the downsampling layer, it is aggregated with the temporal features obtained through the temporal embedding layer. The data dimensionality is then restored through the upsampling layer. The upsampled signal is then passed through the residual layer, and the low-dimensional feature representation of the input signal is preserved through the residual connection. Combined with the extracted high-dimensional feature representation, the reconstructed EEG signal is obtained.
[0048] As a preferred technical solution, the forward diffusion process is represented as follows:
[0049] α t =1-β t
[0050]
[0051]
[0052] Where, β t X represents the interpolation rate used in the t-th step of the noise addition process, β represents the hyperparameter, and X... t Represents the original data X0 and random Gaussian white noise linear combination, and This represents the corresponding combination coefficient.
[0053] As a preferred technical solution, the test set of contaminated EEG signals is input into the trained EEG artifact removal network model. Specifically, the mean squared error (MSE) is used to optimize the parameters of the short-term denoising network, as shown below:
[0054]
[0055] in, is the denoised EEG signal, l is the clean EEG signal corresponding to short-term distribution artifacts, and n is the number of samples;
[0056] The parameters of the long-term denoising network are optimized using the absolute value error L1_loss, specifically as follows:
[0057]
[0058] in, denoised EEG signal, g represents clean EEG signal corresponding to long-term distribution artifact.
[0059] The present invention also provides a brainwave artifact removal system based on deep learning and decision denoising, comprising: a data generation module, a brainwave artifact removal network model construction module, a pre-training module, a brainwave artifact removal network model training module, and a denoised signal output module;
[0060] The data generation module is used to generate contaminated EEG signals containing long-term and short-term artifacts to construct a semi-simulated dataset.
[0061] The EEG artifact removal network model construction module is used to construct an EEG artifact removal network model, which includes a segmentation network, a short-term denoising network, and a long-term denoising network.
[0062] The pre-training module is used to add noise artifact location coding labels to the contaminated EEG signal, and input the contaminated EEG signal into the segmentation network for pre-training to obtain the location codes corresponding to the EEG signals interfered with by long-term artifacts and short-term artifacts.
[0063] The short-term denoising network includes an LSTM layer, a weight-initialized convolutional layer, and a TCN layer. The EEG signal affected by short-term artifacts is input into the LSTM layer to extract the state features of the EEG signal. The state features of the EEG signal are then input into the weight-initialized convolutional layer. Based on the new weight parameters generated by the weight-initialized convolutional layer, a one-dimensional convolution operation is performed on the state features of the EEG signal to output local temporal features. The TCN layer captures the features of short-term artifacts based on the local temporal features and smooths out the short-term artifacts.
[0064] The long-term denoising network includes an auxiliary network and a generator network. The EEG signal affected by long-term artifact interference is input into the auxiliary network to obtain a preliminarily denoised EEG signal, which serves as the conditional information for the generator network. The generator network generates EEG signal data that matches the conditional information based on the attention mechanism, and aggregates it with the temporal features to output the reconstructed EEG signal.
[0065] The EEG artifact removal network model training module is used to train the EEG artifact removal network model based on a semi-simulated dataset.
[0066] The denoising signal output module is used to input the test set of contaminated EEG signals into the trained EEG artifact removal network model and output a denoising signal.
[0067] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0068] (1) This invention constructs a novel EEG artifact removal method, RLANET. By discriminating between long-term and short-term artifacts, and separating long-term artifact samples that are prone to time-varying overlap from short-term artifact samples based on the sample position encoding obtained from the segmentation network output, it solves the technical problem that time-varying overlap of long and short-term artifacts increases the difficulty of model training. Compared with existing artifact removal methods, it achieves the best denoising performance on semi-simulated datasets, with correlation coefficient (CC) and signal-to-noise ratio (SNR) as high as 90.88% and 9.9008, respectively.
[0069] (2) The present invention adopts a technical solution of adding a self-attention module to the skip connection stage of the existing segmentation network ResUnet, which solves the technical problem that the simple skip connection in the ResUnet network is insufficient to capture complex feature relationships. Compared with the original simple skip connection, it enhances the feature representation ability and achieves a more accurate position encoding prediction effect.
[0070] (3) This invention proposes a short-term denoising network LWTCN for removing short-term distribution artifacts. By introducing weight-initialized convolution technology to connect the two time-series processing models LSTM and TCN, it can better capture long-term and short-term dependencies and local complex features, and combine them with overall EEG features to remove short-term distribution artifacts.
[0071] (4) This invention proposes a long-term denoising network ADDPM for the removal of long-term distributed artifacts. It consists of an auxiliary network and a generator network. By introducing an auxiliary network into the existing generator network DDPM, a specific EEG reconstruction is guided. By combining the conditional information obtained by the auxiliary network with the contaminated EEG sample, the long-term denoising network can better capture the potential representation of the EEG signal, reconstruct a clean EEG signal, and reduce the distortion caused by artifact removal. Attached Figure Description
[0072] Figure 1 This is a schematic diagram of the implementation architecture of the EEG artifact removal method based on deep learning and decision denoising according to the present invention;
[0073] Figure 2 (a) is a schematic diagram of the position encoding corresponding to the sample signal of the short-term distribution of artifacts output by the segmentation network of the present invention;
[0074] Figure 2 (b) is a schematic diagram of the position encoding corresponding to the sample signal of the long-term distribution of artifacts output by the segmentation network of the present invention;
[0075] Figure 3 This is a schematic diagram of the network structure of the Short-Term Denoising Network (LWTCN) of the present invention;
[0076] Figure 4 This is a schematic diagram of the structure of the residual block in the TCN module of the present invention;
[0077] Figure 5 This is a schematic diagram of the network structure of the Long-Term Denoising Network (ADDPM) of the present invention;
[0078] Figure 6 (a) is a schematic diagram of the effect of the present invention on the removal of long-term distributed artifacts;
[0079] Figure 6 (b) is a schematic diagram of the effect of the present invention on the removal of short-term distribution artifacts;
[0080] Figure 7 This diagram illustrates the performance comparison between the present invention and other artifact removal methods. Detailed Implementation
[0081] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0082] Example 1
[0083] like Figure 1 As shown, this embodiment provides a method for removing EEG artifacts based on deep learning and decision denoising, including the following steps:
[0084] S1: Construct a semi-simulated dataset;
[0085] In this embodiment, the clean EEG signal, the short-term distributed EOG in the time domain, and the randomly distributed EMG are obtained from the EEGDenoiseNet benchmark dataset. The short-term distributed and regular ECG is obtained from the MIT-BIH arrhythmia dataset, with a sampling rate of 360 Hz and a recording duration of 30 seconds per time period. The above four signals are resampled to 256 Hz. Since ECG is relatively weak compared to other signals, it is easily affected by various factors during acquisition. Wavelet transform is used to obtain a relatively clean ECG signal. Then, all signals are standardized and synthesized into a contaminated EEG signal. EOG, EMG, and ECG are introduced as artifacts into the clean EEG signal. The synthesis formula is shown below:
[0086] X N =S+λN
[0087] Among them, X N The synthesized contaminated EEG signal is represented by S, the clean EEG signal is represented by N, and the artifact noise is represented by λ, which is a weighting coefficient calculated according to the signal-to-noise ratio (SNR) formula and used to control the degree of contamination of the clean EEG signal by noise. The SNR value is set to a range of -5dB to 5dB, with 1dB intervals. The SNR formula is shown below:
[0088]
[0089] Among them, s i For the amplitude of a clean EEG signal, n i λ represents the amplitude of the artifact noise, and λ is the weighting coefficient.
[0090] Based on the above formula, mixed EEG data with different signal-to-noise ratio levels can be generated. The number of sampling points of the synthesized contaminated EEG signal is 1280, the duration is 5s, and it contains long-term artifacts and short-term artifacts, as well as multiple artifacts overlapping. After the mixed data is cross-validated by 10 times, it is divided into training set (80%), test set (10%) and validation set (10%), thus completing the construction of the semi-simulated dataset.
[0091] S2: Construct RLANET, a network model for removing EEG artifacts based on deep learning and decision denoising, which includes a segmentation network, a short-term denoising network, and a long-term denoising network.
[0092] S21: Construct a segmentation network;
[0093] In this embodiment, a one-dimensional residual U-shaped network (ResUNet1D) is used as the network structure for the segmentation network. ResUNet1D can fuse and stitch together low-level and high-level features, and utilize residual learning and shortcut connection mechanisms to obtain the artifact location encoding.
[0094] In this embodiment, the specific network architecture of the one-dimensional residual U-shaped network ResUNet1D is as follows:
[0095] (1) Encoder part: For a contaminated EEG sample, the input sequence X = {x1, x2, ..., x...} N} where N is the length of the sequence (N = 1280). A one-dimensional convolutional layer is used to extract features from the input sequence. The convolution operation slides the convolution kernel (kernel size is 3) on the input sequence to obtain a convolutional feature map. Max pooling is performed on each convolutional feature map (pooling window is 2). After each pooling operation, the length of the output sequence will be half the length of the input sequence, reducing the spatial dimension of the feature map while retaining the most significant feature information. By stacking convolutional and pooling layers, the spatial dimension of the feature map gradually decreases while the feature dimension increases, finally obtaining a series of high-level abstract feature maps that represent different aspects and abstract levels of information in the input sequence.
[0096] (2) Skip Connections: After each pooling operation, the encoder saves the feature map of the current layer and passes it directly to the decoder through skip connections. These skip connections are concatenated with the feature map of the corresponding layer in the decoder after each upsampling operation, providing fine-grained feature information and helping to recover the detailed information of the sequence. This embodiment integrates a self-attention module into the skip connections. After each upsampling, the self-attention module is applied to process the features of the skip connections. This enhances the utilization of the encoder stage features by the decoder stage, enabling the network to capture a wider range of contextual information during the upsampling process.
[0097] (3) Decoder Section: The decoder first applies a deconvolution operation to the feature maps extracted from the encoder, enlarging the size of the feature maps to gradually restore them to the size of the original input (length 1280). Simultaneously, in each layer of the decoder, skip connections are used to merge feature maps from the same layer as the encoder. Skip connections fuse high-resolution features from the encoder with features from the decoder, providing richer information to recover lost details. The merged feature maps are then input into the convolutional layers of the decoder, where they undergo a 1D convolution operation (kernel size 3) along with the original encoder features. The purpose of this step is to fuse the features extracted from the encoder and decoder and reconstruct the feature representation of the original input through convolution. Furthermore, residual connections are used to directly add the outputs of the same layers from the encoder and decoder to retain more original information.
[0098] In this embodiment, since the distribution characteristics of EOG and ECG are both short-term distributions, while the distribution characteristics of EMG are random, the main function of the segmentation network is to obtain the location codes of samples affected by long-term EMG artifacts. For the location code, 1 represents artifact interference, and 0 represents the opposite. Then, its distribution characteristics are further judged. Samples with all location code values of 1 are those affected by long-term EMG artifacts, thus indicating that the distribution characteristics of the sample are long-term, thereby determining the distribution characteristics of the sample signal.
[0099] like Figure 2 (a) and Figure 2 As shown in (b), the output of the segmentation network is obtained, which includes sample signals of the short-term and long-term distributions of artifacts, along with their corresponding location codes. Before constructing the semi-simulated data, this embodiment uses artificial labels to encode the location codes of noise artifacts (EOG, EMG, and ECG), and these artificially labeled location codes are used as location code labels for the synthesized contaminated EEG samples. These labels and their corresponding contaminated EEG sequences are input into the segmentation network for training, enabling the network to learn to extract the location codes corresponding to the artifacts from the contaminated EEG samples. Finally, for a contaminated EEG sample sequence, the segmentation network will obtain the location codes corresponding to its artifacts. The obtained location codes are then processed for discrimination. Samples with all location code values of 1 are input into the long-term denoising network for denoising, while samples with other location code values are input into the short-term denoising network for denoising.
[0100] S22: Construct a Short-term Denoising Network;
[0101] In this embodiment, the Shortest Time To Noise Reduction Network (LWTCN) comprises three parts: an LSTM block, a weight initialization convolutional layer (WS Conv), and a TCN block. The introduction of WS Conv better integrates LSTM and TCN, as shown below. Figure 3 As shown, LWTCN combines the advantages of both LSTM and TCN time-series processing models. While maintaining long-term memory capabilities, TCN can learn complex local features and short-term dynamic changes, which is beneficial for the efficient removal of local artifacts.
[0102] In this example, the specific network architecture of LWTCN is as follows:
[0103] (1) LSTM and Connector Layers: LSTM and connector layers are used to preprocess the EEG noise signal and learn important EEG features. The input sequence of the LSTM layer is a sample sequence affected by short-term artifacts. At the beginning of the sequence, the hidden state h0 and the unit state C0 of the LSTM are initialized to zero vectors. For each time step t in the input sequence...s LSTM receives the current input x t and the hidden state h from the previous moment t-1 As input, output the hidden state h at the current time step. t and unit state C t In this embodiment, the dimension of the hidden state is set to 50, and the hidden state h is used. t The features extracted by LSTM contain long-term dependencies and contextual information of the sequence. Finally, a linearly connected layer (FC) maps the feature space of the LSTM output to the same dimensional space as the WS Conv layer, reducing computational complexity and improving the model's performance and generalization ability.
[0104] (2) WS Conv Layer: This layer introduces weight normalization (WS). Compared to WN and BN, WS only requires normalization of the convolutional kernel weights, eliminating the need for additional computational steps and learnable parameters. Furthermore, WS is unaffected by batch size, exhibiting better convergence and stability, and avoiding issues like vanishing or exploding gradients, thus resulting in smoother model loss. The state features output by the LSTM are input into the WS Conv layer. Before weighting, the weight matrix of the input convolutional kernel is obtained, and the mean and variance of the weight matrix are calculated. Then, the weight matrix is normalized using the formula shown below:
[0105]
[0106] Among them, w ij This represents the element in the i-th row and j-th column of the weight matrix, where ∈ is a very small constant (usually added for numerical stability to prevent the denominator from being zero), and is normalized. ij The input state features are used as new weight parameters to perform one-dimensional convolution operations, combining long-term and short-term information to output local temporal features, and these features are then input into the TCN layer.
[0107] (3) TCN layer: such as Figure 3 As shown, the TCN includes residual modules, connection layers, and corrected linear units, where the residual modules contain three sets of residual layers. Figure 4As shown, in the structure of the residual layer, each residual layer is connected to the corresponding input and output streams. The first and last residual layers use a skip output method to preserve the appropriate gradient flow. The middle residual layers mainly consist of two parts: dilated convolutional layers and 1×1 convolutional layers. The dilated convolutional layers (dilation factor d = 2, convolutional kernel is 1×3) capture the features of local artifacts based on the representative features and contextual information output by the WS Conv layer. The 1×1 convolutional layers perform dimensionality reduction to improve the computational efficiency and speed of the model. At the same time, their output is regularized by WN and Dropout (p = 0.1). Then, the features of different layers are integrated through the connection layer, and the high-dimensional features are mapped to the low-dimensional space, reducing computational complexity while enhancing feature representation ability. Finally, nonlinear features are introduced by correcting the linear unit to better fit the data distribution of the clean EEG signal after artifact removal, outputting a clean EEG signal and achieving the removal of short-term artifacts.
[0108] S23: Construct a long-term denoising network;
[0109] In this embodiment, the long-term denoising network ADDPM is used for the removal of long-term distribution artifacts, such as... Figure 5 As shown, it mainly consists of two parts: an auxiliary network and a generative network. It can perform EEG reconstruction on sample signals to remove noise and distortion signals.
[0110] In this embodiment, the specific network architecture of ADDPM is as follows:
[0111] (1) Auxiliary network: This network employs the same structure as the Short-Term Denoising Network (LWTCN), guiding the generative model to further reconstruct the denoised EEG. While separating different samples through discriminative location encoding can significantly reduce artifact overlap and achieve efficient removal of short-term artifacts, the long-term distribution of EMG artifacts overlaps with the time-varying nature of EEG, making it difficult for the LWTCN to incorporate the overall characteristics of the EEG signal for artifact removal, potentially leading to distortion of some EEG signals. Therefore, the noise signal with long-term artifact distribution is processed through the auxiliary network, outputting the conditional information required by the conditional attention layer in the generative network—that is, the sample signal for initial denoising by LWTCN. This sacrifices the diversity of DDPM generation to achieve reconstruction of specific EEG signals.
[0112] (2) Generating Network: The generating network, based on the original DDPM framework, reduces the number of sampling layers, retaining only one upsampling layer and one downsampling layer, thereby reducing the model's inference time. For example... Figure 5As shown, its main structure includes a residual layer, a conditional attention layer, a downsampling layer, a temporal embedding layer, and an upsampling layer. In this embodiment, the generative network performs EEG reconstruction in two steps: forward diffusion and reverse denoising.
[0113] First, generate time step t. s ~Uniform(0,n T ) and Gaussian random noise A forward diffusion process is then performed, where Gaussian white noise is randomly generated at each time step and added to the EEG sample, ultimately resulting in a data sequence of T time steps (X1, X2, ..., X...). T The expression for the forward diffusion process is as follows:
[0114] α t =1-β t
[0115]
[0116]
[0117] Where, β t This refers to the interpolation rate used in the t-th step of the noise addition process. It is generated based on the cosine time table and varies with time, where the hyperparameter β takes the value (8e). -5 8e -1 ). X t It can be viewed as a linear combination of the original data X0 and random Gaussian white noise. and Then it is its combination coefficient.
[0118] Each time step represents a point in time in the data sequence, and as t gradually increases, the obtained data sample X... t It's getting closer and closer to Gaussian noise. (Time step t) s After normalization, we get T en It represents the position of the current time step relative to the entire time series, expressed as a 128-dimensional time vector T. en The input is fed into the temporal embedding layer for temporal embedding encoding, which facilitates the learning of relevant features at different time points. The specific encoding formula is shown below:
[0119]
[0120] Where d is half the dimension of the embedding vector, and i is the dimension index of the embedding vector. The reverse denoising process involves taking the data X at the T-th time step... T The original sample X0 is gradually restored by denoising. The specific calculation process is as follows:
[0121]
[0122] in, μ θ and Σ θ The predictions made using the Unet network represent the mean and covariance matrix of the posterior distribution of the network parameters θ.
[0123] For the prediction process of the Unet network, the EEG signal D1, which is affected by long-term artifacts, first passes through the residual layer ResNet to extract high-dimensional feature representations, including weighted normalized convolutional layers (kernel size 3), normalization layers, and parameterized corrected linear units. The obtained features, together with the conditional information obtained by the auxiliary network, are input into the conditional attention layer. The conditional information S is then queried and projected using the attention mechanism to obtain Q. s The input features are projected onto keys and values to obtain K and V, and then the attention weights are calculated. The attention formula is shown below:
[0124]
[0125] Where softmax is the activation function. Using an attention mechanism as a scaling factor, key EEG features in the signal are captured by an attention mechanism, filtering out most long-term artifacts that do not match the conditional information, thus helping the model generate EEG signal data that matches the conditional information. At the same time, the data dimension is reduced by a downsampling layer (data length is reduced by half), and then aggregated with the temporal features obtained by the temporal embedding layer. The addition of the temporal embedding layer enables the network to capture the temporal dependence characteristics and long-term distribution patterns of the signal, thereby further removing the remaining long-term distribution artifacts and reconstructing the distorted signal after denoising. The data dimension is then restored by an upsampling layer, and finally the upsampled signal is further processed and refined by ResNet (kernel size of 3). The low-level features of the input signal are preserved by residual connections, and combined with the extracted high-level features, the detailed reconstruction of the EEG signal is achieved, and the reconstructed EEG signal is finally output, thus removing long-term distribution artifacts.
[0126] Step 4: Network pre-training and overall training;
[0127] In this embodiment, two loss functions are used to train the model, and mean squared error (MSE) is used to optimize the parameters of the short-term denoising network (LWTCN), as shown in the following formula:
[0128]
[0129] in, denoised EEG signal, l represents the clean EEG signal corresponding to short-term distribution artifacts, and n is the number of samples. For the Long-Term Denoising Network (ADDPM), the absolute value error L1_loss is used to optimize the parameters of the generative model, and its formula is shown below:
[0130]
[0131] in, denoised EEG signal, g represents clean EEG signal corresponding to long-term distribution artifact.
[0132] In this embodiment, the training process is divided into pre-training and overall training. For the pre-training process, the trained model includes a segmentation network and an auxiliary network within the long-term denoising network. First, the segmentation network model ResUnet is trained, where the training location labels are manually labeled. Then, the location codes are obtained using the pre-trained segmentation network and further discriminative processing is performed to distinguish between long-term and short-term artifact samples in the semi-simulated dataset. Finally, the long-term artifact samples are used separately for the pre-training of the auxiliary network, completing the pre-training process. For the overall training process, the parameters of the pre-trained models of the segmentation network and the auxiliary network are first obtained, and then the samples from the semi-simulated dataset are input to complete the overall training of the EEG artifact removal network RLANET on the PyTorch deep learning framework.
[0133] In this embodiment, a contaminated EEG data test set is input into the trained RLANET network model, and the final output is a denoised signal. The contaminated EEG signal (input sample), the clean EEG signal (sample label), and the model's denoised signal are then visualized and compared, as shown below. Figure 6 (a) Figure 6 As shown in (b), where, Figure 6 (a) shows the artifact removal results of the long-term denoising network. Figure 6 (b) shows the artifact removal results of the short-term denoising network.
[0134] For visualization results of short-term artifact removal, it is clear that EMG artifacts are mainly distributed in the time intervals of 1s–1.5s and 4s–5s, with local time-varying overlap. EOL artifacts are mainly distributed in the time interval of 1.5s–3s, while ECG artifacts are regularly distributed throughout the entire time interval. By capturing the local features of the samples and the long-term and short-term dependencies, RLANET can effectively restore clean EEG signals in time intervals severely affected by artifacts.
[0135] The visualization results of long-term artifacts clearly show that EMG artifacts and EEG artifacts overlap for almost the entire time period. In the 0.5s-1.5s time period, EMG artifacts and EMG artifacts overlap, and EEG artifacts also overlap with EMG artifacts in the time period where ECG artifacts are present. It is not difficult to find that although the denoised signal after reconstruction by the long-term denoising network has slight Gaussian white noise, it can restore clean EEG signals well at the artifact overlap areas while solving the interference of time-varying overlap of EMG artifacts and EEG artifacts.
[0136] In this embodiment, as Figure 7 As shown, performance metrics for different artifact removal methods tested on a semi-simulated dataset are presented, including traditional EEG denoising methods EEMD-ICA and EEMD-CCA, which can remove artifacts based on different time scales and frequency components, as well as deep learning-based EEG denoising methods SCNN, EEGDNET, and RU-RNN. Figure 7 It can be observed that, compared with other artifact removal methods, the model constructed in this embodiment achieves the best denoising performance on the semi-simulated dataset, and can better restore the clean EEG signals in the contaminated EEG samples.
[0137] Example 2
[0138] This embodiment provides a deep learning and decision-based denoising EEG artifact removal system to implement the deep learning and decision-based denoising EEG artifact removal method of Embodiment 1 above. The system includes: a data generation module, an EEG artifact removal network model construction module, a pre-training module, an EEG artifact removal network model training module, and a denoising signal output module.
[0139] In this embodiment, the data generation module is used to generate contaminated EEG signals containing long-term and short-term artifacts to construct a semi-simulated dataset.
[0140] In this embodiment, the EEG artifact removal network model construction module is used to construct an EEG artifact removal network model, which includes a segmentation network, a short-term denoising network, and a long-term denoising network.
[0141] In this embodiment, the pre-training module is used to add noise artifact location coding labels to the contaminated EEG signal, and input the contaminated EEG signal into the segmentation network for pre-training to obtain the location codes corresponding to the EEG signals interfered with by long-term artifacts and short-term artifacts.
[0142] In this embodiment, the short-term denoising network includes an LSTM layer, a weight-initialized convolutional layer, and a TCN layer. The EEG signal affected by short-term artifacts is input into the LSTM layer to extract the state features of the EEG signal. The state features of the EEG signal are then input into the weight-initialized convolutional layer. Based on the new weight parameters generated by the weight-initialized convolutional layer, a one-dimensional convolution operation is performed on the state features of the EEG signal to output local temporal features. The TCN layer captures the features of short-term artifacts based on the local temporal features and smooths out the short-term artifacts.
[0143] In this embodiment, the long-term denoising network includes an auxiliary network and a generating network. The EEG signal affected by long-term artifact interference is input into the auxiliary network to obtain a preliminarily denoised EEG signal, which serves as the conditional information for the generating network. The generating network generates EEG signal data that matches the conditional information based on the attention mechanism, and aggregates it with the time features to output the reconstructed EEG signal.
[0144] In this embodiment, the EEG artifact removal network model training module is used to train the EEG artifact removal network model based on a semi-simulated dataset.
[0145] In this embodiment, the denoising signal output module is used to input the test set of contaminated EEG signals into the trained EEG artifact removal network model and output a denoised signal.
[0146] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A method for removing EEG artifacts based on deep learning and decision denoising, characterized in that, Includes the following steps: A semi-simulated dataset was constructed by generating contaminated EEG signals containing both long-term and short-term artifacts. A network model for removing EEG artifacts is constructed, which includes a segmentation network, a short-term denoising network, and a long-term denoising network. The segmentation network adopts a one-dimensional residual U-shaped network, including an encoder, skip connections, and a decoder; In the encoder, a one-dimensional convolutional layer is used to extract features from the contaminated EEG signal to obtain a convolutional feature map. Max pooling is performed on each convolutional feature map. By stacking convolutional layers and pooling layers, a feature map of high-dimensional features is obtained. After each pooling operation, the encoder saves the convolutional feature map of the current layer and passes it to the decoder via skip connections. The decoder performs deconvolution on the convolutional feature maps. At the same time, in each layer of the decoder, the feature maps of the same layer as the encoder are merged through skip connections. The merged feature maps are input into the convolutional layer of the decoder and perform one-dimensional convolution with the features extracted by the original encoder. The outputs of the same layer of the encoder and decoder are added through residual connections. The location coding labels for adding noise artifacts to the contaminated EEG signals are input into the segmentation network for pre-training to obtain the location codes corresponding to the EEG signals interfered with by long-term and short-term artifacts. The short-term denoising network includes an LSTM layer, a weight-initialized convolutional layer, and a TCN layer. The EEG signal affected by short-term artifacts is input into the LSTM layer to extract the state features of the EEG signal. The state features of the EEG signal are then input into the weight-initialized convolutional layer. Based on the new weight parameters generated by the weight-initialized convolutional layer, a one-dimensional convolution operation is performed on the state features of the EEG signal to output local temporal features. The TCN layer captures the features of short-term artifacts based on the local temporal features and smooths out the short-term artifacts. The long-term denoising network includes an auxiliary network and a generator network. The EEG signal affected by long-term artifact interference is input into the auxiliary network to obtain a preliminarily denoised EEG signal, which serves as the conditional information for the generator network. The generator network generates EEG signal data that matches the conditional information based on the attention mechanism, and aggregates it with the temporal features to output the reconstructed EEG signal. A network model for removing EEG artifacts was trained using a semi-simulated dataset. The test set of contaminated EEG signals is input into the trained EEG artifact removal network model, and the output is a denoised signal.
2. The EEG artifact removal method based on deep learning and decision denoising according to claim 1, characterized in that, The specific steps for constructing a semi-simulated dataset include: Acquire clean EEG signals, short-term distributed EOG signals in the time domain, and randomly distributed EMG signals; Based on wavelet transform processing of ECG signals, all signals are standardized. EOG, EMG, and ECG signals are introduced as artifacts into the clean EEG signal to synthesize the contaminated EEG signal, represented as: ; in, The synthesized contaminated EEG signal, For clean EEG signals, This is artifact noise. These are the weighting coefficients; The signal-to-noise ratio (SNR) is calculated, and weighting coefficients are set based on the SNR to control the degree of contamination of clean EEG signals by artifact noise. The formula for calculating the SNR is expressed as follows: ; in, The amplitude of a clean EEG signal. The amplitude of the artifact noise.
3. The EEG artifact removal method based on deep learning and decision denoising according to claim 1, characterized in that, The short-term denoising network includes an LSTM layer, a weight-initializing convolutional layer, and a TCN layer. The specific processing steps include: The EEG signal affected by short-term artifacts is input into the LSTM layer to extract the state features of the EEG signal. The hidden state and cell state of the LSTM layer are initialized as zero vectors. For each time step of the EEG signal affected by short-term artifacts, the LSTM layer receives the current input and the hidden state of the previous time step as input, and outputs the hidden state and cell state of the current time step. The hidden state is used as the state feature of the EEG signal extracted by the LSTM layer, which includes long-term dependencies and contextual information. The feature space output by the LSTM layer is mapped to the same dimension space as the weight-initialized convolutional layer through a linear connection layer.
4. The EEG artifact removal method based on deep learning and decision denoising according to claim 1, characterized in that, The new weight parameters generated by the weight initialization of the convolutional layer are specifically represented as follows: ; in, This represents the new weight parameters. This represents the mean of the weight matrix. The variance of the weight matrix is represented by... Represents the weight matrix of the first element. line, number Column elements, Represents a constant.
5. The EEG artifact removal method based on deep learning and decision denoising according to claim 1, characterized in that, The TCN layer includes a residual module, a connection layer, and a corrected linear unit. The residual module includes multiple residual layers, each connected to a corresponding input and output stream. The first and last residual layers use a skip output method. The intermediate residual layers include dilated convolutional layers and 1×1 convolutional layers. The dilated convolutional layers initialize the local temporal features of the output of the convolutional layers according to the weights to capture the features of short-term artifacts. Holes are inserted in the middle of the convolutional kernels to increase the receptive field of the convolutional kernels and smooth out short-term artifacts. The 1×1 convolutional layers perform dimensionality reduction and regularize the output. The connection layer integrates the features of different layers and maps high-dimensional features to a low-dimensional space. The corrected linear unit introduces non-linear features to fit the data distribution of clean EEG signals and outputs clean EEG signals.
6. The EEG artifact removal method based on deep learning and decision denoising according to claim 1, characterized in that, The generative network generates EEG signal data that matches conditional information based on an attention mechanism, and aggregates it with temporal features to output a reconstructed EEG signal, specifically including: The generative network performs EEG reconstruction including forward diffusion and reverse denoising processes. The generative network includes a residual layer, a conditional attention layer, a downsampling layer, a temporal embedding layer, and an upsampling layer; A time step and Gaussian random noise are generated, and a forward diffusion process is performed. Gaussian white noise is randomly generated at each time step and added to the EEG signal to obtain... A data sequence at each time step; The time vector is obtained after normalizing the time steps. , time vector The input is fed into the time embedding layer for time embedding encoding, specifically as follows: ; in, This represents half the dimension of the embedding vector. Indicates the dimension index of the embedded vector; The reverse denoising process will be the first Data at each time step Denoising and restoring the original sample Specifically, it is expressed as: ; in, , and Representing network parameters The mean and covariance matrix of the posterior distribution; EEG signals affected by long-term artifacts are processed through a residual layer to extract high-dimensional feature representations, which are then input into a conditional attention layer along with conditional information. The attention mechanism is then used to process the conditional information. Query projection to obtain Projecting the input features onto the keys and values yields... and Calculate the attention weights; the attention calculation formula is expressed as: ; in, For activation function, This is the scaling factor; By using attention mechanisms to filter out long-term artifacts that do not match the conditional information, EEG signal data that matches the conditional information is generated. After reducing the data dimensionality through the downsampling layer, it is aggregated with the temporal features obtained through the temporal embedding layer. The data dimensionality is then restored through the upsampling layer. The upsampled signal is then passed through the residual layer, and the low-dimensional feature representation of the input signal is preserved through the residual connection. Combined with the extracted high-dimensional feature representation, the reconstructed EEG signal is obtained.
7. The EEG artifact removal method based on deep learning and decision denoising according to claim 1, characterized in that, The forward diffusion process is represented as: ; ; ; in, This represents the interpolation rate used in the t-th step of the noise addition process. Indicates hyperparameters, Represents raw data and random Gaussian white noise linear combination, and This represents the corresponding combination coefficient.
8. The EEG artifact removal method based on deep learning and decision denoising according to claim 1, characterized in that, The test set of contaminated EEG signals is input into the trained EEG artifact removal network model. Specifically, the mean squared error (MSE) is used to optimize the parameters of the short-term denoising network, as shown below: ; in, This is the noise-reduced EEG signal. This represents the clean EEG signal corresponding to short-term distribution artifacts. The number of samples; The parameters of the long-term denoising network are optimized using the absolute value error L1_loss, specifically as follows: ; in, This is the noise-reduced EEG signal. This represents the clean EEG signal corresponding to long-term distribution artifacts.
9. A brainwave artifact removal system based on deep learning and decision denoising, characterized in that, The method for implementing the EEG artifact removal method based on deep learning and decision denoising as described in any one of claims 1-8 includes: a data generation module, an EEG artifact removal network model construction module, a pre-training module, an EEG artifact removal network model training module, and a denoised signal output module. The data generation module is used to generate contaminated EEG signals containing long-term and short-term artifacts to construct a semi-simulated dataset. The EEG artifact removal network model construction module is used to construct an EEG artifact removal network model, which includes a segmentation network, a short-term denoising network, and a long-term denoising network. The segmentation network adopts a one-dimensional residual U-shaped network, including an encoder, skip connections, and a decoder; In the encoder, a one-dimensional convolutional layer is used to extract features from the contaminated EEG signal to obtain a convolutional feature map. Max pooling is performed on each convolutional feature map. By stacking convolutional layers and pooling layers, a feature map of high-dimensional features is obtained. After each pooling operation, the encoder saves the convolutional feature map of the current layer and passes it to the decoder via skip connections. The decoder performs deconvolution on the convolutional feature maps. At the same time, in each layer of the decoder, the feature maps of the same layer as the encoder are merged through skip connections. The merged feature maps are input into the convolutional layer of the decoder and perform one-dimensional convolution with the features extracted by the original encoder. The outputs of the same layer of the encoder and decoder are added through residual connections. The pre-training module is used to add noise artifact location coding labels to the contaminated EEG signal, and input the contaminated EEG signal into the segmentation network for pre-training to obtain the location codes corresponding to the EEG signals interfered with by long-term artifacts and short-term artifacts. The short-term denoising network includes an LSTM layer, a weight-initialized convolutional layer, and a TCN layer. The EEG signal affected by short-term artifacts is input into the LSTM layer to extract the state features of the EEG signal. The state features of the EEG signal are then input into the weight-initialized convolutional layer. Based on the new weight parameters generated by the weight-initialized convolutional layer, a one-dimensional convolution operation is performed on the state features of the EEG signal to output local temporal features. The TCN layer captures the features of short-term artifacts based on the local temporal features and smooths out the short-term artifacts. The long-term denoising network includes an auxiliary network and a generator network. The EEG signal affected by long-term artifact interference is input into the auxiliary network to obtain a preliminarily denoised EEG signal, which serves as the conditional information for the generator network. The generator network generates EEG signal data that matches the conditional information based on the attention mechanism, and aggregates it with the temporal features to output the reconstructed EEG signal. The EEG artifact removal network model training module is used to train the EEG artifact removal network model based on a semi-simulated dataset. The denoising signal output module is used to input the test set of contaminated EEG signals into the trained EEG artifact removal network model and output a denoising signal.
Citation Information
Patent Citations
Electroencephalogram artifact removing method based on convolutional neural network
CN116671933A
Image acquisition and transcoding system
US20100309975A1