Electrocardiogram Waveform Classification Based on P-QRS-T Wave Recognition

Muzhir Shaban Al-Ani

Department of Information Technology, College of Science and Technology, University of Human Development, Sulaimani, Kurdistan Region, Iraq

Corresponding author’s e-mail: Muzhir Shaban Al-Ani, Department of Information Technology, College of Science and Technology, University of Human Development, Sulaimani, Kurdistan Region, Iraq. E-mail: muzhir.al-ani@uhd.edu.iq
Received: 12-05-2018 Accepted: 11-06-2018 Published: 25-07-2018
DOI: 10.21928/uhdjst.v2n2y2018.pp7-14


Electrocardiogram (ECG) is a periodic signal reflects the activity of the heart. ECG waveform is an important issue to define the heart function, so it is helpful to recognize the type of heart diseases. ECG graph generates a lot of information that is converted into an electrical signal with standard values of amplitude and duration. The main problem raised in this measurement is the mixing between normal and abnormal, in addition, sometimes, there are overlapping between the P-QRS-T waveform. This research aims to offer an efficient approach to measure all parts of P-QRS-T waveform in order to give a correct decision of heart functionality. The implemented approach including many steps as follows: Preprocessing, baseline process, feature extraction, and diagnosis. The obtained result indicated an adequate recognition rate to verify the heart functionality. The proposed approach depends mainly on the classifier process that based mainly on the extracted ECG waveform features that achieved from exact baseline detection.

Index Terms: Electrocardiogram, Electrocardiogram Signal, Feature Extraction, QRS Wave


Monitoring the mechanical and electrical dynamics of the heart is essential to fully characterize and understand cardiac functions [1], [2]. Most of the attention has focused on the evaluation of the biophysical properties of the components of the heart through the use of conventional measurement approaches such as the ECG [3], [4]. The electrocardiogram (ECG) is usually used to obtain measurements for different cardiac parameters [5], [6]. It is usually used in a procedure that facilitates the recording of the electrical activity of the heart muscle during a specific time interval [7], [8]. In this procedure, several probes are placed in certain positions to define places in a bare chest [9], [10]. These probes generate electrical current as a result of measuring the electrical activity of each heartbeat on the surface of the chest [11], [12].

An ECG is widely used in medicine to control small electrical changes in the skin of a patient’s body that arise from the activities of the human heart [13], [14]. This simple and non-invasive measure easily indicates a variety of heart conditions [15], [16]. The medical industry builds dedicated device that helps with diagnosis [17], [18]. This device requires high-resolution oscilloscope to get the waveform on its screen [19], [20].

This approach tries to design an efficient ECG waveform classification based on the P-QRS-T wave recognition. This approach will be concentrated on recognizing the ECG waveform that related to heart functionality.


An ECG signal consists of three main parts such as P-wave, QRS wave, and T-wave [21]. These waveforms are corresponding to the electrical activities of various parts of the human heart [22]. During the analysis of the ECG signal, the data includes the positions or magnitudes of the QRS, PR, QT and ST intervals, PR and ST segments, and so on [23]. ECG waveform can be divided into the following parts (Fig. 1) [24]:


Fig. 1. Electrocardiogram wave.

  • The P-wave is a small deflection wave that represents atrial depolarization [25].

  • The PR interval is the time between the first deflection of the P-wave and the first deflection of the QRS complex [26].

  • The three waves of the QRS complex represent ventricular depolarization [27].

  • The small Q-waves correspond to depolarization of the interventricular septum.

  • The R-wave reflects depolarization of the main mass of the ventricles.

  • The S-wave signifies the final depolarization of the ventricles

  • The ST segment is the time between the end of the QRS complex and the start of the T-wave [28]. It reflects the period of zero potential between ventricular depolarization and repolarization [29].

  • The T-waves represent ventricular repolarization [30].

The normal ECG waveform contains many standard signals P, R, Q, and T waves [31], [32]. The amplitudes of these signals are shown in Table 1 [33]. In addition, these waves have duration time as shown in Table 2 [34].

TABLE 1 Amplitude of waves of normal ECG


TABLE 2 Timing values of waves of ECG



Many literatures are published related to the subject recognition of ECG waveform. Below some of these updated works:

