{'fraction_non_alphanumeric': 0.041923980168739675, 'fraction_numerical': 0.016830477515873705, 'mean_word_length': 4.908273381294964, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
IC-U-Net: A U-Net-based Denoising Autoencoder Using Mixtures of Independent Components for Automatic EEG Artifact Removal

Electroencephalography (EEG) signals are often contaminated with artifacts. It is imperative to develop a practical and reliable artifact removal method to prevent misinterpretations of neural signals and underperformance of brain-computer interfaces. This study developed a new artifact removal method, IC-U-Net, which is based on the U-Net architecture for removing pervasive EEG artifacts and reconstructing brain sources. The IC-U-Net was trained using mixtures of brain and non-brain sources decomposed by independent component analysis and employed an ensemble of loss functions to model complex signal fluctuations in EEG recordings. The effectiveness of the proposed method in recovering brain sources and removing various artifacts (e.g., eye blinks/movements, muscle activities, and line/channel noises) was demonstrated in a simulation study and three real-world EEG datasets collected at rest and while driving and walking. IC-U-Net is user-friendly and publicly available, does not require parameter tuning or artifact type designations, and has no limitations on channel numbers. Given the increasing need to image natural brain dynamics in a mobile setting, IC-U-Net offers a promising end-to-end solution for automatically removing artifacts from EEG recordings.


Introduction
Electroencephalography (EEG), a non-invasive and convenient modality for measuring hightemporal-resolution changes in electrical potentials over the human scalp, is one of the dominant neuroimaging modalities used in brain-computer interfaces (BCIs) (Gu et al., 2021;Lazarou et al., 2018;Nicolas-Alonso and Gomez-Gil, 2012;Rashid et al., 2020). Advances in signal processing and analytic methods have expanded the capabilities and applicability of EEG in real-world practices.
Nevertheless, there is an emerging need to measure brain dynamics in moving humans (Jungnickel and Gramann, 2016), and one of the associated challenging issues is removing artifacts from EEG signals (Gwin et al., 2010;Jiang et al., 2019) with minimum distortion and contamination. A practical and effective method for suppressing artifacts and reconstructing EEG signals would considerably improve the signal-to-noise ratio (SNR) of the recordings, enhance the performance of BCIs, and increase the accuracy of data interpretation (Haumann et al., 2016;Radüntz et al., 2015).
The realization of such a technology has taken center stage in the research on EEG signal processing. Several researchers have proposed various countermeasures to remove signal contamination caused by, for example, eye blinks/movements, muscle activity, and line noise. One commonly adopted countermeasure is blind source separation (BSS) (Fitzgibbon et al., 2007;Joyce et al., 2004;Jung et al., 2000), in which various statistical assumptions, such as independence (Jung et al., 2000;Makeig et al., 1996), correlation (de Cheveigné et al., 2018;Lin et al., 2018), covariance (Chang et al., 2020), or stationarity (Maddirala and Veluvolu, 2021;von Bunau et al., 2010), are used to extract the underlying sources from their mixtures at sensors. Artifact subspace reconstruction (ASR) (Chang et al., 2020), for instance, assumes that the EEG data share the same principal component space, projects raw EEG signals onto this feature space, and then reconstructs signals by preserving those projected principal components whose variance does not exceed a certain predefined threshold. Another well-grounded and effective BSS method is independent component analysis (ICA) (Jung et al., 2000;Makeig et al., 1996), which separates instantaneously and linearly mixed recordings into mutually independent components (ICs). Given that an IC classifier (Pion-Tonachini et al., 2019;Winkler et al., 2011) can automatically differentiate artifactual ICs from brain ICs, artifact-corrected EEG signals can be obtained by pruning non-brain sources and backprojecting brain sources to the sensor level. Numerous studies, including those discussed herein, have advocated for better EEG representation through BSS, which would allow deeper scientific analysis and broader use of EEG data. However, most BSS techniques seek a single linear or nonlinear mapping function between source signals and sensor observations, which might be too simplistic for the complex nature of brain activity.
Recently, deep learning models have been widely applied to EEG analysis and BCIs (Lawhern et al., 2018;Schirrmeister et al., 2017), with the key idea being to extract the underlying feature representation (Bengio et al., 2013;Shorten and Khoshgoftaar, 2019) using a powerful neural network. Unlike conventional BSS methods, deep learning enables the construction of data representations without the need of restrictive assumptions. One such representative feature learning model is the autoencoder (Hinton and Salakhutdinov, 2006). For example, the denoising autoencoder (DAE) (Vincent et al., 2010) has great potential for removing EEG artifacts (Leite et al., 2018), as evidenced by its effectiveness in other applications, such as removing noise from images (Phadikar et al., 2020), restoring speech (Lu et al., 2013), decoding incomplete EEG recordings (Li et al., 2015), and enhancing ECG signals (Chiang et al., 2019;Xiong et al., 2016). Another representative encoderdecoder scheme is U-Net (Ronneberger et al., 2015) that originated from convolutional neural networks and was initially developed for biomedical image segmentation. U-Net and its variants have recently been successfully applied to image denoising (Guan et al., 2020;Gurrola-Ramos et al., 2021) and various EEG applications (Chatzichristos et al., 2020;Perslev et al., 2019;You et al., 2021).
However, to the best of our knowledge, no study has yet used U-Net to denoise EEG signals. Because encoder and decoder networks can serve as the source separation and mixing, respectively ( Fig. 1), we conjecture that U-Net can recover brain sources and thereby suppress artifacts. Furthermore, because of its simple structure and its minimal training sample requirement, U-Net is well suited for processing EEG signals, which are typically difficult to accumulate on a large scale.
In artifact removal, the availability of noisy-free EEG pairs is crucial and considerably affects the signal reconstruction performance regardless of the DAE model used. Such pairs can be obtained by backprojecting selected brain sources decomposed by BSS to the sensor level, in addition to generating and adding artificial noises to EEG data (Delorme et al., 2007;Li et al., 2021;Val-Calvo et al., 2019;Zeng et al., 2016). For instance, the spatial mixing matrix of ICA can be used to thoroughly mix brain and non-brain sources to generate clean EEG targets and noisy EEG inputs.
Each spatial mixing matrix is unique to its corresponding source, enabling data generation in a natural manner.
This study developed a new model, IC-U-Net, by combining the strengths of ICA and U-Net in EEG artifact removal. This model, based on the U-Net architecture with a loss function ensemble, was trained with mixtures of independent EEG sources. This study is novel in three ways. First and foremost, the proposed IC-U-Net model is the first EEG artifact removal method that uses the U-Net architecture. Second, IC-U-Net has an ensemble of loss functions, which allows it to simultaneously capture multiple signal variations in EEG recordings. This ensemble design can overcome a major limitation of the frequency principle (Xu et al., 2019), which is that a deep neural network often fits target functions to low frequencies first and later to high frequencies. Third, the proposed method is a nonlinear mapping scheme that learns the latent properties of independent brain sources and automatically removes multiple artifacts, such as eye blinks/movements, muscle activities, and line/channel noises, from EEG signals.

IC-U-Net
This study developed a novel technique, IC-U-Net (Fig. 2), which creates a mapping between noisy and clean signals to reconstruct signals and remove artifacts. The proposed method, which is based on the U-Net architecture, was trained with brain and non-brain sources through minimizing an ensemble of loss functions. The robustness and feasibility of the proposed IC-U-Net were evaluated through one simulation study (Section 3) and three real-world EEG experiments (Section 4).

Network architecture
The deep denoising autoencoder (DDAE) aims to establish a correspondence between noisy inputs, " , and reconstructed outputs, , through encoding and decoding processes, enabling the latter to approximate the clean targets, . The objective function, ℒ , is a reconstruction loss function determining the disparity between inputs and outputs that the DDAE tries to minimize to achieve the best artifact removal performance, which can be expressed as [ℒ( , ) ] = -ℒ .De .En3 " 45 , 5 6 . (1) First, the encoder network (En) embeds the signals, " , into the latent space, where noises and nonnoises are assumed to be well distinguishable. Then, the decoder network (De) obtains the reconstructed signals, = De .En3 " 45. is the expectation over the distribution of ℒ( , ).
These encoding and decoding processes are implemented using the DDAE and a U-Net-like network architecture ( Fig. 2A), which mainly comprises a one-dimensional (1D) convolution neural network. In the encoder network, multiple layers of CBR blocks (i.e., convolution, batch normalization, and ReLU activation function (Glorot et al., 2011)) and downsampling blocks attempt to extract increasingly more abstract representations of the input data by using the max-pool operator.
To extract contextual information, the number of convolution filters doubles after each downsampling block. During decoding, the upsampling block with 1D transposed convolution (i.e., deconvolution) works with the CBR blocks, and the number of convolution filters halves after each upsampling block.
To better reconstruct signals and recover spatial information, skip connections activate at the end of each decoder layer to concatenate the resultant decoded features with the corresponding encoded features. Figure 2A details the model structure and the hyperparameters, including kernel sizes, numbers of convolution and deconvolution filters, and stride.

Loss function ensemble
To capture the highly fluctuating structure of EEG signals, this work adopted an ensemble approach of forming multiple loss functions that could collaboratively gauge the difference between reconstructed and clean signals. This ensemble is a simple linear combination of four terms covering the amplitude, velocity, acceleration, and frequency components of EEG signals: where $ , * , -, and / denote the weights used to regulate the contribution of each term. Given that the channel number is and the data length is , the loss from the amplitude component is where MSE indicates the operator of the mean square error (i.e., L2 loss) between two arguments.
The second loss deduced from the velocity component (ℒ vel ) is the MSE between the first-order differential estimates of and . The third loss deduced from the acceleration component (ℒ '.. ) is the MSE between the second-order differential estimates of and . The fourth loss is generated from the following frequency component (ℒ freq ): where ( , ) and ( , ) represent the spectral estimates of and , respectively, in the range of 1-50 Hz with frequency bins. Each spectral estimate is the power spectral density converted by fast Fourier transformation, followed by z-score normalization.

Model training using brain and non-brain sources
We hypothesize that EEG artifacts can be removed if the proposed model can learn latent representations of clean EEG through the DDAE. To implement this learning, the clean targets and noisy inputs of the proposed U-Net model were mixtures of brain sources (denoted as mixB) and mixtures of brain and non-brain sources (denoted as mixBnB), respectively, decomposed by ICA.
Specifically, as shown in Fig. 2B, ICA was first applied to training data, and then ICLabel (Pion-Tonachini et al., 2019), an automated IC classifier, was used to distinguish the Brain IC from the six non-brain ICs (Muscle, Eye, Heart, Line Noise, Channel Noise, and Other). The selected A ≤ Brain ICs were then backprojected to the sensor level using the inverse of the corresponding unmixing matrix to synthesize the mixB, , as follows: The time series, brain ∈ ℝ 3 # ×5 , were A ICs with probabilities of being brain activities, estimated by ICLabel, were more than 80%. The time series, non-brain ∈ ℝ (3E3 # )×5 , denotes the − A ICs with probabilities of less than 80% being brain activities. The weight matrix corresponding to Brain ICs, F B1'C" ∈ ℝ 3×3 $ , was preserved, but the one corresponding to non-brain ICs was set as a zero matrix, ∈ ℝ 3×(3E3 # ) , to maximally eliminate non-brain activities in .
Given that ICLabel had classified the categories of all ICs in the training dataset, the mixBnB, " , could be synthesized by combining with at least one of the artifact ICs. Consider $ Eye ICs (i.e., blinks and eye movements) as an example: where F !M! ∈ ℝ 3×3 % and eye ∈ ℝ 3 % ×5 are the time series and corresponding weight matrix of Eye ICs, respectively. By arbitrarily combining mixB with recognizable artifacts, the range of mixBnB can be feasibly diversified to facilitate model training.

Performance evaluation
The proposed model was validated using the MSE and SNR as the performance metrics (Eqs. (3) and (4)) in one simulation (Section 3) and three real-world EEG experiments (Section 4). Specifically, the MSE between the mixB, , and the reconstructed output, , was used to evaluate the model performance and confirm the convergence of the model training, and the SNR was calculated as These two metrics were further averaged across samples, with a lower MSE and a higher SNR indicating better artifact removal and signal reconstruction performance.
Two other validation methods were used to determine whether the reconstructed signals were brain activities. First, the number of brain sources was calculated. Specifically, ICA and ICLabel were applied again, but this time to the reconstructed signals, to calculate the numbers of available Brain ICs. We hypothesize that an effective artifact removal method can increase the number of brain sources in the reconstructed signals. Second, within the reconstructed EEG signals, the presence of typical EEG activity, such as event-related potential (ERP), in response to specific events was verified.

Simulation Experiments and Results
The proposed method was first validated through a simulation experiment (Fig. 3A) to verify 1) the convergence of model training, 2) the preference of each loss function in capturing frequency bins, and 3) the robustness of signal reconstruction. was made of a linear combination of six sinusoidal waves whose frequency (Hz), amplitude (arbitrary units), and phase (radians) ranged between (0,50), (0,1), and (0,2π), respectively. Z-score normalization was used to rescale each synthetic time series. The model hyperparameters, maximum number of epochs, batch size, and learning rate were set to 150, 128, and 0.01, respectively.

