syncopy.specest.mtmconvol.mtmconvol#
- syncopy.specest.mtmconvol.mtmconvol(data_arr, samplerate, nperseg, noverlap=None, taper='hann', taper_opt=None, boundary='zeros', padded=True, detrend=False)[source]#
(Multi-)tapered short time fast Fourier transform. Returns full complex Fourier transform for each taper. Multi-tapering only supported with Slepian windwows (taper=”dpss”).
- Parameters:
data_arr ((N,)
numpy.ndarray
) – Uniformly sampled multi-channel time-series data The 1st dimension is interpreted as the time axissamplerate (float) – Samplerate in Hz
nperseg (int) – Sliding window size in sample units
noverlap (int) – Overlap between consecutive windows, set to
nperseg - 1
to cover the whole signaltaper (str or None) – Taper function to use, one of scipy.signal.windows Set to None for no tapering.
taper_opt (dict or None) – Additional keyword arguments passed to the taper function. For multi-tapering with
taper='dpss'
set the keys ‘Kmax’ and ‘NW’. For further details, please refer to the SciPy docsboundary (str or None) – Wether or not to auto-pad the signal such that a window is centered on each sample. If set to None half the window size (nperseg) will be lost on each side of the signal. Defaults ‘zeros’, for zero padding extension.
padded (bool) – Additional padding in case
noverlap != nperseg - 1
to fit an integer number of windows.
- Returns:
ftr (4D
numpy.ndarray
) – The Fourier transforms, complex output has shape:(nTime, nTapers x nFreq x nChannels)
freqs (1D
numpy.ndarray
) – Array of Fourier frequencies
Notes
For a (MTM) power spectral estimate average the absolute squared transforms across tapers:
Sxx = np.real(ftr * ftr.conj()).mean(axis=0)
The STFT result is normalized such that this yields the power spectral density. For a clean harmonic and a frequency bin width of dF this will give a peak power of A**2 / 2 * dF, with A as harmonic ampltiude.