question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SNR in calculation in `add_noise_evoked` might be incorrect

See original GitHub issue

I’m trying to see how the data is scaled to achieve a given SNR in add_noise_evoked in mne-python/mne/simulation/evoked.py, but do not really get it.

The SNR in this function is defined as the standard SNR in dB, which is:

SNR = 10 * log10 [ var(signal) / var(noise) ]

The piece of code that should do this is:

tmp = 10 * np.log10(np.mean((evoked.data[:, tmask] ** 2).ravel()) / np.mean((noise.data ** 2).ravel()))
noise.data = 10 ** ((tmp - float(snr)) / 20) * noise.data

However, I am think that it should be instead:

tmp =  np.log10(np.mean((evoked.data[:, tmask] ** 2).ravel()) / np.mean((noise.data ** 2).ravel()))
noise.data = 10 ** (tmp - float(snr) / 10) * noise.data

Is this a bug, or am I missing something?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
clamuscommented, Jun 13, 2016

Should I go ahead and fix this?

0reactions
agramfortcommented, Jun 15, 2016

lol 😃

yes please just add a test but don’t update what’s new

thx

Read more comments on GitHub >

github_iconTop Results From Across the Web

snr - Incorrect signal-to-noise ratio estimation
In this case the OP has a signal, and alone and is incorrectly using ... How can I find SNR, PEAQ, and ODG...
Read more >
SNR calculation wrong by 3 dB? - Custom IC Design
My calculation of SNR over a 100kHz bandwidth gives: rms of signal = 0.707V, and rms of noise = sqrt(4*kT*R*100k) = 12.87uV.
Read more >
signal-to-noise ratio (S/N or SNR) - TechTarget
Signal-to-noise ratio measures the strength of a desired signal relative to background noise. Learn to calculate it and the disturbances that can cause...
Read more >
Signal-to-Noise (SNR) and Uncertainty Estimates
As simple as this may sound, error estimate is quite complicated. ... If the region contains more than one peak, the SNR calculated...
Read more >
Signal-to-noise ratio - Wikipedia
SNR is defined as the ratio of signal power to the noise power, often expressed in decibels. A ratio higher than 1:1 (greater...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found