def compute(self, waveforms, window_length, increment, samplerate=16000, min_freq=0, max_freq=None, nstd=6, offset=50): signal, stimulus = waveforms self.time, self.frequencies, spec = gaussian_stft(signal, samplerate, window_length, increment, min_freq=min_freq, max_freq=max_freq, nstd=nstd)[:3] stim_spec = gaussian_stft(stimulus, samplerate, window_length, increment, min_freq=min_freq, max_freq=max_freq, nstd=nstd)[2] ratio_mask = np.abs(spec) ** self.alpha / np.abs(stim_spec) ** self.alpha ratio_mask = np.maximum(0, np.minimum(1, ratio_mask)).T stim_spec = log_spectrogram(np.abs(stim_spec), offset=offset).T self.mean = np.mean(stim_spec, axis=0) stim_spec -= self.mean return stim_spec, ratio_mask
def compute(self, waveform, window_length, increment, samplerate=16000, min_freq=0, max_freq=None, nstd=6, offset=50): self.time, self.frequencies, spec = gaussian_stft(waveform, samplerate, window_length, increment, min_freq=min_freq, max_freq=max_freq, nstd=nstd)[:3] return log_spectrogram(np.abs(spec), offset=offset).T