Ablation study of loss functions
Loss functions can have a big impact on a model's performance. Thus, this section examines the convergence of model training and the capability of each loss function in capturing frequency. Figure   4A compares the loss values of the validation samples derived from the model trained using (left to (2) within comparable numbers of epochs to reach convergence. Figure 4C presents an example of a 1-s temporal segment reconstructed using the proposed model with different loss functions. The models trained with ℒ amp and ℒ ens had the greatest results in terms of restoring the waves and the frequency components and the smallest errors across frequency bins (Fig. 4D). The error distribution suggested that ℒ vel and ℒ acc could preferentially capture highfrequency components over low-frequency components. Although the errors obtained from the models trained with ℒ vel , ℒ acc , and ℒ freq were larger than those obtained from the model trained with ℒ amp , by combining all loss functions, the model was still able to suppress the overall errors across frequency bins. Further investigation of the error peak between 30 and 35 Hz is required.

Real-world EEG Experiments and Results
The proposed IC-U-Net model was trained using a large number of real resting-state EEG signals from 546 recording sessions. As in the simulations, loss values and SNR were used to characterize the model's convergence and performance. Moreover, the model's performance was assessed against a variety of artifacts (Fig. 3B). The proposed model was further validated against two non-resting-  After being decomposed into brain and artifact sources by ICA and ICLabel, each dataset was segmented into multiple 4-s segments [each of dimension 30 (channels) × 1,024 (points)] in a nonoverlapping manner. Following the procedures described in Section 2.3, this study generated clean targets (i.e., mixB) by mixing brain sources through the corresponding weights of spatial distribution and noisy data (i.e., mixBnB) by mixing brain sources with one of the artifacts (Eye, Muscle, Heart, Channel Noise, and Other). Table 2 lists the numbers of mixB and mixBnB records; Line Noise was not present in any of the datasets. Before training, z-score normalization was used to rescale each time series. As the model hyperparameters, the number of epochs, batch size, and learning rate were set to 150, 128, and 0.01, respectively.

