Frequency response of equivalent filters at five scales for 500 Hz sampling rate.
Chronic kidney disease (CKD) is considered a risk factor for the development of cardiovascular disease. QT interval is an electrocardiographic parameter that quantifies the duration of ventricular repolarization. An increase of its spatial variability measured from the selected leads of a standard electrocardiogram (ECG), named QT dispersion (QTd), is considered a risk factor for malign ventricular arrhythmias and sudden death in the CKD. An algorithm for automatic measurement of QTd in the ECG leads DI, aVF and V2 using the continuous wavelet transform with splines is presented. Validation of QRS complex detection has been done on records from MIT-BIH database, and the accuracy is 99.5%. Validation of detection of QRS wave onset and T wave end has been done on records from CSE and QT databases, and the measurements were within the tolerance limits for deviations with respect to the manual measurements defined by the experts. The algorithm was applied in two studies. In the first study, QTd was evaluated in normal subjects and patients with CKD. In the second study, QTd was analyzed in patients with CKD before, during and after the hemodialysis treatment. In both studies, the algorithm had a good performance for the QTd analysis.
- wavelet transform
- QT dispersion
- cardiovascular disease
- chronic kidney disease
According to the World Health Organization (WHO), cardiovascular diseases (CVDs) are the number one cause of death globally, and an estimated 17.7 million people died from CVDs in 2015, representing 31% of all global deaths, of these deaths, an estimated 7.4 million were due to coronary heart disease (CHD) . CHD is a narrowing or blockage of the blood vessels that supply blood and oxygen to the heart, then, the cells in the region served by the vessel will behave abnormally due to hypoxia (myocardial ischemia) or may die (myocardial infarction) . In Mexico, data of the National Institute of Statistics and Geography (INEGI) showed that in 2015, the heart diseases are the main cause of death, and the most frequent is the ischemic heart disease (IHD) .
The kidneys are a pair of bean-shaped organs that lie on either side of the spine in the lower middle of the back. Its main function is to remove soluble waste products and excess water and electrolytes from the bloodstream. Chronic kidney disease (CKD) is defined as abnormalities of kidney structure or function, present for 3 months or more, with implications for health . Abnormalities in kidney structure (damage) usually precede abnormalities in function. CKD is divided into five stages of increasing severity. Stage 5 referred to as kidney failure or end-stage renal disease (ESRD) is traditionally considered as the most serious outcome of CKD because there is total or near-total loss of kidney function and patients require treatment with dialysis or transplantation.
CKD is considered a risk factor for the development of cardiovascular disease (CVD) because patients with CKD are more likely to die of CVD than to develop kidney failure [4, 5]. Primary types of CVDs with a high prevalence in CKD are arterial vascular disease in its two subtypes: atherosclerosis and arteriosclerosis, and cardiomyopathy. Clinical presentations of atherosclerosis include IHD, manifested as angina, myocardial infarction and sudden cardiac death, which is common in CKD, cerebrovascular disease, peripheral vascular disease and heart failure . Patients with ESRD requiring maintenance hemodialysis (HD) have a high mortality rate, which is primarily attributable to CVD, including ventricular arrhythmias and sudden death, and the incidence of arrhythmias increases during and immediately after HD [6, 7].
Therefore, the use and development of noninvasive techniques such as electrocardiography, which records the electrical activity generated by the muscles of the heart in the surface of the body, open a useful perspective for diagnosis and treatment in patients with heart diseases such as ischemia and infarction. The electrocardiogram (ECG) is the waveform produced by this electrical activity of the heart and its generation depends on four electrophysiological processes such as the formation of electrical impulse in the main heart pacemaker (sinoatrial node), the transmission of this impulse through specialized fibers in the conduction, the activation (depolarization) and the recovery (repolarization) of the myocardium .
The electrical activity generated by the heart can be modeled as a vector whose magnitude and direction change throughout the cardiac cycle. To record the different projections of this vector, several electrodes are attached to the body in different locations known as leads. Because each lead measures the ECG between two points from different directions, amplitudes, polarities, times and durations of the ECG components vary between leads, so these have been standardized. The lead system most accepted in clinical practice is the standard 12-lead system, that is, the combination of the bipolar limb leads I, II and III, the augmented unipolar limb leads aVR, aVL and aVF and the six unipolar precordial leads V1–V6. Limb leads (I, II, III) derive signals from the left arm (LA), the right arm (RA) and the left leg (LL). The right leg (RL) electrode is the common reference in the amplifier .
In Figure 1, waves and intervals of interest of the ECG are shown. The P, QRS and T waves reflect the rhythmic electrical depolarization and repolarization of the myocardium associated with the contractions of the atria and ventricles. The P wave represents depolarization of the atrial musculature. The QRS complex is the combined result of the repolarization of the atria and the depolarization of the ventricles, which occur almost simultaneously. The T wave represents repolarization of the ventricles.
Time intervals like RR and QT are important in electrocardiographic diagnosis because they reflect electrophysiological processes of heart and autonomic nervous system (ANS) and carry clinical implications when they lie outside the range of the normal variation. The RR interval measured from the R wave peak to the peak of the next consecutive R wave is the interval between consecutive heart beats, and it determines the heart rate (HR). The QT interval measured from the Q wave onset to the T wave end reflects the total period of ventricular depolarization and repolarization, and it is used in clinical electrocardiology to quantify the duration of ventricular repolarization .
Prolongation of the QT interval is recognized as an indicator of an increased risk of malignant ventricular arrhythmias and/or sudden cardiac death in various clinical conditions such as myocardial infarction or ischemia, electrolyte or metabolic imbalance or the action of various drugs [9, 10]. Also, QT interval has an interlead space variability, which led to the hypothesis that the differences between electrocardiographic leads might reflect regional differences in repolarization. Based on experimental and clinical electrophysiological studies which supported the evidence that increased heterogeneity of repolarization may be responsible for generation of malignant ventricular arrhythmias, the interlead variation of QT interval duration was proposed as an index of arrhythmia susceptibility . This measure was termed QT dispersion (QTd), and it was defined as the difference between the maximum and minimum QT interval on the standard 12-lead ECG .
Increased QTd has been associated with an increased risk for ventricular arrhythmias and sudden death in the general population and in various clinical conditions, among them, CKD is common. Several studies have reported that QTd increased in patients with ESRD, particularly after the end of HD [6, 12], so that it may be useful to identify patients at high risk for overall and cardiovascular mortality . However, this index is affected by: an inaccurate measurement of the QT interval because of different definitions for the T wave end (with and without fusion with U or P waves), influence of HR, no simultaneous ECG leads recordings and number of ECG leads and of the ECG lead system used .
As beat-by-beat manual measurement of QTd on three orthogonal ECG leads is impractical in routine clinical practice, the development of accurate and robust methods for automatic detection of characteristic points of QRS and T waves is important in electrocardiographic diagnosis, in particular for the analysis of long recordings . Wavelet transform is a suitable tool that has been used to determine peaks and limits of ECG waves because of its ability to detect transients and of its robustness in front of noise and artifacts [16, 17, 18]. This chapter presents the development of an algorithm based on the continuous wavelet transform (CWT) with splines for the automatic measurement of QTd in the quasi-orthogonal leads DI, aVF and V2, and its application for the analysis of QTd in patients with CKD.
2. Wavelet transform
Wavelet transforms at different scales describe the time characteristics of a signal in different frequency bands, but the analysis is restricted to scales that are powers of two . The use of B-splines as base functions permits the evaluation of the CWT in any integer scale , which enables to use a wider range of scales and to reduce noise and artifacts more efficiently. This feature can allow the direct application of the algorithm over the raw ECG signal without any preprocessing stage because frequency filtering is performed when the CWT is computed.
The CWT of a time-continuous signal is defined as:
where is the complex conjugate of the analyzing wavelet function , and and are the scale and translation parameters, respectively. The function compresses or dilates depending on , which enables the CWT to extract the low- and high-frequency components of . To implement the CWT, and are usually discretized. If is discretized over a sequence the analysis is restricted to scales that are powers of two, and the result is the dyadic wavelet transform that can be computed with Mallat’s algorithm .
In this chapter, B-splines have been used which allow the evaluation of the CWT in any integer scale . In this formulation, the input signal and the analyzing wavelet are both polynomial splines of degree and , respectively. The splines considered are constructed from polynomial segments of degree of unit length that are smoothly connected together at joining points called knots in such a way that guarantees the continuity of the function and its derivatives up to order (n−1) 
Assuming that the input signal is characterized in terms of its B-spline expansion of degree and the sequence of B-spline coefficients
Likewise, the wavelet is a spline of degree with its B-spline expansion
B-splines satisfy a two-scale equation for any integer , where is not restricted to a power of two; thus, the wavelet expanded by a factor can be expressed as:
where the sequence , when and are not both even, is given by z transform,
Therefore, the resulting CWT at scale evaluated at integer time samples is a polynomial spline function given by:
where the notation represents the upsampling of the sequence by a factor of , the filter is equivalent to a cascade of filters of moving average of order with an offset that ensures its symmetry, is the B-spline representation of a spline of order and are the B-spline coefficients.
The program developed by Arregui (written in MATLAB®, The MathWorks Inc.)  calculates the CWT of the discrete signal at the integer scale of the cubic spline wavelet (with expansion coefficients spline , where is considered a spline of order . Implementation of the program is based on the fast algorithm proposed by Unser et al. , which is done in the following three steps:
Initialization: calculus of the B-spline coefficients that interpolate the signal and the convolution with the B-spline of order .
Iterated moving sum: calculus of the scalar products of the signal with the B-splines of order dilated by a factor and divided by the root of .
Zero-padded filter: filtering with the expansion coefficients, spline of the basis wavelet upsampling (with zeros) by a factor of to obtain wavelet coefficients.
The selected wavelet function is the first derivative of a fourth-order cubic B-spline expanded by two, which leads to the sequence given in Table 1 of . This wavelet is similar to the first derivative of a Gaussian function so that it yields good time and frequency resolution (Figure 2).
|Scale (e)||– 3 dB bandwidth (Hz)|
In Table 2, the −3 dB bandwidths of the Fourier transform of the wavelet at four scales for the sampling rates of 250–1000 Hz are listed, which correspond to three ECG databases used in this study. MIT-BIH Arrhythmia database (MITDB) , QT database (QTDB)  and CSE multilead measurement database (CSEDB)  used for the validation of the algorithm have sampling rates of 360, 250 and 500 Hz, respectively. The PTB Diagnostic ECG Database (PTBDB) [26, 27] and the E-HOL-12-0051-016 database of the Telemetric and Holter ECG Warehouse of the University of Rochester (THEWDB)  used for the application have a sampling rate of 1000 Hz.
|250 Hz||1000 Hz|
|Scale||−3 dB bandwidth (Hz)||Scale||−3 dB bandwidth (Hz)|
Figure 4 shows the relation between the characteristic points of ECG and its CWT at four scales. Because of the form of the wavelet function selected, each distinct wave of the ECG corresponds to a pair of local maxima of the modulus (Pmm) of the CTW at each different scale with a zero crossing between them that corresponds to its peak. The rising slope of each wave yields a minimum and the falling slope yields a maximum . According to the spectrum of the ECG waves , most of the energy of the ECG signal lies within the scales 2–10 (Figure 3). P and T waves have their major component at scales 8 and 10, but higher scales can be affected by baseline wandering. If the ECG is contaminated with high-frequency noise, scales 2 and 3 are the most affected.
3. Description of the algorithm
The algorithm for automatic measurement of QTd in the quasi-orthogonal leads DI, aVF and V2 is based on the multilead generalization of a previous algorithm for single-lead detection of characteristic points of the QRS complex and T wave using the CWT with splines . This new algorithm for multilead detection includes the identification of more types of morphologies of QRS complex and T waves , which are integrated with the previous algorithm for single-lead detection. Figure 5 shows the algorithm proposed which is organized in four modules. In the first module, different kinds of QRS complexes and T-waves are detected and identified. In the second module, the algorithm detects the Q wave onset, R wave peak and T wave end, which is based on an algorithm for single-lead detection previously mentioned . Next, the algorithm measures the QT and RR intervals from detections of significant points in each quasi-orthogonal lead. Finally, the algorithm calculates QTd as the difference in duration between the longest and shortest QT intervals measured on the three quasi-orthogonal leads and HR.
3.1. Detection of different kinds of QRS complex and T wave
As a first step in this stage, polarity of QRS complex and T wave is identified. QRS complex corresponds to a Pmm of the CTW and the scale used is w2, where it has its major component. Then, the highest positive peak (Wpq) and its nearest negative peak backwards (Wnq) are searched within the first 2 s of the record in order to define the position of these peaks. If Wnq position is before the Wpq position, then the type complex is qRs, which is defined as positive QRS. If Wnq position is after the Wpq position, then the type complex is rS, which is defined as negative QRS (Figure 6). Flowchart of polarity detection of the QRS complex is shown in Figure 2 of .
To determine the type of QRS complex once its polarity is defined, two algorithms are applied depending if QRS complex is positive or negative. The algorithm to determine the type of QRS complex with positive polarity when R is higher, it defines if Q or S wave is present as follows. From the onset of the Pmm corresponding to the R wave at scale w2, Q wave is present if the nearest positive peak backwards is larger than a defined positive threshold. From the end of this Pmm, S wave is present if the nearest negative peak forward is lower than a defined negative threshold. These peaks are detected by looking inside a search window defined by the maximal duration of both waves. This algorithm detects and identifies the morphologies qR, qRs, R and Rs (Figure 7). Flowchart of the QRS complex type detection when R is higher is shown in Figure 5 of .
The algorithm to determine the QRS complex with negative polarity when S is higher, it defines if Q or R wave is present as follows. From the onset of the Pmm corresponding to the S wave at scale w2, R wave is present if the nearest negative peak backwards is lower than a defined negative threshold. From this point, Q wave is present if the nearest positive peak backwards is larger than a defined positive threshold. These peaks are detected by looking inside a search window defined by the maximal duration of both waves. This algorithm detects and identifies the morphologies qrS, rS and QS. Figure 8 shows rS complex type and its CWT at scale w2. Flowchart of the QRS complex type detection when S is higher is shown in Figure 6 of .
Identification of polarity and type of T wave is performed with two algorithms. The first one classifies T wave into only two types: positive and negative (although it is biphasic, ascending or descending) as follows. As T wave corresponds to a Pmm of the CWT and only in this procedure, the scale used is w4 to enhance its characteristics. The highest positive peak (Wpt) and its nearest negative peak backwards (Wnt) larger than a defined threshold are searched from the end of the Pmm corresponding to R or S wave in a window whose limits depend on HR . If Wnt position is before the Wpt position, then the T wave is positive or normal (Figure 9a). If Wnt position is after the Wpt position, then the T wave is inverted or negative. Flowchart of polarity detection of the T wave is shown in Figure 3 of .
The second algorithm to determine the type of T wave is applied after, once the R or S wave position is defined by the algorithm for single detection of characteristic points described later , and before the T wave detection. To identify T waves, the same procedure used for detecting of Wpt and Wnt of Pmm of T wave described earlier is used. According to the comparison of the absolute values of these peaks with defined thresholds and its position, the algorithm classifies five types of T waves: positive, negative, ascending, descending and biphasic (Figure 9b). Flowchart of the T wave type detection is shown in Figure 4 of .
3.2. Detection of characteristic points of QRS complex and T wave
3.2.1. QRS detection
QRS complex is the most characteristic waveform in the ECG due to its shape with high amplitude, which makes its detection easier than other ECG waves. Its accurate detection in the presence of noise and interferences is the most important task in the ECG automatic analysis because it is used as a reference in the cardiac cycle to perform a more detailed analysis of other ECG waves, segments and intervals, as automated measurement of HR and QT interval.
According to the wavelet function selected, QRS complex corresponds to a Pmm of the CWT at selected scale, where the R wave peak (Rp) corresponds to the zero crossing observed between the Pmm (Figure 6). The developed algorithm  detects the QRS by using the scale w2 and the Pmm corresponding to the R wave by defined threshold comparing inside a search window defined by the average RR interval and the last RR interval calculated . From that Pmm, the start of the Q wave defined as Qi (or the start of R wave (Ri) in the absence of Q wave) corresponds to the zero crossing preceding the Pmm; the end of the S wave defined as Se (or the end of the R wave in the absence of the S wave) corresponds to the zero crossing after the Pmm (Figure 10). Those zero crossings are detected by looking inside a search window defined by the maximal duration of both waves. Flowcharts of the Rp and Qi (Ri) detection algorithms are shown in Figures 11 and 12, respectively.
3.2.2. T wave detection
Because of the low-frequency components of T wave , scale w3 of the CWT was used for its detection. The process for detection of positive and negative T waves is as follows: from the end of the Pmm of the Rp, we define a search window whose length decreases when RR diminishes ; inside that window, we look for the Pmm corresponding to the T wave that exceeds a defined threshold. The end of this Pmm and the zero crossing between them, corresponds to, respectively, the end (Te) and the peak (Tp) of the T wave. Detection and identification of ascending, descending and biphasic types depend on the number, polarity and absolute values of the found local maxima (Wpt) or minimum (Wnt). Figure 13 shows peak and end of the positive and biphasic T wave and their characteristic points of CWT at scale w3. Flowchart of the Tp and Te detection algorithm of T wave monophasic or biphasic is shown in Figure 14.
3.3. Measurement of QT and RR intervals and calculus of QTd and HR
Once Qi and Te have been detected, the algorithm measures the QT and RR interval points in each quasi-orthogonal lead. Finally, the algorithm calculates QTd as the difference in duration between the longest and the shortest QT intervals measured in the three quasi-orthogonal leads, in which each QT interval is the average of three consecutive QT intervals. HR is calculated from the average of RR intervals measured in the same leads, in which each RR interval is the average of two consecutive RR intervals.
4. Validation and results
4.1. QRS detection
The developed algorithm for QRS detection  has been first tested on eight 30 min recordings resampled to 500 Hz from the MITDB , in which only channel 1 of the two-channel ECG recordings was used. The selected recordings included serious noise bursts, baseline drifts and movement artifacts. Table 3 shows that QRS detector had 81 false QRS detections of 17,095 beats (0.47%); 51 of them were false positives and 30 were false negatives.
4.2. Delineation of characteristic points of the QRS complex and T wave
The developed algorithm for delineation of Qi and Se of the QRS complex and Te of the T wave has been tested on 25 recordings from the CSE database , which includes 15 ECG leads and manual annotations on them. Table 4 shows the average (m) and standard deviation (sd) of the difference between the (WT-based) automatic and the (CSE) manual (annotated) location of those characteristic points. The results for that difference are within the tolerance limits accepted by the CSE experts, as shown in the last row of Table 4 .
|25 Recordings CSE|
|WT – CSE||WT – CSE||WT – CSE|
|m ± sd||– 4.5 ± 1.5||7.6 ± 1.8||8.2 ± 3.6|
|Tolerance limits for deviations according to experts |
Also, the algorithm has been tested on 15 recordings from MITDB included in the QTDB . Within each record of two channels, between 30 and 100 representative beats were manually annotated by cardiologists, who identified among other characteristic points of ECG waves, Qi of the QRS-complex and Te of the T-wave. Channel 1 was used in most recordings, in case of ECG distorted, channel 2 was used. Table 5 shows the mean (m) and standard deviation (sd) of the differences between the manual measurements (C1) and automatic measurements (WT) of Qi and Te for each record. The results for the differences between WT and C1 are within the tolerances for deviations with respect to the measurements made by the CSE experts, as shown in the last row of Table 5 .
|WT – C1||WT – C1|
|m ± sd||5.8(8)||7(15)|
|Tolerance limits for deviations according to experts |
Figure 15 shows some ECG excerpts of records with different T wave morphologies from QTDB with the manual annotations (square symbol) and the automatic detections (star symbol). It can be seen that Qi and Te are well determined by the algorithm, and its accuracy is comparable to a manual measurement of human experts.
5. Application in chronic kidney disease
The QTd algorithm was applied in two studies. In the first study, QTd was evaluated in normal subjects and patients with CKD. In the second study, QTd was analyzed in patients with CKD before, during and after the HD treatment.
5.1. QTd analysis in normal subjects and patients with CKD
In this study, 14 ECG recordings belonging to the PTBDB were used [26, 27], where the three quasi-orthogonal leads DI, aVF and V2 have been analyzed to obtain QTd. This database includes records of healthy people and patients with different pathologies. The study group was of seven normal subjects (two women and five men, age 66 ± 3.6 years) and seven renal insufficiency patients (three women and four men, age 70 ± 4.5 years). QTd corresponding to both groups was compared by the Wilcoxon rank sum test, where p < 0.05 was considered statistically significant.
Table 6 shows QTd and HR in both groups. Difference in HR in both groups is not significant and therefore HR influence is similar in both groups [(67.7 ± 9) beats/min vs. (70.8 ± 12) beats/min, p = 0.53]. QTd was significantly larger in patients with CKD than in normal subjects [(67.7 ± 28) ms vs. (21.4 ± 12), p = 0.0041]. The results obtained showed that the algorithm is effective to differentiate both groups.
|m ± sd||21.4(11)||67.7(9)||m ± sd||67.7(28)||70.8(12)|
5.2. QTd analysis in patients with CKD before, during and after hemodialysis
In this study, four ECG records of patients with CKD in the stage referred to as kidney failure or ESRD of the THEWDB , before (pre-HD), during and after (post-HD) HD session were used. For each patient, the three quasi-orthogonal leads DI, aVF and V2 have been analyzed to obtain QTd in a period of 10 h, in which pre-HD, HD and post-HD periods correspond to the hours 1, 2–6 and 7–10, respectively. Figure 16 shows the dynamics of QTd averaged every 15 min in a period of 10 h of the four CKD patients. It is observed that all the patients have an increase of QTd during HD and post-HD, which has been associated with malign ventricular arrhythmias and sudden death [6, 12].
This chapter presents and validates an algorithm based on the CWT with splines for the automatic measurement of QTd in the ECG quasi-orthogonal leads DI, aVF and V2. This algorithm permits the evaluation of the CWT in any integer scale which enables to use a wider range of scales and therefore to reduce noise and artifacts. In addition, the filters implemented in the algorithm based on B-splines are iterated discrete convolutions of moving sums, so that it can be computed without any multiplication, which results in a very efficient algorithm. Some functions of wavelet toolbox of MATLAB® related with this algorithm are as follows: the spline for cubic spline data interpolation, cwt that implements the CWT and gauswavf that returns the first order derivate of the Gaussian wavelet.
This new algorithm is based on the multilead generalization of a previous algorithm for single-lead detection of characteristic points of the QRS complex and T wave. It includes the identification of more types of morphologies of these waves, which are common in the analysis of several ECG leads and heart diseases. To evaluate its performance, ECG recordings of standard annotated databases MIT-BIH, QTDB and CSEDB were used. The results showed that the developed algorithm provides a reliable and accurate QRS detection and delineation of Qi and Te, with standard deviation of the errors within the tolerance limits for variations with respect to the measurements made by different experts.
The QTd algorithm was applied in two studies. In the first one, QTd was evaluated as a discriminator of patients with CKD from normal subjects. The results showed that QTd was significantly larger in CKD patients than in normal subjects, which agrees with similar studies. In the second study, QTd was analyzed in four patients with CKD before, during and after the HD treatment. The results showed that all the patients have an increase of QTd during HD and post-HD, which has been associated with malign ventricular arrhythmias and sudden death in previous studies.
Future applications of this algorithm will focus on to evaluate dispersion in other ECG ventricular activity intervals like JT (from S wave end to T wave end) and Tpe (from T wave peak to T wave end), in order to determine whether they improve the identification of CKD patients with risk of malign ventricular arrhythmias compared with QT dispersion.