# A Complete Pipeline for Heart Rate Extraction from Infant ECGs
## 2 Materials and Results
### The ECG Pipeline
#### 2.2.1 Existing ECG Approaches  
Firstly, 12 open source pre-existing ECG methods (Table 2) were applied to Datasets A and B. These approaches represented the available open source methods for R-peak extraction. Based on an investigation of open source approaches, three separate Python packages that contained all or a subset of these methods were initially considered--HeartPy, Neurokit2, and py-ecg detectors. However, all ECG methods in py-ecg detectors were found to contain matching implementations in Neurokit2, without the flexibility to implement preprocessing and the peak detection of a method separately. This reduced the selection of ECG methods to those found in the HeartPy and Neurokit2 packages--the default HeartPy method and 11 other approaches from the Neurokit2 package (including the default Neurokit2 approach). The open source nature of Neurokit2 meant that some methods may match more closely than others to the authors' original intentions. Figure 3: Age of participant vs. length of recording. (**a**) Dataset A: the recordings are roughly grouped into cohorts of 2.9–7.9 months (\(n=25\), M\({}_{\text{age}}=5.8\) months), 8–10.9 months (\(n=15\), M\({}_{\text{age}}=9.3\) months), 11–19.9 months (\(n=23\), M\({}_{\text{age}}=13.4\) months), and 20–42.3 months (\(n=34\), M\({}_{\text{age}}=30.8\) months). (**b**) Dataset B: the recordings are grouped into cohorts of 5.6–8.9 months (\(n=15\), M\({}_{\text{age}}=7.1\) months) and 9–13.0 months (\(n=10\), M\({}_{\text{age}}=10.7\) months). (**c**) Dataset C: the recordings are grouped into cohorts of 5.3–7.9 months (\(n=7\), M\({}_{\text{age}}=5.8\) months) and 8–10.4 months (\(n=5\), M\({}_{\text{age}}=9.5\) months). All y-axes and x-axes have different scales. A consistent colour-scale for age is used in all subplots, with each colour representing a specific age. Almost all methods within the Neurokit2 package were tested, but some were excluded. A sum-slope approach [40] was initially tested but then excluded due to very poor performance (to the point that including it in the analysis made it hard to visualise the other results). An approach by [PERSON] and [PERSON] [41] relied on visibility graphs, but was much slower than other methods, requiring an additional package to work. Two methods did not successfully run when tested within the Neurokit2 framework: an approach by [PERSON] [34] and a Probabilistic Methods Agreement via Convolution (ProMAC) approach, which combined the results of other peak-detection methods. The ProMAC method, which relies on other approaches, likely failed because the [PERSON] method also failed. Aside from these exclusions, which were made for reasons of performance, our analysis captured all open source approaches to R-peak labelling in ECGs within common Python packages. It is acknowledged that proprietary measures for measuring infant ECGs may well exist as part of commercial innovations and research. The specificity, sensitivity, and positive predictive value (PPV) of the methods were then compared against a ground truth set of labels (Figures 4 and 5). Specificity penalises incorrect peak selection, and PPV identifies the ratio of correctly identified peaks out of all the peaks identified for a given method. Given the sparsity of peaks within a signal, both measures tend to be preferable due to their inclusion of false positives within the denomi