Table of Contents Author Guidelines Submit a Manuscript
Computational and Mathematical Methods in Medicine
Volume 2017, Article ID 8081361, 16 pages
Research Article

Shannon’s Energy Based Algorithm in ECG Signal Processing

Department of Electronic Engineering, Islamic Azad University, Tabriz Branch, Tabriz, Iran

Correspondence should be addressed to Nasser Lotfivand;

Received 20 July 2016; Revised 25 November 2016; Accepted 5 December 2016; Published 18 January 2017

Academic Editor: Luis J. Mena

Copyright © 2017 Hamed Beyramienanlou and Nasser Lotfivand. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.


Physikalisch-Technische Bundesanstalt (PTB) database is electrocardiograms (ECGs) set from healthy volunteers and patients with different heart diseases. PTB is provided for research and teaching purposes by National Metrology Institute of Germany. The analysis method of complex QRS in ECG signals for diagnosis of heart disease is extremely important. In this article, a method on Shannon energy (SE) in order to detect QRS complex in 12 leads of ECG signal is provided. At first, this algorithm computes the Shannon energy (SE) and then makes an envelope of Shannon energy (SE) by using the defined threshold. Then, the signal peaks are determined. The efficiency of the algorithm is tested on 70 cases. Of all 12 standard leads, ECG signals include 840 leads of the PTB Diagnostic ECG Database (PTBDB). The algorithm shows that the Shannon energy (SE) sensitivity is equal to 99.924%, the detection error rate (DER) is equal to 0.155%, Positive Predictivity (+P) is equal to 99.922%, and Classification Accuracy (Acc) is equal to 99.846%.

1. Introduction

In recent years, cardiovascular disorders have been one of the major diseases threatening human life. Therefore, the detection of heart signal waves such as QRS complex is highly significant [1]. Electrocardiogram is used to detect most of heart disorders and shows the electrical activities of heart as a signal [2]. ECG signals contain a lot of information concerning heart diseases. The detection of special points and different parameters such as QRS complex are one of the basic topics and are of high importance, because they lead to the diagnosis of heart diseases. The QRS are used to diagnose many cardiac diseases and noncardiac pathologies such as autonomic malfunction vascular, respiratory (RR) assessment in cardiomyopathy and the normal ventricular myocardium, estimate the heart rate and heart rate variability analysis, and detect ST segment [35]. Heart problems usually involve leaking valves and blocked coronary arteries. This research is motivated by reasons expressed. Heart rate cycle consists of a P-wave, a QRS complex, T-wave, and sometimes U-wave [5]. Figure 1 shows schematic representation of normal ECG.

Figure 1: Schematic diagram of normal ECG.

Detecting any of heart signal waves may be difficult due to variable physiology, arrhythmia, disease, and noise. Therefore, in methods such as artificial neural networks and supportive vector machines, detection by the wave R is not always successful and true detection cannot be reached in different signals [6, 7].

The shape of the waves T, P, and QRS is well known; however, the time and frequency of these waves depend on the physiological and physical conditions. In addition, the signal may face polluted recordings with noises such as transmission lines [3].

In recent decades, various methods have been presented to improve the detection of heart signal waves, including Pan-Tompkins algorithm [7], Wavelet Transform, by usage of a constant scale in signal analysis, not considering the characteristics of the signal [8, 9], and artificial neural networks, containing of a series of interconnected simple processing units that each connection has a weight. Input layer, one or multiple hidden layers, and output layer constitute a neural network [10, 11]. Adaptive filter [12], called Hilbert-Huang Transform (HHT), is a new technique for extracting features that are nonlinear and nonstationary signals. This technique has a leakage in practical tasks [13]. Filter bank [14], a Hidden Markov Model (HMM), describes the process where direct observation is not possible, when sequence of symbols can observe HMM. It is used in many fields such as classification of heartbeat and apnea bradycardia detection in preterm infants [15]. Hermite Transform (HT) was recently used instead of Fourier Transform. HT shows better performance, when optimization is done properly [16]. Threshold method [17], Shannon energy envelope (SEE), is the average spectrum of energy and is better able to detect peaks in case of various QRS polarities and sudden changes in QRS amplitude. SEE detects R-peak with a better estimate [18]. S-Transform and Shannon energy (SSE) create a frequency-dependent regulation which is directly related with the Fourier spectrum. S-Transform includes short time Fourier Transform (STFT) and the Wavelet Transform (WT). SSE gives a smooth cover for P-waves and T-waves and completely decreases their influence [19]. Methods such as pattern matching are based on their comparing and contrasting. The calculations are complex and need manual classification [6].

