Paced ECG Analysis in Mobile Cardiac Monitor
Alexander N. Kalinichenko1, Maria K.Chaykovskaya2, Daria A.Danilova1
1Saint Petersburg Electrotechnical University, Saint Petersburg, Russia
2Petrovsky National Research Centre of Surgery, Moscow, Russia

The main goal of this work was development of ECG processing algorithm for the real-time detection and displaying of implanted pacemaker artifacts, if they are present in the signal. In case of traditionally used characteristics of ECG acquisition circuits and analog-to-digital conversion pacemaker artifacts are often scarcely distinguished. Wide frequency band of ECG amplifier (0.2-10000 Hz) and high ADC sampling rate (20000 Hz) were used to resolve this problem. All pacemaker spikes detection procedures were realized fully digitally. The developed algorithm testing with the use of the real ECG recordings set showed the following results of pacemaker spikes detection: sensitivity 86.6 % and positive predictivity 99.6 %. The proposed algorithm was included in the ECG processing software of mobile cardiac monitor CardioQVARK based on iPhone series 5, 5S and 6.

Mobile communication technology development makes it possible to create compact and easily available smartphone based devices that provide real-time control of human physiological parameters and translation of the registered data to medical centers where they can be reviewed by doctors. The possibility like this is especially important for the cardiac patients supervision. The conditions of physiological signals acquisition (first of all of ECG) in case of the mobile based devices use differ much from the conditions typical for standard ECG equipment. So the task of special ECG processing algorithms development becomes urgent. If a patient has implanted pacemaker, it is very important to use a method of ECG acquisition and processing that provides the pacemaker spikes detection and visualization. As most of the modern pacemakers uses bipolar mode, that is characterized by very small amplitude of pacemaker spikes in ECG signal (typically
about several millivolt and 0.4 -1.5 ms duration [1]), routinely used standard ECG acquisition equipment doesn’t provide reliable detection and display of the pacemaker spikes due to limited frequency bandwidth of the signal and to low sampling rate [2, 3]. Analog detection of pacemaker spikes [4, 5] sometimes is not effective as it based on rather simple threshold detectors.
This work is devoted to the development of ECG analysis algorithm for the real-time detection of pacemaker pulses in mobile cardiac monitor. The main goal of the algorithm is providing reliable visualization of pacemaker pulses, if they are present in the signal. Due to the use of wide frequency range of ECG signal amplifier and very high sampling rate, the procedures of pacemaker spikes detection and estimation of their parameters are realized by fully digital methods.

2. Materials and Methods
The described algorithm was developed for the use in the mobile cardiac monitor CardioQVARK [6], based on iPhone series 5/5S or 6. This device represents a portable case into which a smartphone is inserted. On the rear side of the case two electrodes are placed for the ECG acquisition from fingers of both arms that corresponds to the standard ECG lead I. Ultra high impedance ECG sensors PS25251 and 24-bit stereo audio analog-to-digital converter ADAU1361 are used for the ECG acquisition and sampling that provides frequency range of the signal 0.2-10000 Hz and sampling rate 20000 Hz. Registered signal is first preprocessed in the smartphone and displayed in the real-time mode at the screen. Then the signal is decimated to 1000 Hz and transferred via Internet to the cloud service where additional analysis of the signal is implemented and the ECG and its analysis results are saved in the database. The data from the service are available both to the patient and to the doctor with the use of special client application that can be installed at smartphone, clipboard computer, notebook or desktop computer.
The following main functions of ECG processing and analysis are realized:
•pacemaker spikes detection (if they are present);
•heart rate control and measuring of RR-intervals;
•cardiac arrhythmia recognition;
•heart rate variability parameters estimation.
The algorithms of ECG processing and analysis are distributed between the mobile device and the cloud service. The part of the preprocessing procedures (including pacemaker pulses detection), that has to be implemented in the real-time mode, is realized at the smartphone while most of the ECG analysis algorithms are concentrated in the cloud service software. So in case of some algorithms modernization, most part of the ECG analysis software should be updated only at the cloud service.

