Robust T-End Detection via T-End Signal Quality Index and Optimal Shrinkage

An automatic accurate T-wave end (T-end) annotation for the electrocardiogram (ECG) has several important clinical applications. While there have been several algorithms proposed, their performance is usually deteriorated when the signal is noisy. Therefore, we need new techniques to support the noise robustness in T-end detection. We propose a new algorithm based on the signal quality index (SQI) for T-end, coined as tSQI, and the optimal shrinkage (OS). For segments with low tSQI, the OS is applied to enhance the signal-to-noise ratio (SNR). We validated the proposed method using eleven short-term ECG recordings from QT database available at Physionet, as well as four 14-day ECG recordings which were visually annotated at a central ECG core laboratory. We evaluated the correlation between the real-world signal quality for T-end and tSQI, and the robustness of proposed algorithm to various additive noises of different types and SNR’s. The performance of proposed algorithm on arrhythmic signals was also illustrated on MITDB arrhythmic database. The labeled signal quality is well captured by tSQI, and the proposed OS denoising help stabilize existing T-end detection algorithms under noisy situations by making the mean of detection errors decrease. Even when applied to ECGs with arrhythmia, the proposed algorithm still performed well if proper metric is applied. We proposed a new T-end annotation algorithm. The efficiency and accuracy of our algorithm makes it a good fit for clinical applications and large ECG databases. This study is limited by the small size of annotated datasets.


Introduction
The electrocardiogram (ECG) is a ubiquitous diagnostic tool for cardiovascular diseases. One important clinical application is information about the QT interval, a measure of ventricular repolarization. A prolonged heart rate corrected QT is associated with ventricular arrhythmia and sudden death [1], and also used to study adverse drug reactions [2].
The accuracy of QT measurement directly depends on the ability to accurately determine the Q onset and T offset. Compared with the Q onset, determination of the T-end is challenging. Nevertheless, various techniques have been proposed for automatic T-end detection. This includes threshold on the first derivative [3,4], threshold on an area connected by points around the T-wave [5][6][7], wavelet transform [8,9], mathematical model [10], support vector machine [11], artificial neural network (ANN) [12][13][14], hidden Markov model (HMM) [15,16], partially collapsed Gibbs sample

Three Existing T-End Detection Algorithms
To keep things self-contained, we summarize three commonly applied T-end detection algorithms here. The algorithms are referred to by the last name of the first author, including Zhang [5], Carlos [6], and Martinez [8]. All these three algorithms require the locations of the QRS complex and T-wave before estimating T-end points. Both Zhang's and Carlos's algorithms are based on the idea that inside the designed searching window related to the detected R peaks, the maximum value of an area function is reached over the T-end point. Martinez's algorithm uses dyadic wavelet transform to find the peaks and limit points of QRS cycles, P waves, and T waves. The T-end points are defined as the local maximum or minimum in the wavelet transform with dilation factor 2 4 or 2 5 . These algorithms have been evaluated on the PhysioNet QT database [28] with low T-end detection errors. The performance of Martinez's algorithm has also been validated on the dataset 3 of the CSE multilead measurement database (CSEDB) [29]. The MATLAB package of Zhang's algorithm can be downloaded at http://www.irisa.fr/sosso/zhang/biomedical/ and Martinez's algorithm can be downloaded at https://github.com/marianux/ecg-kit. We coded Carlos's algorithm according to the original paper's description. For T-wave locations, Zhang's and Martinez's algorithms have their built-in algorithms, so we simply adopted them. The T-wave locations estimated by Martinez were applied in Carlos. The other parameters of each algorithm were tuned in the same settings described in the original papers.

