IMU Wear-Time Detection
A Python library providing validated wear-time detection algorithms for lower-back worn IMU sensors. Includes both established methods from the literature and novel signal processing, machine learning, and deep learning approaches.
This library was developed as part of the SUSTAIN Mobilise-D project and implements algorithms designed to work within the MobGap ecosystem for mobility analysis.
Novel algorithms outperform all literature methods by 8- to 131-fold in wear-time quantification accuracy.
Software developed by Dr Dimitrios Megaritis. Scientific authorship is listed in CITATION.cff.
Installation
From PyPI (recommended)
pip install imu-weartime
From source
git clone https://github.com/[username]/imu-weartime.git
cd imu-weartime
pip install .
Quick Start
from mobgap.data import LabExampleDataset
from mobgap.utils.conversions import to_body_frame
from imu_weartime.weartime import WtdMegaritis_CNN
# Load example data
data = LabExampleDataset().get_subset(
cohort="HA", participant_id="001", test="Test11", trial="Trial1"
)
# Apply wear-time detection
wtd = WtdMegaritis_CNN(version="cnn_lstm").detect(
to_body_frame(data.data_ss),
sampling_rate_hz=data.sampling_rate_hz
)
print(f"Total wear-time: {wtd.total_weartime_hours_:.2f} hours")
print(wtd.weartime_list_)
Available Algorithms
Novel Algorithms (Megaritis et al.)
Developed and validated specifically for this library (ranked by performance):
-
WtdMegaritis_CNN- Deep learning with 1D CNN and CNN-LSTM variants (best-performing)- Versions:
"cnn"(baseline) or"cnn_lstm"(with LSTM, default) - Operates on raw windowed IMU data (no feature engineering)
- Versions:
-
WtdMegaritisXGBoost- Gradient boosting classifier- Versions:
"full"(230 features) or"lightweight"(79 features, default) - SHAP-based feature selection for lightweight variant
- Versions:
-
WtdMegaritis_LogReg- Logistic regression with feature scaling- Versions:
"full"(230 features) or"lightweight"(99 features, default) - StandardScaler normalization included
- Versions:
-
Wtd_Megaritis_signal- Signal processing using gyroscope spectral patterns- Gyroscope spectral centroids (ML and IS axes) with accelerometer variability (PA axis)
- Multi-level voting with biomechanical post-processing
- No machine learning required
Literature Algorithms
Implementations of published methods (adapted for compatibility):
WtdTroiano,WtdChoi,WtdVanHees,WtdAhmadi,WtdKing,WtdDuncan,WtdRasmussen,WtdZhou,WtdVert,WtdPagnamenta,WtdNishiyama,WtdHecht
See individual algorithm documentation for references and parameter details.
Usage Examples
Deep Learning (Recommended)
from imu_weartime.weartime import WtdMegaritis_CNN
# CNN-LSTM (best performing)
wtd = WtdMegaritis_CNN(version="cnn_lstm").detect(
imu_data, sampling_rate_hz=100.0
)
# CNN baseline
wtd = WtdMegaritis_CNN(version="cnn").detect(
imu_data, sampling_rate_hz=100.0
)
Machine Learning
from imu_weartime.weartime import WtdMegaritisXGBoost, WtdMegaritis_LogReg
# XGBoost (lightweight by default)
wtd_xgb = WtdMegaritisXGBoost(version="lightweight").detect(
imu_data, sampling_rate_hz=100.0
)
# Logistic Regression
wtd_lr = WtdMegaritis_LogReg(version="lightweight").detect(
imu_data, sampling_rate_hz=100.0
)
Signal Processing
from imu_weartime.weartime import Wtd_Megaritis_signal
wtd = Wtd_Megaritis_signal().detect(imu_data, sampling_rate_hz=100.0)
Literature Methods
from imu_weartime.weartime import WtdTroiano, WtdVanHees, WtdAhmadi
wtd_troiano = WtdTroiano(nci=False).detect(imu_data, sampling_rate_hz=100.0)
wtd_vanhees = WtdVanHees().detect(imu_data, sampling_rate_hz=100.0)
wtd_ahmadi = WtdAhmadi(version="sd_xyz").detect(imu_data, sampling_rate_hz=100.0)
Algorithm Performance
Novel algorithms ranked by validation performance:
- CNN-LSTM (best overall)
- CNN
- XGBoost (lightweight)
- Signal Processing = Logistic Regression
Novel methods outperform all literature algorithms by 8- to 131-fold in wear-time quantification accuracy.
Detailed performance metrics and validation results will be published in the accompanying manuscript.
Citation
If you use this library in your research, please cite:
@software{megaritis2026imu_weartime,
author = {Megaritis, Dimitrios},
title = {IMU Wear-Time Detection: Validated Algorithms for Wearable Sensors},
year = {2026},
publisher = {GitHub},
url = {https://github.com/[username]/imu-weartime},
license = {Apache-2.0}
}
Compatibility
- Python: 3.9 to 3.13
- Dependencies:
mobgap==1.1.0,pandas,numpy,scikit-learn,xgboost,tensorflow - Sensor: Lower-back worn IMU (100 Hz sampling recommended)
- Data format: MobGap body-frame coordinates
Funding and Support
This work was supported by the SUSTAIN Mobilise-D Consortium. Content in this publication reflects the authors' view and neither EFPIA, or any Associated Partners are responsible for any use that may be made of the information contained herein.
License
Licensed under the Apache License 2.0. Free to use for any purpose, including commercial use. See LICENSE for full terms.
Disclaimer: This software is provided "as is" without warranty. It is not a medical product nor licensed for medical use.
Metadata
Release files for imu-weartime 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| imu_weartime-1.0.0.tar.gz | 8.6 MB | Without provenance | Details for imu_weartime-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| imu_weartime-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for imu_weartime-1.0.0-py3-none-any.whl |
Total release size: 17.3 MB
Release files / imu_weartime-1.0.0.tar.gz
| Download URL | imu_weartime-1.0.0.tar.gz |
|---|---|
| Size | 8.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
24e53fe1af68eeb6135e93c3e5c303dbac3d3904c35716079a43eaa0afb94e95
|
|
BLAKE2b-256 checksum How to use checksums |
4f3c53b769134ca09869f99041f567dc38f6d0f1ee90658c494360dff6df94fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.10 Darwin/24.6.0
|
Release files / imu_weartime-1.0.0-py3-none-any.whl
| Download URL | imu_weartime-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28b8c10ec0e6b3a806480e1b6cf7bca411d19e10d23481cd855294e967823787
|
|
BLAKE2b-256 checksum How to use checksums |
23ea4c791ce887aff907561a0cfc06b71eef2d1579306cfce47529d70ab9a935
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.10 Darwin/24.6.0
|
Security for imu-weartime 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.