qumphy.data.signal_preprocessing.noise module

File: qumphy/data/signal_preprocessing/noise.py Project: 22HLT01 QUMPHY Contact: oskar.pfeffer@ptb.de Gitlab: https://gitlab.com/qumphy Description: Functions for adding noise to the signals.

qumphy.data.signal_preprocessing.noise.add_noise(data, noise_params=None)[source]

Adds noise to the given data.

Parameters:

data (np.ndarray) – Input data.

Returns:

Data with added noise.

Return type:

np.ndarray

qumphy.data.signal_preprocessing.noise.baseline_wander_noise(signal, signal_frequency, snr, cutoff=0.5, seed=None)[source]

Add baseline wander noise to a signal.

Return type:

ndarray

Parameters:
  • signal (np.ndarray) – Input array with shape (…, L), where the last dimension is the signal length and all preceding dimensions index different signals (e.g. (batch, channels, length))

  • snr (float) – The signal-to-noise ratio (SNR) in decibels.

  • cutoff (float) – The cutoff frequency of the low-pass filter.

  • seed (int or None, optional) – Seed of the RNG.

Returns:

The signal with added baseline wander noise.

Return type:

np.ndarray

qumphy.data.signal_preprocessing.noise.gaussian_noise(signal, snr, seed=None)[source]

Add Gaussian noise to a signal.

Return type:

ndarray

Parameters:
  • signal (np.ndarray) – Input array with shape (…, L), where the last dimension is the signal length and all preceding dimensions index different signals (e.g. (batch, channels, length))

  • snr (float) – The signal-to-noise ratio (SNR) in decibels.

  • seed (int or None, optional) – Seed of the RNG.

Returns:

The signal with added Gaussian noise.

Return type:

np.ndarray

qumphy.data.signal_preprocessing.noise.powerline_noise(signal, signal_frequency, snr, noise_frequency=50.0)[source]

Add powerline noise to a signal.

Typically, powerline noise is a sinusoidal signal with a frequency of 50 or 60 Hz.

Return type:

ndarray

Parameters:
  • signal (np.ndarray) – Input array with shape (…, L), where the last dimension is the signal length and all preceding dimensions index different signals (e.g. (batch, channels, length))

  • signal_frequency (float) – The sampling frequency (Hz) of the signal.

  • snr (float) – The signal-to-noise ratio (SNR) in decibels.

  • noise_frequency (float) – The frequency (Hz) of the powerline noise.

Returns:

The signal with added powerline noise.

Return type:

np.ndarray