Signal Quality Index (SQI) for T-End Detection
Signal quality index (SQI) has been a critical quantity in the analysis of biomedical time series. It could be considered as an index summarizing the relationship between noise, artifact, and the signal of interest. In the ideal situation, if both the clean signal and the noise are clearly defined, the concept of signal-to-noise ratio (SNR) is a common approach to define SQI. However, usually it is challenging to get the clean signal and the noise or artifact from the given noisy signal, particularly when there is only one channel. Therefore, we need a different approach to determine the SQI.
There have been various ideas in the past decades to define SQI for different biomedical signals [30][31][32][33]. The bSQI proposed by Li et al. [32] is a typical example. They applied two different R peak detection algorithms to the given ECG signal and obtained two sets of estimated R peak locations. If an ECG signal has a high signal quality, the estimated R-peak locations should be the same, or at least similar. This similarity is quantified as the SQI. This idea is simple but brilliant, and it can help us understand the quality of a given ECG signal. However, it only tells us the quality of the given ECG signal in the sense of R peak detection but not from all aspects. Specifically, it may not tell us how good the P wave is, or how clean the T wave is. See Figure 1 for an example. In this example we have a noisy ECG recording. Although R-peak locations estimated by two different R-peak detection algorithms, the Elgendi's [34] and jqrs [30] algorithms, are similar, visually the T waves are not of high quality. Quantitatively, the T-end's estimated by Zhang's and Martinez's algorithms are quite different. In summary, the bSQI only describes the signal quality from the aspect of R peak locations, and it cannot well manifest the signal quality for T-wave, and hence the T-end location.  [34] (jqrs [30]). The intersection of x-axis and red (green) vertical lines are the time stamps of T-end locations estimated by Zhang's algorithm (Martinez's algorithm). The magenta vertical lines are shifted right by 10 milliseconds to avoid the overlap with blue lines. The value of bSQI is 0.99, and the value of tSQI is 0.66, which are calculated by matching points from two different algorithms as the same point if the time difference between them is smaller than 50 ms.
Motivated by this observation, we propose a new SQI for the automatic T-end detection here. Similar to the idea behind the bSQI, we take two sequences of T-end locations detected by two T-end detection algorithms, and then determine the SQI in the following way. For each ECG segment, we assume that the R peak detection algorithm performs well and use the detected R peaks to estimate T-end points by two chosen algorithms. Denote A ∈ N to be the number of detected R peaks and hence estimated T-end points. Given a grace period γ > 0, we consider that two chosen algorithms match if the time difference between the two estimated T-ends is smaller than γ. Assuming we have B ∈ N of T-end points that match, we denote a value tSQI ∈ [0, 1] as which is the desired SQI for the T-end detection. When tSQI = 1, it means that the two sequences of estimated T-end locations are perfectly matched, and hence the T-end quality is high; a lower tSQI stands for less matched estimations, and hence a lower T-end quality. In this work, we chose Zhang's and Martinez's algorithms to determine the tSQI in the following sections.

Proposed Algorithm
We detail the propose automatic T-end annotation algorithm, step by step, here.

Step 0: Preprocessing
Given an ECG recording, we resample it at the sampling rate 250 Hz. To remove the baseline wandering, a Butterworth lowpass filter of order 4 with the cut-off frequency l o f f Hz is applied. Since the source of data is unknown, we apply two notch filters with the notches centered at 50 and 60 Hz to reduce the powerline interference. The recording after the preprocessing is denoted as z ∈ R N , where N ∈ N is the number of samples.

Step 1: Estimate QRS Complex
There have been several works [30,34,35] discussing how to detect the location of QRS complexes. Since the T-end detection is our focus, here we simply use QRS locations estimated by Elgendi's algorithm before applying any T-end detection algorithm. We denote the collected timestamps of estimated R-peak locations as (1) where R(i) is the timestamp of the i-th detected R peak and n ∈ N is the total number of estimated R peaks.

Step 2: Evaluate tSQI
For the i-th cardiac cycle, we evaluate its tSQI on a signal segment [z(R(i) − 1250), . . . , z(R(i) + 1250)] with a grace period γ. Given a threshold number q ∈ [0, 1], if the tSQI ≥ q, the final estimated T-end of each cardiac cycle is determined by applying the desired T-end detection algorithm. Otherwise, the following steps are applied, and the final estimation would be made in Step 4.

