# Improved Noise Cancelling Algorithm for Electrocardiogram Based on Moving Average Adaptive Filter

^{1}

^{2}

^{3}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Electrocardiogram Background

## 3. Methodology

#### 3.1. Phase-Locked-Loop (PLL)

#### 3.1.1. Phase Detector (PD)

_{i}) and the error signal (v

_{o}cosine feedback). The corresponding output resulting from the comparison between these two inputs is Φ

_{d}, which is a linearization of the sinusoidal signal to small angles, according to Equations (1) and (2):

_{mult}is composed of the signal Φ

_{d}multiplied by a gain added to a high frequency component (n), which represents a disturbance applied to the system:

_{mult}signal. The transfer function in the z domain is defined in Equation (4), where N is the filter order, defined according to the desired cut-off frequency (f

_{c}) and the sampling frequency (f

_{a}), presented in Equation (5):

#### 3.1.2. Compensator

_{s}), the limits of the damping coefficient (ζ) and the undamped natural frequency (ω

_{n}) are defined according to Equations (6) and (7), respectively. Equation (8) demonstrates a standard discrete PI controller, where K

_{p}is the proportional gain and K

_{i}is the integral gain. Equations (6)–(8) are calculated as follows:

^{−3}(0.9557437866536668) and 3.19 × 10

^{2}(319.1934263090495), respectively. Those values are the results given by the software used to analyze and tune the controller, without eliminating decimal fractional digits. However, those numbers are difficult to implement in a 32-bit microcontroller. Simulations and experimental tests were performed to reduce the number of these digits without affecting the controller performance. Thus, the aforementioned tests allow for defining the minimal numerical resolution for those parameters:

- -
- The parameter K requires, at least, two decimal fractional digits (K = 319.19).
- -
- The parameter α requires, at least, six decimal fractional digits (α = 0.955744).

#### 3.1.3. Numerically Controlled Oscillator

_{s}is the sampling period:

#### 3.2. Adaptive Moving Average Filter (MAV)

_{MAV}is the filtered ECG signal, x

_{i}is the ECG signal read from the patient with EMI noise, and the filter order N is a function of sampling frequency (f

_{a}) and fundamental frequency of the estimated EMI noise through the PLL (f

_{n}), as shown in Equation (14). The variation of the filter order as a function of the EMI frequency guarantees an adequate filtering even when there is a variation in the EMI frequency. Equations (13) and (14) are calculated as follows:

## 4. EMI Cancellation Algorithm

#### Waveforms Used in the System Validation

## 5. Project Guidelines

#### 5.1. Embedded Firmware

#### 5.2. Experimental Setup

## 6. Results and Discussion

#### 6.1. Simulation Results

_{signal}) and the average power of the noise (P

_{noise}) according to Equation (15). However, for signals under the same impedances, Equation (15) can be used to measure the SNR as long as it has the same sampling window. Equation (16) presents the SNR of the input signal in terms of the average amplitudes. Thus, SNR

_{in}is the SNR of the input signal, A

_{signal}is the average amplitudes of the input signal, and noise is the average noise amplitudes of the input signal [27]. Equations (15) and (16) are calculated as follows:

_{sol}) and the corrupted signal with filtered EMI (A

_{scf}). The difference between these two is the residue after filtering. So dB

_{out}, in Equation (18), is the SNR of the ECG after the filtering process. The SNR is 584.3627 or 63.7052 dB:

#### 6.2. Experimental Evaluations

## 7. Conclusions

## Author Contributions

## Funding

## Acknowledgments

## Conflicts of Interest

## References