In this paper, an algorithm based on Shannon energy has been proposed to improve the QRS complex detection and simplify the detection process. First, a band-pass filter is used for eliminating noise. Second, Shannon energy of ECG signal is calculated. Third, include moving averages and a differential for the envelope of step 2. Finally, with defining a threshold, peaks are detected. The proposed algorithm is tested on 115-second (to end) ECG signal of PTB Diagnostic ECG Database (PTBDB) [20, 21] and detection accuracy of 99.846% is obtained. The proposed technique results in good performance without being mathematically complex.

2. Method

The block diagram of detecting QRS complex algorithm is shown in Figure 2. It includes four stages. Stage 1 includes band-pass digital filter and amplitude normalization. Stage 2 includes calculating Shannon energy of stage 1. In stage 3, with moving average and differencing, make a pack of Shannon energy, and in stage 4, with defining a threshold, QRS complex is detected.

Figure 2: Block diagram to detect QRS complex.
2.1. Preparations Signal

Digital-analog conversion process is causing all kinds of noise interference and sometimes strongly affects the information. These interactions include frequency interference, muscle contraction, and wandering signals from the baseline or Gaussian white noise [5].

The ECG signal recorded from human beings is a poor signal and is often contaminated by noise. Frequency interference includes a narrow band from 48 to 60 Hz and harmonic interference, and the noise from muscle contraction occurs in 38 to 45 Hz. To eliminate this noise, notch filter is good [22]. Deep breathing, loosely connected electrodes, and sudden changes in voltage lead the baseline signal to be wondered (baseline drift) [5]. Random variable vector (mean) and chromatogram baseline estimation and denoising using sparsity (BEADS) algorithm [23] are good methods to eliminate baseline drift. The band-pass filter decreases efficacy of muscle contraction, frequency interference, baseline drift, and P-wave and T-wave interference [7, 24]. To repress these noises, Butterworth band-pass digital filter with stop-point set at 5 to 16 Hz is used. Butterworth has no ripple in band-pass. [25]. After band-pass filter, the signal is normalized with (1) in stage 1 [26].where is a normalized amplitude; is an after processes band-pass filter (BPF). denotes the number of samples.

2.2. Shannon Energy and Detection of QRS Complex

The proposed method is based on the use of signal energy. The signal square is very close to the signal energy. For discrete time signal energy is defined as follows:

Here, expresses the signal energy, defined ECG data, and is samples. represents sum from [27]. To explain, we have the following:

Shannon energy calculates the average spectrum of the signal energy. In other words, discount the high components into the low components. So, input amplitude is not important. Shannon energy and Hilbert Transform (SEHT) provide a good accessory for detecting R-peak but this technique has a problem. SEHT needs high memory and has delays [28]. It is designed for solving our actual requirements. To find smooth Shannon energy, zero-phase filter and Shannon energy approximate are playing a basic role [24, 28].

Shannon energy (SE) calculates the energy of the local spectrum for each sample. Below is a calculation of Shannon energy: where is after process normalization.

Energy that better approaches detection ranges in presence of noise or domains with more width results in fewer errors. Capacity to emphasize medium is the advantage of using Shannon energy rather than classic energy [18, 19]. The selected signal is normalized with (5) in stage 3 for decreasing the signal base and placing the signal below the baseline.where is the random variable vector and defined standard deviation of the signal.

In stage 3, after computing Shannon energy, small spikes around the main peak of the energy are generated. These spikes make main peaks detection difficult. To eliminate this spike, Shannon energy is converted into energy package (Shannon energy envelope (SEE)). To overcome this problem, the Hilbert Transform is used. SEHT method is a simple and high accessory but the SEHT needs high memory and has delays, so it is unfit for real time detection [24, 28]. To smooth out the spikes, rectangular () with length is used. Filtering operation is shown as follows:where defines moving average, is a constant, and defines Shannon energy from previous steps. For spikes reducing and enveloping, the nonzero peaks obtained from differential get linked. In other words, diagnosed peaks are linked together.

