0
$\begingroup$

Using the STFT function from scipy.signal has produced unexpected results for me.

I am performing an STFT on 10 seconds of data, sampled at 25,000 Hz. I am using STFT settings of nperseg=256 and noverlap=192.

Using these settings I expected to get 3903 FFTs in my STFT array i.e.

(fs x t - nperseg )/(nperseg-noverlap) (25000 x 10 - 256)/(256-192) = 3902 (no. of windows subsequent to first window, rounded down) so 3902+1 total windows.

That's assuming that the first segment ends at sample 256, and subsequent segments end at integer multiples of 64 above 256 (e.g. 320, 384, 448 etc.) until there are no full 256-sample long windows left.

However, the STFT time array output seems to give time values based on the start of the window e.g. for the first window spanning sample 0 to sample 256, the time is given as 0. It also increments in integer multiples of 64 until terminating at 250048, 48 samples higher than the length of my input array.

Can anyone shed any light on what is going on here?

Thanks

$\endgroup$
0
$\begingroup$

I think my problem was that I did not include the input argument "boundary=None" in the STFT function, which specifies whether the input signal is extended at both ends, and how to generate the new values, in order to center the first windowed segment on the first input point.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.