Step 3: Denoise Low Quality Cardiac Cycles by Optimal Shrinkage
• Construct ECG templates. On the i-th cardiac cycle determined by the i-th R peak, we find a window large enough, so that the whole P-QRS-T waveform is covered. For instance, denote w ∈ N to be the rounding number of the 95% quantile of R to R intervals in R, and denote the corresponding ECG segment over the cardiac cycle as where L w ∈ N, R w ∈ N, and p := L w + R w + 1. A library for the ECG template is built and denoted as • Remove nuisance variables by optimal shrinkage. Define a metric d(s a , s b ) between the a-th and b-th template. For instance, we can use R-R interval difference in respect to the cycles or l 2 norm ||s a − s b || l2 as the metric. For the i-th cardiac cycle s i , from the library L we selecte ξ ∈ N neighbors that have the smallest difference. We then construct a data matrix S of size p × ( ξ + 1) consisting of the i-th cardiac cycle in the first column and all other neighbors in the remaining ξ columns. We assume that the S can be decomposed into two parts, S = X + N, where X is the clean data matrix containing QRS cycles and N is the matrix modeling noise. We also assume each entry of N has independent and identical noisy component with zero mean and the same variance and finite fourth moment, and X has a low rank. Under these assumptions, there is an elegant solution based on the random matrix theory proposed by Gavish and Donoho [26] to recover X from S, which is named as optimal shrinkage (OS). We apply OS on the data matrix S in the following manner: Suppose p ξ ≤ 1 (if not, we simply take the transpose of S and apply the same approaches on S as the following). Denote the SVD of the data matrix S as where r is the matrix rank, u i and v i are the i-th left and right singular vector corresponding to the singular value λ i , and λ 1 ≥ λ 2 ≥ . . . ≥ λ p . We normalize S with the noise level estimated by and where k = 1, . . . , p. Then, the denoised data matrix is estimated from S by OS and denoted as where is the optimal shrinker. In this work, we let η * be the optimal shrinker that minimize the asymptotic loss with respect to the operator norm, such that when λ ≥ 1 + √ β and η * (λ) = 0 otherwise. The first column of S η * is the estimated QRS complex of s i , denoted as s i . Applying OS on every cardiac cycle in L, we acquire a denoised library and denote it as

Step 4: Evaluate T-End Locations
As mentioned earlier, T-end detection algorithms of Zhang, Carlos, and Martinez are chosen for T offset delineation. Chosen T-end detection algorithm is applied in the library L, and locations of T-end are estimated for each denoised cardiac cycles. Based on the R-peak locations R estimated in Equation (2), estimated T-end locations on the signal z are the final output of the proposed algorithm.

QT Database
The first database we considered is a common benchmark database, the PhysioNet QT database [28]. It includes ECG signals chosen from the MIT-BIH database [36] and the European ST-T database [37]. The database contains 105 subjects. Each subject has fifteen-minutes recordings of 2-channel ECG signals sampled at the 250 Hz, which include a broad variety of QRS and ST morphology. A subset of cardiac cycles in the database have been manually annotated with waveform boundaries, and only a small portion of signals was annotated for T-end. The manual annotations were made by two cardiologists using an interactive graphic display to view both signals simultaneously. The first cardiologist (Cardio 1) made annotations on all 105 subjects, and the second cardiologist (Cardio 2) made annotations on only 11 subjects. Following the same approach in Zhang's work [5], we separated the QT database into three sets for analysis according to which cardiologists made the annotations. The first set (Set 1) contains all 105 subjects, in which we considered the 3542 annotations made by Cardio 1 as the true T-end points. The second set (Set 2) is from the 11 subjects annotated by both Cardio 1 and Cardio 2, in which we considered the 487 T-end points annotated by Cardio 1 as the ground truth. The third set (Set 3) also includes the same 11 subjects as Set 2, but the ground truth is the 402 annotations made by Cardio 2.
To evaluate our proposed algorithm under various noisy environment, we considered two additive noise models, the random Gaussian noise and the ARMA(1,1) noise [38], and contaminated the QT database by these noises. Assume the original signal is z ∈ R N , where N ∈ N is the number of samples. The Gaussian noise was generated by N random points following the Gaussian distribution with mean 0 and variance 1. The ARMA (1,1) noise was generated by the ARMA (1,1) process: where t = 1, . . . , N is the sampling point, X t is the ARMA (1,1) process sampled at point t, Z t is a random variable following Student t-4 distribution sampled at point t, and c, φ and θ are selected constant. We set c = 0.5, φ = 0.5 and θ = −0.5 for following evaluation. The desired ARMA (1,1) noise at point t with variance 1 was then acquired by where SNR is the desired signal to noise ratio and P z is the power of original signal. We then multiplied both Gaussian and ARMA (1,1) noise by S and added them to z to create the noisy signal with desired SNR. We evaluated SNR of 10 dB and 5 dB in the following evaluation.

