# The Effects of Compression on the Detection of Atrial Fibrillation in ECG Signals
## 2 Methods
### Performance Metrics  
Compression ratio (CR) is one of the key characteristics for a compression algorithm. In this work, CR is defined as the ratio of the number of bits in the original signal, \(s_{r}\), divided by the number of bits required for the compressed signal, \(s_{c}\) (see Equation (1)).  
\[CR=\frac{s_{r}}{s_{c}} \tag{1}\]  
A number of measures are used to determine performance of compression algorithms. One of the simplest and most widely-used measures is the Percent RMS Distortion (PRD), which quantifies the amount of signal distortion in the reconstructed signal relative to the original signal. PRD is given by Equation (2) where \(s[i]\) and \(\hat{s}[i]\) indicate the original and reconstructed signals, respectively.  
\[PRD(\%)=\sqrt{\frac{\sum_{i=1}^{N}(s[i]-\widehat{s}[i])^{2}}{\sum_{i=1}^{N}(s [i])^{2}}}\times 100\% \tag{2}\]  
PRD is usually evaluated over a signal segment of length N samples, as indicated in Equation (2). While PRD is a useful measure of signal distortion, it does not adequately capture the functional impact of compression in particular applications, e.g., how compression impacts upon classification accuracy in a diagnostic application. Therefore, in this paper we also evaluate the effect of compression by detecting atrial fibrillation from the reconstructed signal, for different values of CR, using the data from the MIT-BIH AF database. This is carried out using the following approach, and making use of the AF detection algorithm described above. The original ECG waveforms are first compressed at different CRs, and the ECG signal reconstructed from the compressed bit stream. R peaks are located from the reconstructed signals, and the R-R intervals are calculated. To evaluate AF detection accuracy, the R-R series are classified into AF episodes and non-AF episodes using the approach described in Section 2.3. The classification is performed on the basis of 50 consecutive detected R-peak positions, based on previous work in [37; 38]. The Receiver  
Figure 2: Illustration of AF detection algorithm, showing annotations and Shannon entropy.  
Operating Characteristic (ROC) is a commonly-used graphical plot that captures the classification performance of a binary classifier as its detection threshold is varied. The ROC captures the trade-off between the two primary types of error made by a classifier, i.e., false positives and false negatives, as reflected in the standard measures of sensitivity and specificity, defined as follows:  
\[Sensitivity(\%) = TP/(TP+FN); \tag{3}\] \[Specificity(\%) = TN/(TN+FP) \tag{4}\]  
where _TP_ stands for true positives, _TN_ stands for true negatives, _FN_ stands for false negatives, and _FP_ stands for false positives. Sensitivity reports the proportion of detected true episodes out of all true AF episodes, while Specificity reports the proportion of correctly identified non-AF episodes out of all detected beats. The manual annotations provided with the MIT-BIH AF database provide the gold standard used for performance evaluation and calculation of these quantities. A compact and effective way of capturing the overall performance of a classifier, over all of its potential operating points, is to calculate the Area under the ROC (AUC). This takes values from 0 to 1, where a value of 0 indicates complete failure of the detection algorithm, and a value of 1 reflects a perfectly accurate algorithm.