nussl/evaluation/bss_eval.py
def _scale_bss_eval(references, estimate, idx, compute_sir_sar=True):
    """
    Helper for scale_bss_eval to avoid infinite recursion loop.
    """
    source = references[..., idx]
    source_energy = (source ** 2).sum()

    alpha = (
        source @ estimate / source_energy
    )

    e_true = source
    e_res = estimate - e_true

    signal = (e_true ** 2).sum()
    noise = (e_res ** 2).sum()

    snr = 10 * np.log10(signal / noise)

    e_true = source * alpha
    e_res = estimate - e_true

    signal = (e_true ** 2).sum()
    noise = (e_res ** 2).sum()

    si_sdr = 10 * np.log10(signal / noise)

    srr = -10 * np.log10((1 - (1/alpha)) ** 2)
    sd_sdr = snr + 10 * np.log10(alpha ** 2)

    si_sir = np.nan
    si_sar = np.nan

    if compute_sir_sar:
        references_projection = references.T @ references

        references_onto_residual = np.dot(references.transpose(), e_res)
        b = np.linalg.solve(references_projection, references_onto_residual)

        e_interf = np.dot(references, b)
        e_artif = e_res - e_interf

        si_sir = 10 * np.log10(signal / (e_interf ** 2).sum())
        si_sar = 10 * np.log10(signal / (e_artif ** 2).sum())

    return si_sdr, si_sir, si_sar, sd_sdr, snr, srr

    Helper for scale_bss_eval to avoid infinite recursion loop.
    
Helper for scale_bss_eval to avoid infinite recursion loop.
Helper for scale_bss_eval to avoid infinite recursion loop .
def _scale_bss_eval(references, estimate, idx, compute_sir_sar=True):
    source = references[..., idx]
    source_energy = (source ** 2).sum()
    alpha = (
        source @ estimate / source_energy
    )
    e_true = source
    e_res = estimate - e_true
    signal = (e_true ** 2).sum()
    noise = (e_res ** 2).sum()
    snr = 10 * np.log10(signal / noise)
    e_true = source * alpha
    e_res = estimate - e_true
    signal = (e_true ** 2).sum()
    noise = (e_res ** 2).sum()
    si_sdr = 10 * np.log10(signal / noise)
    srr = -10 * np.log10((1 - (1/alpha)) ** 2)
    sd_sdr = snr + 10 * np.log10(alpha ** 2)
    si_sir = np.nan
    si_sar = np.nan
    if compute_sir_sar:
        references_projection = references.T @ references
        references_onto_residual = np.dot(references.transpose(), e_res)
        b = np.linalg.solve(references_projection, references_onto_residual)
        e_interf = np.dot(references, b)
        e_artif = e_res - e_interf
        si_sir = 10 * np.log10(signal / (e_interf ** 2).sum())
        si_sar = 10 * np.log10(signal / (e_artif ** 2).sum())
    return si_sdr, si_sir, si_sar, sd_sdr, snr, srr
def _scale_bss_eval ( references , estimate , idx , compute_sir_sar = True ) : source = references [ ... , idx ] source_energy = ( source ** 2 ) . sum ( ) alpha = ( source @ estimate / source_energy ) e_true = source e_res = estimate - e_true signal = ( e_true ** 2 ) . sum ( ) noise = ( e_res ** 2 ) . sum ( ) snr = 10 * np . log10 ( signal / noise ) e_true = source * alpha e_res = estimate - e_true signal = ( e_true ** 2 ) . sum ( ) noise = ( e_res ** 2 ) . sum ( ) si_sdr = 10 * np . log10 ( signal / noise ) srr = - 10 * np . log10 ( ( 1 - ( 1 / alpha ) ) ** 2 ) sd_sdr = snr + 10 * np . log10 ( alpha ** 2 ) si_sir = np . nan si_sar = np . nan if compute_sir_sar : references_projection = references . T @ references references_onto_residual = np . dot ( references . transpose ( ) , e_res ) b = np . linalg . solve ( references_projection , references_onto_residual ) e_interf = np . dot ( references , b ) e_artif = e_res - e_interf si_sir = 10 * np . log10 ( signal / ( e_interf ** 2 ) . sum ( ) ) si_sar = 10 * np . log10 ( signal / ( e_artif ** 2 ) . sum ( ) ) return si_sdr , si_sir , si_sar , sd_sdr , snr , srr
Helper for scale_bss_eval to avoid infinite recursion loop.
Helper for scale_bss_eval to avoid infinite recursion loop .
"""
    Helper for scale_bss_eval to avoid infinite recursion loop.
    """
references
estimate
idx
compute_sir_sar