AlMahamdy. described the ECG as an important tool for measuring health and disease detection. Due to many sources of noise, this signal must be eliminated and presented in a clear waveform. The noise sources can be the interference of the electric line, the external electromagnetic fields, the random corporal movements, or the breathing. This research implemented five common noise elimination methods and applied to real ECG signals contaminated by different noise levels. These algorithms are as follows: Discrete wavelet transformation (universal and local threshold), adaptive filters (LMS and RLS), and Savitzky–Golay filtering. Its noise elimination performance was implemented, compared, and analyzed using Matlab environment [35].

Yapici. (2015) proposed electrode by immersing a nylon fabric in a reduced graphene oxide solution, followed by a subsequent heat treatment to allow the conformal coating of conductive graphene layers around the fabric. The application of the electrode has been demonstrated by successful measurements of the ECG. The performance of the textile-based electrodes was compared with conventional silver/silver chloride (Ag/AgCl) electrodes in terms of cutaneous electrode impedance, ECG signal quality, and noise levels. An excellent compliance and a 97% cross-correlation were obtained between the measured signals with the new graphene-coated textile electrodes and the conventional electrodes [36].

Wang. designed an ECG noise elimination method based on adaptive Fourier decomposition (AFD). The AFD decomposes a signal according to its energy distribution, which makes this algorithm capable of separating the pure ECG signal and noise with overlapping frequency ranges but different energy distributions. A stopping criterion for the iterative decomposition process in the AFD is calculated based on the estimated signal-to-noise ratio of the noisy signal. The proposed AFD method is validated with the synthetic ECG signal using an ECG model, as well as the actual ECG signals from the MIT-BIH arrhythmia database with additive white Gaussian noise. Results of the simulation of the proposed method showed a better performance in QRS detection and noising compared to the main ECG schemes of noise elimination based on the wavelet transform, transform the empirical mode of Stockwell decomposition, and empirical decomposition mode [37].

Zou (2017) performed a method to detect the entire QRS complex and eliminates noise between two QRS complexes while recovering the P and T waves. As verified in the simulated noise ECG signal tests, the QRSMR outputs with severely contaminated ECG signals have an increase in the correlation with its original cleaning signals from 40% to almost 80%, demonstrating the improved QRSMR noise elimination capability. In addition, in the tests of the real ECG signals measured in volunteers with a flexible ECG control device developed at Fudan University, QRSMR is able to recover P and T waves from the contaminated signal, which shows its improved performance in the reduction of artifacts comparing with the adaptive filtering method and other methods based only on empirical decomposition [38].

Yu introduced a method called peak-to-peak entropy, the entropy of the R-R interval, correlation coefficient, and heart rate (PRCH) for automatic identification. This method defines four types of characteristics, which include the amplitude, the instantaneous heart rate (HR), the morphology, and the average HR, to characterize a signal and determine certain decision parameters through automatic learning. Experiments and comparisons were given with the other three existing methods. Taking the F1 metric for the evaluation, it showed that the proposed PRCH method has the highest accuracy of identification and generalization capacity [39].

Most of the ECG waveform recognition methods are concentrated statistical measures. This approach will be concentrated on recognizing the ECG waveform through a correct measure of the baseline detection that can be considered as cross detection approach compared with the amplitude of ECG waveform.


The methodology of this research can be concentrated on the design and implementation of the procedure steps to achieve the overall approach. The first step is preparing ECG data with different types to be ready for the system implementation. The implemented approach for ECG signal classification passed into four main steps as follows (Fig. 2): Preprocessing, baseline process, feature extraction, and diagnosis.


Fig. 2. Implemented approach for electrocardiogram.

4.1. Preprocessing

This is an important step that covers the following: Selecting the ECG region of interest, converting ECG image into grayscale, converting ECG image into binary image, noise reduction, and ECG thinning.

  • ECG region of interest, in which determine the rectangular with both vertical and horizontal directions to restrict ECG waveform.

  • Converting ECG image into grayscale, in which converting the color ECG image into grayscale image in order to avoid the interference of colors.

  • Converting ECG image into binary image, in which converting ECG image into black and white (ECG waveform is black, and the background is white) depending on a certain threshold.

  • Noise reduction, in which remove the unwanted noise as possible in order to achieve the real ECG waveform. This operation is implemented through a simple median filter.

  • Thinning process, in which is implemented in order to eliminate the redundant unwanted data. This process is performed through convolution process of ECG waveform image with the mask.

4.2. Baseline Process

The baseline voltage of the ECG waveform is known as the isoelectric line. This process can be implemented through two steps as follows:

  • Baseline detection, in which the baseline is detected depending on the horizontal line that contains more than the number of black points in ECG image. Then, draw the baseline in another color in order to distinct it from ECG waveform.

  • Baseline adjustment, in which baseline is modified and connect the waves. The baseline adjustment divide waveform image into blocks and compare each block with the baseline to make a decision for shift up or shift down or keep it on the baseline.

4.3. Feature Extraction

This process deals with the extraction of features from ECG waveform. This step aims to find the smallest set of features that enable acceptable diagnosis rate to be achieved. Calculating the width and height of each rectangular established on the baseline in order to match these values to ECG waveform that indicated the values of PQRST.

Calculate ECG regular or irregular rhythm that indicated the HR by the help of human expert.The regular rhythms can be quickly determined by counting the number of large graph boxes between two R-waves that number is divided into 300 to calculate beats per minute.

4.4. Diagnosis

This processdepends directly on the human experts (doctors) whom have the knowledge in order to help the user to take a decision. The implemented diagnosis process depends on the expert knowledge collected from doctors to identify the disease according to the obtained ECG data. The implemented diagnosis process is performed through applying four steps as follows: ECG waveform as an input, factors observed from doctors expertise about ECG waveform characteristics, designed model comparing the received data, and the ECG database that contains the ECG waveform characteristics.


The implemented approach for ECG waveform classification passed into four main steps as follows: Preprocessing, baseline process, feature extraction, and diagnosis, in addition, each step divided into other substeps. This section will demonstrate the shape and effect of each step on the ECG waveform. The implementation of this approach is done by programming Matlab package version 2016.

Preprocessing step starts with ECG region of interest, converting ECG image into grayscale, and converting ECG image into binary image; these are covered in Fig. 3.


Fig. 3. Electrocardiogram gray scale binary image.

In general, ECG waveform has different type of noise, which may affect the shape of the waveform. Median filter is applied in this case to eliminate the noise as possible this waveform is illustrated in Fig. 4.


Fig. 4. Electrocardiogram noise removal.

ECG waveform may have some thickness according to the output device. The thinning process is performed through skeleton operation in which eliminates the redundant of data as shown in Fig. 5.


Fig. 5. Electrocardiogram thinning.

The baseline voltage of the ECG is the continuous part of the T-wave tracing and preceding to the next P-wave. This baseline level detection is required because ECG amplitude at different locations in the beat is measured relative to this level. The output of this process is shown in Fig. 6.


Fig. 6. Electrocardiogram baseline detection

Modify the baseline and connecting wave is performs by waving. This process divided the image into blocks and each block compares it with the baseline in order to generate the blocks as shown in Fig. 7.


Fig. 7. Electrocardiogram baseline adjustment.

Detecting the type of wave begins by calculating the maximum peak height of the waveform. The maximum top amplitude value referred to R-wave. Any detecting of R-wave leading to calculate the Q-wave that placed before R-wave. This operation is illustrated in Fig. 8.


Fig. 8. Electrocardiogram crossing detecting

After detecting of waveform, starts the drawing stage to create rectangle around each waveform in the image. This waveform is illustrated in Fig. 9.


Fig. 9. Electrocardiogram drawing blocks.

The decision step start after ending all above steps, in this step, compares the obtained waveform with the stored ECG data. Fig. 10 indicated that the tested ECG waveform having sinus normal Rhythm.


Fig. 10. Normal electrocardiogram diagnosis.

Three types of heart diseases are tested using this approach in order to evaluate the matching rate. Fig. 11 shown ECG signal having sinus tachycardia heart that was recognized correctly.


Fig. 11. Electrocardiogram sinus tachycardia

Another test implemented for ECG waveform that having sinus bradycardia heart as shown in Fig. 12, and it was matched correctly.


Fig. 12. Electrocardiogram sinus bradycardia.

Last test implemented for ECG waveform that having sinus arrhythmia heart as shown in Fig. 13, and it was matched correctly.


Fig. 13. Electrocardiogram sinus arrhythmia


