## 4 WFDB Window-Based Evaluation
### Allowable Window Tolerance  
Another issue observed in the literature is the ambiguity of the acceptable window tolerance. Online WFDB documentations mention a window of 150 ms or 0.15 s without specifying the acceptable \(\pm\) tolerance range, whether it is \(\pm\)75 ms [44] or \(\pm\)150 ms [30], as shown in Figure 5a. There is further confusion about whether the WFDB R-peak validation tools use exact \(\pm\)75, \(\pm\)150 sample values or any other sample limits. Online resources typically indicate a window size of 0.15 s, but R-peak validation is usually conducted on samples. Therefore, the time unit must be converted first into samples as  
\[\text{Sample Size}=0.15\times\text{F}_{\text{s}} \tag{5}\]  
where Fs is the sampling frequency of the validated dataset. For the MIT-BIH arrhythmia database with sampling frequency of 360 Hz, a \(\pm\)150 ms window corresponds to \(\pm\)54 samples, and a \(\pm\)75 ms window corresponds to \(\pm\)27 samples, as shown in Figure 5b.  
The actual allowable sample limit for the R-peak validation window is \(\pm\)54 samples or \(\pm\)150 ms. To confirm this acceptable tolerance range, one can take the following steps:  
Figure 4: Case-based analysis of window size and its effect on FPs/FNs. (**a**) presents case study 1 featuring record 108 from the MIT-BIH dataset. (**b**) displays case study 2 with record 203 from the MIT-BIH arrhythmia dataset. These cases are included to demonstrate how altering window size can affect FP and FN counts.  
Figure 5: Acceptable Window Sample Tolerance. (**a**) Window tolerance reported in literature and (**b**) window tolerance in samples.  
1: Choose a single reference sample value, for example, 550.  
2: Calculate the predicted sample value by adding or subtracting 28 samples from the reference sample value. In this case, subtract 28 samples from 550 to obtain the predicted sample of 522.  
3: When validating using WFDB tools with the AAMI benchmark window size of 0.15 s, it doubles the window size to cover the entire R-wave by uniformly distributing the total size of 0.30 s on either side of the reference annotation.  
4: During validation, check for FNs and FPs. If they are reported, the allowable tolerance for the benchmark of 150 ms is \(\pm\)75 ms or \(\pm\)27 samples, as shown in Figure 6, because our predicted sample exceeds the window size by \(\pm\)1 sample. If FNs and FPs are not reported, then the allowable tolerance would be \(\pm\)54 samples for a 150 ms window, which is equivalent to a \(\pm\)150 millisecond tolerance.  
This proves that whenever a WFDB R-peak validation tool is used with a window size of 0.15 s (or 150 ms), it employs a tolerance of \(\pm\)54 samples or \(\pm\)150 ms before and after the reference annotation, effectively doubling the window size to 0.3 ms to check if the predicted sample is within or outside this evenly distributed window size. The reason for \(\pm\)tolerance is because the prediction can be either side of the reference R-peak time location. While WFDB validation tools handle this automatically, custom validation methodologies require implementation of this mechanism, rather than simply defining the window size of 0.15 s. Therefore, it is important to specify the tolerance used, whether \(\pm\)75 ms or \(\pm\)150 ms.