# Ecg Compression Eval

> Evaluates the efficiency and fidelity of ECG signal compression algorithms, focusing on how well they preserve critical clinical features like R-peaks for heart rate variability analysis. Use when the user wants to benchmark on MIT-BIH arrhythmia database, or asks about evaluating this task. Reports PRD.

- Skill: `qhjqhj00/ecg-compression-eval` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/ecg-compression-eval`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/ecg-compression-eval/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Product & Planning
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/ecg-compression-eval

---


# ecg-compression-eval

> A Novel Blaschke Unwinding Adaptive Fourier Decomposition based Signal Compression Algorithm with Application on ECG Signals — Chunyu Tan et al. (2018) (arXiv:1803.06441, 2018)

## What this evaluates

Evaluates the efficiency and fidelity of ECG signal compression algorithms, focusing on how well they preserve critical clinical features like R-peaks for heart rate variability analysis.

## Datasets

- **MIT-BIH arrhythmia database** — total 48; splits: test (48)

## Metrics

- `PRD` **(primary)** — range: percent
  - Percentage Root-mean-square Difference: 100 * sqrt(sum((X_s - X_r)^2) / sum(X_s^2)). Lower values indicate better reconstruction fidelity.
- `CR` — range: ratio
  - Compression Ratio: N_inp / N_out. Higher values indicate better compression efficiency.
- `Se` — range: percent
  - Sensitivity: 100 * TP / (TP + FN). Measures the proportion of actual QRS complexes correctly detected.
- `PPV` — range: percent
  - Positive Predictive Value: 100 * TP / (TP + FP). Measures the proportion of detected QRS complexes that are correct.
- `F1` — range: percent
  - F1-measure: 100 * 2*TP / (2*TP + FN + FP). Harmonic mean of Se and PPV.

## Input / output format

**Input**: 600-sample contiguous, non-overlapping windows of the first lead from MIT-BIH ECG recordings (360Hz, 11-bit resolution).

**Output**: Reconstructed ECG signal window, plus detected QRS peak locations for sensitivity/PPV/F1 calculation.

## Scoring recipe

```python
def compute_metrics(original, reconstructed, detected_peaks, ground_truth_peaks, tolerance_ms=10):
    cr = len(original) / len(reconstructed)
    prd = 100 * math.sqrt(sum((o - r)**2 for o, r in zip(original, reconstructed)) / sum(o**2 for o in original))
    tp = fp = fn = 0
    for gt in ground_truth_peaks:
        if any(abs(gt - det) <= tolerance_ms for det in detected_peaks): tp += 1
        else: fn += 1
    for det in detected_peaks:
        if not any(abs(det - gt) <= tolerance_ms for gt in ground_truth_peaks): fp += 1
    se = 100 * tp / (tp + fn) if (tp + fn) > 0 else 0
    ppv = 100 * tp / (tp + fp) if (tp + fp) > 0 else 0
    f1 = 100 * 2 * tp / (2 * tp + fn + fp) if (2 * tp + fn + fp) > 0 else 0
    return cr, prd, se, ppv, f1
```

## Common pitfalls

- Tolerance for R-peak matching is set to 10ms, which is stricter than the common 50ms used in other studies.
- Compression is evaluated on 600-sample windows to avoid long latency, which may not reflect full-record performance.
- QS metric combines CR and PRD but can be misleading if PRD approaches zero.

## Evidence (verbatim from paper)

> We consider the following measurements to evaluate of the proposed compression algorithm – the compression ratio (CR), the percentage root-mean-square difference (PRD), the quality score (QS) and the signal to noise ratio (SNR).

## Citation

```bibtex
@misc{tan2018ecgcompression,
  title={A Novel Blaschke Unwinding Adaptive Fourier Decomposition based Signal Compression Algorithm with Application on ECG Signals},
  author={Chunyu Tan et al. (2018)},
  year={2018},
  note={arXiv:1803.06441}
}
```

- arXiv: 1803.06441

