nussl/separation/spatial/duet.py
def _make_histogram(self):
        """Receives the stft of the two channel mixtures and the frequency matrix to a create
        a smooth and normalized histogram.

        Parameters:
        stft_ch0 (complex np.array): a 2D Numpy matrix containing the stft of channel 0
        stft_ch1 (complex np.array): a 2D Numpy matrix containing the stft of channel 1
        symmetric_atn (np.array): the symmetric attenuation between two channels
        delay (np.array): the time delay between 2 channels
        wmat(np.array): a 2D Numpy matrix containing the frequency matrix of the signal

        Returns:
            histogram (np.array): a smooth and normalized histogram
            atn_bins (np.array): The range of attenuation values distributed into bins
            delay_bins (np.array): The range of delay values distributed into bins
        """
        # calculate the weighted histogram
        time_frequency_weights = (np.abs(self.stft_ch0) * np.abs(self.stft_ch1)) ** self.p * \
                                 (np.abs(self.frequency_matrix)) ** self.q

        # only consider time-freq. points yielding estimates in bounds
        attenuation_premask = np.logical_and(self.attenuation_min < self.symmetric_atn,
                                             self.symmetric_atn < self.attenuation_max)

        delay_premask = np.logical_and(self.delay_min < self.delay, self.delay < self.delay_max)
        attenuation_delay_premask = np.logical_and(attenuation_premask, delay_premask)

        nonzero_premask = np.nonzero(attenuation_delay_premask)
        symmetric_attenuation_vector = self.symmetric_atn[nonzero_premask]
        delay_vector = self.delay[nonzero_premask]
        time_frequency_weights_vector = time_frequency_weights[nonzero_premask]

        bins_array = np.array([self.num_attenuation_bins, self.num_delay_bins])
        range_array = np.array([[self.attenuation_min, self.attenuation_max], [self.delay_min, self.delay_max]])

        # compute the histogram
        histogram, atn_bins, delay_bins = np.histogram2d(symmetric_attenuation_vector, delay_vector,
                                                         bins=bins_array, range=range_array,
                                                         weights=time_frequency_weights_vector)

        # Save non-normalized as an option for plotting later
        self.attenuation_delay_histogram = histogram

        # Scale histogram from 0 to 1
        histogram /= histogram.max()

        # smooth the normalized histogram - local average 3-by-3 neighboring bins
        histogram = self._smooth_matrix(histogram, np.array([3]))
        return histogram, atn_bins, delay_bins
Receives the stft of the two channel mixtures and the frequency matrix to a create
        a smooth and normalized histogram.

        Parameters:
        stft_ch0 (complex np.array): a 2D Numpy matrix containing the stft of channel 0
        stft_ch1 (complex np.array): a 2D Numpy matrix containing the stft of channel 1
        symmetric_atn (np.array): the symmetric attenuation between two channels
        delay (np.array): the time delay between 2 channels
        wmat(np.array): a 2D Numpy matrix containing the frequency matrix of the signal

        Returns:
            histogram (np.array): a smooth and normalized histogram
            atn_bins (np.array): The range of attenuation values distributed into bins
            delay_bins (np.array): The range of delay values distributed into bins
        
Receives the stft of the two channel mixtures and the frequency matrix to a create
a smooth and normalized histogram.



