clarity.evaluator.haspi.ebm module

HASPI EBM module

clarity.evaluator.haspi.ebm.add_noise(reference_db: ndarray, thresh_db: float) ndarray[source]

Add independent random Gaussian noise to the subsampled signal envelope in each auditory frequency band.

Parameters:
  • () (thresh_db) – subsampled envelope in dB re:auditory threshold

  • () – additive noise RMS level (in dB)

Returns:

auditory threshold

Return type:

() envelope with threshold noise added, in dB re

Updates:

James M. Kates, 23 April 2019. Translated from MATLAB to Python by Zuzanna Podwinska, March 2022.

clarity.evaluator.haspi.ebm.cepstral_correlation_coef(reference_db: ndarray, processed_db: ndarray, thresh_cep: float, thresh_nerve: float, nbasis: int) tuple[ndarray, ndarray][source]

Compute the cepstral correlation coefficients between the reference signal and the distorted signal log envelopes. The silence portions of the signals are removed prior to the calculation based on the envelope of the reference signal. For each time sample, the log spectrum in dB SL is fitted with a set of half-cosine basis functions. The cepstral coefficients then form the input to the cepstral correlation calculation.

Parameters:
  • () (thresh_nerve) – subsampled reference signal envelope in dB SL in each band

  • () – subsampled distorted output signal envelope

  • () – threshold in dB SPL to include sample in calculation

  • () – additive noise RMS for IHC firing (in dB)

  • nbasis – number of cepstral basis functions to use

Returns:

refernce_cep cepstral coefficient matrix for the ref signal

(nsamp,nbasis) processed_cep cepstral coefficient matrix for the output signal (nsamp,nbasis) each column is a separate basis function, from low to high

Return type:

tuple

Updates:

James M. Kates, 23 April 2015. Gammawarp version to fit the basis functions, 11 February 2019. Additive noise for IHC firing rates, 24 April 2019.

Translated from MATLAB to Python by Zuzanna Podwinska, March 2022.

clarity.evaluator.haspi.ebm.env_filter(reference_db: ndarray, processed_db: ndarray, filter_cutoff: float, freq_sub_sample: float, freq_samp: float) tuple[ndarray, ndarray][source]

Lowpass filter and subsample the envelope in dB SL produced by the model of the auditory periphery. The LP filter uses a von Hann raised cosine window to ensure that there are no negative envelope values produced by the filtering operation.

Parameters:
  • reference_db (np.ndarray) – env in dB SL for the ref signal in each auditory band

  • processed_db (np.ndarray) – env in dB SL for the degraded signal in each auditory band

  • () (freq_samp) – LP filter cutoff frequency for the filtered envelope, Hz

  • () – subsampling frequency in Hz for the LP filtered envelopes

  • () – sampling rate in Hz for the signals xdB and ydB

Returns:

reference_env - LP filtered and subsampled reference signal envelope

Each frequency band is a separate column. processed_env - LP filtered and subsampled degraded signal envelope

Return type:

tuple

Updates:

James M. Kates, 12 September 2019. Translated from MATLAB to Python by Zuzanna Podwinska, March 2022.

clarity.evaluator.haspi.ebm.fir_modulation_filter(reference_envelope: ndarray, processed_envelope: ndarray, freq_sub_sampling: float, center_frequencies: ndarray | None = None) tuple[ndarray, ndarray, ndarray][source]

Apply a FIR modulation filterbank to the reference envelope signals contained in matrix reference_envelope and the processed signal envelope signals in matrix processed_envelope. Each column in reference_envelope and processed_envelope is a separate filter band or cepstral coefficient basis function. The modulation filters use a lowpass filter for the lowest modulation rate, and complex demodulation followed by a lowpass filter for the remaining bands. The onset and offset transients are removed from the FIR convolutions to temporally align the modulation filter outputs.

Parameters:
  • reference_envelope (np.ndarray) – matrix containing the subsampled reference envelope values. Each column is a different frequency band or cepstral basis function arranged from low to high.

  • processed_envelope (np.ndarray) – matrix containing the subsampled processed envelope values

  • () (freq_sub_sampling) – envelope sub-sampling rate in Hz

  • center_frequencies (np.ndarray) – Center Frequencies

Returns:

reference_modulation (): a cell array containing the reference signal

output of the modulation filterbank. reference_modulation is of size [nchan,nmodfilt] where nchan is the number of frequency channels or cepstral basis functions in reference_envelope, and nmodfilt is the number of modulation filters used in the analysis. Each cell contains a column vector of length nsamp, where nsamp is the number of samples in each envelope sequence contained in the columns of reference_envelope.

processed_modulation (): cell array containing the processed signal output

of the modulation filterbank.

center_frequencies (): vector of modulation rate filter center frequencies

Return type:

tuple

Updates:

James M. Kates, 14 February 2019. Two matrix version of gwarp_ModFiltWindow, 19 February 2019. Translated from MATLAB to Python by Zuzanna Podwinska, March 2022.

clarity.evaluator.haspi.ebm.modulation_cross_correlation(reference_modulation: ndarray, processed_modulation: ndarray) ndarray[source]

Compute the cross-correlations between the input signal time-frequency envelope and the distortion time-frequency envelope. The cepstral coefficients or envelopes in each frequency band have been passed through the modulation filterbank using function ebm_ModFilt.

Parameters:
  • reference_modulation (np.array) – cell array containing the reference signal output of the modulation filterbank. Xmod is of size [nchan,nmodfilt] where nchan is the number of frequency channels or cepstral basis functions in Xenv, and nmodfilt is the number of modulation filters used in the analysis. Each cell contains a column vector of length nsamp, where nsamp is the number of samples in each envelope sequence contained in the columns of Xenv.

  • processed_modulation (np.ndarray) – subsampled distorted output signal envelope

Output:
float: aveCM modulation correlations averaged over basis functions 2-6

vector of size nmodfilt

Updates:

James M. Kates, 21 February 2019. Translated from MATLAB to Python by Zuzanna Podwinska, March 2022.