❤️⚡ CARDIO-RS ⚡❤️
A Rust library for Heart Rate Variability (HRV) analysis!
📊 Compute HRV time-domain & frequency-domain & geometric metrics from RR intervals with ease!
💓 Preprocess ECG & PPG raw data for accurate HRV analysis!
📟 Supports embedded systems with no_std!
✨ Features
✅ Time-domain HRV metrics: SDNN, RMSSD, PNN50, SDSD, CVSD, and more!
✅ Frequency-domain HRV metrics: LF, HF, VLF using Welch’s method!
✅ Geometric-domain HRV metrics: Triangular Index & TINN!
✅ ECG & PPG preprocessing: Filtering, denoising, peak detection!
✅ Raw & interpolated RR intervals supported!
✅ 🚀 no_std compatibility!
✅ Window Analysis: Split data into windows of a defined size for segment-based HRV analysis.
✅ Live Analysis: Perform real-time HRV analysis with customizable pipelines for processing RR intervals!
📏 Time-domain HRV Metrics
- 🔹 RMSSD – Measures short-term HRV.
- 🔹 SDNN – Measures overall HRV.
- 🔹 PNN50 – Percentage of successive RR intervals > 50ms.
- 🔹 SDSD – Standard deviation of successive differences.
- 🔹 Mean HR – Average heart rate.
- 🔹 AVNN – Mean of all RR intervals.
- 🔹 CVSD – RMSSD divided by the mean RR interval.
📐 Geometric HRV Metrics
- 📊 Triangular Index – Measures RR interval distribution.
- 📊 TINN (Triangular Interpolation of NN Interval Histogram) – Estimates RR variability.
🎵 Frequency-domain HRV Metrics
📡 Computed using Welch’s method for spectral density estimation:
- 🎼 LF (Low Frequency) – Sympathetic & parasympathetic balance (0.04 - 0.15 Hz).
- 🎼 HF (High Frequency) – Parasympathetic activity (0.15 - 0.40 Hz).
- 🎼 VLF (Very Low Frequency) – Long-term regulatory processes (0.003 - 0.04 Hz).
🏥 ECG & PPG Data Processing
📡 ECG Processing – R-wave peak detection, filtering, and RR extraction!
💡 PPG Processing – Pulse detection & signal cleaning for HRV computation!
🪟 Window Analysis
Cardio-rs supports window analysis, where your data can be split into windows of a defined size. This feature is ideal for segment-based HRV analysis, where the data is divided into distinct time periods (windows).
Example:
use ;
let data = vec!;
// Create the window analysis builder
let analysis = new
.with_window_size
.build;
// Get the HRV metrics for each window
println!;
This allows you to perform HRV analysis on distinct segments of data, making it ideal for scenarios where you want to analyze specific time periods independently.
🔄 Live Analysis
The live analysis module enables real-time HRV analysis, processing incoming RR intervals and calculating HRV metrics dynamically. This allows you to process data in real-time as it is received.
You can define a custom analysis pipeline for processing the data, enabling flexible and modular HRV calculations. A default pipeline is provided for standard HRV calculations.
Example:
use ;
use RR_INTERVALS;
let mut queue = new;
let rr_intervals = RR_INTERVALS.to_vec;
for interval in rr_intervals
let hrv = queue.get_hrv;
println!;
🦀 Example Usage
🚀 Compute HRV Metrics & Load ECG Data
use ;
let path = "tests/ecg.csv";
let signal = "ECG_Raw";
let rate = 1000.;
let hrv_metrics = standard_analysis!;
println!;
🔥 Start analyzing HRV today with cardio-rs! 🚀💓