histogram (np.array): a smooth and normalized histogram
atn_bins (np.array): The range of attenuation values distributed into bins
delay_bins (np.array): The range of delay values distributed into bins
Receives the stft of the two channel mixtures and the frequency matrix to a create a smooth and normalized histogram . histogram ( np . array ) : a smooth and normalized histogram atn_bins ( np . array ) : The range of attenuation values distributed into bins delay_bins ( np . array ) : The range of delay values distributed into bins
def _make_histogram(self):
        time_frequency_weights = (np.abs(self.stft_ch0) * np.abs(self.stft_ch1)) ** self.p * \
                                 (np.abs(self.frequency_matrix)) ** self.q
        attenuation_premask = np.logical_and(self.attenuation_min < self.symmetric_atn,
                                             self.symmetric_atn < self.attenuation_max)
        delay_premask = np.logical_and(self.delay_min < self.delay, self.delay < self.delay_max)
        attenuation_delay_premask = np.logical_and(attenuation_premask, delay_premask)
        nonzero_premask = np.nonzero(attenuation_delay_premask)
        symmetric_attenuation_vector = self.symmetric_atn[nonzero_premask]
        delay_vector = self.delay[nonzero_premask]
        time_frequency_weights_vector = time_frequency_weights[nonzero_premask]
        bins_array = np.array([self.num_attenuation_bins, self.num_delay_bins])
        range_array = np.array([[self.attenuation_min, self.attenuation_max], [self.delay_min, self.delay_max]])
        histogram, atn_bins, delay_bins = np.histogram2d(symmetric_attenuation_vector, delay_vector,
                                                         bins=bins_array, range=range_array,
                                                         weights=time_frequency_weights_vector)
        self.attenuation_delay_histogram = histogram
        histogram /= histogram.max()
        histogram = self._smooth_matrix(histogram, np.array([3]))
        return histogram, atn_bins, delay_bins
def _make_histogram ( self ) : time_frequency_weights = ( np . abs ( self . stft_ch0 ) * np . abs ( self . stft_ch1 ) ) ** self . p * ( np . abs ( self . frequency_matrix ) ) ** self . q attenuation_premask = np . logical_and ( self . attenuation_min < self . symmetric_atn , self . symmetric_atn < self . attenuation_max ) delay_premask = np . logical_and ( self . delay_min < self . delay , self . delay < self . delay_max ) attenuation_delay_premask = np . logical_and ( attenuation_premask , delay_premask ) nonzero_premask = np . nonzero ( attenuation_delay_premask ) symmetric_attenuation_vector = self . symmetric_atn [ nonzero_premask ] delay_vector = self . delay [ nonzero_premask ] time_frequency_weights_vector = time_frequency_weights [ nonzero_premask ] bins_array = np . array ( [ self . num_attenuation_bins , self . num_delay_bins ] ) range_array = np . array ( [ [ self . attenuation_min , self . attenuation_max ] , [ self . delay_min , self . delay_max ] ] ) histogram , atn_bins , delay_bins = np . histogram2d ( symmetric_attenuation_vector , delay_vector , bins = bins_array , range = range_array , weights = time_frequency_weights_vector ) self . attenuation_delay_histogram = histogram histogram /= histogram . max ( ) histogram = self . _smooth_matrix ( histogram , np . array ( [ 3 ] ) ) return histogram , atn_bins , delay_bins
Receives the stft of the two channel mixtures and the frequency matrix to a create
a smooth and normalized histogram.
Receives the stft of the two channel mixtures and the frequency matrix to a create a smooth and normalized histogram .
"""Receives the stft of the two channel mixtures and the frequency matrix to a create
        a smooth and normalized histogram.

        Parameters:
        stft_ch0 (complex np.array): a 2D Numpy matrix containing the stft of channel 0
        stft_ch1 (complex np.array): a 2D Numpy matrix containing the stft of channel 1
        symmetric_atn (np.array): the symmetric attenuation between two channels
        delay (np.array): the time delay between 2 channels
        wmat(np.array): a 2D Numpy matrix containing the frequency matrix of the signal

        Returns:
            histogram (np.array): a smooth and normalized histogram
            atn_bins (np.array): The range of attenuation values distributed into bins
            delay_bins (np.array): The range of delay values distributed into bins
        """ # calculate the weighted histogram # only consider time-freq. points yielding estimates in bounds # compute the histogram # Save non-normalized as an option for plotting later # Scale histogram from 0 to 1 # smooth the normalized histogram - local average 3-by-3 neighboring bins
self