Welch功率谱密度(scipy)窗口参数的正确使用



我正试图计算用于EEG信号处理的特定频带($\delta$(0–4 Hz(、$\theta$(4–8 Hz(、\\alpha$(8–13 Hz(、[\beta$(13–30 Hz(、$$gamma_1$(30–60 Hz(和$gamma_2$(60–90 Hz((上的Welch功率谱密度。我想我可以通过将一个具有所需频率仓的整数数组传递到"window"参数来实现这一点,但这并不像预期的那样有效。不幸的是,这个参数的特殊用例没有得到很好的记录,所以我很难理解如何修改我的代码,以至少接近上面提到的bin。

目前,我正在做以下工作:

bands = [0,4,8,13,30,60,90]
frequency_bins, psd = welch(sample, fs=256, window=bands)

然而,frequency_bins==[0, 36.57142857, 73.14285714, 109.71428571]。有人能解释一下window参数在这种情况下完成了什么吗?以及是否有可能以某种方式使frequency_bins的输出等于bands

我认为这段代码可能会对您有所帮助。

# Frequency bands !
frequencies_bandes = {"delta" : [0,4],
"theta" : [4,8],
"alpha" : [8, 13],
"beta" : [13,35],
"gamma" : [30, 40]}

# Welch method to get spectrums estimation check parameters in the begining of this file 
freq , spectrum = signal.welch(your_signal,sf,nperseg=nperseg,nfft=nfft,scaling='density')
# Geting frequencies indexes 
frequencies_indexes = [np.logical_and(freq >= band[0], freq <= band[1]) for band in frequencies_bandes.values()]
# Getting mean power_energy per frequency band 
mean_power_per_band_per_channel += [np.mean(spectrum[idx]) for idx in frequencies_indexes]