Skip to content

mat-kie/hrv-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hrv-rs

Pipeline Status Coverage

Hrv-rs is a Rust-based application designed to analyze Heart Rate Variability (HRV) using Bluetooth Low Energy (BLE) chest straps.

Disclaimer

This project is in a very early stage and is not intended for any medical applications.

Features

  • Bluetooth Connectivity:
    • Scan and connect to BLE chest straps that provide R-R interval data.
  • HRV Analysis:
    • Compute HRV metrics such as RMSSD, SDRR, SD1, SD2, and Poincaré plots.
    • Visualize HRV statistics in real-time.

HRV Metrics

  • RMSSD: Root Mean Square of Successive Differences between R-R intervals.
  • SDRR: Standard Deviation of R-R intervals.
  • SD1/SD2: Short- and long-term HRV metrics derived from Poincaré plots.
  • Poincaré Plot: A scatter plot of successive R-R intervals.

Getting Started

Prerequisites

  • A BLE-compatible chest strap for HRV measurement.
  • A system with BLE support.

Installation

  1. Clone the repository:

    git clone https://github.com/mat-kie/hrv-rs.git
    cd hrv-rs
  2. Build the project:

    cargo build --release
  3. Run the application:

    cargo run --release

Code Structure

Architecture

The project uses a modular, event-driven MVC architecture.

Modules

1. Core

  • Constants: Application-wide constants.
  • Events: Defines application events, including user interactions and system updates.
  • View Trait: Trait definitions for views.

2. Controller

  • Acquisition: Handles data acquisition from BLE devices.
  • Application: Orchestrates application logic, including transitions between views.
  • Bluetooth: Manages Bluetooth adapters, device discovery, and communication.

3. Model

  • Acquisition: Handles runtime and stored data related to HRV measurement sessions.
  • Bluetooth: Represents BLE devices, adapters, and connections.
  • HRV: Structures and methods for storing, calculating, and retrieving HRV statistics.
  • Storage: General data storage and processing.

4. Math

  • HRV: Functions and structures for HRV computation.

5. View

  • Acquisition: UI for managing Bluetooth connections and data acquisition.
  • Overview: Displays computed HRV statistics and visualizes Poincaré plots.
  • Manager: Coordinates transitions between views and manages their lifecycle.

License

This project is licensed under the GNU General Public License. See the LICENSE file for details.

Acknowledgments

This project uses the following libraries. Please refer to the Cargo.toml file for an up-to-date overview:

  • Rust Language: The programming language that powers this project.
  • egui: A simple, immediate-mode GUI library for Rust.
  • egui_extras: Extensions for egui for richer GUI elements.
  • egui_plot: A plotting library built for egui.
  • eframe: An easy-to-use framework for building GUI applications in Rust using egui.
  • image: A library for image processing, used for handling PNGs and more.
  • rfd: A cross-platform file and folder dialog library.
  • env_logger: A flexible and human-readable logging library.
  • btleplug: A Bluetooth Low Energy library for interacting with BLE devices.
  • uuid: A library for generating and handling UUIDs.
  • tokio: An asynchronous runtime for the Rust programming language.
  • futures: Asynchronous programming utilities for Rust.
  • nalgebra: A linear algebra library for efficient mathematical computations.
  • time: A library for date and time handling, with serialization support.
  • log: A lightweight logging facade for Rust.
  • serde: A framework for serializing and deserializing Rust data structures.
  • serde_json: A library for working with JSON in Rust.
  • mockall: A mocking library for testing.