def spec(T, axis=0):
  T = signal.detrend(T, axis=axis)
  win = np.hanning(T.shape[axis])
  win.shape = (np.where(np.arange(T.ndim) == axis, -1, 1))
  return np.fft.rfft(T * win, axis=axis)
Combined detrending, windowing and real-valued FFT over axis.
dataset/ETHPy150Open breuderink/eegtools/eegtools/featex.py/spec