# QRS Detection Based on Medical Knowledge and Cascades of Moving Average Filters
## 1 Introduction
[PERSON] [23] proposed an algorithm where two moving averages were used to determine blocks of interests. Knowledge-based thresholds on the duration of the blocks assessed the presence of the QRS complex. Considering 109,985 beats in the MIT-BIH Arrhythmia database [24], [PERSON] reported an F1 score for his work of 99.82%. [PERSON] et al. [25] proposed a method based on the energy of the signal and its rate of change. This was done by applying moving average filters to the squared and differentiated ECG filtered signals. QRS complexes were detected though a set of amplitude and duration thresholds in both energy level and energy rate of change. On the MIT-BIH Arrhythmia database the reported F1 score for this method was 99.91%, considering 109,494 beats. [PERSON] et al. [4] used the moving average as a high-pass filter, combined it with wavelet denoising and then squared the high-pass filtered signal. QRS complexes were found with an adaptive threshold on the squared signal. This algorithm achieved an F1 score of 99.52% on the MIT-BIH Arrhythmia database, considering 102,654 beats. In [PERSON] et al. [26], the ECG signal was filtered with a moving average, band-pass filter and then differentiated. A noise index automatically excluded noisy channels which would reduce detection accuracy. This algorithm achieved an F1 score of 99.78% on the MIT-BIH Arrhythmia database, considering 109,494 beats. All the aforementioned methods employ moving average filters in some form. The performance scores of QRS detectors are customarily computed on standard databases, like the MIT-BIH Arrhythmia database. In theory, such practice should allow a straightforward comparison between different methods. Yet, different authors often adopt different inclusion criteria for the records in the databases. As an example, records 108 and 207 are sometimes excluded from the evaluation of the confusion matrix due to the abnormal shapes taken by the ECG signal [2]. Moreover, different authors may use different acceptance window values for QRS complex positives. For these reasons, comparing published results could be incorrect, as they may have been calculated on different records and/or with a different acceptance window. On the other hand, some authors compare the algorithm they propose with pertinent literature by rewriting the corresponding routines. However, the description is often not complete enough and the re-written routines do not replicate the published performances. In this paper, we directly compare performances of different QRS detection methods computed using the same rules. To this end we considered the best performing QRS detection softwares we found available to our knowledge. We did not edit the code of the detection routines of other authors in any way. Authors of QRS detection literature often report performances on a single database. This is the case for many of the works mentioned above. While the printed results may be excellent, the generalizability of the proposed methods to real world data remains indeterminate. For this reason, we included several databases in the evaluation of our work. When optimizing an algorithm on several data sources, overperforming on a single data source may considerably reduce the accuracy achieved on the other databases. In this paper, we propose a fast, accurate approach to QRS detection based on combining simple unweighted moving averages. In particular, the basic elements of our ECG signal processing are cascades of moving averages (MACs). Our algorithm enhances the QRS complex by selecting a MAC from a pool of wide, derivative MACs that are inherently resistant to noise. We compare the performance of the QRS detector with those of three public algorithms, both in terms of accuracy and execution time, on the same calculator and the same initial conditions. The algorithm we propose aims to be an efficient, accurate, and generalizable method for QRS detection that improves on the concept of derivative transforms. Our software was developed with MATLAB (The Mathworks Inc., Natick, MA, USA).