14-Day ECG Recordings Database
Our database of single-lead, ultra-long-term ECG recordings comprised of four recordings; each recording is approximately two weeks (14 days) in length. The data was recorded using the ZIO ® Patch cardiac monitor (iRhythm Technologies, Inc., San Francisco, CA, USA) at a sampling rate of 200 Hz. The underlying information of the subjects was unknown to us. Across the four 14-day recordings, we randomly selected 51, 11, 24, 80, and 32 segments of 10 s for manual review and annotation at the Epidemiological Cardiology Research Center (EPICARE Center, Wake Forest School of Medicine, Winston Salem, NC, USA). The ECG core laboratory was provided with the automated T annotation generated by our algorithm, and the results were reviewed by the ECG core readers for accuracy and editing. The quality of each ECG segment was also documented as part of the annotation process. In total, 173 segments were labeled good, 16 segments were labeled intermediate, and 9 segments were labeled bad.

Evaluation
We evaluated our proposed T-end annotation algorithm, which is an enhancement of Zhang, Carlos, or Martinez, on the above-mentioned databases. For each ECG recording, we cropped a segment for analysis, which started from 1 min before the first T-end annotations and ended at 1 min after the last T-end annotation. The R-R interval difference between cardiac cycles was applied as the metric d(s a , s b ). Since our focus was automatically annotating T-end, the R peaks were assumed to be known. The T-end detection error is the time difference between the automatically detected T-end points and the provided annotations. In the QT database, since each subject has two recordings, the estimated T-end points were chosen from the best result that minimized the detection error among the two computed T-end positions. This approach is the same as that used by Zhang and Carlos. The justification of this approach is that the cardiologists made their annotations by evaluating both ECG records. For the Ultra-Long-Term ECG recordings database, since there is only one channel for each recording, we simply calculated the estimated T-end locations and provided annotations.
In our previous work, the effects of noise robustness and morphology recovery by optimal shrinkage and other template estimation algorithms had been compared for the purpose of extracting fetal ECG from the trans-abdominal maternal ECG [27] over the Physionet CinC Challenge 2013 database [39]. These methods included independent component analysis (ICA), principal component analysis (PCA), least mean square (LMS), recursive least square (RLS), echo state neural network (ESN), and extended Kalman filter (EKF). To further demonstrate the strength of optimal shrinkage, in this work we compared with another ECG denoising method named wavelet shrinkage [40,41]. The idea is similar to the optimal shrinkage, where the empirical wavelet coefficients are shrunk, and the signals are recovered by the inverse wavelet transform. The main difference is that in OS, the basis is adaptive to the data, while in the wavelet shrinkage, the basis is predetermined. We compared these two algorithms on the QT database with the additive Gaussian or ARMA (1,1) noise. The wavelet shrinkage is applied after Step 0: preprocessing, where wavelet shrinkage is applied on the denoised signal z ∈ R N following the setup detailed [42]. Then, Step 1 and Step 4 are applied for R peaks and T offset delineation.
To evaluate the performance of each algorithm, the mean (ME) for the absolute values of detection errors of each recording were calculated. Then, the median and MAD and 2.5-97.5% quantile interval of ME over all recordings were computed and reported. To evaluate if the proposed OS approach improved the existing algorithm, we applied the Wilcoxon signed rank test with the statistical significance level set to 0.05.

