Skip to content

HBClab/boost-hr-py

Repository files navigation

HBC Heart Rate QC and Adherence Reporting

Pipeline for quality control (QC) of Polar heart rate CSVs and zone adherence reporting for the BOOST study. The main entrypoint scans supervised and unsupervised sessions, runs QC checks, computes zone metrics, and writes summary CSVs for reporting.

Project layout

  • hr/main.py - Main pipeline entrypoint and orchestration.
  • hr/util/ - File discovery and data extraction helpers.
  • hr/qc/ - QC checks and output writers.
  • hr/plot/ - Helpers for assembling plotting metadata.
  • hr/tests/ - Pytest coverage for zone metrics. (excluded from git but available upon request)
  • docs/meta_plot/ - Saved plots and HTML outputs.
  • rust-ols-adherence-cli/ - Optional Rust CLI for OLS/WLS modeling.
  • environment.yml - Conda environment definition.
  • flake.nix, dev-shells/ - Nix-based dev shells.
  • qc_out.csv, zone_out.csv - Output artifacts (generated).
  • variable_dictionary.txt - Metric dictionary (if maintained here).

Data expectations

The pipeline expects the BOOST data tree and file naming conventions below. Paths are derived from system in hr/main.py:

Base paths:

  • Argon -> /Shared/vosslabhpc/Projects/BOOST/
  • Home -> /mnt/lss/Projects/BOOST/
  • vosslnx -> /mnt/nfs/lss/vosslabhpc/Projects/BOOST/

Expected inputs:

  • Zone sheet: InterventionStudy/1-projectManagement/participants/ExerciseSessionMaterials/Intervention Materials/BOOST HR ranges.xlsx
  • HR CSVs: InterventionStudy/3-experiment/data/polarhrcsv/{Supervised,Unsupervised}/sub###/*.csv

File naming pattern used by QC:

  • Week extracted from _wk## in filename.
  • Session extracted from _wk##_ses##.

If week or session tokens are missing, the file is skipped and logged.

Setup

Conda (recommended):

conda env create -f environment.yml
conda activate boost-hr

Nix (optional):

nix develop

Run the pipeline

Run from the repo root:

python hr/main.py Argon

Allowed system arguments are Argon, Home, and vosslnx. The script logs to main.log and writes outputs to the repo root.

Outputs

  • qc_out.csv - QC errors/warnings per file (missing gaps, long NaN runs, bounded time failures).
  • zone_out.csv - Per-session zone metrics (time in allowed zones, time above/below, longest bounded bout, MAZD).
  • main.log - Run log with warnings for skipped or malformed files.

Both CSVs are regenerated on each run.

QC logic summary

  • Missing data check: gaps > 30 seconds.
  • NaN run check: > 30 consecutive NaNs.
  • Zone QC: weekly plan rules for supervised weeks 1-6 and unsupervised weeks 7-12.

See hr/qc/sup.py and hr/qc/zone/zone_qc.py for details.

Tests

Run from the repo root:

pytest hr/tests

Rust adherence model (optional)

The rust-ols-adherence-cli subproject fits OLS/WLS models for supervised vs. unsupervised adherence. See rust-ols-adherence-cli/README.md for data format and usage.

Notes

  • If you need to export the master adherence data for the Rust CLI, see the commented gd.save_for_rust(...) line in hr/main.py.
  • Plot artifacts in docs/meta_plot/ are static outputs and not regenerated by default.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors