def _mt_spectra(x, dpss, sfreq, n_fft=None):
 if (n_fft is None):
  n_fft = x.shape[1]
 x = (x - np.mean(x, axis=(-1))[:, np.newaxis])
 freqs = fftpack.fftfreq(n_fft, (1.0 / sfreq))
 freq_mask = (freqs >= 0)
 freqs = freqs[freq_mask]
 n_tapers = (dpss.shape[0] if (dpss.ndim > 1) else 1)
 x_mt = np.zeros((len(x), n_tapers, freq_mask.sum()), dtype=np.complex128)
 for (idx, sig) in enumerate(x):
  x_mt[idx] = fftpack.fft((sig[np.newaxis, :] * dpss), n=n_fft)[:, freq_mask]
 return (x_mt, freqs)

def _mt_spectra ( x , dpss , sfreq , n_fft = None ) : if ( n_fft is None ) : n_fft = x . shape [ 1 ] x = ( x - np . mean ( x , axis = ( - 1 ) ) [ : , np . newaxis ] ) freqs = fftpack . fftfreq ( n_fft , ( 1.0 / sfreq ) ) freq_mask = ( freqs >= 0 ) freqs = freqs [ freq_mask ] n_tapers = ( dpss . shape [ 0 ] if ( dpss . ndim > 1 ) else 1 ) x_mt = np . zeros ( ( len ( x ) , n_tapers , freq_mask . sum ( ) ) , dtype = np . complex128 ) for ( idx , sig ) in enumerate ( x ) : x_mt [ idx ] = fftpack . fft ( ( sig [ np . newaxis , : ] * dpss ) , n = n_fft ) [ : , freq_mask ] return ( x_mt , freqs )
compute tapered spectra .