nussl/separation/primitive/repet.py
def _compute_repeating_mask(self, magnitude_spectrogram_channel):
        """
        Computes the soft mask for the repeating part using the magnitude 
        spectrogram and the repeating period

        Args:
            magnitude_spectrogram_channel (:obj:`np.array`): 2D matrix containing the 
              magnitude spectrogram of a signal
            
        Returns:
            (:obj:`np.array`): 2D matrix (Lf by Lt) containing the soft mask for the 
              repeating part, elements of M take on values in ``[0, 1]``

        """
        period = self.repeating_period
        freq_bins, time_bins = magnitude_spectrogram_channel.shape
        n_repetitions = int(np.ceil(float(time_bins) / period))
        one_period = freq_bins * period

        # Pad to make an integer number of repetitions. Pad with 'nan's to not affect the median.
        remainder = (period * n_repetitions) % time_bins
        mask_reshaped = np.hstack(
            [magnitude_spectrogram_channel,
             float('nan') * np.zeros((freq_bins, remainder))]
        )

        # reshape to take the median of each period
        mask_reshaped = np.reshape(mask_reshaped.T, (n_repetitions, one_period))

        # take median of repeating periods before and after the padding
        median_mask = np.nanmedian(mask_reshaped, axis=0)

        # reshape to it's original shape
        median_mask = np.reshape(
            np.tile(median_mask, (n_repetitions, 1)),
            (n_repetitions * period, freq_bins)).T
        median_mask = median_mask[:, :time_bins]

        # take minimum of computed mask and original input and scale
        min_median_mask = np.minimum(median_mask, magnitude_spectrogram_channel)
        mask = (min_median_mask + constants.EPSILON) / (
                    magnitude_spectrogram_channel + constants.EPSILON)

        return mask

        Computes the soft mask for the repeating part using the magnitude 
        spectrogram and the repeating period

        Args:
            magnitude_spectrogram_channel (:obj:`np.array`): 2D matrix containing the 
              magnitude spectrogram of a signal
            
        Returns:
            (:obj:`np.array`): 2D matrix (Lf by Lt) containing the soft mask for the 
              repeating part, elements of M take on values in ``[0, 1]``

        
Computes the soft mask for the repeating part using the magnitude
spectrogram and the repeating period
Computes the soft mask for the repeating part using the magnitude spectrogram and the repeating period
def _compute_repeating_mask(self, magnitude_spectrogram_channel):
        period = self.repeating_period
        freq_bins, time_bins = magnitude_spectrogram_channel.shape
        n_repetitions = int(np.ceil(float(time_bins) / period))
        one_period = freq_bins * period
        remainder = (period * n_repetitions) % time_bins
        mask_reshaped = np.hstack(
            [magnitude_spectrogram_channel,
             float('nan') * np.zeros((freq_bins, remainder))]
        )
        mask_reshaped = np.reshape(mask_reshaped.T, (n_repetitions, one_period))
        median_mask = np.nanmedian(mask_reshaped, axis=0)
        median_mask = np.reshape(
            np.tile(median_mask, (n_repetitions, 1)),
            (n_repetitions * period, freq_bins)).T
        median_mask = median_mask[:, :time_bins]
        min_median_mask = np.minimum(median_mask, magnitude_spectrogram_channel)
        mask = (min_median_mask + constants.EPSILON) / (
                    magnitude_spectrogram_channel + constants.EPSILON)
        return mask
def _compute_repeating_mask ( self , magnitude_spectrogram_channel ) : period = self . repeating_period freq_bins , time_bins = magnitude_spectrogram_channel . shape n_repetitions = int ( np . ceil ( float ( time_bins ) / period ) ) one_period = freq_bins * period remainder = ( period * n_repetitions ) % time_bins mask_reshaped = np . hstack ( [ magnitude_spectrogram_channel , float ( 'nan' ) * np . zeros ( ( freq_bins , remainder ) ) ] ) mask_reshaped = np . reshape ( mask_reshaped . T , ( n_repetitions , one_period ) ) median_mask = np . nanmedian ( mask_reshaped , axis = 0 ) median_mask = np . reshape ( np . tile ( median_mask , ( n_repetitions , 1 ) ) , ( n_repetitions * period , freq_bins ) ) . T median_mask = median_mask [ : , : time_bins ] min_median_mask = np . minimum ( median_mask , magnitude_spectrogram_channel ) mask = ( min_median_mask + constants . EPSILON ) / ( magnitude_spectrogram_channel + constants . EPSILON ) return mask
Computes the soft mask for the repeating part using the magnitude
spectrogram and the repeating period
Computes the soft mask for the repeating part using the magnitude spectrogram and the repeating period
"""
        Computes the soft mask for the repeating part using the magnitude 
        spectrogram and the repeating period

        Args:
            magnitude_spectrogram_channel (:obj:`np.array`): 2D matrix containing the 
              magnitude spectrogram of a signal
            
        Returns:
            (:obj:`np.array`): 2D matrix (Lf by Lt) containing the soft mask for the 
              repeating part, elements of M take on values in ``[0, 1]``

        """ # Pad to make an integer number of repetitions. Pad with 'nan's to not affect the median. # reshape to take the median of each period # take median of repeating periods before and after the padding # reshape to it's original shape # take minimum of computed mask and original input and scale
`np.array`): 2D matrix (Lf by Lt) containing the soft mask for the
repeating part, elements of M take on values in ``[0, 1]``
` np . array ` ) : 2D matrix ( Lf by Lt ) containing the soft mask for the repeating part elements of M take on values in ` ` [ 0 1 ] ` `
(
self
magnitude_spectrogram_channel
magnitude_spectrogram_channel (
`np.array`): 2D matrix containing the
magnitude spectrogram of a signal
` np . array ` ) : 2D matrix containing the magnitude spectrogram of a signal