Results
The parameters of proposed algorithm were set as follows. We set the grace period γ = 50 ms for the tSQI evaluation. Moreover, we set the cutoff frequency for low pass filter as l o f f = 0.5 Hz, window length L w = R w = 1 2 , where x is the smallest integer larger than x, and number of neighbors ξ = 19. The evaluation was performed on MATLAB 2019b, Microsoft 10 system, Intel i7-6700HQ CPU@2.60GHz 4 cores, and 16GB RAM. The code can be downloaded at: https: //github.com/MagineZ/Tend-Project.

tSQI and Quality in the 14-Day ECG Database
The comparison of the signal quality provided in the 14-day ECG database and the proposed tSQI in the ultra-long ECG recording database is reported in Table 1. We observe that the ECG signals labeled as good (or bad) quality have higher (or lower) tSQI's. If we view label good as 1, label intermediate as 3, and label bad as 5, the correlation coefficient between the tSQI and labeled quality is −0.71.

Noise Suppression
We examined if the proposed OS denoising could help stabilize existing T-end detection algorithms under various noise types and noise levels. The results for different SNR levels are reported in Table 2 for the Gaussian noise and ARMA (1,1) noise respectively. It is clear that the proposed OS algorithm helps improve the traditional algorithms and outperforms wavelet shrinkage. Wilcoxon signed rank test over the 20 rounds' rejects the null hypothesis with statistical significance. To appreciate how the OS recovers the ECG signal, some examples are shown in Figures 2 and 3. We see that the deviations of estimated T-end from the annotation is obvious on the signals without OS applied, and the OS helps recover the ECG morphology and thus reduces the automatic annotation errors. This suggests the potential of the proposed denoise algorithm to help stabilize existing algorithms.  Comparison of different T-end detection algorithms with or without optimal shrinkage when the signal is contaminated by the additive ARMA (1,1) noise. In each subplot, the black line is the ECG signal from the first channel of a subject in the QT database with additive noise, the light blue line is the denoised ECG signal by the optimal shrinkage, and the magenta line is the original ECG signal without adding any noise. The red (green) vertical lines indicate the estimated T-end by the chosen detection algorithm on noisy signals without (with) OS applied. The deep blue vertical line indicates the annotated T-end by Cardio 1. The plots in the first (second) row are the results when the SNR is 10 dB (5 dB). The chosen T-end algorithm in the first, second and third column is Zhang's, Carlos's, and Martinez's algorithms respectively. The case index of each plot is in the title.

Evaluation in the QT and 14-Day ECG Databases
We applied the proposed tSQI and OS denoising to the QT and 14-day ECG recording databases. We considered tSQI thresholds q = 0.9 when applying the proposed algorithm; that is, the OS was applied to those cardiac cycles with the tSQI less than 0.9. Note that q = 0 means we do not apply the OS. The results are shown in Tables 3 and 4. First, note that in Zhang's and Carlos's algorithms, the ME and SD were defined without taking the absolute value. The error is thus underestimated since the detection error of the estimated T-end has positive or negative values. Therefore, smaller MEs were reported by Zhang and Carlos in comparison with our results when q = 0, even if we applied their announced codes on the same database. We see that, overall, the MAD and 97.5% quantile are improved, while there is no statistical significance. To have a better feeling about how the algorithm performs, the scatterplots of T-end detection errors of the QT database are shown in Figure 4.  Note: Column one indicates which set is analyzed. Column 2 is the number of heart beats. Column 3, 4, and 5 are the results of T-wave end detection error using algorithms of Zhang, Carlos, and Martinez respectively. The median ± mean absolute deviation (MAD) of detection errors are evaluated. The unit is millisecond. Note that since the sampling rate is 200 Hz, the median error is the multiple of 5 ms.