2.1. ECG data set
A special set of real ECG recordings from the patients having implantable pacemakers was formed to provide the data needed for the pacemaker spikes detection algorithm development. The data was obtained at the clinical base of Petrovsky National Research Centre of Surgery, (Moscow, Russia). This data set contains recordings representing all most commonly used modes of pacing and different types of pacemakers from several producers. The iPhone based cardiac monitor CardioQVARK was used for the ECG registration and transferring to the cloud service. The data set contains 156 recordings of raw ECG, each having duration 300 s and digitized with sampling rate 20000 Hz. From the point of view of the used pacing modes the data set contains the following variants: atrial pacing (n=15), ventricular pacing (n=42), dual pacing (n=99, including 21 recordings with biventricular pacing). Positions of all visible pacemaker spikes in all recordings were verified in semiautomatic mode with the use of special MATLAB program. This verified dataset was used further as a test data for the developed algorithm quality estimation.
Preliminary visual examination of the ECG dataset showed that in case of used sampling rate all pacemaker pulses are distinctly discernible (each pulse includes at least 8-10 samples). Most typically the form of the pulses is close to rectangular and contains characteristic central plateau with duration no less than 0.3 ms (see example at the upper plot of Figure 1). Very short high spikes are often take place before the front slope of the pulse and just after its rear slope. Magnitude of the pacemaker pulses varies from 0.1 mV up to several volts. As a rule each pulse is succeeded by a jump caused by the electrodes polarization [1]. This jump has polarity opposite to the pacemaker pulse and falls down to zero by exponential mode. Intensive high frequency background noise caused by pacemaker takes place in some recordings. Sometimes the magnitude of this noise splashes is higher than that of stimulus. In cases of biventricular pacing two adjacent ventricular spikes can overlap each other.
All the listed above features were taken into account in the process of the algorithm conception development.

ECG ETU Petrovsky CardioQVARK
Figure 1. Stages of pacemaker spike detection and ECG correction

A special training subset of ECG fragments including 148 ECGs with 15 s duration was formed to support the work connected with the developed algorithm examination and optimization. Most typical situations were included in this subset. Besides, the selected fragments should not contain segments with too intensive noise.

2.2. Pacemaker spikes detection algorithm
The following main requirements to developed pacemaker spikes detection algorithm were postulated:
•real-time ECG processing to provide current display of the signal with minimal time delay;
•the algorithm should not use any preliminary information concerning presence of pacing in each particular signal;
•the algorithm should work both in case of paced ECG and in case of ECG without pacing.
At the first stage of the spikes detection procedure the current mean QRS-complexes amplitude estimation is implemented. This amplitude estimation is needed for the further adjusting of some thresholds used in the detection algorithm. The spikes detection procedure itself includes the following stages:
•estimation of background high frequency noise level for the adaptive correction of pacemaker spike detection thresholds;
•pacemaker spikes search, based on detection of two steep slopes separated by a plateau having duration between 0.15 and 1.0 ms;
•estimation of the detected pulse parameters (duration and magnitude);
•compensation of the signal jump (just after the spike) caused by the pacemaker electrodes polarization; this procedure is based upon polynomial approximation.
•deleting the detected spike from the signal with the use of linear interpolation;
The pacemaker spikes detection algorithm causes the signal delay 30 ms. Figure 1 illustrates the spike detection process and the further signal correction.

2.3. ECG reconstruction and further processing
To prepare the ECG for display on the smartphone screen the signal after spikes deleting is filtered by two digital filters: notching (removing AC interference) and low-pass (smoothing) filter. If some pacemaker spikes were detected, they are inserted in the filtered signal as vertical lines having the height equal to the measured magnitude of the spikes (Figure 2).
After the spikes detection procedure the signal is decimated to 1000 Hz with preliminary smoothing and then translated to the cloud service in parallel with the detected spikes parameters.
The ECG signal with sampling frequency 1000 Hz transmitted from the smartphone is stored in the cloud service database both in original and filtered forms. The signal filtering is implemented with the use of comb filter (removing DC component, AC interference and its harmonics) and low-pass filter with cutoff frequency about 35 Hz. The obtained signal together with the parameters of the detected pacemaker spikes is used further for off-line display.
The unfiltered signal with sampling frequency 1000 Hz is used as an input for the further ECG analysis stages. As pacemaker pulses and polarization jumps are removed from the signal, the same QRS detection algorithm is used as for the ECG without pacing [7].

3. Results and discussion
The results of the pacemaker spikes detection algorithm performance for both training and test sets of ECG recordings are shown in Table 1. Here N – the total number of the verified spikes, TP – the number of the correctly detected pulses, FP – the number of the false positives, Se – the sensitivity of the detection algorithm (Se=TP/N×100 %) and +P – the positive predictivity (+P=TP/(TP+FP)×100 %).

Table 1. Pacemaker spikes detection results
ETU Petrovsky CardioQVARK

These results show that the algorithm has sufficiently high robustness to noises (high value of the positive predictivity) but at the same time misses considerable part of spikes. It can be interpreted as a result of a compromise between the requirement of false detection minimization (that is important for the patients having no pacemaker at all) and the attempt to achieve as high sensitivity as possible.
Analysis of the detection errors reveals the following main problems:
1) very low magnitude of spikes in some recordings; this is mostly connected with the used method of ECG acquisition that permits to get only standard ECG lead I;
2) some recordings contain intensive high frequency background noise produced by pacemaker itself;
3) “atypical” form of pacemaker pulses in individual recordings that hampers identification of this pulses in case of high level of noises.
We plan to enhance the algorithm performance by more profound considering of the signal context and by using of self-training procedures that should make the algorithm more adaptive to the specific features of each individual signal.

ECG ETU Petrovsky CardioQVARK
Figure 2. Reconstruction of the detected pacemaker spikes for the ECG display (here Fs – sampling frequency)

This work has been supported by the following projects: the Russian Foundation for Basic Research project #16-07-00722; the Ministry of Education and Science of Russia project # 14.578.21.0122; medical project “CardioQVARK. ECG by Smartphone” (

[1] Chow AW, Buxton AE. Implantable Cardiac Pacemakers and Defibrillators: All You Wanted to Know. Blackwell Publishing Ltd, 2006.
[2] Guglin ME, Datwani ND. Electrocardiograms with pacemakers: accuracy of computer reading. Journal of Electrocardiology 2007;40:144-6.
[3] Andersson HB, Hansen MB, Thorsberger M, Biering-Sørensen T, Nielsen JB, Graff C, Pehrson S, Svendsen JH. Diagnostic accuracy of pace spikes in the electrocardiogram to diagnose paced rhythm. Journal of Electrocardiology 2015;48(5): 834-839.
[4] Kruse JM, Redmond C. Detecting and Distinguishing Cardiac Pacing Artifacts. Analog Dialogue 2012; 46(4): 13-8.
[5] Tsibulko VV, Iliev IT, Jekova II. Methods for Detecting Pacemaker Pulses in ECG Signal: A Review. Annual Journal of Electronics 2014; 8:77-80.
[6] Kalinichenko AN, Motorina SV, Uskov AV. ECG Analysis Algorithms for Smartphone Based Cardiac Monitor. In Proceedings of 12th Russian-German Conference on Biomedical Engineering. Vladimir: Vladimir State University, 2016:65-9.
[7] Nemirko AP, Kalinichenko AN, Manilo LA. Algorithms and software for the real-time ECG analysis. In Proceedings of 5th Russian-Bavarian Conference on Biomedical Engineering. Munich: TUM, 2009:259-260.

Address for correspondence.
Alexander N. Kalinichenko.
Saint Petersburg Electrotechnical University "LETI".
Prof. Popova str. 5, 197376, Saint Petersburg, Russia.