I have looked around online and it seems that the signaltonoise ratio function inside the scipy.stats is deprecated and is not available in version 1.1. Is there any other equivalent method inside scipy package since I have not been able to find it online.
And if not scipy then is there any other library recommended for such calculations ?
stats. signaltonoise(arr, axis=0, ddof=0) function computes the signal-to-noise ratio of the input data.
To calculate the signal-to-noise ratio, you need the level of both the signal and the noise. Then: If you have the signals in decibels (dB), subtract noise from the signal. If your calculations are in watts, use the power signal-to-noise ratio formula SNR = 10 × log(signal / noise) .
Calculating Signal to Noise Ratio Most commonly used generic formula for Signal to Noise = 2*Peak Height/Noise. For such calculation, two possible approaches exist: The Noise is determined from the same chromatogram within area with no peaks.
Find peaks inside a signal based on peak properties. This function takes a 1-D array and finds all local maxima by simple comparison of neighboring values. Optionally, a subset of these peaks can be selected by specifying conditions for a peak's properties.
As indicated in scipy issue #609 on github, the signaltonoise
function
[...] is not useful except for backwards compatibility. The reason is that there's a Matlab signal-to-noise function http://www.mathworks.com/help/signal/ref/snr.html which means something different. This is not good, because scipy clones the Matlab interface of other signal-related functions, and this incompatibility apparently has no offsetting benefit.
If you do need this function for backward compatibility, the short implementation can be found in the history of scipy repository as (reproduced here without the documentation comments, license):
def signaltonoise(a, axis=0, ddof=0):
a = np.asanyarray(a)
m = a.mean(axis)
sd = a.std(axis=axis, ddof=ddof)
return np.where(sd == 0, 0, m/sd)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With