Utility to generate signals for algorithm development and verification.
Project description
Magnes Signal Generation Utility
Utility to generate signals for algorithm development and verification.
Quickstart
Install the package using pip:
pip install magnes-signal-generation-utility
Generate Synthetic Signal with Artifacts
from msgu.mixture import generate_synthetic_wave_with_cardiac_artifacts
# Generate synthetic signal with cardiac artifacts
data = generate_synthetic_wave_with_cardiac_artifacts(
fs=250.0,
freqs=[10.0, 30.0], # Peak frequencies
widths=[2.0, 5.0], # Frequency widths
gamma=3.0, # Disturbance gain
sigma=0.2, # Noise level
nbeats=10
)
# Access the components
t = data.t # Time array
signal = data.x # Ground truth signal
disturbance = data.d # Cardiac artifacts
noise = data.n # Pink noise
measurement = data.z # Composite measurement
Generate White and Pink Noise
from msgu.noise import generate_white_noise, generate_pink_noise, PINK_NOISE_ALGO
# Generate white noise
white_noise = generate_white_noise(n=1000)
# Generate pink noise using FFT algorithm
pink_noise = generate_pink_noise(n=1000, algo=PINK_NOISE_ALGO.FFT)
Basic Example: Generate ECG Signal
import numpy as np
import matplotlib.pyplot as plt
from msgu.cardio import generate_ecg
# Generate a 5-beat ECG signal at 250 Hz
fs = 250.0
t, ecg_signal = generate_ecg(fs, nbeats=5, sigma=0.01)
# Plot the signal
plt.plot(t, ecg_signal)
plt.xlabel('Time [s]')
plt.ylabel('Signal [mV]')
plt.title('Pseudo-ECG Signal')
plt.show()
Submodules
Cardio
Pseudo-ECG signals generation utility. Defines a (heart) Beat object, which
can be used as a generator of a pseudo-random, single-beat signal. A utility
function allows to concatenate n beats into a singe time series.
Gauss
Helper definitions of the Gaussian bell and its derivatives.
Mixture
Signal synthesizers: combining various signal generators into composite signals.
Pseudo-Random Waves Synth prsynth
Superposing blurred-peak, random-phase sine-waves, with additive disturbances (ECG artifacts) and pink noise.
Noise
Noise generation utility.
Periodic
(Quasi) periodic signals generation utility.
Tidal - Pseudo-random sine waves
Includes the implementation of blurred-peak, randomly-phased sine-waves generation
Trajectory
Trajectory generation utility.
S-Curves
Helper utility for the generation of normed, polynomial (order 3 and 5) S-curves.
Usage Examples
Scripts illustrating the intended usage of the msgu package are available in scripts/.
To run the script foo.py call
uv run scripts/foo.py
from project root.
Testing
Unittests can be run with uv and pytest from root as
uv run -m pytest [OPTIONS]
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 magnes_signal_generation_utility-0.1.0.tar.gz.
File metadata
- Download URL: magnes_signal_generation_utility-0.1.0.tar.gz
- Upload date:
- Size: 442.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f6ede25965ba7b3924d4c70cbd6b89e79fcf897488308f2a617b12f841a1f30
|
|
| MD5 |
85f191bfa9bf015f6f507b1eccbf6aa0
|
|
| BLAKE2b-256 |
58dab64383ef47187578a4674a04c246af2db997a2e100fcec76415e4ef16ddc
|
File details
Details for the file magnes_signal_generation_utility-0.1.0-py3-none-any.whl.
File metadata
- Download URL: magnes_signal_generation_utility-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57db447726e010220717f1eceb4aca240439d85658c4d8fcbd1d3a11046e7291
|
|
| MD5 |
2aa9ab41e1df384b883fe6d730b4436e
|
|
| BLAKE2b-256 |
1d23781e866a3c274b0b80df874ea9f11b59c4af3b5b2edf53bf324db620028e
|