{'fraction_non_alphanumeric': 0.03325582415653929, 'fraction_numerical': 0.011933488351686922, 'mean_word_length': 4.841619682214249, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Detection and classification of ECG noises using decomposition on mixed codebook for quality analysis

In this Letter, a robust technique is presented to detect and classify different electrocardiogram (ECG) noises including baseline wander (BW), muscle artefact (MA), power line interference (PLI) and additive white Gaussian noise (AWGN) based on signal decomposition on mixed codebooks. These codebooks employ temporal and spectral-bound waveforms which provide sparse representation of ECG signals and can extract ECG local waves as well as ECG noises including BW, PLI, MA and AWGN simultaneously. Further, different statistical approaches and temporal features are applied on decomposed signals for detecting the presence of the above mentioned noises. The accuracy and robustness of the proposed technique are evaluated using a large set of noise-free and noisy ECG signals taken from the Massachusetts Institute of Technology-Boston's Beth Israel Hospital (MIT-BIH) arrhythmia database, MIT-BIH polysmnographic database and Fantasia database. It is shown from the results that the proposed technique achieves an average detection accuracy of above 99% in detecting all kinds of ECG noises. Furthermore, average results show that the technique can achieve an average sensitivity of 98.55%, positive productivity of 98.6% and classification accuracy of 97.19% for ECG signals taken from all three databases.


Introduction:
Continuous cardiac monitoring has become increasingly important for early detection of cardiovascular diseases by recording electrocardiogram (ECG) signals [1][2][3]. In continuous monitoring, ECG signal is corrupted by different noises which include baseline wander (BW), power line interference (PLI), muscle artefact (MA) and instrumentation noise (IN) [2,3]. Example of these noises is illustrated in Fig. 1. It can be noted from Fig. 1 that presence of these low-frequency (LF) and high-frequency (HF) noises results in inaccurate estimation of characteristics points, feature extraction, beat segmentation, alert generation during long-term recordings which can lead to wrong diagnostic decisions. Identification of noisy ECG segments in steady or Holter recordings is of particular importance since these signals are of no clinical use [1]. Therefore, it is very important to analyse the signal quality before signal analysis, feature extraction, deterioration identification, alarm generation and risk stratification [4]. Therefore, signal quality assessment (SQA) of acquired cardiac signals is an important process at the initial stage of implementing a decision system or computer-aided system to avoid incorrect decisions [4]. Furthermore, SQA can help in suppressing false alarms, identifying the improper placement of sensors, distributing resources adequately in a clinical setting, precise or robust extraction of clinically relevant features [5].
SQA is the semi-automated process of rejecting corrupted signals with the help of a human operator [6]. Generally, this subjective measure of signal quality analysis can be time-consuming, costly and prone to error during long-term measurements. Furthermore, this problem is more profound in many applications moving toward multi-channel arrays [7]. Therefore, there is a need of automated algorithms which can help to screen the signals at the front end of any decision-making system. Furthermore, it can prompt the operator for reacquisition when quality is poor. Thus, the quality appraisal of the recorded signals plays an important aspect in the vision of providing continuous health monitoring. Also, not only the noise detection in SQA but also classification of noises is also extremely important for selecting noise-specific and computational simple denoising algorithm [3].
1.1. ECG SQA techniques: In the literature, many SQA techniques have been proposed based on the simple thresholding, morphological change detection, QRS and fiducial point detection, machine learning approaches, higher order statics, temporal domain statistics, transform domain and signal decomposition. In [1] Orphanidou et al. proposed heuristic rules for quality appraisal of ECG and photplethsmogram (PPG) signals using extracted features based on the QRS or pulse portions, RR intervals, RR max /RR min , and template matching. In [8], quality appraisal is accomplished based on regularity in the shape of PQRST complexes and ensemble averaging of PQRST complexes. Furthermore, effect on myocardial ischemia alarms due to motion artefact has been analysed in an ambulatory ECG leads. In [9] Naseri and Homaeinezhad proposed a machine learning approach based on the neural network followed by energy-based index and correlation analysis for quality appraisal of ECG signal.
In [10], Behar et al. derived signal quality indices (SQIs) for the different varieties of arrhythmias and for the reduction of false alarm using a trained support vector machine (SVM) classifier. In [11], ECG signal quality is labelled as unacceptable based on the lead absence, spike detection, lead crossing points and robustness of QRS detection. In [12], Clifford et al. employed higher order moments and spectral energy information for SQIs and data fusion. Then, multi-layer perceptron, artificial neural network and SVM are trained using moments and energy features for determining clinical acceptability of ECGs. In [13], Hayn et al. proposed ECG SQA for patient treatment in m-Health applications. The method relies on signal parameters, crossing counts among various leads, and R-peak amplitude versus noise-amplitude ratio. In [14], Lee et al. exploited empirical mode decomposition (EMD) followed by statistical approaches for automatic motion artefact detection. A novel SQI is proposed for PPG, arterial blood pressure and ECG based on adaptive multi-channel prediction in [15]. In [16,17], LF and HF information of local waves of ECG signals and noises are extracted using various decomposition techniques followed by different temporal features for the detection and classification of ECG noises. In [18], a Daubechies wavelet-based method is proposed for assessing the ECG signal with unacceptable quality using heuristic rules and temporal features.
Many of the techniques based on the detection of QRS complex, R-R interval and fiducial points from the input ECG signal are not suitable for SQA since detection of correct R-R interval, QRS complex, fiducial points is difficult due to frequent variation in PQRST morphology in the ECG signal and under severe noises [16,17]. Many machine learning-based SQA techniques require a large number of ECG beats with different morphological shapes and noises for improving the detection accuracy [19]. Although detection and classification of ECG noises based on signal and noise separation using various decomposition techniques provide a promising approach, the accuracy of detection and classification highly depends on decomposition techniques. For example, in EMD-based SQA techniques, localised components of ECG signal and noises are segregated over a number of intrinsic mode functions (IMFs). Under this situation, it is quite challenging to identify the noisy IMFs from the signal IMFs [16]. In wavelet-based techniques, the wavelet coefficients of BW, PLI, and MA noises and ECG signal are dispersed over detail and approximation subbands. Although the spectral range of each wavelet subband is known, characterisation of noisy subband is quite challenging under time-varying PQRST morphologies and noise characteristics. Thus, selection of the wavelet filter, decomposition level and characteristic subband is quite difficult. Therefore, in this Letter, sparse signal decomposition (SSD) of ECG signal on mixed codebooks is exploited for signal separation followed by low-level feature extraction to detect and classify different ECG noises including BW, MA, PLI, and IN.

Proposed ECG noise detection and classification technique:
In this section, the sparse representation of ECG signal on mixed hybrid overcomplete codebooks is briefly described for simultaneously extracting the local components of ECG signal and different noises such as BW, PLI, MA and additive white Gaussian noise (AWGN).
2.1. ECG signal decomposition on hybrid codebooks: A composite ECG signal (with its local waves and noises) x can be adequately represented on hybrid mixed codebook F [ R P×Q , where P , Q, including temporal-bound and spectral-bound elementary waveforms [20][21][22]. Hence, ECG signal for a predefined mixed codebook can be expressed as where a = [a 1 , a 2 , . . . a Q ] is the sparse transformed vector, which can be derived from an overcomplete codebook. The overcomplete codebook can be constructed using analytical orthogonal functions or beat patterns by exploiting the prior knowledge about the temporal and spectral characteristics of ECG local waves and noises [20][21][22]. Hence, spectral-domain bound components such as LF components of an ECG signal and BW and PLI noises can be effectively modelled using sinusoidal waveforms [20][21][22]. The spike-like components of MAs and AWGN may be modelled as impulsive elementary waveforms. It is worth to note that the high spectral components of QRS complex are also captured by these elementary waveforms. This codebook provides an efficient sparse representation for ECG local waves as well as noises. Thus, the codebook including both temporal-bound and spectral-bound signals is derived from different orthogonal functions to provide adequate representations of ECG signals and inherent noises [20][21][22]. In this Letter, the ECG signal is decomposed using the overcomplete mixed codebook with a size of P × Q as where P denotes the length of the ECG signal x and Q denotes the number of orthogonal waveforms. F BW denotes the codebook of elementary waveforms of BW to capture the BW components present in the signal. F LF denotes the codebook containing LF elementary waveforms to capture the P wave, T wave and LF portions of QRS complexes. F PLI denotes the codebook of the elementary waveforms of power line frequencies to capture the PLI noise components present in the signal. F HF with size of P × P denotes identity codebook to capture spike-like components such as MAs, AWGN or HF components of QRS complex that are well bound in the temporal domain. The BW codebook F BW , LF codebook F LF , and PLI codebook F PLI codebooks are constructed using the orthogonal sine and cosine signals derived from the discrete sine and cosine functions to capture the information of the noise components including the BW, PLI, and local ECG waves including the P-wave, T-wave and wide QRS complexes. The codebooks S and C both with size P × K contain a set of elementary sine and cosine signals, respectively, for a known spectral bin range of each aforementioned codebook, which can be computed similar to [20][21][22] and can be written as In this work, both discrete cosine and sine elementary waveforms are used to avoid signal discontinuities at the segment boundaries [20]. The computational complexity for estimating the sparse coefficients relies upon the dimension of the codebook and the number of iterations taken by the algorithm [20,21,23]. Codebook can be learned based on the characteristics of the signals of interests for specific type of applications such as event identification, parameter estimation, compression and denoising problems [20,21]. Since the main goal is to detect and classify the presence of ECG noises, spectral-bound codebooks F BW , F PLI and F LF are constructed based upon the dominant spectral ranges of the BW, the PLI and the ECG local waves, respectively. In this Letter, spectral bin ranges of [0-1] Hz, [47-53] Hz and [1][2][3][4][5][6] Hz for the sinusoidal codebooks F BW , F PLI and F LF , respectively, are chosen to capture BW, PLI and LF components of ECG signal as mentioned in [20,21,24]. For a given frequency f 1 , the column  number is calculated as ⌊2Pf 1 /F s ⌋, where F s is the sampling rate and P denotes the length of the signal. Then, the orthogonal sine and cosine basis signals are calculated for desired spectral bin ranges. The LF component P/T wave and wide QRS complexes are adequately captured by the LF codebook F LF . The main goal is to estimate the sparse coefficients which can adequately capture all ECG local waves and ECG noises including BW, PLI, MA, AWGN compactly. These sparse coefficients can be estimated by well-known l 1 norm optimisation algorithm [20,21] where l is the regularisation parameter which adjusts relative weights between reconstruction fidelity Fa − x 2 2 and sparsity term a 1 .â is the reconstructed sparse coefficients vector which consists of coefficients reconstructed from F BW , F PLI , F LF and F HF , which can be written aŝ whereâ BW represents the sine and cosine coefficients derived for the BW codebook F BW ,â LF represents the sine and cosine coefficients derived for the LF codebook F LF ,â PLI represents the sine and cosine coefficients derived for the PLI codebook F PLI and a PLI represents the impulsive coefficients derived for the HF codebook F HF . Using (1), (2) and (4), ECG signal and inherent noises can be described as a linear combination of weighted columns of codebook F Once, the detection is accomplished then it is classified in the subsequent classes based on values of statistical features. Different statistical features such as dynamic range, zero-crossing, kurtosis are employed to detect and classify the various noises.
In this work, 10 s ECG segment is used for processing, Fig. 2.
A detailed discussion is presented on detection and classification of individual noise type in the following section.
2.2.1 BW noise detection: The information of LF components <0.5 Hz is captured in the decomposed signal x B [n]. Fig. 3a shows that ECG signal is corrupted with BW and PLI noises. Also, BW noise is captured in the decomposed component x B [n] as depicted in Fig. 3b. Fig. 3b shows the large variation in the amplitude range. Therefore, for detecting the presence of the BW noise, dynamic range of x B is compared with a threshold g B as follows: Then, implementing amplitude thresholding rule with a predefined threshold g B , the BW noise event is detected as follows: where H B is the hypothesis for the BW noise. Here, the value of g B is chosen as 0.1 mV such that acceptable level of BW noise does not distort the minimum amplitude value of P-wave of the ECG signal [20,24].

PLI detection: SSD exploits the information of elementary
waveforms of the power line frequency. Therefore, information about 50/60 Hz frequency is adequately captured in the decomposed signal x P . It is evident from Fig. 3a that complete ECG segment is corrupted by uniformly distributed PLI and adequately captured in x P as shown in Fig. 3c. For detecting the presence of PLI, a predefined threshold (let g P ) can be employed. Typically, the minimum value of P-wave amplitude lies below 0.1 mV [20,24]. Hence, the value of the threshold can be chosen such that it should not distort the local P wave. Here, the value of the threshold g P is chosen as 0.05 mV. It can be observed in case of higher MA or Gaussian noise, x P may exceed the predefined threshold g P as shown in Fig. 4. In order to discriminate the PLI noise from either MA or AWGN, two temporal domain parameters, i.e. kurtosis and high zero-crossing rate ratio (HZCRR) are employed. HZCRR is defined as the ratio of the number of segments having a zero-crossing rate (ZCR) above 1.5-times as compared to average ZCR in 10 s block [25]. HZCRR basically estimates the dynamic amplitude range of the zero-crossings. HZCRR can be computed as: where L is the number of blocks and ZCR is the mean of zero-crossings rate in each block. In order to discriminate the MA from PLI (under severe MA), HZCRR is employed. In such cases, dynamic amplitude range of zero-crossings in x P is not consistent which is indicated by the non-zero value of HZCRR. However, in presence of high Gaussian noise, dynamic amplitude range of zero-crossings in x P is consistent. Hence, in order to discriminate it from PLI, kurtosis measure k is used. Kurtosis measures the sharp peaks of the distribution of random variable [26] in the signal. Kurtosis measure k can be computed as: (11) where N is the length of noisy signal x P and m is the mean of x P . It is well known fact that kurtosis value of Gaussian distribution is ∼3. Therefore, by comparing the kurtosis value, PLI and AWGN can be classified. The reason for setting predefined threshold (g P ) is to avoid computation of kurtosis and HZCRR in case of lower noise in x P . Therefore, the detection problem becomes in PLI case as follows: the presence of HF noise before classification of MA and AWGN. It can be observed from Figs. 5 and 6 that amplitude of zero-crossings is increased. Therefore, information of the amplitude and number of zero-crossings is employed to detect the presence of HF noise. The zero-crossing computation and amplitude thresholding stages are implemented based on the overlapped segmentation of the HF signal x H . In the segmentation process, the decomposed signal x H is divided into overlapping segments with segment duration of 100 ms with a segment shift (Q) of 10%. The overlapping segmenting process is implemented as where k = 0, 1, . . . , M 1 − 1 and M 1 = ⌊N /Q⌋. P denotes the size of window. Then, ZCR is calculated for each block x k P [n]. To detect the presence of HF noises, median of amplitudes and ZCR of that block are compared with thresholds g P1 and g P2 , respectively. Here, the value of threshold g P1 for median is chosen 0.02 mV to avoid distortion in the local P wave. Median feature has been used to reduce the effect of R peak amplitude in the window. The value of threshold g P2 is chosen as 5. This threshold is selected based on the fact that the block containing QRS complex should not have >5 zero-crossings in the case of noise-free ECG signal. Let the instances in which the block does not fulfil the above two conditions be r. Then, the hypothesis problem for HF detection case can be written as follows: where L is the length of the vector r. To discriminate the MA and AWGN after detecting the presence of HF noise, uniformity of the zero-crossings above threshold (same as g P2 ) has been used. If ratio of number of the blocks exceeded the zero-crossing threshold to the total number of blocks is above 80% then it is classified as AWGN and vice versa. Let L be this ratio then resulting signal can be written as: Hence, all the noises can be classified using SSD and statistical features.
3. Results and discussion: In this section, the detection and classification performance of the proposed technique is evaluated using a variety of ECG signals taken from three publicly available databases, i.e. Massachusetts Institute of Technology-Boston's Beth Israel Hospital (MIT-BIH) arrhythmia database (MITBIHAD), MIT-BIH polysmnographic database (MITBIHPD) and Fantasia database (FD).
3.1. Databases and performance metrics: MITBIHAD contains 48 records of ECGs for two leads [27]. Each signal is recorded longer than 30-min and digitised at 360 samples/s with sample resolution of 11-bits per sample [27]. The database contains ECG signals with normal sinus rhythm (NSR) and different arrhythmias including atrial fibrillation, supraventricular tachyarrhythmia, atrial flutter, sinus bradycardia, ventricular tachycardia, ventricular flutter, atrial premature beat, premature ventricular contraction, left bundle branch block, right bundle branch block [27]. MITBIHPD consists of four physiological signals ECG, blood pressure, EEG (electroencephalogram) and respiratory signal [28]. ECG signals are taken from the database for evaluating the proposed technique. This database contains long recordings (varying in time for different records) of the ECG signal recorded at a sampling frequency of 250 Hz and 12-bit resolution [28]. The FD consists of 2 h of continuous supine resting ECG signals recorded from 20 young and 20 elderly subjects. Each signal was digitised at 250 Hz with 12/16-bit resolution [29].
Mostly, ECG records consist of different kinds of PQRST morphologies and contaminated by various kinds of artefacts and noises including BW, PLI and MA. For creating the PLI annotated database with ECGs + PLI, sinusoidal noise is added with varying amplitude and frequency ranging from 47 to 52 Hz. Similarly, other noises including, BW and MA are added in noise-free ECG signal to increase the test ECG segments using synthetic noise generator available in [30]. Consequently, for ECG corrupted with AWGN noise, WGN is added with 0 to 15 dB SNR. The ECG records were taken from all records of MITBIHAD, MITBIHPD and FD. Then, a large ECG signal database is  Table 2 depicts the average classification performance of the proposed technique for ECG signals taken from all three databases in terms of benchmark parameters such as sensitivity (Se), positive predicitivity (+P) and classification accuracy (A c ). The proposed technique achieves a classification accuracy of 97% approximately for all ECG and noise classes taken from all three databases as shown in Table 2. It is clear from the results that SSD enables to detect the presence of BW, PLI and HF noise from the subsequent decomposed signals using simple statistical parameters. Although all databases provide good Se, +P and classification accuracy, it is important to identify the unacceptable recording of signal by detecting the type of noise. However, one can bypass the step of classification by neglecting the unacceptable records after detecting HF noise itself which may further improve the detection accuracy of the proposed technique. It is evident from the results that the proposed technique can be suitable for detecting most commonly encountered noise types including BW, PLI, MA, AWGN and mixture noise types including BW + PLI, and BW + MA.

Conclusion:
In this Letter, a new technique is presented for detection and classification of ECG noises based on SSD on mixed codebooks and statistical features such as dynamic amplitude range, HZCRR, kurtosis measures, ZCR. The proposed detection and classification technique is evaluated using a wide variety of clean and noisy ECG signals taken from three publicly available MITBIHAD, MIT-BIH polysomnographic database and FD. Results demonstrate that the proposed technique achieves the average detection accuracy of above 99% in detecting all kinds of ECG noises. Furthermore, average results show that the technique can achieve an average sensitivity (Se) of 98.55%, positive productivity (+P) of 98.60% and classification accuracy of 97.19% for all three databases.