Skip to main content

A classical signal processing library for generating synthetic physiological signals with realistic noise.

Project description

🌟 BioSignal Simulator (BSS)

PyPI version Python support License: MIT Interactive Colab Demo

Stress-test biomedical ML models and digital signal processing (DSP) filters under highly realistic physical noise.

Don't train physiological classifiers on pristine clinical databases and expect them to succeed in the wild. BSS generates clinical-grade clean bio-signals (ECG, EEG, EMG, PPG, EDA, respiration) and contaminates them with precise, parameterized physical noise engines (colored noise, electrode drift, motion artifacts, wearable packet loss).


⚡ Quick Start (Copy-Paste)

pip install biosignal-simulator

Generate a clean PPG signal, contaminate it with a ramping pink noise drift and motion artifacts, and export it to a clinical EDF file in under 10 lines of code:

import biosignal_simulator as bss

# 1. Configure and instantiate PPG generator
ppg_config = bss.PPGConfig(fs=125.0, duration_s=10.0, heart_rate=72.0)
ppg_generator = bss.PPGGenerator(ppg_config)

# 2. Schedule a ramping Pink (1/f) noise drift
pink_noise = bss.NoiseScheduler(
    noise_model=bss.ColoredNoise(exponent=1.0),
    schedule=bss.RampSchedule(control_times=[0.0, 10.0], levels=[0.0, 0.4])
)

# 3. Mix targeting exactly 12 dB SNR
mixed = bss.SignalMixer(
    signal_generator=ppg_generator,
    noise_models=[pink_noise],
    target_snr_db=12.0
).mix()

# 4. Symmetrically export to European Data Format (EDF)
bss.BiosignalExporter.export_edf(mixed, "ppg_stress_test.edf")

🎨 Interactive Visual Previews

1. Signal Composition Pipeline

The SignalMixer dynamically scales physical noise templates using scheduling envelopes (Ramps, Steps, Sigmoids) to meet your target SNR decibel constraint:

Signal Mixer Pipeline

2. Contaminating Physical Noise Gallery

BSS models 10 distinct physical noise categories, including pink/brown flicker noise, electrode popcorn pops, motion transients, and wearable packet loss:

Contaminating Noise Gallery

3. Interactive Metrics Dashboard

BSS automatically generates beautiful, diagnostic HTML dashboards with zoomable charts and Pan-Tompkins peak analysis to verify your DSP filters:

Metrics Dashboard Preview

4. Clean Bio-Signal Waveform Showcase

BSS includes high-fidelity mathematical models and dynamical ODE systems for 6 core biosignal categories, generating clean, realistic baseline templates:

ECG (McSharry 12-Lead standard projection)
EEG (Delta, Theta, Alpha, Beta, Sleep states)
EMG (MUAP activation firing & pathology library)
PPG (Dual-wavelength & arterial stiffness)
EDA (Tonic SCL + Phasic SCR sweat responses)
Respiration (Eupnea, deep, rapid breathing)

🚀 Key Highlights

  • 🧠 6 BioSignals: Clinical-grade generators for ECG (McSharry ODE, 12-lead projection), EEG (resting state, sleep stages, seizures), EMG (MUAPs, muscle fatigue), PPG (dual-wavelength, arterial stiffness), EDA (SCL/SCR decomposition), and Respiration (pathological patterns).
  • ⚡ 10 Physical Noise Engines: Additive white Gaussian, colored ($1/f^\alpha$ Pink/Brown/Blue/Violet), baseline wander, powerline harmonics, motion transient impact bursts, electrode contact popcorn/thermal drift, muscle activity contamination, impulse spikes, ADC quantization, and wearable packet loss/sensor detachment.
  • 🎛️ Dynamic Composer: Envelopes (Ramp, Sigmoid, Periodic, Stochastic) to schedule time-varying noise levels and target SNR decibel scalers.
  • 💾 Symmetrical Exporters: Symmetrical round-trip reads and writes for EDF, WFDB Format 16/212, HDF5, CSV comments, and JSON metadata.
  • 📈 Diagnostic Metrics: Bandpass and Wavelet SNR, Spectral Edge Frequency, SSIM, Pearson correlation, and Percent Residual Difference (PRD).

📖 Comprehensive Documentation

For detailed guides, class APIs, configuration schemas, mathematical background, and CLI options:

  • 📘 BSS User Guide: Standard pipelines, setups, quick examples, and configurations.
  • 📕 BSS Technical Reference Manual: Deep dive into all mathematical models, equations, 10 physical noises, metrics, clinical binary specs, validation, and benchmarking.

🧪 Robustness & Test Verification

BSS comes with a production-grade test suite checking physical parameters, mathematical boundaries, file roundtrips, and fuzzed signal invariants:

# Run the complete test suite
python -m pytest tests/ -v

All 1,443 test cases pass cleanly:

tests\test_composer.py .                                                 [  0%]
tests\test_composer_exhaustive_mixes.py .                                [ 15%]
tests\test_core_abstractions.py .                                        [ 22%]
...
tests\test_validation_engine_exhaustive.py .                             [100%]

============================ 1443 passed in 36.78s ============================

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

biosignal_simulator-0.1.3.tar.gz (271.0 kB view details)

Uploaded Source

Built Distribution

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

biosignal_simulator-0.1.3-py3-none-any.whl (229.8 kB view details)

Uploaded Python 3

File details

Details for the file biosignal_simulator-0.1.3.tar.gz.

File metadata

  • Download URL: biosignal_simulator-0.1.3.tar.gz
  • Upload date:
  • Size: 271.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for biosignal_simulator-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6b4c193fa82fb1818245c0af7ff4c305b97b29e8a740d41eac06ab015f4f9d9e
MD5 1dc296133603e49339874c1933a5c88f
BLAKE2b-256 b6777daa1f1db7da70dea135eec8a4fb4f334101ae010601191e7f5ab6c03794

See more details on using hashes here.

Provenance

The following attestation bundles were made for biosignal_simulator-0.1.3.tar.gz:

Publisher: publish.yml on therajpoots/Biosim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file biosignal_simulator-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for biosignal_simulator-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 01ba2ee9681d4ed2d7d03e0ccf9443a03373127e665f14874d4943608df959ac
MD5 a6b1f9a2a7ab71f1b1246ca20a6858ff
BLAKE2b-256 d92bfafc4abbcbd2c54c511bff46fb0afd2f72ed93ea72e5a798fb897dfd8d76

See more details on using hashes here.

Provenance

The following attestation bundles were made for biosignal_simulator-0.1.3-py3-none-any.whl:

Publisher: publish.yml on therajpoots/Biosim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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