Discussion
In this report, we showed that the labeled quality in the 14-day ECG database provided by the ECG core lab is well captured by the proposed tSQI. We also showed how the noise deteriorates the signal quality and thus induces high detection errors in both databases when the commonly applied T-end detection algorithms are applied. The proposed OS denoise was able to recover the ECG morphology when the signal was contaminated by noise, and hence stabilized the T-end detection algorithm. In the arrhythmic cases, the T-wave morphologies could be visually better recovered by selecting proper metric between cardiac cycles.
The spike model underlying the proposed algorithm deserves discussion. As shown in Figure 5, there is T-wave distortion after the OS, and hence the T-end location shifts. In other words, when the ECG signal is clean, a morphology distortion after the OS is applied. This observation suggests that the cardiac cycles cannot be fully captured by the spike model used in Gavish's and Donoho's work [26] for the OS, and hence the morphology is distorted when the noise is dominated by the beat to beat variation. Recall that the PQRST morphology is not fixed from cycle to cycle, and the variation is caused by various physiological dynamics such as the respiratory and heart rate [2]. See Figure 6 for an example, where 20 cycles of clean PQRST waves from the same subject were superimposed. It is also clear that the PQRST variation from cycle to cycle is small compared with the dominant PQRST pattern. Therefore, the data matrix for a set of clean cardiac cycles can be modeled by E = p i=1 µ i e i a i ∈ R p×n , where µ 1 µ 2 ≥ µ 3 ≥ · · · , e 1 ∈ R p is the dominant PQRST pattern, a 1 ∈ R n describes the magnitude the dominant PQRST pattern of each cycle, e 2 . . . e p ∈ R p describe the variation of the PQRST pattern, and a 2 . . . a p ∈ R n describe the magnitude of each variation of the PQRST pattern. Clearly, E can be well approximated by a spike model E = µ 1 e 1 a 1 ∈ R p×n . While this seems to be a nice approximation, it does generate trouble when we apply the OS. Specifically, when the signal is clean, Equation (5) for noise level estimation will consider the physiological variation p i=2 µ i e i a i between each PQRST cycle as a source of noise. Thus, the noise level of the clean signal is overestimated. As a result, the OS might eliminate p i=2 µ i e i a i in order to recover the "clean matrix" µ 1 e 1 a 1 , which leads to a distortion of morphology. The critical observation is that the variation of T wave morphology from cycle to cycle is quantified by the variation term p i=2 µ i e i a i . However, due to the nonlinear relationship among T waves from cycle to cycle, it is not clear how to directly use the T wave information in p i=2 µ i e i a i . When the signal is heavily contaminated by noise, E = p i=1 µ i e i a i + ξ, where ξ is the noise matrix, the small variation term µ 2 e 2 a 2 , . . . , µ p e p a p will be dominated by the noise, particularly those with small singular values. Hence, there is benefit from applying the OS because it will balance between recovering the morphology and reducing the noise. This explains why we only apply OS to those cycles with low tSQI. We mention that in general, the dynamics of T wave morphology can be modeled by a low dimension manifold, which is referred to by the wave-shape manifold [43]. An exploration of this model to further improve the denoising performance, or even noise estimation shown in Equation (5), is out of the scope of this paper.  In the QT and ultra-long-term ECG recordings databases, while there was improvement of the T-end algorithm after applying OS with a properly chosen tSQI threshold, this improvement did not reach statistical significance. See Table 3. There are two possible explanations. First, the motion or other artifacts are inevitable. Usually, artifacts have structures that are unknown to us, unless we have other ECG channels to confirm. Due to these artifacts, visual manual annotation of T-end might be challenging. Consider the following scenario. Suppose the visual manual annotation of T-end was deviated by the existence of noise or artifacts. On the other hand, the denoising tool recovered the T wave, and hence the automatic T-end annotation algorithm provided the correct T-end annotation. In this case, the "correctly detected T-end" will be viewed as a bad annotation compared with visual manual annotation of T wave. To visualize this effect, we show some results in Figure 7. When the signal quality is labeled as average in the ultra-long-term ECG recording database, it is challenging even for experts to annotate the T-end due to noise and artifacts. Second, the OS performance might be masked by the experts' annotation process. This can be observed clearly in the ultra-long-term ECG recording database. Due to the labor-intensive annotation process, the data analysis team provided the automatic annotated labels by applying Zhang's algorithm, and the experts only provided a corrected T-end when they disagreed with the automatic label. This "semi-automatic" process might bias the experts' T-end annotation. We can see this potential bias in Table 4. Before applying the OS, the Zhang's algorithm outperforms other algorithms with or without OS. Therefore, we may conclude that it is possible that the non-statistical significance comes partially from the label uncertainty issue. Combining these facts and its performance when marked noise of different kinds exists, we may argue that the proposed stabilization algorithm by combining tSQI and OS is potential for automatic T-end annotation purpose in practice. We may also discuss a relevant but different topic. The labeling procedure for the ultra-long-term ECG recording database in this study can be viewed as an artificial intelligence aided approach to speed up the standard annotation procedure. By and large, the common labeling procedure is composed of two steps. First, one group of experts provide an initial manual annotation of ECG waveform. Then, another group of experts doubly confirm the provided annotation and edit extreme values as a quality control. In this study, we replace the first step by the existing best automatic annotation system and control the overall quality by a human expert intervention. How to improve this semi-automatic labeling procedure to avoid the above-mentioned issues is of its own interest, and it will be explored in our future work.
Another topic deserves a discussion is arrhythmic ECGs. It is well-known that occasional arrhythmias, like premature ventricular contraction (PVC), can cause sudden T wave changes in normal rhythms. Although we cannot find a publicly available arrhythmia database with T-end annotation, we provide some preliminary visual evaluation of the OS algorithm on the ECG signals with arrhythmia. We consider the Physionet MITDB [44] that contains 48 half hour excerpts of two-channel ambulatory ECG recordings. Each recording has 2 channels with the sampling frequency 360 Hz and the 11-bit resolution over a 10-mV range. The R peak annotations are provided. To see the performance of our proposed algorithm on arrhythmic ECGs, we applied OS on MITDB with Zhang's method for T-end annotation. Both the R-R interval difference and the l 2 -norm of difference between cardiac cycles were applied as the metric d(s a , s b ). See Figure 8 for a typical result. We see that the distortion of T-wave morphology is obvious when the RRI metric is applied. The distortion is less when the l 2 norm is used as the metric to compare two cardiac cycles. For example, for the cycles around 1719.2 s and 1723 s, the T wave is distorted when the RRI metric is applied, and these distortions disappear when the l 2 norm is considered and the ECG signal is better recovered. While we do not have experts' label for T end, visually when the l 2 norm is applied, the detected T ends are closer to those detected from the original ECG signal, while the detected T-ends might not be correct. This preliminary result is encouraging, but an extensive study is needed to evaluate its performance. While developing a more accurate T-end detection algorithm is not the focus of this paper, we mention that developing such an algorithm that is suitable for arrhythmic ECG is another critical topic for exploration. Figure 8. A preliminary comparison of ECG morphologies with different metrics for arrhythmic ECG. For each subplot, the blue line is the ECG contaminated by ARMA (1,1) noise, the orange line is the ECG after OS with RRI as the metric, the yellow line is the ECG after OS with l 2 norm as the metric, the purple line is the original ECG, green vertical lines are the locations of R peaks in each PVC occurrence, and the magenta spots are the corresponding estimations of T-end locations by Zhang's algorithm. The signal is from the first channel of case 106 in MITDB. From top to bottom subplot, the noise level is 20 dB, 10 dB, and 5 dB respectively.
There are several limitations in this study. First, the labeled database is small. Because manual T-end labeling for ultra-long ECG recording to validate the algorithm is a labor intense process, even with the help of the initial labels, the sample size was small. Second, we need to develop a new denoising algorithm that can handle structured artifacts. The main challenge is how to model artifacts when there is no extra information. A basis pursuit approach might be suitable, and we will report our theoretical research result in our future work. Third, in this article we focus on the tSQI and ECG denoising. To further improve the T-end annotation accuracy, we may need to further improve existing T-end annotation algorithms, probably by incorporating some machine learning algorithms.
In conclusion, our proposed T-end annotation algorithm has the efficiency and accuracy that make it a good fit for clinical applications and large ECG databases.