Heart Rate Calculation

The heart rate displayed in the application is a median calculated over the last 5 beats.

This filtering provides a stable reading that is robust against outliers (like missed beats or artifacts) while remaining highly responsive to rapid changes in heart rate (e.g., onset of exercise).

The calculation uses the RR intervals derived from the processed ECG signal:

  1. The last 5 RR intervals are collected.
  2. The median interval is selected (the middle value when sorted).
  3. The Heart Rate is derived from this median interval: HR = 60,000 / Median_RR_ms.