A classical signal processing library for generating synthetic physiological signals with realistic noise.
Project description
🌟 BioSignal Simulator Library (BSS)
A high-performance, classical digital signal processing (DSP) toolkit in Python for generating clean physiological signals contaminated by highly realistic, parameterized physical noise.
Designed for filter prototyping, DSP algorithm benchmarking, clinical feature detector evaluations, and machine learning model validation without deep learning dependencies.
🚀 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, RSA), 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).
- 📊 Verification Dashboard: Styled HTML quality reports with integrated Pan-Tompkins QRS peak detection, clipping/flatline locators, and interactive zoomable JavaScript charts.
🛠️ Installation
Ensure you are in the library root directory:
# Core installation (NumPy & SciPy)
pip install .
# Full installation including exporters (HDF5, pandas), visualizers (matplotlib), YAML config, and test dependencies
pip install -e ".[io,viz,yaml,dev]"
⚡ Quick Start: Composition, Noise Scheduling, & Export
Combine a clean ECG signal with a dynamic colored noise envelope, evaluate the signal quality metrics, and save to a light clinical EDF binary format:
import biosignal_simulator as bss
# 1. Generate clean ECG record
clean_signal = bss.ECGGenerator(
bss.ECGConfig(fs=250.0, duration_s=10.0, heart_rate=75.0)
).generate()
# 2. Schedule a ramping Pink Noise artifact (from 0 to 0.3 amplitude)
pink_noise = bss.ColoredNoise(exponent_alpha=1.0)
scheduled_noise = bss.NoiseScheduler(
noise_model=pink_noise,
envelope=bss.RampSchedule(start_val=0.0, end_val=0.3, duration_s=10.0)
)
# 3. Mix everything targeting an overall SNR of 15.0 dB
mixer = bss.SignalMixer(
signal=clean_signal,
noises=[scheduled_noise],
target_snr_db=15.0
)
record = mixer.mix()
# 4. Symmetrically export to European Data Format (EDF)
bss.BiosignalExporter.export_edf(record, "subject_01.edf")
print("--- Simulation Configured & Saved ---")
print(f"Sampling rate: {record.fs} Hz | Data length: {record.clean.shape[0]} samples")
print(f"Composite mixture target SNR: 15 dB | Actual mixed SNR: {record.snr_db:.2f} dB")
📖 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, 30,000+ line 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,420 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%]
============================ 1420 passed in 36.78s ============================
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 biosignal_simulator-0.1.0.tar.gz.
File metadata
- Download URL: biosignal_simulator-0.1.0.tar.gz
- Upload date:
- Size: 262.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f84bdfd36fb2b54bc26e494a52c9c3ed1742651efb9ddff76946c84fa2314f7
|
|
| MD5 |
d839e64389dfbd7fb9917aa006664a17
|
|
| BLAKE2b-256 |
01eab1a55fa98657d850a446f19dae05eb20aa473e6f6553ccdaa83fbd237d56
|
Provenance
The following attestation bundles were made for biosignal_simulator-0.1.0.tar.gz:
Publisher:
publish.yml on therajpoots/Biosim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
biosignal_simulator-0.1.0.tar.gz -
Subject digest:
6f84bdfd36fb2b54bc26e494a52c9c3ed1742651efb9ddff76946c84fa2314f7 - Sigstore transparency entry: 1707764542
- Sigstore integration time:
-
Permalink:
therajpoots/Biosim@269137c638bb3d0ab5bcad5bcad4d55f5f32e79e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/therajpoots
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@269137c638bb3d0ab5bcad5bcad4d55f5f32e79e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file biosignal_simulator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: biosignal_simulator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 225.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad9dcbd915bbc06fd9b605e5902e7012c59f53c53a087794d1876a71e2c7e213
|
|
| MD5 |
35db3a23a7ac3e58418f9b69ebdc684c
|
|
| BLAKE2b-256 |
3fe66c9630248088cc5aa8edd76fef3c556db41df48a790440eb977fdc2e31b8
|
Provenance
The following attestation bundles were made for biosignal_simulator-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on therajpoots/Biosim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
biosignal_simulator-0.1.0-py3-none-any.whl -
Subject digest:
ad9dcbd915bbc06fd9b605e5902e7012c59f53c53a087794d1876a71e2c7e213 - Sigstore transparency entry: 1707764569
- Sigstore integration time:
-
Permalink:
therajpoots/Biosim@269137c638bb3d0ab5bcad5bcad4d55f5f32e79e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/therajpoots
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@269137c638bb3d0ab5bcad5bcad4d55f5f32e79e -
Trigger Event:
workflow_dispatch
-
Statement type: