Welcome to Journal Of Pakistan Medical Association
June, 2017 >>

Classification of normal and arrhythmic ECG using wavelet transform based template-matching technique

Wajahat Hassan, Aamir Habib, Qamar-ul-Islam  ( Department of Electrical Engineering, Institute of Space Technology, Islamabad, Pakistan. )

Saqib Saleem  ( Department of Electrical Engineering, COMSATS Institute of Information Technology, Sahiwal Campus, Pakistan. )


Objective: To propose a wavelet-based template matching technique to extract features for automatic classification of electrocardiogram signals of normal and arrhythmic individuals.
Methods: The study was conducted from December 2014 to December 2015 at the Department of Electrical Engineering, Institute of Space Technology, Islamabad, Pakistan. Electrocardiogram signals analysed in this study were taken from the freely available database www.physionet.org. The data for normal subjects was taken from the Massachusetts Institute of Technology-Beth Israel Hospital's normal sinus rhythm database and data for diseased subjects was taken from the arrhythmia database.
Results: Of the 30 subjects, there were 15(50%) normal and 15(50%) diseased subjects. The group-averaged phase difference indices of arrhythmic subjects were significantly larger than that of normal individuals (p<0.05) within the frequency range of 0.9-1.1 Hz. Moreover, the scatter plot between the phase difference index and magnitude of wavelet cross-spectrum for frequency range of 0.9-1.1 Hz demonstrated a satisfactory delineation between normal and arrhythmic individuals.
Conclusion: Wavelet decomposition-based template matching technique achieved satisfactory delineation of normal and arrhythmic electrocardiogram dynamics.
Keywords: Arrhythmia, Electrocardiogram, Ventricular fibrillation. (JPMA 67: 843; 2017)


According to the World Health Organisation (WHO), cardiovascular-related mortalities and morbidities are responsible for ~30% of global deaths.1 One key factor causing these cardiovascular-related abnormalities is termed 'arrhythmia' which might occur when electrical impulses, which coordinate with heart beats, are delayed or blocked, causing the heart-beat to become too slow (i.e., bradycardia), too fast (i.e., tachycardia) or uneven. Main types of arrhythmias include premature atrial and ventricular contractions, ventricular fibrillation and Wolff-Parkinson-White syndrome, and can appear in the form of fluttering in chest, sudden cardiac arrest, syncope, palpitations or no symptoms at all.2 Cardiac arrhythmia generates changes in the morphological structure of cardiovascular time series and can be diagnosed by the analysis of electrocardiogram (ECG), electrophysiology or head-up tilt test.3
It is widely accepted that the significant information related to heart rhythm and its functionality is embedded in ECG time series,4 which might be useful for the automatic diagnosis and classification of heart abnormalities. Recent studies5,6 have prompted the utilisation of many signal-processing approaches, including morphological parameters, beat-to-beat time interval analysis,7 frequency based approaches and principal component analysis8 for characterisation of ECG dynamics. These techniques have capability to provide information of either temporal or frequency components only and assume the underlying time series to be stationary. However, electrical activity of heart is highly dynamic and generates non-stationarities in the ECG signal. Therefore, the precise nature of time-varying ECG can be characterised using time-frequency transformation e.g., short-time Fourier transform and wavelet decomposition.9
The current study was planned to propose a wavelet decomposition-based template matching technique to extract features for automatic classification of non-stationary ECG signals of normal and arrhythmic individuals. We hypothesised that the frequency patterns of ~1Hz in arrhythmic individuals have differentiating parameters in terms of phase difference indices and magnitude of wavelet cross-spectrum (WCS) to discriminate from the normal ECG time series. To place our proposed methodology in the context of conventional approaches, we also adopted cross-correlation analysis.

Materials and Methods

