An enhanced threshold free-method for T-Wave detection in noisy environment

The electrocardiogram (ECG) signals provide information on the heart rate where it provides evidence to support the diagnoses of cardiac diseases and arrhythmias. Currently ,T-wave has been used to forecast Sudden Cardiac Death (SCD). T-wave recognition is an excellent indicator in the analysis and interpretation of cardiac arrhythmia. Based on this aspect, it is necessary to develop an accurate technique for the detection of these waves. The main aim of this current study is to develop a new threshold-free method for the detection of T wave peak in an (ECG), which was characterized by a threshold free detection of T peak with a special moving window for T wave (and can be used for P wave) between each two RR peaks. A Band pass filter and a notch filter are used to enhance the detection of these required peaks. This algorithm is implemented using MATLAB tools. The database used in this work is downloaded from MIT-BIH Arrhythmia(Lead II). The method is validated using 40 recorded data. The obtained average sensitivity and average positive predictivity of the detection method are 98.4% and 99.0% respectively.


Introduction
Heart failure is an important risk factor for Sudden Cardiac Death (SCD). Around 50% of all cardiac deaths in the world are due to SCD. The electrocardiogram (ECG) signals provide information on the heart rate where it supplies evidence to support the diagnoses of cardiac diseases and arrhythmias [1]. The ECG signal, among all vital signals, has attracted more attention due to its importance in diagnosing cardiac health conditions. The normal heartbeat (or cardiac cycle) consists of 5 waves : a P wave, a Q wave R wave S wave and a T wave.The ECG is composed of a series of deflections, the P wave, QRS complex, and T wave are separated by isoelectric segments as PR interval and ST segment. Atrial depolarization is represented by P wave, ventricular repolarization by QRS complex and ventricular muscle repolarisation produces the T wave. The normal T wave is asymmetrical; the first half having a more gradual slope than the second half.
The focus of this study is the T-wave which is one of the main and labile waveforms in an ECG. The T-wave morphology and duration may change from beat to beat in cardiac and non-cardiac problems and is used to assess risk of life-threatening ventricular arrhythmias.
The simplest and most easily recognizable change is an amplitude change of this T wave seen in some pathological conditions [2]. The repolarization, as electrical event (T wave) of the left ventricular, has been studied from theoretical and practical points of view [3]. Several T wave peak detection algorithms have been described in literature [4,5]. Over the last few years, the P and T wave detection problem has been addressed using different approaches [8,10]. In most of these methods, P and T waves are detected relative to the position of QRS complex by applying appropriate threshold. The main problems of the threshold techniques are their high noise sensitivity. The algorithm proposed by Sun et al. [9], based on MMD transform, is suggested to perform better as compared to the algorithm based on wavelet transform and adaptive threshold technique, but still gives false detection in biphasic waves. Hence, distinguishing the morphology of T waves in noisy ECG signals is still considered highly difficult. It is of paramount importance and a necessity to address and develop an accurate detection of these waves.In this study, a detection algorithm is developed with R peak and T peak, on a threshold-free basis,is proposed based on normal maximum and minimum heart rate, using updated RR moving interval to detect the R peaks firstly[7] and then followed by another small moving interval to detect the T peak. This algorithm is able to detect the R and T peaks at different levels of threshold, without respecting threshold value which is the principal objective in this study.

Data:
The MIT-BIH arrhythmia database is a medical device development mostly used for medical and research purpose of different heart arrhythmia detections and analyses. This database reads the signal diversity where automated cardiac diagnosis can be done and contains the recorded ECG signal for future medical use. This study utilized MIT-BIH Arrhythmia. The records were of 15 min duration each, and these ECG signals were resampled to 256 Hz and were saved in a personal computer.
In this work ,the algorithm threshold free detection was developed to detect R as well as T peaks in the ECG signal, and was applied to Lead II signal from each record used in this work. The different steps of the proposed methodology is shown in Figure 1, and in the following section: A. Pre-processing: This methodology stage is divided into three main steps as given below: Each observation signal is made zero mean by subtracting its mean as follows: The removal of the baseline wander which is caused by the patient's breathing or movements during recording within the range of 1 Hz, associated with the removal of relatively high frequency noise caused by artifacts of muscular contractions, is done by passing the recorded signals through a FIR band-pass filter with cut-off frequencies at 5 Hz and 35 Hz, and a 1 Hz second order notch filter.
An example of the preprocessing stage is shown in this sample record which is input to the preprocessing steps with the output of this stage shown in Figure 1. This step consists of two main processes, R-R peak detection and T peak detection.

