Skip to main content

A library for generating synthetic Muscle Sympathetic Nerve Activity (MSNA) data with realistic and physiologically accurate characteristics.

Project description

msna-sim

PyPI version License: MIT Python 3.8+

A Python library for generating realistic synthetic Muscle Sympathetic Nerve Activity (MSNA) signals with physiologically accurate timing, noise characteristics, and signal properties. This library also includes an interactive dashboard for real-time parameter exploration and exporting data.

Overview

Muscle Sympathetic Nerve Activity (MSNA) provides direct measurement of sympathetic outflow to skeletal muscle vasculature, offering insights into cardiovascular neural control mechanisms. This library generates realistic synthetic MSNA signals that closely replicate those obtained through microneurography recordings.

The simulator incorporates:

  • Physiologically accurate cardiac synchronization with heart rate variability
  • Respiratory modulation of sympathetic activity
  • Realistic burst morphology with variable timing and amplitude
  • Comprehensive multi-frequency noise modeling based on real clinical recordings
  • Interactive dashboard for parameter exploration and data export

msna-sim is designed for algorithm development, method validation, education, and clinical research applications where realistic synthetic MSNA data is needed.

Installation

Install from PyPI:

pip install msna-sim

Or install from source:

# Clone the repository
git clone https://github.com/ryanirl/msna-sim.git
cd msna-sim

# Install the package
pip install -e .

Requirements will be automatically installed, but can be found in requirements.txt.

Quick Start

Interactive Dashboard

Launch the interactive dashboard for real-time parameter exploration:

msna-sim-dashboard

The dashboard allows you to play with various simulation parmaeters, and export data as CSV. It could be used as the main way to interact with this library for users with minimal programming experience.

Basic Programmatic Usage

from msna_sim import quick_simulation

# Generate a 60-second recording with default settings
results = quick_simulation(duration = 60, preset = "normal_adult")

# Access the signals
time = results.time
clean_msna = results.clean_msna           # Clean MSNA signal
noisy_msna = results.noisy_msna           # Realistic noisy signal
burst_times = results.get_burst_times()   # Burst occurrence times

print(f"Generated {results.n_bursts} bursts")
print(f"Burst rate: {results.burst_rate:.1f} bursts/min")
print(f"Actual burst incidence: {results.actual_burst_incidence:.1f}%")

Using Preset Configurations

from msna_sim import Simulation, create_preset_config

# Available presets include physiological and pathological conditions
presets = [
    "normal_adult", "young_healthy", "athlete", "elderly_healthy",
    "hypertensive", "heart_failure", "bradycardia", "tachycardia", 
    "diabetes", "obesity", "sleep_apnea", "copd", "anxiety",
    "post_exercise", "pristine_lab", "noisy_clinical"
]

# Create simulation with hypertensive patient preset
config = create_preset_config("hypertensive")
simulation = Simulation(config)
results = simulation.simulate(duration = 120, sampling_rate = 1000)

print(f"Heart rate: {results.mean_heart_rate:.1f} bpm")
print(f"Burst incidence: {results.actual_burst_incidence:.1f}%")

Custom Configuration

from msna_sim import Simulation, PatientConfig, SignalConfig

# Create custom patient configuration
patient_config = PatientConfig(
    heart_rate = 75.0,                    # beats per minute
    hrv_std = 0.04,                       # heart rate variability
    burst_incidence = 65.0,               # percentage of cardiac cycles with bursts
    noise_floor = 0.25,                   # baseline noise level
    signal_amplitude = 1.2,               # relative burst amplitude
    resp_rate = 16.0,                     # breaths per minute
    resp_modulation_strength = 0.4        # respiratory modulation strength
)

# Optional: customize signal processing parameters
signal_config = SignalConfig(
    integration_smoothing = 0.95,         # signal integration smoothing
    pink_noise_amplitude = 0.4,           # pink noise contribution
    spike_artifact_amplitude = 0.3        # spike artifact strength
)

simulation = Simulation(patient_config, signal_config)
results = simulation.simulate(duration = 180, sampling_rate = 1000, seed = 42)

Usage Examples

# Launch dashboard
msna-sim-dashboard

Technical Details

For technical details, refer to the SPECS.md file.

API Reference

Core Classes

  • Simulation: Main simulation class
  • PatientConfig: Physiological parameter configuration
  • SignalConfig: Signal processing parameter configuration
  • SimulationResults: Container for simulation outputs

Key Functions

  • quick_simulation(): Convenience function for simple simulations
  • create_preset_config(): Load predefined patient configurations

Simulation Results

The SimulationResults object provides:

  • time: Time array in seconds
  • clean_msna: Clean MSNA signal without noise
  • noisy_msna: Realistic MSNA signal with noise
  • respiratory_signal: Respiratory waveform
  • get_burst_times(): Array of burst occurrence times
  • n_bursts: Total number of bursts
  • burst_rate: Burst rate in bursts per minute
  • actual_burst_incidence: Realized burst incidence percentage

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use this library in your research, please cite:

@software{msna_sim,
  author = {Ryan Peters},
  title = {msna-sim: Realistic MSNA Signal Simulation},
  url = {https://github.com/ryanirl/msna-sim},
  version = {0.1.0},
  year = {2025}
}

Contact

If you have any questions or comments, feel free to email me at ryanirl (at) icloud (dot) com.

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

msna_sim-0.1.1.tar.gz (712.9 kB view details)

Uploaded Source

Built Distribution

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

msna_sim-0.1.1-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file msna_sim-0.1.1.tar.gz.

File metadata

  • Download URL: msna_sim-0.1.1.tar.gz
  • Upload date:
  • Size: 712.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for msna_sim-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dd50bf2ff68aa5ae5cebccfb491a28590718705b39e7c1b41147f3981813862a
MD5 e1ddec0644a524164c5b5820fa5d2c73
BLAKE2b-256 b0fd0acaf8962cf76eba9cf60be6c3fbe57f3b6c91ea20c2385c62d95aab7b35

See more details on using hashes here.

File details

Details for the file msna_sim-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: msna_sim-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for msna_sim-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4122c8926438b306dc8719c71f8dec5eed4bd7984b3b7ed5cea68ed59ed4fff
MD5 3445f7efe5f79d3462a556f8c3f4556c
BLAKE2b-256 54bb338bd590eacf7a14e849df599f9460389544ca27c3ba6f80578bcca78821

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