The study was conducted from December 2014 to December 2015 at the Department of Electrical Engineering, Institute of Space Technology, Islamabad, Pakistan. ECG signals analysed in study were taken from the freely available database www.physionet.org. Wavelet-based cross-spectrum and phase difference indexes (PDI) were evaluated as classification parameters to delineate between normal and arrhythmic ECG patterns. The ECG data was taken from the Massachusetts Institute of Technology-Beth Israel Hospital (MIT-BIH) Arrhythmia Laboratory ECG arrhythmia database.10 The data for normal subjects was taken from the MIT-BIH normal sinus rhythm database. This data is freely available to analyse without any restrictions since the PhysioNet's inception in September 1999 and is updated regularly. The MIT-BIH arrhythmia database contains 48 half-hour excerpts of two-channel ambulatory ECG recordings, collected from 15 patients under observation of the BIH arrhythmia laboratory. In both cases, the extraction of ECG recordings was carried out by the standard 12-lead ECG system. The ECG recording of 60 seconds was selected for each subject for subsequent analyses.
The major problem in analysis of non-linear and non-stationary ECG is to remove the embedded noise e.g., power line interference, instrumentation noise, motion artefacts, muscle artefact, baseline wander and electromyogram, and to get its noise-free smoothed version. For this purpose, we adopted a newly developed signal processing tool, namely complete ensemble empirical mode decomposition (CE-EMD),11 which decomposes a signal into a small number of intrinsic mode functions. Next, we selected only those modes which carried useful information about the ECG characteristics and combined them to give a smoothed noiseless version of the original ECG signal. In this study, we removed the first 2 modes, having high frequency contents, of the recorded ECG signals and the remaining modes were combined to get the noise-free signal.
All values were represented as means± standard deviation (SD) unless otherwise stated. Phase difference index values were arcsine, and cross-correlation values were Fisher transformed to get asymptotical distributions. The normal distribution was determined by the Shapiro-Wilk test.12 For ease of interpretation, all values were presented in standard units. All comparisons were performed using unpaired t-tests with Welch's correction to determine if the significant differences were present. P<0.05 was considered significant.
Wavelet transform is an analytical tool which is used to analyse a non-stationary signal having time-varying frequency contents.13 This technique has been used in many applications including biomedical images, speech and audio signals, geophysics, image and video processing, and provides the time-frequency representation of signals; the time localisation of spectral components embedded in non-stationary time series (Appendix).

WCS is a representation of distribution of power between two time series, and is a frequency domain analogous of cross-correlation. Mathematical details of WCS are provided in Appendix.


Of the 30 subjects, 15(50%) were normal and 15(50%) were diseased. Smaller PDI values at higher frequencies and higher PDI values at lower frequencies were observed for both normal and arrhythmic subjects. PDI values for arrhythmic subjects were found to be significantly higher (0.25±0.04 vs. 0.08±0.07, arrhythmic vs. normal; p<0.05) than that of normal individuals within the frequency range of 0.9-1.1 Hz. However, no significant differences was found for cross-correlation values between arrhythmic and normal subjects (0.41±0.10 vs. 0.36±0.21, arrhythmic vs. normal; p>0.05) (Figure-1).

A representative example of the magnitude and phase of WCS of template ECG with the normal and arrhythmic ECGs is also shown (Figure-2).

The colour bars show the assignment of magnitude and phase values of WCS to various colours. Briefly, it is a representation of the time-localisation of frequency patterns of the magnitude and phase variations. We observed periodic patterns of higher modulus of WCS values with slow variations for arrhythmic ECG (specifically at frequency range of 0.2-1 Hz). However, these periodic patterns of higher modulus of WCS values have faster variations for normal ECG (specifically at frequency range of 0.2-1 Hz). We observed slow variations in phase for normal ECG at higher frequencies (i.e., 0.2-10 Hz) while high variations were observed for arrhythmic ECG. However, the phase patterns remained similar at lower frequencies.
The scatterplot between the phase difference index and magnitude of WCS for the frequency range of 0.9-1.1 Hz revealed that satisfactory delineation was achieved between normal and arrhythmic individuals (Figure-3).


In the current study, we proposed the application of a wavelet decomposition-based template matching technique for delineation of normal and arrhythmic ECG dynamics. The main finding of the present study is that ~1Hz frequency contents of arrhythmic ECG time series have differentiating parameters, in terms of phase difference indices and the magnitude of WCS, to discriminate from the normal ECG time series.
Reduction of mortality from cardiac causes depends on the timely detection and accurate classification of ventricular tachycardia (VT) and ventricular fibrillation (VF) arrhythmias. Conventional algorithms14 made use of surface ECG monitors and implantable cardioverter/defibrillators and relied on simple heart rate for detection and classification purposes. In a study,15 a sequential probability ratio test (SPRT)14 was proposed to measure the surface ECG for the discrimination of VT and VF. The algorithm used a novel regularity measure, namely blanking variability, derived from threshold crossings of the measured ECG.14
The current literature also makes use of the information embedded in QRS (Q, R and S waves) structure of ECG signal to examine its basic characteristic features. However, the fundamental issue in analysis of QRS features is the accurate detection of R-peaks of the ECG. A wealth of different approaches used for QRS detection are discussed in a study,16 including neural networks, filter banks, wavelet transforms and methods based on non-linear transforms.
In previous studies, fast Fourier transform (FFT)-based analyses have been adopted and verified with a computer-generated mathematical model to detect the pre-disposition of VT. In this proposed method, a priori filter is used as a low- and high-pass filter when a priori knowledge is required for extraction of the frequency contents of the signal. This approach17 is commonly preferred to avoid the time-domain analysis by allowing the inherent limitation of high-gain amplification.17
In recent studies,18 wavelet decomposition has been used to describe and identify the isolated cardiac beats. First, six types of ECG signal beats including normal beats, paced beats, atrial premature beats, right and left bundle branch block beats and premature ventricular contraction beats19 are detected using neural network-based classifier. Next, continuous wavelet transform is employed to extract significant features. This approach was adopted for arrhythmia classification and provides sharp threshold between tachycardia, bradycardia and normocardia conditions.18 Similarly, an adaptive wavelet network method has also been used for the ECG heartbeat recognition and detection. In this method, Morlet wavelet and probabilistic neural network20 are used to enhance the features from each heartbeat and to perform subsequent recognition tasks. The adaptive wavelet network works in dynamic environment, because of parameter tuning and automatic target adjustment.20
In the present study, we have suggested the use of wavelet-based cross-spectrum and PDI values for the classification and automatic detection of arrhythmic ECG signals. A template matching scheme has been proposed to extract distinguishing features to delineate between normal and arrhythmic conditions. Our results show that frequency contents of ~0.9-1.1Hz have differentiating parameters, in terms of PDI and magnitude of WCS, to discriminate from the normal ECG time series.
The previous studies20,21 employing frequency-domain based approaches have reported the power spectra variations of individual QRS complex in the range of 0-20 Hz. Lin et al.21 found that the frequencies of VF were concentrated in the range of 4-7 Hz. VT was observed in two distinct frequency bands of 2-5 Hz and 6-8 Hz, while atrial fibrillation was found in the frequency range of 2-10 Hz. Similarly, the respiratory sinus arrhythmia was found having spectral power in the frequency range of 0.15-0.5 Hz.21 Collectively, these studies suggest that the arrhythmia-related abnormalities might be associated with the frequency contents of 0-10Hz. The results of the present study are consistent with the findings of current literature because we found that ~0.9-1.1 Hz frequency contents of arrhythmic ECG are different from the normal ECG time series, and this frequency range lies in the frequency interval where arrhythmia is thought to be distinct from normal ECG dynamics.
The proposed methodology employing wavelet transform has the ability to capture non-linear and non-stationary dynamics of the cardiovascular activity occurring over beat-to-beat interval as a function of both time and frequency. Moreover, this technique also provides an increased degree of freedom to capture the temporal dynamics of the non-stationary time series by dividing the data into small windows (i.e., wavelets). However, it is worth mentioning that this approach cannot explicitly quantify the magnitude of non-stationarity nor can it characterise the nature of non-linear features.22
The preliminary results of the current study were promising, but the study had its limitations as well. The findings were inevitably affected by various factors, including the choice of template ECG signal. To be rigorous in our analysis, we made use of various normal ECG signals as a template and found that the proposed methodology worked appropriately.
Additionally, our sample size was insufficient to prove the clinical utility of the reported ECG analyses; however, it might be useful to relate the proposed model to the current framework of ECG diagnosis in clinical and research practice. Of note, the proposed technique can also be adopted to explore arrhythmic features using other variants, for example, electroencephalogram (EEG)23 and magnetoencephalography (MEG).24


Wavelet decomposition-based template-matching technique achieved satisfactory delineation of normal and arrhythmic ECG dynamics. Moreover, ~1Hz frequency contents of arrhythmic ECG time series had differentiating parameters, in terms of phase difference indices and magnitude of WCS, to discriminate from the normal ECG time series.
Disclaimer: None.
Conflict of Interest: None.
Source of Funding: None.


