# QRS Detection Based on Medical Knowledge and Cascades of Moving Average Filters
## 1 Introduction  
Electrocardiography is the recording of the electrical activity originated by the heart in its duty cycle. The analysis of both rhythm and shape of the characteristic PQRST pattern can reveal altered conditions of the cardiac system. Software-based analysis of the electrocardiogram is a valuable tool, even more so with the increased presence of portable and wearable systems. The first and foremost step of ECG software analysis is heartbeat detection, specifically the ventricular systole which is represented by the combination of the Q, R, and S characteristic waves, the QRS complex. In the ECG analysis pipeline the accuracy of heartbeat detection determines the result quality of the following stages. Thus, this first step should be as accurate as possible. The main limiting factors in QRS detection accuracy are undesired noise, prominent T waves, and abnormal (non-sinus) beats. Scientific literature on heartbeat detection is rich, and several approaches have been proposed over time. The most notable and referenced is [PERSON] algorithm [1], to which newer approaches are still compared to. Their work is based on differentiation, rectification and integration of the filtered ECG signal and a decision threshold calculated from the estimates of signal and noise levels. Several techniques have been applied to QRS detection [2], like filter banks, neural networks, wavelets, and other means of signal decomposition. Recently, [PERSON] [3] introduced quadratic filtering to QRS detection that attempts a thorough frequency characterization of the ECG. Wavelet-based processing has been a mainstay of ECG processing and heartbeat detection [4; 5; 6; 7]. [PERSON] et al. [8] and [PERSON] et al. [9] proposed methods based on empirical mode decomposition while [PERSON] et al. [10] proposed an algorithm consisting in a set of rules applied on variable frequency complex demodulation, a time-frequency representation. Another time-frequency representation was applied in QRS detection by [PERSON] et al. [11], the S-Transform. [PERSON] et al. [12] proposed a QRS peak search logic based on the Hilbert transform applied to the single-step derivative of frequency-filtered ECG. [PERSON] et al. [13] used a finite state machine as a dynamic threshold for QRS complexes. Data-driven machine learning methods have also been applied in this field, notably convolutional neural networks [14; 15]. [PERSON] and [PERSON] [16] reported very high performances on two databases using convolutional neural networks. Lately, researchers have published several QRS detection algorithms specifically designed for wearable applications [17; 18; 19] due to the increasing interest towards ambulatory, daily monitoring [20]. Early detection of cardiac abnormalities may significantly improve the outcome of therapeutic efforts and the general quality of life of the patient. Often, these algorithms designed for wearable applications are based on established, low complexity ECG processing techniques as bandpass filters, single-step derivatives, signal integration, and adaptive amplitude and/or length thresholds. Derivative transforms are often used to enhance the QRS complex [1; 21; 22], however in the discreet time domain there are several ways to compute the derivative [2]. Single-step derivative transformations, as in \(\mathrm{s}[\mathrm{n}]-\mathrm{s}[\mathrm{n}-1]\), are inherently susceptible to noise. Wider derivative transforms that take in account multiple samples reduce this tendency due to their band-pass behavior. Complex approaches may afford the highest of performances, at the cost of increased computational load. When heartbeat detection is performed in battery-driven devices, the computational cost of the QRS detection algorithm should also be contained. One of the possible approaches for a lightweight QRS detection is a combination of moving average filters. Moving average filters require few operations and have been shown to be viable in ECG processing.