Wear-time detection algorithms for IMU wearable sensors
Project description
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:
-
WtdMegaritis_XGBoost- 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 WtdMegaritis_XGBoost, WtdMegaritis_LogReg
# XGBoost (lightweight by default)
wtd_xgb = WtdMegaritis_XGBoost(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}
}
Validation reference (manuscript in preparation):
Megaritis, D., Del Din, S., Tasca, P., Cereatti, A., & Vogiatzis, I. (2026). Novel wear-time detection algorithms for lower-back worn IMU sensors. Manuscript in preparation.
For algorithms from the literature, please cite the original papers listed in the respective algorithm documentation.
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.
Project details
Release history Release notifications | RSS feed
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 imu_weartime-0.1.0.tar.gz.
File metadata
- Download URL: imu_weartime-0.1.0.tar.gz
- Upload date:
- Size: 236.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.10 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6e9ed16879c8ffa1cd9f451445012309d55dbc649e30b1aec00a2a145cf9608
|
|
| MD5 |
dd9d320cc006fc2e67f0ace49915b6a8
|
|
| BLAKE2b-256 |
c454855384d75e8dd7997e83c48152b6111dde4c1b5401981acb8b21f1e181e8
|
File details
Details for the file imu_weartime-0.1.0-py3-none-any.whl.
File metadata
- Download URL: imu_weartime-0.1.0-py3-none-any.whl
- Upload date:
- Size: 265.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.10 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ee42326224628345ca6925d5ddc9475546fb4c158994ab3ee81d81bf7609130
|
|
| MD5 |
070dc8129851cafbf8a93e871cc2809f
|
|
| BLAKE2b-256 |
2cbad42b93ffe5a6d1eb8204d2c18fc1df4d3e7b6811e14a1a0fa05df9d5da00
|