A vendor-abstract health data library.
Project description
MeasureMe (Core Library)
The MeasureMe project is an open source Python library for storing health data in a vendor agnostic way. It utilizes SQLAlchemy to provide a privacy-first, local database (SQLite/MariaDB) to store your metrics safely without requiring cloud servers.
Integrations are required to fetch data from proprietary sources and write them to the database.
Installation
Requires Python 3.9+.
Use pip to install:
pip install measureme
For local development, clone the repository and install the development requirements:
pip install -r requirements-dev.txt
Example
How to use MeasureMe:
FitBit Ingestion
An example script has been provided that ingests FitBit data, exported using Google Takeout.
The script relies on FitOut, which is installed via pypi:
pip install fitout
Export FitBit Data using Google TakeOut
Export your FitBit data, using Google Takeout.
Once the export is complete, download the zip file. I use C:/Dev/Fitbit/Google/.
This directory is the takeout_dir.
Ingest the Data
The ingest_fitout is available as a callable script, and can be used directly:
ingest_fitout "C:/Dev/Fitbit/Google/takeout-20260320T162823Z-3-001.zip" --start 2024-01-01 --end 2026-03-20
By default, this will create and populate a local SQLite database named measureme_dev.db in the current directory.
Once the data has been ingested, it can be queried using the MeasureMe library.
See the tool README for full details.
Trivial Example
For the full, runnable script, see examples/basic_query.py.
from measureme.database import get_engine, get_session_maker
from measureme.models import HealthMetric, HealthSession
engine = get_engine("sqlite:///measureme_dev.db")
Session = get_session_maker(engine)
with Session() as session:
# Query the 5 most recent sleep sessions
recent_sleep = session.query(HealthSession)\
.filter(HealthSession.session_type == 'sleep')\
.order_by(HealthSession.start_time.desc())\
.limit(5).all()
for sleep in recent_sleep:
duration_hrs = sleep.duration_seconds / 3600.0 if sleep.duration_seconds else 0
print(f"Date: {sleep.start_time.date()}, Duration: {duration_hrs:.2f} hours")
Plotting Example with Numpy and Matplotlib
Note: To run this example, you will need to install the dependencies:
pip install matplotlib numpy PyQt6
For the full, runnable script, see examples/plot_calmness.py.
import numpy as np
import fitout as fo
from measureme.database import get_engine, get_session_maker
from measureme.models import HealthMetric
# 1. Fetch raw data from MeasureMe
# ... (Querying logic omitted for brevity) ...
# 2. Extract database rows into lists aligned to continuous dates
breathing_raw = extract_aligned_data(metrics, dates, 'breathing_rate')
hrv_raw = extract_aligned_data(metrics, dates, 'hrv_rmssd')
rhr_raw = extract_aligned_data(metrics, dates, 'resting_heart_rate')
# 3. Apply cleaning algorithms (Clean-On-Read feature via FitOut helpers)
breathing_data = fo.fill_missing_with_neighbours(breathing_raw)
hrv_data = fo.fill_missing_with_neighbours(hrv_raw)
breathing_data = fo.fix_invalid_data_points(breathing_data, 10, 20)
hrv_data = fo.fix_invalid_data_points(hrv_data, 20, 50)
# 4. Create the Derived Calmness Metric and plot!
breathing_arr = np.array(breathing_data).astype(float)
hrv_arr = np.array(hrv_data).astype(float)
rhr_arr = np.array(rhr_data).astype(float)
# Equation: 100 - (RHR/2 + breathing rate*2 - HRV)
calmness_index = 100 - (rhr_arr / 2. + breathing_arr * 2. - hrv_arr)
More Examples
For more examples, see the examples directory.
Contributing
If you'd like to contribute to MeasureMe, follow the guidelines outlined in the Contributing Guide.
License
See LICENSE.txt for more information.
Contact
For inquiries and discussion, use MeasureMe Discussions.
Issues
For issues related to this Python implementation, visit the Issues page.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file measureme-1.2.1.tar.gz.
File metadata
- Download URL: measureme-1.2.1.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0699eb1af9ebd80daf9e625eaff13c8786726fffa6f1e05b123d608a102e7e98
|
|
| MD5 |
a7d49d2a99cc86627aa23595e78093e9
|
|
| BLAKE2b-256 |
289a6c4326de3d233bfd45191e8e9585dd51526140fcc90980ca9370363e4249
|
Provenance
The following attestation bundles were made for measureme-1.2.1.tar.gz:
Publisher:
python-publish.yml on kev-m/MeasureMe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
measureme-1.2.1.tar.gz -
Subject digest:
0699eb1af9ebd80daf9e625eaff13c8786726fffa6f1e05b123d608a102e7e98 - Sigstore transparency entry: 1203452666
- Sigstore integration time:
-
Permalink:
kev-m/MeasureMe@9fae53d85bcaa494077997c88c055b3b5d9b7133 -
Branch / Tag:
refs/tags/core-v1.2.1 - Owner: https://github.com/kev-m
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9fae53d85bcaa494077997c88c055b3b5d9b7133 -
Trigger Event:
release
-
Statement type:
File details
Details for the file measureme-1.2.1-py3-none-any.whl.
File metadata
- Download URL: measureme-1.2.1-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdff5d8c982cbc4bf115e4e16431f3cc1e52a12a4807efb065b2d25f06a4e44a
|
|
| MD5 |
21af47dd692e891ba50e63e6e8984b61
|
|
| BLAKE2b-256 |
c37e1aade77ad265cbcefcf607f280b0df76348756e089937285fce802091c76
|
Provenance
The following attestation bundles were made for measureme-1.2.1-py3-none-any.whl:
Publisher:
python-publish.yml on kev-m/MeasureMe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
measureme-1.2.1-py3-none-any.whl -
Subject digest:
cdff5d8c982cbc4bf115e4e16431f3cc1e52a12a4807efb065b2d25f06a4e44a - Sigstore transparency entry: 1203452670
- Sigstore integration time:
-
Permalink:
kev-m/MeasureMe@9fae53d85bcaa494077997c88c055b3b5d9b7133 -
Branch / Tag:
refs/tags/core-v1.2.1 - Owner: https://github.com/kev-m
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9fae53d85bcaa494077997c88c055b3b5d9b7133 -
Trigger Event:
release
-
Statement type: