ncclabsustech / EEGdenoiseNet

EEGdenoiseNet, a benchmark dataset, that is suited for training and testing deep learning-based EEG denoising models, as well as for comparing the performance across different models.
MIT License
169 stars 44 forks source link

Signal-to-Noise Ratio calculation #6

Closed Gualor closed 3 years ago

Gualor commented 3 years ago

Hi! I'm currently working on a denoising CNN for EOG artifacts. I am implementing a similar procedure to the one described in your paper which cleverly parametrizes the artifact contaminations in the signal by computing the signal with the desired SNR levels to match the physiological ones.

However I couldn't understand why in the EEGdenoiseNet/code/benchmark_networks/data_input.py script you computed the SNR using the RMS instead of the MSE in the ratio.

Line 56 shows:

coe=get_rms(eeg)/(get_rms(noise)*SNR_train[i])

meaning that

SNR_train[i]=get_rms(eeg)/(get_rms(noise)*coe)

Being the definition of SNR the ratio of powers of signal and noise shouldn't the SNR be estimated with MSE as or alternatively using RMS as .

Please let me know if I am missing something. Thank you again for your work.

BR

ncclabsustech commented 3 years ago

As I know they all can be used to calculate SNR, for example in paper "Canonical Correlation Analysis Applied to Remove Muscle Artifacts From the Electroencephalogram'' and paper "Independent Vector Analysis Applied to Remove Muscle Artifacts in EEG Data"

Gualor commented 3 years ago

Hi, thank you for the reply! I will try to be more concise and clear with my question.

I'm using the following additive relationship to describe how noise affects the final signal: y = x + k*n where y is the noisy EEG signal, x is the clean EEG signal, n is the noise (EOG or EMG) and k is a coefficient to parametrize how much n affects y.

By substituting this relationship inside the definition of SNR we get:

SNR = MSE(x) / MSE(k*n) = MSE(x) / ((k^2) * MSE(n))

If we solve the equation for k we get:

k = sqrt(MSE(x) / (SNR * MSE(n)) = RMS(x) / (RMS(n) * sqrt(SNR))

Which is different from the equation used in EEGdenoiseNet/code/benchmark_networks/data_input.py line 56 where there is no square root of the SNR in the denominator.

coe=get_rms(eeg)/(get_rms(noise)*SNR_train[i]) 

# Shoud be changed into this:

coe=get_rms(eeg)/(get_rms(noise)*math.sqrt(SNR_train[i]))

Please let me know if it is an error on your side or I'm missing something.

BR

ncclabsustech commented 3 years ago

Thanks for your reply! In this two papers, SNR is defined by: cc6bd28be3eb1e59b23e2a906cb8df9 different with image We also feel surprise for this difference, because this 2 paper are important in the area of EEG denoise, so we use the first defination. Best regards

Gualor commented 3 years ago

Thank you, I finally understand now. Have a nice day.

Best regards, LG