Giter Site home page Giter Site logo

sdimi / cardiofitness Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 2.0 3.3 MB

๐Ÿ’ช Predict lab-measured cardio fitness (VO2max) through wearables in free-living environments (code for Nature Digital Medicine '22 paper)

Home Page: https://doi.org/jpcc

License: GNU General Public License v3.0

Python 0.75% Jupyter Notebook 99.25%

cardiofitness's Introduction

CardioFitness โ€” VO2max prediction with wearables

๐Ÿ“– Longitudinal cardio-respiratory fitness prediction through wearables in free-living environments

code for Nature Digital Medicine '22 paper

header image

Abstract (click to expand)

Cardiorespiratory fitness is an established predictor of metabolic disease and mortality. Fitness is directly measured as maximal oxygen consumption (VO2max), or indirectly assessed using heart rate responses to standard exercise tests. However, such testing is costly and burdensome because it requires specialized equipment such as treadmills and oxygen masks, limiting its utility. Modern wearables capture dynamic real-world data which could improve fitness prediction. In this work, we design algorithms and models that convert raw wearable sensor data into cardiorespiratory fitness estimates. We validate these estimates' ability to capture fitness profiles in free-living conditions using the Fenland Study (N=11,059), along with its longitudinal cohort (N=2,675), and a third external cohort using the UK Biobank Validation Study (N=181) who underwent maximal VO2max testing, the gold standard measurement of fitness. Our results show that the combination of wearables and other biomarkers as inputs to neural networks yields a strong correlation to ground truth in a holdout sample (r = 0.82, 95CI 0.80-0.83), outperforming other approaches and models and detects fitness change over time (e.g., after 7 years). We also show how the model's latent space can be used for fitness-aware patient subtyping paving the way to scalable interventions and personalized trial recruitment. These results demonstrate the value of wearables for fitness estimation that today can be measured only with laboratory tests.

This repository. We provide the code to reproduce the experiments of the paper [1]. We cannot share the entire dataset due to privacy limitations that safeguard health data, however we provide some real data samples (see below). The main input is a chest ECG device which recorded heart rate and movement in 15-second intervals. For the prediction task, the most important outcome is VO2max (cardiorespiratory fitness), measured with a treadmil test. We have pre-processed the data by extracting statistical features. Then we train models using the Fenland I cohort and evaluate them using the Fenland II and BVS cohorts. We provide Python files and Jupyter notebooks with all figures/visualizations included in the paper.

๐Ÿ› ๏ธ Requirements

The code is written in python 3.6.0. The main libraries needed to execute the code will be installed through:

pip install -r requirements.txt

You might also need some extra helper libraries like tqdm (prettier for-loops) but they are not mandatory.

๐Ÿ—‚๏ธ Data

We use data from the Fenland Study and the Biobank Validation Study. We cannot publicly share this data but it is available from the MRC Epidemiology Unit at the University of Cambridge upon reasonable request. To facilitate easier testing of our code, we provide small samples with the same vector shapes and naming conventions. See data/extracted_features for the features and their order and data/vo2max_F1 for the laboratory treadmill data sample and the data dictionary. Raw sensor signals from a randomly selected participant are provided in /data/FL_511496R.dta.

โ–ถ๏ธ Run

All experiments can be found in python files. Considering that we cannot share the entire datasets but only a single user feature vector, your results will be different than our paper. The hyperparameter tuning was done in a SLURM cluster, and the contribution of the hyperparams was evaluated on the validation set.

To extract features and train the task 1 models, run:

python3 "01_data_extraction.py"
python3 "02_training_task1.py"

To train the task 2 "delta" models, run:

python3 "02_training_task2_binary.py"
python3 "02_training_task2_continuous.py"

Last, to evaluate the models on task 3 using new Fenland II sensor data, run:

python3 "03_inference_task3_FenlandIIsensors.py"

The figures/results included in the paper can be found in /visualization. Please note that these notebooks use the entire datasets, not the sample provided in this repository.

Pre-trained models

We provide the best model and its weights for Task 1 (called comprehensive model in the paper) in the folder /models/20201109-013142. This model can be used as is to predict VO2max values following the pre-processing pipeline in 01_data_extraction.py and 02_training_task1.py.

How to cite our paper

Please consider citing our paper if you use code or ideas from this project:

[1] Dimitris Spathis, Ignacio Perez-Pozuelo, Tomas I. Gonzales, Yu Wu, Soren Brage, Nicholas Wareham, Cecilia Mascolo. "Longitudinal cardio-respiratory fitness prediction through wearables in free-living environments.", Nature Digital Medicine, 2022.

Relevant papers from the same project:

[2] Dimitris Spathis, Ignacio Perez-Pozuelo, Soren Brage, Nicholas J. Wareham, Cecilia Mascolo. "Self-supervised transfer learning of physiological representations from free-living wearable data." In Proceedings of ACM Conference on Health, Inference, and Learning (CHIL), USA, 2021.

[3] Dimitris Spathis, Ignacio Perez-Pozuelo, Soren Brage, Nicholas J. Wareham, Cecilia Mascolo. "Learning Generalizable Physiological Representations from Large-scale Wearable Data." In NeurIPS Machine Learning for Mobile Health workshop, Vancouver, Canada, 2020.

[4] Chi Ian Tang, Ignacio Perez-Pozuelo, Dimitris Spathis, Soren Brage, Nick Wareham, Cecilia Mascolo. "SelfHAR: Improving Human Activity Recognition through Self-training with Unlabeled Data." In Proceedings of the ACM on Interactive, Mobile, Wearable and Ubiquitous Technologies, Volume 5, Issue 1, 2021.

[5] Wu, Yu, Dimitris Spathis, Hong Jia, Ignacio Perez-Pozuelo, Tomas Gonzales, Soren Brage, Nicholas Wareham, and Cecilia Mascolo. "UDAMA: Unsupervised Domain Adaptation through Multi-discriminator Adversarial Training with Noisy Labels Improves Cardio-fitness Prediction." Machine Learning for Healthcare (MLHC), USA, 2023.

License

This code is licensed under the terms and conditions of GPLv3 unless otherwise stated. The actual paper is governed by a separate license and the paper authors retain their respective copyrights.

cardiofitness's People

Contributors

sdimi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.