1. Colin M, Stevens G, Mascarenhas M. Global Health Risk: Mortality and burden of disease. Geneva: World Health Organization, 2009
2. Ashley EA, Niebauer J. Cardiology Explained. London: Remedica; 2004.
3. Noh CI, Kim HS. Head-up tilt test in complicated neurocardiogenic syncope in children. J Korean Med Sci. 1997; 12: 44-8.
4. Zhou H, Hou K, Zuo D. Real-Time Automatic ECG Diagnosis Method Dedicated to Pervasive Cardiac Care. Wireless Sensor Network 2009; 1: 276-83.
5. Graff C, Andersen MP, Xue JQ, Hardahl TB, Kanters JK, Toft E, et al. Identifying Drug-Induced Repolarization Abnormalities from Distinct ECG Patterns in Congenital Long QT Syndrome. J Drug Safety 2009; 32: 599-611.
6. Andersen MP, Xue JQ, Graff C, Hardahl TB, Toft E, Kanter JK, et al. A Robust Method for Quantification of IKr-Related T-Wave Morphology Abnormalities. IEEE, Computers in Cardiology 2007; 34: 341-4.
7. Sosnowski M, Czyz Z, Tendera M. Time and frequency analysis of beat-to-beat R-T interval variability in patients with ischaemic left ventricular dysfunction providing evidence for non-neural control of ventricular repolarisation ventricular repolarisation. Eur J Heart Fail 2002; 4: 737-43.
8. Mohamad FN, Ali MSA, Jahidin AH, Saaid MF, Noor MZH. Principal component analysis and arrhythmia recognition using Elman neural network. IEEE 4th Control and System Graduate Research Colloquium (ICSGRC): IEEE Conference Control and System Graduate Research Colloquium (ICSGRC), 2013.
9. Tanusree G, Debnath B, Kumar BS, Kim T. A Review on Different Techniques to De-noise a Signal. Int J Control Automation 2014; 7: 349.
10. Moody GB, Mark MR. MIT-BIH Arrhythmia Database. IEEE Eng Med Biol 2001; 20: 45-50.
11. Torres ME, Colominas MA, Schlotthauer G, Flandrin P. A complete ensemble empirical mode decomposition with adaptive noise. Acoustics, Speech and Signal Processing (ICASSP); Speech and Signal Processing (ICASSP). IEEE International Conference; 2011.
12. Shapiro SS, Wilk MB. An analysis of variance test for normality (complete samples). Biometrika 1965; 52: 591-611
13. Priestley MB. Wavelets and Time-Dependent Spectral Analysis. Department of statistic. Standfort University, 1995; 311.
14. Clarkson PM, Chen SW, Fan Q. A robust sequential detection algorithm for cardiac arrhythmia classification. IEEE International Conference on Acoustics, Speech, and Signal Processing 1996; 2: 1181-4.
15. Fukunaga K. Introduction to statistical pattern recognition. San Diego, CA, USA: Academic Press Professional, Inc. 1990.
16. Kohler BU, Hennig C, Orglmeister R. The principles of software QRS detection. IFEE Eng Med Bio Mag 2002; 21: 42-57.
17. Cain ME Ambos HD, Witkowski FX, Sobel BE. Fast-Fourier transform analysis of signal-averaged electrocardiograms for identification of patients prone to sustained ventricular tachycardia. Circulation 1984; 69: 711-20.
18. Daqrouq K, Abu-Isbeih IN. Arrhythmia detection using wavelet transform. IEEE International Conference on Computer as a Tool. Warsaw: IEEE International Conference; 2007
19. Niwa K, Warita N, Sunami Y, Shimura A, Tateno S, Sugita K. Prevalence of arrhythmias and conduction disturbances in large population-based samples of children. Cardiology in the Young 2014; 14: 68-74
20. Lin CH, Du YC, Chen T. Adaptive wavelet network for multiple cardiac arrhythmias recognition. Expert Systems with Applications 2008; 34: 2601-11.
21. Lin CH. Frequency-domain features for ECG beat discrimination using grey relational analysis-based classifier. Computers & Mathematics with Applications 2007; 55: 680-90.
22. Saleem S, Teal PD, Kleijn WB, Ainslie PN, Tzeng YC. Identification of human sympathetic neurovascular control using multivariate wavelet decomposition analysis. Am J Physiol Heart Circ Physiol 2016; 31: H837-48.
23. Anderson JH, Bos JM, Cascino GD, Ackerman MJ. Prevalence and spectrum of electroencephalogram identified epilepti form activity among patients with long QT syndrome. Heart Rhythm 2014; 11: 53-7
24. Lina JM, Chowdhury AR, Lemay E, Kobayashi E, Grova C. Wavelet-based localization of oscillatory sources from magnetoencephalography data. IEEE Transactions on Biomedical Engineering 2014; 21: 2350-64.
25. Keissar K, Davrath LR, Akselrod S. Coherence analysis between respiration and heart rate variability using continuous wavelet transform. Philosophical Transactions Mathematical Phys Eng Sci 2009; 367: 1393-1406.


Eurasian Orthopedic Forum will be held from 29-30 June 2017 in Moscow, Russia. Detail information can be obtained from:







This journal is a member of and subscribes to the principles of the Committee on Publication Ethics.

Copyrights © 2015 JPMA- All rights reserved
Powered by: PakCyber