Shannon's Energy Based Algorithm in ECG Signal Processing

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%.


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 [3][4][5]. 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.
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 Pwaves 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.

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.

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 bandpass. [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. signal square is very close to the signal energy. For discrete time signal energy is defined as follows:

Shannon Energy and Detection of QRS
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.

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 5: Process of preparation of ECG signal (record s0292lrem, lead avr).
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].     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%.

Conclusion
In the present study, the most common methods to remove noise in the ECG signal are evaluated. A Shannon energybased 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.