Skip to main content

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
  • 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

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

dsp/

  • Convolution: Signal processing utilities including moving averages

Algorithm Architecture

All algorithms follow a consistent architecture:

  1. Settings: Pydantic-based configuration models for algorithm parameters
  2. Algorithm Class: Inherits from BaseAlgorithm with a run() method
  3. Data Models: Type-safe sensor data classes with validation
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

physiodsp-0.1.0b0.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

physiodsp-0.1.0b0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file physiodsp-0.1.0b0.tar.gz.

File metadata

  • Download URL: physiodsp-0.1.0b0.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for physiodsp-0.1.0b0.tar.gz
Algorithm Hash digest
SHA256 ffc784a0956a50b5bb107a44a9cefecc851ff27df9622cfb22b3eb302ba11884
MD5 bdbe550b86dfecd125dfeae2dd998d62
BLAKE2b-256 084654d779c9cc0affe7ffa999c9d60e22eff170196fad04791f02acdf00ad2d

See more details on using hashes here.

File details

Details for the file physiodsp-0.1.0b0-py3-none-any.whl.

File metadata

  • Download URL: physiodsp-0.1.0b0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for physiodsp-0.1.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d91b8df2ccc13530ea59bd431d78da4aae18db7c70179ee27a29743f4f7fc9c
MD5 8430d8c5a88609f1dc78617395c49338
BLAKE2b-256 4a2ed640260c9d08c9102115fd2fac21a1ffcd804e50294f63b1dc3f2b063983

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page