[英]Proper use of window parameter for Welch power spectral density (scipy)?
I am trying to calculate the Welch power spectral density over specific frequency bands for EEG signal processing ($\delta$ (0–4 Hz), $\theta$ (4–8 Hz), $\alpha$ (8–13 Hz), $\beta$ (13–30 Hz), $\gamma_1$ (30–60 Hz), and $\gamma_2$ (60–90 Hz)).我正在尝试计算用于 EEG 信号处理的特定频段上的 Welch 功率谱密度($\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))。 I thought I could accomplish this by passing an array of integers with the desired frequency bins to the 'window' parameter, but this doesn't quite work as expected.
我想我可以通过将具有所需频率区间的整数数组传递给“窗口”参数来实现这一点,但这并不像预期的那样工作。 Unfortunately this particular use case of the parameter is not well documented, so I'm having a hard time understanding how I can alter my code to at least get close to the abovementioned bins.
不幸的是,这个参数的特殊用例没有得到很好的记录,所以我很难理解如何更改我的代码以至少接近上述垃圾箱。
Currently, I am doing the following:目前,我正在执行以下操作:
bands = [0,4,8,13,30,60,90]
frequency_bins, psd = welch(sample, fs=256, window=bands)
However, frequency_bins==[0, 36.57142857, 73.14285714, 109.71428571]
.但是,
frequency_bins==[0, 36.57142857, 73.14285714, 109.71428571]
。 Can anyone explain what the window
parameter is accomplishing in this case, and if it is possible to somehow make the frequency_bins
output equal to bands
?谁能解释在这种情况下
window
参数完成了什么,以及是否有可能以某种方式使frequency_bins
输出等于bands
?
I think this code may help you.我认为这段代码可以帮助你。
# 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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.