|Year : 2016 | Volume
| Issue : 4 | Page : 218-223
Providing an efficient algorithm for finding R peaks in ECG signals and detecting ventricular abnormalities with morphological features
Mohammad Pooyan1, Fateme Akhoondi2
1 Biomedical Engineering Department, Shahed University, Tehran, Iran
2 Department of Engineering, Shahed University, Tehran, Iran
|Date of Web Publication||17-Sep-2019|
Engineering Faculty, Biomedical Engineering Department, Shahed University, Tehran
Source of Support: None, Conflict of Interest: None
Ventricular arrhythmias are one of the most important causes of annual deaths in the world, which may lead to sudden cardiac deaths. Accurate and early diagnosis of ventricular arrhythmias in heart diseases is essential for preventing mortality in cardiac patients. Ventricular activity on the electrocardiogram (ECG) signal is in the interval from the beginning of QRS complex to T wave end. Variations in the ECG signal and its features may indicate heart condition of patients. The first step to extract features of ECG in time domain is finding R peaks. In this paper, a combination of two algorithms of Pan–Tompkins and state logic machine has been used to find R peaks in heart signals for normal sinus signals and ventricular abnormalities. Then, a healthy or sick beat may be realized by comparing the difference between R peaks obtained from two algorithms in each beat. The morphological features of the ECG signal in the range of QRS complex are evaluated. Ventricular tachycardia (VT), ventricular flutter (VFL), ventricular fibrillation (VFI), ventricular escape beat (VEB), and premature ventricular contractions (PVCs) are abnormalities studied in this paper. In the classification step, the support vector machine (SVM) classifier with Gaussian kernel (one in front of everyone) is used. Accuracy percentages of ventricular abnormalities mentioned above and normal sinus rhythm are respectively obtained as 95.8%, 92.8%, 94.5, 98.9%, 91.5%, and 100%. The database of this paper has been taken from normal sinus rhythm and MIT-SCD banks available on Physionet.org.
Keywords: Electrocardiography, heart conduction system, humans, Pan–Tompkins algorithm, state logic machine, support vector machine, ventricular flutter, ventricular premature complexes
|How to cite this article:|
Pooyan M, Akhoondi F. Providing an efficient algorithm for finding R peaks in ECG signals and detecting ventricular abnormalities with morphological features. J Med Signals Sens 2016;6:218-23
|How to cite this URL:|
Pooyan M, Akhoondi F. Providing an efficient algorithm for finding R peaks in ECG signals and detecting ventricular abnormalities with morphological features. J Med Signals Sens [serial online] 2016 [cited 2022 Jun 29];6:218-23. Available from: https://www.jmssjournal.net/text.asp?2016/6/4/218/195090
| Introduction|| |
Analysis of electrocardiogram (ECG) signals is so important in detecting heart diseases, because such diseases may cause sudden deaths. Ventricular abnormalities are one of the most dangerous heart diseases. Accurate and early diagnosis of these disorders is crucial in patients with ventricular abnormalities. The electrical activity of the ventricles on ECG is in the range of QRS complex to T wave end. One group of ventricular abnormalities is ventricular arrhythmias. Ventricular arrhythmias studied in this article are ventricular fibrillation (VFI), ventricular tachycardia (VT), and ventricular flutter (VFL). Premature ventricular contractions (PVCs) and ventricular escape beat (VEB) are two ventricular abnormalities studied in this paper.
Analysis and classification of ECG beats have been done using numerous methods.
Inan et al. first separated PVC beats from other healthy and cardiac abnormal beats by using wavelet transform and then classified them using time domain features and artificial neural networks. An overall accuracy of 95.6% was reported in this article. In Martis et al., the PCA has been used as a tool for ECG beat classification (normal bits, LBBB, PVC, RBBB). In this article, three features extraction methods [ECG rate basic elements, the basic elements of the linear prediction error signals and the basic elements of discrete wavelet transform (DWT) coefficients] were compared. In Ebrahimzadeh and Khazaee, the ECG signal has been investigated using wavelet coefficients approximation (using three long features) and RBF neural network as a classifier. In this paper, five types of ECG beats (normal, LBBB, RBBB, PVC, and APC) are classified. In Korürek and Doğan, the authors used particle Swann optimization and radial basis function neural network (RBFNN) for classifying six types of ECG beats. In de Chazal et al., the authors classified four types of ECG beats (normal beat, ventricular ectopic beat (VEB), supraventricular ectopic beat (SVEB), and fusion of normal and VEB). In this paper, the classification is performed using time domain features and linear kernel. In Hosseini et al., the combination of independent features and compressed ECG data is used as an input to the multilayered perceptron network. The accuracy of 88.3% has been reported.
In Thomas and Das, the classification of five types of ECG beats (NB, Paced Beat, LBBB, RBBB, and PVC) is performed using wavelet coefficients in fourth and fifth scales and four features from QRS complex are considered in every cycle. The performance of the proposed method of this paper is compared with extracted statistical features using DWT. The overall accuracy of 97.8% has been reported.
In these abnormalities, we faced the dilemma of finding the location of R peaks, and no common method has proper functionality in finding R peaks. In this study, an algorithm has been provided to solve this problem.
The data used in this study are as follows:
- Normal sinus database (containing five 1-min signals or 350 beats) with frequency of 128 Hz.
- Sudden Cardiac Death Database (consisting of three 1-h signals) with frequency of 256 Hz.
In this study, the dataset is extracted from the website Physionet.org. Investigations in this paper are on Lead II. [Table 1] reports the number of abnormal beats which are discussed in this study.
| Materials and Methods|| |
This part of the article consists of two parts: how to detect R peaks, and feature selection, which will be explained in the following.
To improve R peaks diagnosis, plenty of methods have been used. Many methods such as derivative method, Hamilton–Tompkins algorithm, wavelet transform method, and Hilbert transform (HT) method are used to detect R peaks.
Some methods were applied for QRS detection by some translations, and more complex methods did not use from time dimension directly; some of them were mentioned as following.
In Rodríguez et al., the authors were given new approach for the detection of QRS complex in different arrhythmias. QRS was detected using HT and the adaptive threshold. Features were extracted using the principal component analysis.
In Biswas et al., the authors proposed peak synchronization that is novel method and it measures the simultaneity of occurrence of peaks in the signals.
In Ricardo Ferro et al., the authors employed processing of original signal, which included Shannon energy envelope (SEE) estimator, HT, and moving average (MA) filter. Data consisted of 10 records of 5 min length and different signal-to-noise ratios (15, 12, and 9 dB). The accuracy was applied to 100%.
In paper, the authors used a combination of some signal processing techniques, which were Hilbert, wavelet transforms, and an adaptive thresholding method. This combination was named WHAT.
A common method for R peaks detection (such as Pan–Tompkins) does not function properly through cardiac abnormalities occurrence. This study suggests a method based on a combination of Pan–Tompkins and state logic machine which has improved R peaks detection through abnormalities. State logic machine can remove high and low frequency noises. Both algorithms detect the same location for R peaks in the ECG signal containing normal sinus rhythm and the signals not having acute abnormalities. The difference between R peak location detection via Pan–Tompkins algorithm and state logic machine in every single beat for normal sinus signals shows no significant difference or a maximum of 10_samples difference. However, the locations of R peaks obtained from the Pan–Tompkins algorithm and state logic machine are different in beats in the ECG signal having acute ventricular abnormalities. R peaks difference obtained from the two algorithms in two patient (PVC and VFL) and healthy cases are presented in [[Figure 1] and [Figure 2].
|Figure 1: RR intervals obtained from Pan–Tompkins and state logic machine, respectively, for a patient|
Click here to view
|Figure 2: RR intervals obtained from Pan–Tompkins and state logic machine, respectively, for healthy case|
Click here to view
Moreover, a template of normal sinus beat is used in the algorithm. For this beat, the autocorrelation in zero lag is calculated (which is indicated by a1). This value is used in steps of thresholding and comparison. Then, the cross-correlation is calculated at zero lag between each beat and normal sinus beat template. Two conditions to classify data are studied in this paper. If both conditions are present in the meantime, that beat would be a normal sinus beat.
The first condition is, when the cross-correlation between the normal sinus beat template and studied beats from signals in zero lag (which is indicated by a2) is more than 0.3 of a1 and the difference of R peaks obtained from two algorithms (Pan–Tompkins and state logic machine) is smaller than 10, this beat is normal; otherwise, this beat is abnormal. The coefficient (0.3) is obtained from the average of the division a2 to a1. The beats’ labels are available in Physionet.org website.
A significant point is that not all the beats are sampled with the same frequency. Also, all beats are downsampled to the lowest sampling frequency (128 Hz). Sudden cardiac death database (containing three 1-h signals) with frequency of 256 Hz and normal sinus database (containing five 1-min signals) with frequency of 128 Hz are sampled. The second condition is that if a2 is less than 0.3 of a1 or if the difference of R peaks obtained from two algorithms in the studied beat is more than 10, these beats have acute ventricular abnormalities.
At intervals of some ventricular arrhythmias in the ECG signals (such as PVC), no algorithm can find R peaks correctly (as shown in [Figure 3], R peaks in PVC beat was marked wrongly in seconds 1.3 and 3).
Then, to find R peaks locations in ventricular abnormal beats, 70% of the interval between two consequent R peaks obtained from state logic machine is considered and the maximum peaks and their locations are calculated. The differences between the amplitudes of previous and next samples of this sample (obtained from previous step) are calculated to insure that is a real peak. Then, an interval of 0.06 s is considered after and before this sample and the minimum amplitudes are considered as Q and S peaks, respectively. After that, the features associated to QRS complex are obtained. R peaks are obtained using this algorithm for PVC beats with the TP of 57% and FN of 43%, if none of the other algorithms (state logic machine and Pan–Tompkins) are able to find R peaks. FP, FN, TP, and TN of detected R peaks for ventricular abnormalities in ECGs studied in this paper are according to [Table 2].
|Table 2: FP, FN, TP and TN of R peak detection in ventricular abnormalities|
Click here to view
Studied morphological features are as the following: the amplitude of R peak, the rising and falling slopes of QRS complex, QS interval, positive and negative areas (the sign of this value is negative) of the complex QRS [Eqs. (1) and (2) and [Figure 4]].
All of the features are obtained on Lead II.
State logic machine algorithm
In state logic machine algorithm, the ECG signal has passed through band pass filter with zero phase. This filter is necessary to remove background noise fluctuations and power line noise. Then, a 1_second window has been determined on the ECG signal and the average of this window has been calculated (m).
The state logic machine considered two conditions for each of the R and S and T waves. Estimating the location is done by considering the first condition, and definite presence of R peaks in this interval is determined by considering the second condition and its constraints. Each condition has been different for peak detection in ECG at each step.
At zero state, the product of m and an initial weight (w = 1.8) is calculated. If this product is less than the mean value calculated in a 15_sample interval (m1) from the one second interval, and also if the amplitude of the studied sample is larger than the rest of the samples, the amplitude and the location of the first sample from the one second window is stored as R peak; then, we switch to state of one, which reports the definite presence of R peaks. In summary [Eq. (3)]:
In state of one, the stored amplitude from zero state is compared with the next four samples, to ensure that is the maximum one. Each sample in this window must be less than its previous sample. If such a condition is imposed, the index from zero state is stored as the R peak amplitude and its location. An interval containing 0.04 s before this location until the location of this sample is considered, and minimum amplitude is assumed as Q peak. Also, weight is updated in this state, which means that if the number of detected R peaks is more than eight, 0.3 of mean of these eight R peaks is achieved and it is divided to m. then, the state will be equal to two. In the state of two, if m1 is less than m, we switch to state of three for finding S peak. The period of investigation for state of three is 0.2 s. If, among the eight samples, the studied sample is less than the rest of the samples and if each sample is less than its previous sample, we ensure that the studied sample is S. Then, the state is equal to four. In the state of four, if m1 is less than m, we switch to state of six for finding T peaks.
In state of six, the studied interval of 0.7 s is assumed. The threshold is considered based on the recent values of S and m. If m1 is more than this threshold [Eq. (4)], this condition is acceptable for three consecutive samples, and the peak of the studied sample is more than its subsequent eight samples (each sample in this eight-sample window should be smaller than the previous sample), this sample is stored as T peak and state is updated to six.
State of six is for prevention of finding several R peaks in a 0.4 s window. After this delay, the algorithm switches to zero state and this algorithm is repeated for each 1_second window.
The flowchart of the state logic machine is shown in [Figure 5].
After extracting signal features, support vector machine (SVM) by (Gaussian) radial basis function kernel is used for classification of ventricular abnormalities. This is done for obtaining more reliable responses. The method used in SVM is one-against-all., To classify each arrhythmia, data segmentation includes 8% of training data and 20% of testing data. The accuracy of the data is obtained by six times shuffles.
In this research, eight records of ECG signals were used from physionet. These signals include sudden cardiac death records for three patients and five normal sinus rhythms of five healthy persons. The feature extraction step extracted six features from more than 300 beats of MIT-SCD that included six acute abnormalities studied in this research, and 350 beats from normal sinus rhythm. These features, including the amplitude of R peak, the rising and falling slope of QRS complex, QS interval, and positive and negative areas of the complex QRS, were obtained from each beat. The data with more details were shown in [Table 1].
The classification accuracies of normal sinus rhythm, VT, VFL, VFI, PVC, and VEB rhythm were evaluated. The accuracies achieved from this essay are compared with previous studies and the maximum accuracy is reported. By using the combined algorithm in this paper, we obtained acceptable accuracy percentages compared to the previous studies. Percent accuracies have been reported in [Table 3].
|Table 3: Percent of accuracies for studied ventricular abnormalities in this paper|
Click here to view
| Discussion and Conclusion|| |
The algorithm used in this study was applied to increase the classification reliability of normal and abnormal beats in ECG real time signals and a combination of two algorithms (Pan–Tompkins and state logic machine) was used for finding R peaks in beats containing acute ventricular abnormalities.
In this research, morphological features were applied for classification of the aforementioned ventricular abnormalities. In this research, studying beat was done in beat-to-beat, real time for classification of ventricular arrhythmias. As a result, studying beat-to-beat may help the medicines for faster recognition of abnormalities rather than heart rate.
If each abnormality is studied at each lead and the most effective features in each lead are obtained, the abnormality classification will have very high accuracy. Independent features of leads will be very useful if they are diagnosed with high accuracy. 
Financial support and sponsorship
Conflicts of interest
There are no conflicts of interest.
| References|| |
Inan OT, Giovangrandi L, Kovacs GT. Robust neural-network-based classification of premature ventricular contractions using wavelet transform and timing interval features. IEEE Trans Biomed Eng 2006;53:2507-15.
Martis RJ, Acharya UR, Mandana KM, Ray AK, Chakraborty C. Application of principle component analysis to ECG signals for automated diagnosis of cardiac health. Expert Syst Appl 2012;39:11792-800.
Ebrahimzadeh A, Khazaee A. An efficient technique for classification of electrocardiogram signals. Adv Electric Comput Eng 2009;9:89-93.
Korürek M, Doğan B3 ECG beat classification using particle swarm optimization and radial basis function neural network. Expert Syst Appl 2010;37:7563-9.
de Chazal P, O’Dwyer M, Reilly RB. Automatic classification of heartbeats using ECG morphology and heartbeat interval features. IEEE Trans Biomed Eng 2004;51:1196-206.
Hosseini HG, Reynolds KJ, Powers D. A multi-stage neural network classifier for ECG events. IEEE EMBS 2001;2:1672-5.
Thomas M, Das MK. Classification of cardiac arrhythmias based on dual tree complex wavelet transform. International Conference on Communication and Signal Processing, 2014. p. 3-5.
Reddy DC. Biomedical Signal Processing: Principle and Techniques. New Delhi: TMH Publication; 2005. p. 254-300.
Hamilton PS, Tompkins WJ. Quantitative investigation of QRS detection rules using the MIT/BIH arrhythmia database. IEEE Trans Eng Biomed Eng 1986;33:1157-65.
Rodríguez R, Mexicano A, Bila J, Cervantes S, Ponce R. Feature extraction of electrocardiogram signals by applying adaptive threshold and principal component analysis. J Appl Res Technol 2015;13:261-9.
Biswas R, Khamaru K, Majumdar KK. A peak synchronization measure for multiple signals. IEEE Trans Signal Process 2014;62:4390-8.
Ricardo Ferro BT, Ramírez Aguilera A, Fernández de la Vara Prieto RR. Automated detection of the onset and systolic peak in the pulse wave using Hilbert transform. Biomed Signal Process Control 2015;20:78-84.
Rabbani H, Mahjoob MP, Farahabadi E, Farahabadi A. R peak detection in electrocardiogram signal based on an optimal combination of wavelet transform, Hilbert transform, and adaptive thresholding. J Med Signals Sens 2011;1:91-8.
Pan J, Tompkins WJ. A real-time QRS detection algorithm. IEEE Trans Biomed Eng 1985;32:230-6.
Boser BE, Guyon IM, Vapnik VN. A training algorithm for optimal margin classifiers. Proceedings of the Fifth Annual Workshop on Computational Learning Theory, 1992. p. 144-52.
Vapnik V. The Nature of Statistical Learning Theory. Springer Science & Business Media; 2013.
Lee SH, Ko HC, Yoon YR. Classification of ventricular arrhythmia using a support vector machine based on morphological features. Annual International Conference of the IEEE EMBS, 2013. p. 5785-8.
Ahmed R, Arafat S. Cardiac arrhythmia classification using hierarchical classification model. International Conference on CSIT, 2014. p. 203-7.
Matul Imah E, Jatmiko W, Basaruddin T. Adaptive multilayer generalized learning vector quantization (AMGLVQ) as new algorithm with integrating feature extraction and classification for arrhythmia heartbeats classification. 35th
Annual International Conference on Systems Man and Cybernetics, 2012. p. 150-5.
[Figure 1], [Figure 2], [Figure 3], [Figure 4], [Figure 5]
[Table 1], [Table 2], [Table 3]
|This article has been cited by|
||In-Body Electromagnetic Sensor Combined with AI-Enhanced Electrocardiography for Pacemaker Working Status Telemonitoring
| ||Wu Lu, Ranran Ding, Bingjie Wu, Wenbin Zhao, Dong Huang, Xue Zhang, Yunze He |
| ||Journal of Sensors. 2021; 2021: 1 |
|[Pubmed] | [DOI]|
||Impact of Data Transformation: An ECG Heartbeat Classification Approach
| ||Yongbo Liang,Ahmed Hussain,Derek Abbott,Carlo Menon,Rabab Ward,Mohamed Elgendi |
| ||Frontiers in Digital Health. 2020; 2 |
|[Pubmed] | [DOI]|
||Outlier Detection and Quasi-periodicity Optimization Algorithm: Frequency Domain Based Outlier Detection (FOD)
| ||Ekin Can Erkus,Vilda Purutçuoglu |
| ||European Journal of Operational Research. 2020; |
|[Pubmed] | [DOI]|
||Aiding the Detection of QRS Complex in ECG Signals by Detecting S Peaks Independently
| ||Pooja Sabherwal,Latika Singh,Monika Agrawal |
| ||Cardiovascular Engineering and Technology. 2018; 9(3): 469 |
|[Pubmed] | [DOI]|