Model validation
As shown in Figs

Model deployment I: lane-keeping driving experiment
The proposed model was then tested on one of our existing databases collected in a virtual driving experiment (Chuang et al., 2014;Lin et al., 2016) to see if it can remove pervasive artifacts during driving and compare its performance to that of other methods (Fig. 3C). In the experiment, each subject participated in a 1.5-h event-related lane departure task in the afternoon, during which time their 30-channel EEG signals were collected at a sampling rate of 500 Hz using Neuroscan SynAmps2.
The electrode placement was identical to that in the resting-state experiment described in Section 4.1.
The objective of this experiment was to investigate the EEG correlates of sustained attention during driving. The subjects were tasked with keeping the vehicle cruising in the center of the designated lane by correcting the vehicle's trajectory (using the steering wheel) as soon as possible if the vehicle began to drift. Seventy-six test datasets were selected in total, 60 of which are publicly available (Cao et al., 2019) and 16 were added from our data repository. Before testing, the data were downsampled to 256 Hz and filtered using a zero-phase FIR filter with a cutoff frequency between 0.1 and 80 Hz. Figures 6A-6C showed that ASR, 1D-ResCNN, and IC-U-Net could all remove artifacts from EEG signals with a low MSE and a high SNR (Table 4). However, only IC-U-Net could best preserve the waveform for a clean EEG segment. Overall, the proposed IC-U-Net model outperformed the other three. To further investigate whether the reconstructed signals were brain activities, this study analyzed ERPs time-locked to lane-departure events to verify the presence of neural responses associated with attention processing, with the assumption that the classical P3 activity would occur in response to the stimulus-driven event (Bledowski et al., 2004). As revealed by the ERP data (Delorme and Makeig, 2004) (upper panel) and their average (lower panel) in Fig. 6D, the signals processed with the filter, ASR, and IC-U-Net models preserved clear P3 amplitudes.
Next, this study analyzed the components underlying the reconstructed signals to confirm that applying an artifact removal method to EEG can facilitate the extraction and preservation of relatively more brain activities. As shown in Fig. 6E, the proposed method and the three representative methods could all extract more Brain sources from the reconstructed signals (color circles) than from the raw signals (gray circles). Specifically, IC-U-Net allowed the ICA to extract the most (i.e., 23.9 ± 2.8) Brain sources from 30-channel EEG signals. In addition, the extracted Brain sources contained an average of >80% activity arising from cortical patches (Table 5). Furthermore, Muscle, Line Noise, and Channel Noise were all removed from the signals processed with the proposed model. In summary, IC-U-Net outperformed the other three models.