Difference is defined below:

The sign is defined as follows:where is a real number.

In stage 4, positive peaks are QRS complex location. To detect QRS complex, a threshold (see (9)) is defined. In fact, samples with greater amplitude than the threshold are selected as output.where is a constant.

3. Result

The experimental results are obtained after simulation on 70 healthy patients’ signals for all 12 leads and using PTB Diagnostic ECG Database (PTBDB). The Physikalisch-Technische Bundesanstalt (PTB) is the National Metrology Institute of Germany. PTB database is provided for PhysioNet and has different morphologies. The ECGs in this database obtain 15 input channels including the conventional 12 leads (i, ii, iii, avr, avl, avf, v1, v2, v3, v4, v5, and v6) together with the 3 Frank lead ECGs (vx, vy, and vz). Input voltage is ±16 mV, input resistance is 100 Ω, ADC resolution is equal to 16 bits with 0.5 μ/LSB, and sampling frequency is equal to 1 KHz [20, 21]. The proposed algorithm was performed on a 2.4 GHz Intel core i3 CPU using GNU Octave version 4.0.2 [29]. A selected signal from patient 117 has a variety of physiology and baseline drift. Leads (i, ii, avl, avf, v3, v4, v5, and v6) of record s0291lrem and leads (i, ii, iii, avf, v1, v2, v4, v5, and v6) of record s0292lrem have high amplitude. Leads (i, avl, v2, v3, and v4) of record s0291lrem and leads (avr, avl, and avf) of record s0292lrem have a sharp and tall T-wave.

Figure 3 shows the result of simulation to detect each lead of patient 117 in Octave. Figures 4 and 5 show the process of ECG signal provision and peak detection. The QRS detection of the 12 channels of healthy ECG signal in patient 117 of the PTB database is reported in Table 1 and the Appendix. Detection of the 12 leads is shown in Figure 6. Figure 7 shows 3 leads of 3 cases.

Table 1: The QRS detection of ECG signal of the PTB database.
Figure 3: Simulation result. Time and number of peaks detection in each lead are shown. ((a) record s0292lrem; (b) record s0291lrem).
Figure 4: Process of preparations of ECG signal (record s0291lrem, lead v3).
Figure 5: Process of preparation of ECG signal (record s0292lrem, lead avr).
Figure 6: Detected QRS complex of ECG data (record s0292lrem); red line defines QRS complex detection. -axis represents the amplitude, and -axis represents the sample.
Figure 7: (a) Detected QRS complex of ECG data (record s0020arem, lead avf). Records s0020arem and s0020brem include tall and sharp P-wave and T-wave. In this case, the QRS area has low energy. (b) Detected QRS complex of s0087lrem-lead 3. This case includes Irregular RR interval. (c) Lead v5 of s0089lrem. FN (false negative) is the number of not detected R peaks, and FP (false positive) is the number of noise spikes detected as R peaks. -axis represents the amplitude, and -axis represents the sample.

In order to define performance and efficiency of the algorithm, the Classification Accuracy (Acc), Positive Predictivity (+P), sensitivity (Se), and detection error rate were calculated by using the following equations:

Here, TP defines a true detected peak by the algorithm; FN (false negative) is the number of not detected R peaks, and FP (false positive) is the number of noise spikes detected as R peaks [3, 30].

Figures 4(a) and 5(a) show the output after the band-pass filter and normalized amplitude . Figures 4(b) and 5(b) show Shannon energy and normalized amplitude, and Figures 4(c) and 5(c) show after envelope signal. QRS complex of ECG signal is shown in Figures 4(d) and 5(d). Red line defines a detected peak. -axis represents the amplitude, and -axis represents the sample.

In this study, the proposed technique is tested on 840 leads of PTB Diagnostic ECG Database (PTBDB), and values achieved showed that sensitivity (Se) equals 99.924%, detection error rate (DER) equals 0.155%, Positive Predictivity (+P) equals 99.922%, and Classification Accuracy was 99.846%.

4. Conclusion