ECG waveform gives very important information about heart diseases patients. Combing the ECG experts for both doctors and users expert in order to generate an efficient approach used for ECG waveform analysis and diagnosis. This research provides support for medical diagnosis based on the ECG information retrieved from the patients. In order to recognize the ECG waveform, it passed through many steps such as follows; Preprocessing, baseline process, feature extraction, and diagnosis. The obtained result indicated a good recognition for detection all parts of P-QRS-T waveform. All the tested ECG waveform such as; sinus normal rhythm, sinus tachycardia, sinus bradycardia, and sinus arrhythmia are high accuracy matched. This approach can be applied in clinical center to help the ECG reader to take a correct decision. The main finding in this research is through applying a simple method of baseline detection in which a comparison of ECG waveform amplitude values can be achieved and measure correctly.


[1]. M.S. Al-Ani and A.S. Abdulbaqi. “The role of m-healthcare and its impact on healthcare environment”. vol. 2, no. 3-4, Dec. 2016.

[2]. M.S. Al-Ani. “Efficient architecture for digital image processing based on EPLD”. vol. 12, no. 6, pp. 1-7, 2017.

[3]. S.K. Berkaya, A.K. Uysal, E.S. Gunal, S. Ergin and M.B. Gulmezoglu. A survey on ECG analysis. vol. 43, pp. 216-235, May. 2018.

[4]. H. Sharma and K.K. Sharma. ECG-derived respiration using Hermite expansion., vol. 39, pp. 312-326, Jan. 2018.

[5]. R.L. Lux. Basis and ECG measurement of global ventricular repolarization., vol. 50, no. 6, pp. 792-797, Dec. 2017.

[6]. L. Mesin. Heartbeat monitoring from adaptively down-sampled electrocardiogram., vol. 84, 217-225, May. 2017.

[7]. D. Poulikakos and M. Malik. Challenges of ECG monitoring and ECG interpretation in dialysis units. vol. 49, no. 6, pp. 855-859, Dec. 2016.

[8]. G. Zhang, T. Wu, Z. Wan, Z. Song and F. Chen. A new method to detect ventricular fibrillation from CPR artifact-corrupted ECG based on the ECG alone., vol. 29, pp. 67-75, Aug. 2016.

[9]. P.W. Macfarlane, S.M. Lloyd, D. Singh, S. Hamde and V. Kumar. Normal limits of the electrocardiogram in Indians. vol. 48, no. 4, pp. 652-668, Aug. 2015.

[10]. F. Gargiulo, A. Fratini, M. Sansone and C. Sansone. Subject identification via ECG fiducial-based systems: Influence of the type of QT interval correction., vol. 121, no. 3, pp. 127-136, Oct. 2015.

[11]. M. R. Homaeinezhad, M.E. Moshiri-Nejad and H. Naseri. A correlation analysis-based detection and delineation of ECG characteristic events using template waveforms extracted by ensemble averaging of clustered heart cycles., vol. 44, pp. 66-75, Jan. 2014.

[12]. R.J. Martis, U.R. Acharya and H. Adeli. Current methods in electrocardiogram characterization., vol. 48, pp. 133-149, May. 2014.

[13]. M.S. Al-Ani and A.A. Rawi. “ECG beat diagnosis approach for ECG printout based on expert system”. vol. 3, no. 4, Apr. 2013.

[14]. K.N.V.P.S. Rajesh and R. Dhuli. Classification of imbalanced ECG beats using re-sampling techniques and Ada boost ensemble classifier., vol. 41, pp. 242-254, Mar. 2018.

[15]. M.S. Al-Ani and K.M.A. Alheeti. “Precision statistical analysis of images based on brightness distribution”. vol. 2, no. 4, 99-104, 2017.

[16]. A.K. Dohare, V. Kumar and R. Kumar. Detection of myocardial infarction in 12 lead ECG using support vector machine., vol. 64, pp. 138-147, Mar. 2018.

[17]. X. Dong, C. Wang and W. Si. ECG beat classification via deterministic learning. vol. 240, pp. 1-12, May. 2017.

[18]. P. Xiong, H. Wang, M. Liu, S. Zhou and X. Liu. ECG signal enhancement based on improved denoising auto-encoder. vol. 52, pp. 194-202, Jun. 2016.

[19]. C.G. Raj, V.S. Harsha, B.S. Gowthami and R. Sunitha. Virtual instrumentation based fetal ECG extraction., vol. 70, pp. 289-295, 2015.

