# QRS Detection Based on Medical Knowledge and Cascades of Moving Average Filters
## 3 Results  
The detection performances are reported as F1 scores, which is a global metric of performance. F1 is the harmonic mean of Sensitivity (Se) and Positive Predictive Value (+P)  
\[\text{Se}=\frac{\text{TP}}{\text{TP}+\text{FN}} \tag{5}\]  
\[+\text{P}=\frac{\text{TP}}{\text{TP}+\text{FP}} \tag{6}\]  
\[\text{F1}=\frac{2\ \text{TP}}{2\ \text{TP}+\text{FN}+\text{FP}} \tag{7}\]  
Figure 7: Decreasing dynamic of the detection threshold. At time = 0, a QRS detection has just occurred. Initially, the threshold T/ decreases from 2.4 T\({}^{n+1}\) to T\({}^{n+1}\). During the refractory period, portrayed by the gray area, no detection is registered. As the time elapsed without a detection increases, T/ decreases from T\({}^{n+1}\) to 0.6 T\({}^{n+1}\), then plateaus again. where TP are the true positives, FP are the false positives and FN are the false negatives of QRS detection. Figure 8 shows a strip of ECG signal, its respective absolute derivative, and detection markers for a strip of signal where true positives, false positives, and false negatives are registered. This is an example of a critical instance of signal. The first false positive of Figure 8 is caused by an artifact that closely resembles a QRS complex. This misdetection causes the algorithm to enter its refractory period, thus the next true heartbeat is missed resulting in a false negative. The second false negative is a heartbeat with very low amplitude which is challenging to spot even by eye. As this beat is missed, the adaptive threshold decreases until the second false positive is detected, despite its relatively low amplitude. While these instances of error are not common, they represent the challenging aspects of QRS detection. Heartbeats can be divided in two groups: (1) normal beats, which are originated from the dominant pacemaker, the sinus node and (2) ectopic beats, which are generated by secondary (ectopic) pacemakers. Ectopic beats are often premature and can be atrial, supraventricular or ventricular in origin. Sometimes, sinus beats and ventricular beats collide in a fusion beat. Ectopic beats are expression of cardiac automaticity disorders and can be the hallmark of life-threatening conditions like ventricular tachycardia. The shape of these heartbeats on the ECG can differ substantially from normal beats, and are thus more challenging to detect. This is especially true for beats of ventricular origin. Moreover, conduction disorders like bundle branch blocks can also significantly alter the shape of the normal, healthy ECG pattern. Since bundle branch blocks and ventricular beats are clinically relevant for diagnosis and therapy, we also report sensitivity to these abnormal beats (Se-A)  
\[\text{Se-A}=\frac{\text{TP}^{\text{A}}}{\text{TP}^{\text{A}}+\text{FN}^{\text {A}}} \tag{8}\]  
where TPA and FN\({}^{\text{A}}\) are true positive and false negatives of confusion matrix computed only by considering the heartbeats annotated as: bundle branch block, premature ventricular contractions, R-on-T premature ventricular contractions, fusion beats and ventricular escape beats. Comparing algorithm results to annotations requires the definition of an acceptance window. This is a two-sided interval of appropriate size, centered around annotated beats. When a detected beat falls inside the acceptance window of an annotated beat it is considered a true positive. The following QRS detection results are obtained with a window of 300 ms (+/\(-\) 150 ms). This is the same window size used in Physionet's _bxb_ annotation comparator. To evaluate the performances of the QRS detector we introduced we implemented and operated three publicly available detectors. They are [PERSON]'s _jqrs_[33], [PERSON]'s [25] and [PERSON]'s [34] detectors. [PERSON]'s QRS detector features a Mexican hat pre-processing filter, maximization of the signal's energy in local windows, a fixed threshold and a backward search phase for missed heartbeats.