In the present study, the most common methods to remove noise in the ECG signal are evaluated. A Shannon energy-based approach to determine the QRS complex of the 12-lead ECG signal is provided. ECG signal is selected with a variety of physiology from the PTB Database and examined by Octave software. Accuracy and sensitivity achieved from Table 1 showed that the presented algorithm is fast and simple, without complex equations. This algorithm does not need a high memory and high hardware. Diagnosis time for each lead is approximately 2.5 seconds based on Octave. The results showed that algorithm detection has very little lag, less than 0.013 seconds, without error. This lag is generated from stage 3.


See Table 2.

Table 2: The QRS detection of the 12 channels of the PTB database.

Competing Interests

The authors declare that they have no competing interests.


  1. K. Wang, S. Ma, J. Feng, W. Zhang, M. Fan, and D. Zhao, “Design of ECG signal acquisition system based on DSP,” in Proceedings of the International Workshop on Information and Electronics Engineering (IWIEE '12), vol. 29, pp. 3763–3767, Harbin, China, March 2012. View at Publisher · View at Google Scholar · View at Scopus
  2. Y.-C. Yeh and W.-J. Wang, “QRS complexes detection for ECG signal: the difference operation method,” Computer Methods and Programs in Biomedicine, vol. 91, no. 3, pp. 245–254, 2008. View at Publisher · View at Google Scholar · View at Scopus
  3. M. Yochum, C. Renaud, and S. Jacquir, “Automatic detection of P, QRS and T patterns in 12 leads ECG signal based on CWT,” Biomedical Signal Processing and Control, vol. 25, pp. 46–53, 2016. View at Publisher · View at Google Scholar · View at Scopus
  4. F. Jin, L. Sugavaneswaran, S. Krishnan, and V. S. Chauhan, “Quantification of fragmented QRS complex using intrinsic time-scale decomposition,” Biomedical Signal Processing and Control, vol. 31, pp. 513–523, 2017. View at Publisher · View at Google Scholar
  5. H. Zhang, “An improved QRS wave group detection algorithm and matlab implementation,” Physics Procedia, vol. 25, pp. 1010–1016, 2012. View at Publisher · View at Google Scholar
  6. D. Sadhukhan and M. Mitra, “R-peak detection algorithm for Ecg using double difference and RR interval processing,” Procedia Technology, vol. 4, pp. 873–877, 2012. View at Publisher · View at Google Scholar
  7. J. Pan and W. J. Tompkins, “A real-time QRS detection algorithm,” IEEE Transactions on Biomedical Engineering, vol. 32, no. 3, pp. 230–236, 1985. View at Publisher · View at Google Scholar · View at Scopus
  8. Y. Zou, J. Han, S. Xuan et al., “An energy-efficient design for ECG recording and R-peak detection based on wavelet transform,” IEEE Transactions on Circuits and Systems II: Express Briefs, vol. 62, no. 2, pp. 119–123, 2015. View at Publisher · View at Google Scholar · View at Scopus
  9. J. Yan and L. Lu, “Improved Hilbert-Huang transform based weak signal detection methodology and its application on incipient fault diagnosis and ECG signal analysis,” Signal Processing, vol. 98, pp. 74–87, 2014. View at Publisher · View at Google Scholar · View at Scopus
  10. V. J. Ribas Ripoll, A. Wojdel, E. Romero, P. Ramos, and J. Brugada, “ECG assessment based on neural networks with pretraining,” Applied Soft Computing, vol. 49, pp. 399–406, 2016. View at Publisher · View at Google Scholar
  11. J. Mateo, A. M. Torres, M. A. García, and J. L. Santos, “Noise removal in electroencephalogram signals using an artificial neural network based on the simultaneous perturbation method,” Neural Computing and Applications, vol. 27, no. 7, pp. 1941–1957, 2016. View at Publisher · View at Google Scholar · View at Scopus
  12. B.-U. Köhler, C. Hennig, and R. Orglmeister, “The principles of software QRS detection,” IEEE Engineering in Medicine and Biology Magazine, vol. 21, no. 1, pp. 42–57, 2002. View at Publisher · View at Google Scholar · View at Scopus
  13. J. Bo, X. Cao, Y. Wan et al., “Investigation performance on electrocardiogram signal processing based on an advanced algorithm combining wavelet packet transform (WPT) and Hilbert-Huang Transform (HHT),” Lecture Notes in Electrical Engineering, vol. 269, pp. 959–968, 2014. View at Publisher · View at Google Scholar · View at Scopus
  14. M. Lagerholm and G. Peterson, “Clustering ECG complexes using hermite functions and self-organizing maps,” IEEE Transactions on Biomedical Engineering, vol. 47, no. 7, pp. 838–848, 2000. View at Publisher · View at Google Scholar · View at Scopus
  15. M. Akhbari, M. B. Shamsollahi, O. Sayadi, A. A. Armoundas, and C. Jutten, “ECG segmentation and fiducial point extraction using multi hidden Markov model,” Computers in Biology and Medicine, vol. 79, pp. 21–29, 2016. View at Google Scholar
  16. M. Brajović, I. Orović, M. Daković, and S. Stanković, “On the parameterization of Hermite transform with application to the compression of QRS complexes,” Signal Processing, vol. 131, pp. 113–119, 2017. View at Publisher · View at Google Scholar
  17. R. Jane, A. Blasi, J. Garcia, and P. Laguna, “Evaluation of an automatic threshold based detector of waveform limits in Holter ECG with the QT database,” in Computers in Cardiology 1997, pp. 295–298, IEEE Computer Society Press, Piscataway, NJ, USA, 1997. View at Google Scholar
  18. M. S. Manikandan and K. P. Soman, “A novel method for detecting R-peaks in electrocardiogram (ECG) signal,” Biomedical Signal Processing and Control, vol. 7, no. 2, pp. 118–128, 2012. View at Publisher · View at Google Scholar · View at Scopus
  19. Z. Zidelmal, A. Amirou, D. Ould-Abdeslam, A. Moukadem, and A. Dieterlen, “QRS detection using S-Transform and Shannon energy,” Computer Methods and Programs in Biomedicine, vol. 116, no. 1, pp. 1–9, 2014. View at Publisher · View at Google Scholar · View at Scopus
  20. A. L. Goldberger, L. A. Amaral, L. Glass et al., “PhysioBank, PhysioToolkit, and PhysioNet: components of a new research resource for complex physiologic signals,” Circulation, vol. 101, no. 23, pp. E215–E220, 2000. View at Publisher · View at Google Scholar · View at Scopus
  21. PhysioNet, The PTB Diagnostic ECG Database (ptbdb),
  22. A. R. Verma and Y. Singh, “Adaptive tunable notch filter for ECG signal enhancement,” Procedia Computer Science, vol. 57, pp. 332–337, 3rd International Conference on Recent Trends in Computing 2015 (ICRTC-2015), 2015. View at Publisher · View at Google Scholar
  23. X. Ning, I. W. Selesnick, and L. Duval, “Chromatogram baseline estimation and denoising using sparsity (BEADS),” Chemometrics and Intelligent Laboratory Systems, vol. 139, pp. 156–167, 2014. View at Publisher · View at Google Scholar · View at Scopus
  24. H. Zhu and J. Dong, “An R-peak detection method based on peaks of Shannon energy envelope,” Biomedical Signal Processing and Control, vol. 8, no. 5, pp. 466–474, 2013. View at Publisher · View at Google Scholar · View at Scopus
  25. D. Schlichthärle, “Analog filters,” in Digital Filters: Basics and Design, pp. 19–83, Springer, Berlin, Germany, 2011. View at Google Scholar
  26. B. T. Ricardo Ferro, A. Ramírez Aguilera, and R. R. Fernández De La Vara Prieto, “Automated detection of the onset and systolic peak in the pulse wave using Hilbert transform,” Biomedical Signal Processing and Control, vol. 20, article no. 672, pp. 78–84, 2015. View at Publisher · View at Google Scholar · View at Scopus
  27. V. K. Ingle and J. G. Proakis, Digital Signal Processing Using MATLAB, Brooks/Cole, Boston, Mass, USA, 2000.
  28. M. Rakshit, D. Panigrahy, and P. K. Sahu, “An improved method for R-peak detection by using Shannon energy envelope,” Sādhanā. Academy Proceedings in Engineering Sciences, vol. 41, no. 5, pp. 469–477, 2016. View at Google Scholar · View at MathSciNet
  29. GNU-Octave,
  30. M. Merah, T. A. Abdelmalik, and B. H. Larbi, “R-peaks detection based on stationary wavelet transform,” Computer Methods and Programs in Biomedicine, vol. 121, no. 3, pp. 149–160, 2015. View at Publisher · View at Google Scholar · View at Scopus