1、Scipy计算SNR,正式版本中已删除,原定义如下:

    1. def signaltonoise(a, axis=0, ddof=0):
    2. """
    3. The signal-to-noise ratio of the input data.
    4. Returns the signal-to-noise ratio of `a`, here defined as the mean
    5. divided by the standard deviation.
    6. Parameters
    7. ----------
    8. a : array_like
    9. An array_like object containing the sample data.
    10. axis : int or None, optional
    11. Axis along which to operate. Default is 0. If None, compute over
    12. the whole array `a`.
    13. ddof : int, optional
    14. Degrees of freedom correction for standard deviation. Default is 0.
    15. Returns
    16. -------
    17. s2n : ndarray
    18. The mean to standard deviation ratio(s) along `axis`, or 0 where the
    19. standard deviation is 0.
    20. """
    21. a = np.asanyarray(a)
    22. m = a.mean(axis)
    23. sd = a.std(axis=axis, ddof=ddof)
    24. return np.where(sd == 0, 0, m/sd)

    2、Dipy提供了SNR的计算

    https://github.com/scipy/scipy/blob/v0.16.0/scipy/stats/stats.py#L1963