Model deployment II: walking experiment
Finally, the proposed model was tested in a walking experiment (Fig. 7A). An adult subject's 32channel EEG activities (LiveAmp, Brain Products GmbH) were recorded while walking down a jogging track in a stadium. Figure 7B shows the EEG time series before and after artifact removal using IC-U-Net. ICA and ICLabel were used to analyze the components in the reconstructed signal.
As shown in Fig. 7C, IC-U-Net removed 16 artifact sources-4 Eye, 1 Channel Noise, and 11 Line Noise-from the original EEG recording. There was only one identified Brain source (>80% brain) in the original EEG recording, whereas after reconstruction using IC-U-Net, the number of qualified Brain sources increased substantially to 16. Table 6 summarizes the probability of finding decomposed brain sources in the reconstructed signals; these results suggest that IC-U-Net could increase the probability of finding brain sources in walking data from 4.5% to 61.8%. Such a remarkable improvement was also found in resting-state and lane-keeping driving data. Taken together, the results validate the use of the proposed IC-U-Net method for reconstructing EEG signals to increase the number of extractable brain sources.

Conclusion
This study proposed a new end-to-end artifact removal method,   Refer to ICLabel for the definitions of Eye, Muscle, Heart, Channel Noise, Line Noise, and Other.  *Heart, Line Noise, and Channel Noise are omitted because they are rarely decomposed from this dataset. − indicates that none of the sources could be decomposed after signal reconstruction.    PSDs of one clean EEG segment and two 4-s EEG segments contaminated by eye-blinking and square-like artifacts (gray traces), which were corrected by the aforementioned four artifact removal methods. (D) ERP image and average ERP of the Cz channel after artifact removal using different methods. The results in A and B were obtained using a specific lane-keeping dataset: s05_061019m. (E) Number of Brain ICs decomposed from 76 lane-keeping datasets; the x-axis indicates the number of Brain ICs, and the y-axis indicates the number of Brain ICs whose probability of being brain activity exceeds 80%.