def snr(test, ref, mask=None):
    """Signal-to-Noise Ratio (SNR)

    Calculate the SNR between a test image and a reference image.

    Parameters
    ----------
    ref: np.ndarray
        the reference image
    test: np.ndarray
        the tested image
    mask: np.ndarray, optional
        the mask for the ROI

    Notes
    -----
    Compute the metric only on magnetude.

    Returns
    -------
    snr: float, the snr

    """

    test, ref, mask = _preprocess_input(test, ref, mask)

    if mask is not None:
        test = mask * test

    num = np.mean(np.square(test))
    deno = mse(test, ref)

    return 10.0 * np.log10(num / deno)
Signal-to-Noise Ratio (SNR)

    Calculate the SNR between a test image and a reference image.

    Parameters
    ----------
    ref: np.ndarray
        the reference image
    test: np.ndarray
        the tested image
    mask: np.ndarray, optional
        the mask for the ROI

    Notes
    -----
    Compute the metric only on magnetude.

    Returns
    -------
    snr: float, the snr