[20]. A. Ebrahimzadeh, B. Shakiba and A. Khazaee. Detection of electrocardiogram signals using an efficient method. vol. 22, pp. 108-117, Sep. 2014.

[21]. M.S. Al-Ani and A.A. Rawi. “A rule-based expert system for automated ECG diagnosis”. vol. 6, no. 4, pp. 1480-1493, 2013.

[22]. M.S. Al-Ani. Study the characteristics of finite impulse response filter based on modified Kaiser window. vol. 1, no. 2, pp. 1-6, Aug. 2017.

[23]. K.K. Patro and P.R. Kumar. Effective feature extraction of ECG for biometric application. vol. 115, pp. 296-306, 2017.

[24]. R.E. Gregg, S.H. Zhou and A.M. Dubin. Automated detection of ventriculr pre-excitation in pediatric 12-lead ECG. vol. 49, no. 1, pp. 37-41, Jan. 2016.

[25]. S. Yazdani and J.M. Vesin. Extraction of QRS fiducial points from the ECG using adaptive mathematical morphology. vol. 56, 100-109, Sep. 2016.

[26]. A. R. Verma and Y. Singh. Adaptive tunable notch filter for ECG signal enhancement., vol. 57, pp. 332-337, 2015.

[27]. R. Rodríguez, A. Mexicano, J. Bila, S. Cervantes and R. Ponce. Feature extraction of electrocardiogram signals by applying adaptive threshold and principal component analysis. vol. 13, no. 2, pp. 261-269, Apr. 2015.

[28]. R. Salas-Boni, Y. Bai, P.R.E. Harris, B.J. Drew and X. Hu. False ventricular tachycardia alarm suppression in the ICU based on the discrete wavelet transform in the ECG signal., vol. 47, no. 6, pp. 775-780, Dec. 2014.

[29]. A. Awal, S.S. Mostafa, M. Ahmad and M.A. Rashid. An adaptive level dependent wavelet thresholding for ECG denoising. vol. 34, no. 4, pp. 238-249. 2014.

[30]. S.S. Al-Zaiti, J.A. Fallavollita, Y.W.B. Wu, M.R. Tomita and M.G. Carey. Electrocardiogram-based predictors of clinical outcomes: A meta-analysis of the prognostic value of ventricular repolarization. vol. 43, no. 6, pp. 516-526, Dec. 2014.

[31]. A. Cipriani, G. D’Amico, G. Brunello, M.P. Marra and A. Zorzi. The electrocardiographic “triangular QRS-ST-T waveform” pattern in patients with ST-segment elevation myocardial infarction: Incidence, pathophysiology and clinical implications. vol. 51, no. 1, pp. 8-14, Jan. 2018.

[32]. S. Kota, C. B. Swisher, T. Al-Shargabi, N. Andescavage and R. B. Govindan Identification of QRS complex in non-stationary electrocardiogram of sick infants., vol. 87, pp. 211-216, Aug. 2017.

[33]. P.R.E. Harris. The normal electrocardiogram: Resting 12-lead and electrocardiogram monitoring in the hospital. vol. 28, no. 3, pp. 281-296, Sep. 2016.

[34]. D. Saini, A.F. Grober, D. Hadley and V. Froelicher. Normal computerized Q wave measurements in healthy young athletes. vol. 50, no. 3, pp. 316-322, May-Jun. 2017.

[35]. M. AlMahamdy and H.B. Riley. Performance study of different denoising methods for ECG signals., vol. 37, pp. 325-332, 2014.

[36]. M.K. Yapici, T. Alkhidir, Y.A. Samad and K. Liao. Graphene-clad textile electrodes for electrocardiogram monitoring., vol. 221, pp. 1469-1474, Dec. 2015.

[37]. Z. Wang, F. Wan, C.M. Wong and L. Zhang. Adaptive Fourier decomposition based ECG Denoising., vol. 77, pp. 195-205, Oct. 2016.

[38]. C. Zou, Y. Qin, C. Sun, W. Li and W. Chen. Motion artifact removal based on periodical property for ECG monitoring with wearable systems., vol. 40, pp. 267-278, Sep. 2017.

[39]. Q. Yu, H. Yan, L. Song, W. Guo and Y. Zhao. Automatic identifying of maternal ECG source when applying ICA in fetal ECG extraction., vol. 38, no. 3, pp. 448-455, 2018.