Skip to content

Add Alpha-SNR-Based Noise Model for Sensor Signal Simulation - #17

Merged
orabe merged 1 commit into
mainfrom
data/simulation
Jul 25, 2025
Merged

orabe merged 1 commit into
mainfrom
data/simulation

Conversation

@orabe

@orabe orabe commented Jul 25, 2025 •

Copy link
Copy Markdown
Collaborator

Closes #5

Implemented an interpretable noise injection method based on the Alpha-SNR formulation. The approach allows to control signal-to-noise ratio (SNR) in a bounded and unitless manner during EEG/MEG simulation by specifying a single parameter: $\alpha \in (0, 1)$.

Motivation

The traditional decibel-based SNR control using $\text{SNR}_{\text{dB}}$ can be unintuitive and difficult to interpret across varying signal strengths. The Alpha-SNR approach addresses this by defining noise level via the relative energy of the signal in the total signal-plus-noise mixture.

Mathematical Formulation

Let:

  • $\mathbf{Y}_{\text{signal}} \in \mathbb{R}^{M \times T}$: clean sensor signal
  • $\boldsymbol{\varepsilon} \sim \mathcal{N}(0, \sigma_{\varepsilon}^2 \cdot \mathbf{I})$: i.i.d. zero-mean Gaussian noise with standard deviation $\sigma_{\varepsilon}$ (default is $\sigma_{\varepsilon} = 1.0$)
  • $\eta \in \mathbb{R}+$: scaling factor applied to noise

We define signal and noise power:

  • $P_{\text{signal}} := \frac{1}{MT} | \mathbf{Y}_{\text{signal}} |_F^2 \quad$ (signal power),
  • $P_{\text{noise}} := \frac{1}{MT} | \eta \cdot \boldsymbol{\varepsilon} |_F^2$ (noise power)

The Alpha-SNR parameter $\alpha \in (0, 1)$ defines the signal proportion:
$\alpha := \frac{P_{\text{signal}}}{P_{\text{signal}} + P_{\text{noise}}} = \frac{1}{1 + \eta^2 / P_{\text{signal}}}$

Solving for $\eta$, we obtain:
$\eta = \left( \frac{1 - \alpha}{\alpha} \right) \cdot \frac{| \mathbf{Y}_{\text{signal}} |_F}{| \boldsymbol{\varepsilon} |_F}$

The final noisy signal is:
$\mathbf{Y}{\text{noisy}} = \mathbf{Y}{\text{signal}} + \eta \cdot \boldsymbol{\varepsilon}$

The noise variance per element is given by the variance of any entry $\varepsilon_{ij}^{\text{scaled}}$:

$\text{Var}[\eta \cdot \varepsilon_{ij}] = \eta^2 \cdot \text{Var}[\varepsilon_{ij}] = \eta^2$

Hence, the total noise variance (used in the simulation return value) is:

$\sigma^2 = \eta^2$

Changes Introduced

  • Implemented Alpha-SNR noise model in the _add_noise() method.
  • The updated method now returns:
    • The noisy signal
    • The added (scaled) noise
    • The effective noise variance
  • Modified files:
    • data_simulation.py
    • benchmark.py
    • run_experiments.py

Usage

data_simulator =  DataSimulator(alpha_SNR=0.8)
data = data_simulator.simulate(
    subject='fsaverage', 
    seed=42
)
y_noisy, L, x, x_active_indices, noise, noise_var = data

Notes

This PR only implements homoscedastic, white Gaussian noise.

…ain control parameter for noise level in DataSimulator class
@orabe
orabe merged commit c7c6878 into main Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Use Alpha-SNR Instead of SNR (dB)

1 participant