- Ministry of Health. Epidemiological and Morbidity. 2019. Available online: https://datasus.saude.gov.br/epidemiologicas-e-morbidade (accessed on 14 June 2021).
- World Health Organization. Cardiovascular Diseases (CVDs). 2017. Available online: https://www.who.int/en/news-room/fact-sheets/detail/cardiovascular-diseases-(cvds) (accessed on 14 June 2021).
- Moffa, P.J.; Uchida, A.H.; Barbosa, P.B. Standardization of equipment and techniques for conducting electrocardiography and high-resolution electrocardiography exams. Braz. Arch. Cardiol.
**2003**, 80, 572–578. [Google Scholar] - Colantonio, S.; Conforti, D.; Martinelli, M.; Moroni, D.; Perticone, F.; Salvetti, O.; Sciacqua, A. An intelligent and integrated platform for supporting the management of chronic heart failure patients. In Proceedings of the 2008 Computers in Cardiology, Bologna, Italy, 14–17 September 2008; pp. 897–900. [Google Scholar]
- Zompanti, A.; Sabatini, A.; Grasso, S.; Pennazza, G.; Ferri, G.; Barile, G.; Chello, M.; Lusini, M.; Santonico, M. Development and Test of a Portable ECG Device with Dry Capacitive Electrodes and Driven Right Leg Circuit. Sensors
**2021**, 21, 2777. [Google Scholar] [CrossRef] [PubMed] - Fye, W.B. A History of the Origin, Evolution, and Impact of Electrocardiography. Am. J. Cardiol.
**1994**, 73, 937–949. [Google Scholar] [CrossRef] - van Rijn, A.C.M.; Peper, A.; Grimbergen, C.A. High-quality recording of bioelectric events part 1, interference reduction, theory and practice. Med. Biol. Eng. Comput.
**1990**, 28, 389–397. [Google Scholar] [CrossRef] [PubMed] - Loring, Z.; Sen, S.; Black-Maier, E.; Atwater, B.D.; Russell, S.D.; DeVore, A.D.; Piccini, J.P. Reducing ECG Artifact from Left Ventricular Assist Device Electromagnetic Interference. J. Am. Heart Assoc.
**2020**, 9, e017563. [Google Scholar] [CrossRef] [PubMed] - Winter, B.B.; Webster, J.G. Driven-Right-Leg Circuit Design. IEEE Trans. Biomed. Eng.
**1983**, 30, 62–66. [Google Scholar] [CrossRef] [PubMed] - van Rijn, A.C.M.; Peper, A.; Grimbergen, C.A. High-quality recording of bioelectric events part 2, low-noise, low-power multichannel amplifier design. Med. Biol. Eng. Comput.
**1991**, 29, 433–440. [Google Scholar] [CrossRef] [PubMed] - Meidani, M.; Mashoufi, B. Introducing new algorithms for realising an FIR filter with less hardware in order to eliminate power line interference from the ECG signal. IET Signal Process.
**2016**, 10, 709–716. [Google Scholar] [CrossRef] - Mishra, S.; Das, D.; Kumar, R.; Sumathi, P. A Power-Line Interference Canceler Based on Sliding DFT Phase Locking Scheme for ECG Signals. IEEE Trans. Instrum. Meas.
**2015**, 64, 132–142. [Google Scholar] [CrossRef] - Aiboud, Y.; el Mhamdi, J.; Jilbab, A.; Sbaa, H. Review of ECG Signal de-noising techniques. In Proceedings of the 2015 Third World Conference on Complex Systems (WCCS), Marrakech, Morocco, 23–25 November 2015. [Google Scholar]
- Martinez, A.C.; Pfrimer, F.W.D.; Costa, M.S.; Nakano, A.Y. How to Develop a Single Channel Electrocardiograph with a Low Budget. IEEE Lat. Am. Trans.
**2018**, 16, 1057–1063. [Google Scholar] [CrossRef] - Electrocardiographs-Metrological Characteristics, OIML R90. 1990. Available online: https://www.oiml.org/en/files/pdf_r/r090-e90.pdf (accessed on 16 June 2021).
- Bai, Y.W.; Chu, W.Y.; Chen, C.Y.; Lee, Y.T.; Tsai, Y.C.; Tsai, C.H. The Combination of Kaiser Window and Moving Average for the Low-Pass Filtering of the Remote ECG Signals. In Proceedings of the 17th IEEE Symposium on Computer-Based Medical Systems (CBMS’04), Bethesda, MD, USA, 25 June 2004. [Google Scholar]
- Pandey, V.; Giri, V. High Frequency Noise Removal from ECG using Moving Average Filters,” International Conference on Emerging Trends in Electrical. In Proceedings of the Electronics and Sustainable Energy Systems (ICETEESES–16), Sultanpur, India, 11–12 March 2016; pp. 191–195. [Google Scholar]
- Chaturvedi, R.; Yadav, Y. Application of moving average filter in ECG denoising. World Acad. J. Eng. Sci.
**2014**. [Google Scholar] [CrossRef] - Ama, N.R.N.; Komatsu, W.; Junior, L.M. Single and three phase moving average filter PLLs: Digital controller design recipe. Electr. Power Syst. Res.
**2014**, 116, 276–283. [Google Scholar] [CrossRef] - Guyton, A.C.; Hall, J.E. The Heart. Medical Physiology; Elsevier: Rio de Janeiro, Brazil, 2006; pp. 103–160. [Google Scholar]
- Berne & Levy Physiology; Koeppen, B.M.; Stanton, B.A. (Eds.) Elsevier: Rio de Janeiro, Brazil, 2009; pp. 289–416. [Google Scholar]
- Webster, J.G. (Ed.) Medical Instrumentation: Application and Design; John Wiley & Sons: Hoboken, NJ, USA, 2010. [Google Scholar]
- Hwang, I.D.; Webster, J.G. Direct Interference Canceling for Two-Electrode Biopotential Amplifier. IEEE Trans. Biomed. Eng.
**2008**, 55, 2620–2627. [Google Scholar] [CrossRef] [PubMed] - Dobrev, D. Two-electrode non-differential biopotential amplifier. Med. Biol. Eng. Comput.
**2002**, 40, 546–549. [Google Scholar] [CrossRef] [PubMed] - Ama, N.R.N.; Komatsu, W.; Junior, L.M. Digital Control for PLLs Based on Moving Average Filter: Analysis and Design in Discrete Domain. Rev. Eletrônica De Potência
**2015**, 20, 293–299. [Google Scholar] - PhysioNet. MIT-BIH Arrhythmia Database. 2005. Available online: https://physionet.org/content/mitdb/1.0.0/ (accessed on 16 June 2021).
- Medeiros, J.C.D.O. Principles of Telecommunications: Theory and Practice; Érica: São Paulo, Brazil, 2007. [Google Scholar]
- Electromedical Equipment—Part 2–27: Particular Requirements for Basic Safety and Essential Performance of Electrocardiographic Monitoring Equipment, IEC 60601-2-27; IEC: Geneva, Switzerland, 2013.

