[SciPy-Dev] signal.spectrogram doesn't change nperseg to length of window?

David Nicholson nicholdav at gmail.com
Sat Nov 19 22:41:15 EST 2016


Hi scipy-dev list,

I'm using spectrogram from scipy.signal with a custom window. My
understanding from the docs is that when I provide an array_like for the
window, the value for nperseg will change from the default of 256 to
whatever the length is of the window I provide.

But instead I get an error saying  'noverlap must be less than nperseg' and
when I check with pdb I can see that nperseg is still the default value.
I'm using a value for noverlap that's larger than the default nperseg, but
less than the length of the window. I don't get the error if I call the
function with 'nperseg=window.shape[0]'.

 I skimmed the source and don't see anything in the _spect_helper function
that would change nperseg to the length of window.

Am I misunderstanding the docs, or am I calling the function wrong, or is
this a bug?

Here's my code:
from scipy.io import wavfile
from scipy.signal import slepian # i.e. 'DPSS' window used for FFT
from scipy.signal import spectrogram

FFT_SIZE = 512
FFT_OVERLAP = FFT_SIZE - 32
win_dpss = slepian(FFT_SIZE, 4/FFT_SIZE) #shape =

[rate,data] = wavfile.read('a_file_you_have.wav')
f,t,spec = spectrogram(data, rate, window=win_dpss, noverlap=FFT_OVERLAP)

Thanks for your help
--David

-- 
David Nicholson, Ph.D. Candidate
Sober Lab <http://www.biology.emory.edu/research/Sober/Home.html>, Emory
Neuroscience Program. <http://www.emory.edu/NEUROSCIENCE/>
www.nicholdav.info; <http://www.nicholdav.info>https://github.com/NickleDave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20161119/3e97d6a9/attachment.html>


More information about the SciPy-Dev mailing list