A comprehensive Python library for processing and analyzing physiological sensor data
Project description
PhysioDSP
A comprehensive Python library for processing and analyzing physiological sensor data. PhysioDSP provides algorithms for activity recognition, ECG and heart rate analysis, HRV (Heart Rate Variability) scoring, and digital signal processing from wearable sensors.
Features
- Activity Analysis: ENMO (Euclidean Norm Minus One), personalized Activity Score, activity intensity detection, energy expenditure estimation (coming soon)
- ECG Processing: QRS peak detection, heart rate calculation, inter-beat interval analysis
- HRV Scoring: Advanced heart rate variability scoring with trend analysis and stability metrics
- Balance Tests: Postural sway analysis with stabilometric indices and 95% confidence ellipse
- Sleep Analysis: Sleep quality and duration metrics (coming soon)
- Sensor Support: Accelerometer, gyroscope, magnetometer, and ECG data processing
- Digital Signal Processing: Convolution and filtering utilities for physiological signals
- Type-Safe Design: Built with Pydantic for robust data validation
- Configurable Algorithms: Each algorithm includes customizable settings and parameters
Installation
pip install physiodsp
Requirements
- Python >= 3.11
- NumPy >= 2.4.0
- Pandas >= 2.3.3
- SciPy >= 1.16.3
- Pydantic >= 2.12.0
Quick Start
Activity Analysis - ENMO
from physiodsp.activity.enmo import ENMO, ENMOSettings
from physiodsp.sensors.imu.accelerometer import AccelerometerData
# Create accelerometer data
accel_data = AccelerometerData(
timestamps=timestamps,
x=x_values,
y=y_values,
z=z_values,
fs=64 # 64 Hz sampling frequency
)
# Initialize and run ENMO algorithm
enmo = ENMO(settings=ENMOSettings(window_len=1, aggregation_window=60))
result = enmo.run(accel_data)
# Get results
print(result.biomarker) # DataFrame with timestamps and ENMO values
result.aggregate(method='mean') # Aggregate results
ECG Peak Detection
from physiodsp.ecg.peak_detector import EcgPeakDetector
from physiodsp.sensors.ecg import EcgData
# Create ECG data
ecg_data = EcgData(
timestamps=timestamps,
values=ecg_values,
fs=250 # 250 Hz sampling frequency
)
# Initialize and run peak detector
detector = EcgPeakDetector()
result = detector.run(ecg_data)
# Get heart rate and inter-beat intervals
print(result.biomarker) # DataFrame with RR intervals and heart rate
Balance Test - Sway
from physiodsp.balance_tests.sway import Sway, SwaySettings
from physiodsp.sensors.imu.accelerometer import AccelerometerData
# Create accelerometer data (X = medio-lateral, Z = antero-posterior)
accel_data = AccelerometerData(
timestamps=timestamps,
x=x_values, # medio-lateral axis
y=y_values, # vertical axis
z=z_values, # antero-posterior axis
fs=50 # 50 Hz sampling frequency
)
# Initialize and run sway algorithm
sway = Sway(settings=SwaySettings(filter_order=4, filter_high_freq=2.5))
result = sway.run(accel_data, sensor_height=1.0) # sensor height in meters
# Get stabilometric indices and ellipse metrics
print(result.biomarker)
HRV Scoring
from physiodsp.hrv.hrv_score import HrvScore, HrvScoreSettings
from physiodsp.sensors.hrv import HrvData
# Create HRV data (RMSSD values)
hrv_data = HrvData(
timestamps=timestamps,
values=rmssd_values
)
# Calculate HRV score
hrv = HrvScore(settings=HrvScoreSettings(window_len=30, method="sigmoid"))
result = hrv.run(hrv_data)
# Get HRV score (0-100)
print(result.biomarker_agg) # DataFrame with HRV score
Core Modules
activity/
- ENMO ✅ (unit tested): Euclidean Norm Minus One - physical activity metric from accelerometer
- Zero Crossing ✅ (unit tested): Activity intensity detection
- Time Above Threshold ✅ (unit tested): Vigorous activity quantification
- PIM ✅ (unit tested): Proportional Integration Mode - multi-axis activity processing
- Activity Score ✅ (unit tested): Personalized 0-100 daily activity and recovery score with baseline personalization
- Energy Expenditure (coming soon): Calorie burn estimation algorithms
- Activity Recognition (coming soon): Machine learning-based activity classification
- Sleep Metrics (coming soon): Sleep quality and duration analysis
sensors/
- IMU (Inertial Measurement Unit):
- Accelerometer data processing
- Gyroscope data processing
- Magnetometer data processing
- ECG: Electrocardiogram signal handling
- HRV: Heart rate variability metrics
ecg/
- Peak Detector: QRS complex detection using filtering and peak detection
hrv/
- HRV Score: Comprehensive 0-100 HRV scoring with trend and stability analysis
balance_tests/
- Sway ✅ (unit tested): Postural sway analysis — stabilometric indices (average distance, RMS, total path, velocity) for the full, ML, and AP paths, plus 95% confidence ellipse metrics
dsp/
- Convolution: Signal processing utilities including moving averages
Algorithm Architecture
All algorithms follow a consistent architecture:
- Settings: Pydantic-based configuration models for algorithm parameters
- Algorithm Class: Inherits from
BaseAlgorithmwith arun()method - Data Models: Type-safe sensor data classes with validation
- Results: Biomarkers stored in Pandas DataFrames for easy analysis
Development
Setup Development Environment
# Install development dependencies
pip install -r requirements-dev.txt
# Install test dependencies
pip install -r requirements-test.txt
Running Tests
pytest tests/
Contributing
Contributions are welcome! Please ensure:
- Code follows the existing project structure
- All new algorithms inherit from
BaseAlgorithm - Settings are defined using Pydantic models
- Tests are included for new functionality
License
[Add your license here]
References
- ENMO algorithm: based on accelerometer magnitude data
- ECG Peak Detection: Pan-Tompkins-like approach with filtering
- HRV Scoring: Z-score based with trend and stability analysis
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 physiodsp-0.1.0.tar.gz.
File metadata
- Download URL: physiodsp-0.1.0.tar.gz
- Upload date:
- Size: 34.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f837bd095fb26d07182972615f95e1b90c5b5def500484ddaa964066d8e9d108
|
|
| MD5 |
b52d2d0144527151061663c2d3b42e83
|
|
| BLAKE2b-256 |
54292c655cac750c38174cff6e967695d3d9c26e5006df74304efc0cca546cc4
|
File details
Details for the file physiodsp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: physiodsp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 33.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f989647a18ac52f6a311219f8746dcc93b4f10a7df97707160319d9ec3b4419
|
|
| MD5 |
81b27edd4acaa12ac4089d189944d733
|
|
| BLAKE2b-256 |
2d452fb464c6ea3f41f1abe6500eb934abe0909ad0adbbc3d1d7f5ea9d21312b
|