**Figure 5.**Bode plot—Module and phase of the MA filter for N = 10, f

_{a}= 1200 Hz, and f

_{c}= 120 Hz.

**Figure 13.**Prototype under analysis. (

**a**) Top view of the prototype; (

**b**) front view of the prototype.

Derivations | Electrodes | Definition |
---|---|---|

Bipolar | BE, BD, and PE | DI = BE − BD DII = PE − BD DIII = PE − BE |

Unipolar Augmented (Goldberg) | BE, BD, and PE | aVR = BD − ½(BE + PE) aVL = BE − ½ (PE + BD) aVF = PE − ½ (BE + BD) |

Unipolar (Wilson) | BE, BD, PE, V1, V2, V3, V4, V5, and V6 | V1 = v1 − (BD + BE + PE)/3 V2 = v2 − (BD + BE + PE)/3 V3 = v3 − (BD + BE + PE)/3 V4 = v4 − (BD + BE + PE)/3 V5 = v5 − (BD + BE + PE)/3 V6 = v6 − (BD + BE + PE)/3 |

Figure | Block | Equation | Parameter | Value |
---|---|---|---|---|

10 | Moving average | (4) | N | 10 |

10 | Gain 1 | - | K_{1} | 180/π |

10 | Compensator | (9) | K | 319.1934263090495 |

10 | Compensator | (9) | A | 0.957437866536668 |

10 | Limiter | - | min | 360 × 50 |

10 | Limiter | - | max | 360 × 70 |

10 | Integrator | (12) | K | 1 |

10 | Integrator | (12) | T_{s} | 1/1200 |

10 | Range_limit | - | min | 0 |

10 | Range_limit | - | max | 360 |

10 | Gain 2 | - | K_{2} | 1/360 |

10 | 2nd LPF | - | num(z) | 1 |

10 | 2nd LPF | - | den(z) | s^{2} + 2.s + 1 |

11 | Adaptive | (13)/(14) | f_{a} | 1200 |

12 | Limiter | - | min | 1 |

12 | Limiter | - | max | 8 |

Data | SNR (dB) |
---|---|

Minimum | 30.60 |

Maximum | 46.99 |

Average | 38.90 |

Variation | 16.39 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Tanji, A.K., Jr.; de Brito, M.A.G.; Alves, M.G.; Garcia, R.C.; Chen, G.-L.; Ama, N.R.N.
Improved Noise Cancelling Algorithm for Electrocardiogram Based on Moving Average Adaptive Filter. *Electronics* **2021**, *10*, 2366.
https://doi.org/10.3390/electronics10192366

**AMA Style**

Tanji AK Jr., de Brito MAG, Alves MG, Garcia RC, Chen G-L, Ama NRN.
Improved Noise Cancelling Algorithm for Electrocardiogram Based on Moving Average Adaptive Filter. *Electronics*. 2021; 10(19):2366.
https://doi.org/10.3390/electronics10192366

**Chicago/Turabian Style**

Tanji, Américo K., Jr., Moacyr A. G. de Brito, Marcos G. Alves, Raymundo C. Garcia, Gen-Lang Chen, and Naji R. N. Ama.
2021. "Improved Noise Cancelling Algorithm for Electrocardiogram Based on Moving Average Adaptive Filter" *Electronics* 10, no. 19: 2366.
https://doi.org/10.3390/electronics10192366