B1. R peak Detection:
A threshold free algorithm that is based on a moving window technique is applied for R peak detection. In the first place R peaks are detected.
To achieve this purpose, firstly a moving window Mi(i+10 : i+235) as shown in Figure 2 is used to detect the first R peak MP(i), whereby the average of RR interval is estimated. Then, from the start, the observations are processed to detect all the R peaks and their respective locations [7]. If the average RR for the next peak coincides with the next R peak, it will be counted as real peak; otherwise it will be skipped to the next one.
According to the heart rate and the sampling frequency, the RR interval can be calculated as follows: RR ≅ 1/ HR*256*60 (2) RR(max) ≅ 235samples 2*RR(max) ≅ 470samples RR(min) ≅ 150samples 2*RR(min) ≅ 300samples From Mi(i+10) , the RR interval will range from 150 -235 samples, which means that one peak will be detected in this range by moving the window, as shown in (2.a), the moving window will skip for detecting next R peak, as shown in (2.b upper side) , and double RR interval become 300 -470 samples out of the moving window. The principal of detection can be shownin (2.b , upper side is R peak and lower side is T peak).

QRS Complex removal:
R peak detection is very important to remove or scale down the QRS complex in order to make the T wave as the main aspect of the processed signal. The R peak locations will be used to search for the T peaks between each R peak and next R peak that is the RR interval, as illustrated in the next sub-section.

B2. T Peak Detection:
Around more than 75 signals were used to detect and investigate the location of T wave peak. It was observed that the T wave peak is normally located in the first half of RR interval. In addition, the moving window technique is used to detect T wave peaks and their locations.
These R peaks will be the edges of the moving window by taking the first location as first edge, then we search for the T peak between the 1st R peak and the second edge which is equal to 0.5 of RR interval, as illustrated in figure 3. A threshold free algorithm with a moving window (i+5: i+0.5* RR) is applied. Any peak reading within this range may be considered as T wave. If there is more than one candidate within the specified range, the peaks with highest amplitude are selected. Any peaks outside this range are considered as P waves or noise.

Result and Discussion :
The accuracy of the algorithm was tested by applying it to 40 recorded signals. Each of them is about 15 minutes long. The algorithm was implemented using MATLAB 2007b software package. The MIT-BIH database contains records of normal ECG signals as well as records of ECG signals with premature atrial beats, premature ventricular beats, inverted T waves, T waves of low amplitude and ventricular ectopic beats. A number of records have a low signal to noise ratio.
The algorithm was implemented for testing purposes, and a capture of the results obtained is illustrated in Figure 4. It can be observed from these results that the algorithm is able to detect the peaks in upward deflection and also downward deflection (inverted peaks) revealing how effective the algorithm traces and detects the Rpeaks and Tpeaks, as well as the inverted T-waves peaks.

Figure 4: Illustration of detected R-peaks and T-peaks in ECG signals
Further illustrations, for the recorded cases with less fluctuation, the results are obtained and shown clearly in Figure 5, revealing that the proposed algorithm is able to detect all the R -peaks and Tpeaks.   The sensitivity is the fraction of real events that are correctly detected and is defined by The Positive Predictively is the fraction of detections that are real events and it is defined by: (4) Table 1 gives the performance of the proposed algorithm on the 40 records of the MIT-BIH Arrhythmia database that was considered. The average Sensitivity (Se) of the algorithm is 98.4% and its Positive Predictivity (+P) is 99.0 % . It shows that the proposed algorithm was probably more successful in detecting the T peak.
A higher proportion of the (FN) and (FP) T peaks were found in the following records: 122, 208, 209, 210, 212, 214, and 114. It was documented that a lot of noise records, with an extremely low signal to noise ratio, was observed , especially in 122 and 208, which lead to some practical difficulties in detecting some R and T peaks.During the last sample of the signal, undetected peaks were not documented because there were no sufficient samples to create the second edge of the moving interval. In addition, it was quite difficult to detect some first R and T peaks that were skipped due to the requirement for TT interval average, as shown in Figures 5 and 6 respectively This algorithm able to detect T and R peaks of 40 recorded signals from the totally 48 signals of the MIT-BIH Arrhythmia database. Compared with [5], which detect around 33 signals, the proposed algorithm proves that it is able to detect even some noisy signals such as 109,111,112,113,118 and 119, but the remaining 8 signals of the MIT-BIH Arrhythmia database were very noisy.

Conclusion
A threshold-free algorithm for the detection of T wave peaks as well as R wave peaks and QRS complexes in an electrocardiogram (ECG) has been developed. The presented algorithm in this study was used to detect these T peaks more accurately and rapidly with heart rate calculation by RR-interval in ECG. It is characterized by a threshold free moving window technique. The algorithm was evaluated using the MIT-BIH Arrhythmia. Lead II produces a performance of