首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >利用信噪比检测脑电信号中的α波?python

利用信噪比检测脑电信号中的α波?python
EN

Stack Overflow用户
提问于 2019-02-23 10:58:20
回答 1查看 783关注 0票数 1

我正在编写一个实时检测阿尔法波的函数。我的函数接收256个单个通道的样本值作为参数。在那之后,它的fft必须被发现,然后分类在α,β和伽马范围。然后我要找出信噪比来检查是否存在阿尔法波,即在10赫兹频率下是否存在任何峰值。所以我需要找出10赫兹的振幅平方除以b/w范围内8-12赫兹除以N的所有数值的平方。

SNR =10 No/(8~12 No/ No. )安培值的平方.在这些价值中)

然后记录信噪比并检查阈值。

基本上,如何得到10赫兹的安培值的平方,然后排除这个值,除以其余的数值。

我已经写了启动码,下面可以有人指导或帮助完成代码,以完成所需的工作。非常感谢。

def分类(标志,data=[]):

代码语言:javascript
复制
fs = 200  # Sampling rate (512 Hz)


# Get real amplitudes of FFT (only in postive frequencies)
fft_vals = np.absolute(np.fft.rfft(data))    #these are my fft values rfft returns only the part of the result that corresponds to nonpositive frequences. (Avoids complex conjugaes) faster and for plotting

# Get frequencies for amplitudes in Hz
fft_freq = np.fft.rfftfreq(len(data), 1.0 / fs)     # that might be fixed (window length n , and  sample spacing) inverse of the sampling rate   returns sample freq of length n .

# Define EEG bands
eeg_bands = {'Delta': (0, 4),
             'Theta': (4, 8),
             'Alpha': (8, 12),
             'Beta': (12, 30),
             'Gamma': (30, 45)}

# Take the mean of the fft amplitude for each EEG band
eeg_band_fft = dict()
for band in eeg_bands:
    freq_ix = np.where((fft_freq >= eeg_bands[band][0]) &   #np.where is like asking "tell me where in this array, entries satisfy a given condition".
                       (fft_freq <= eeg_bands[band][1]))[0]    #for fft_frreq at all point where it satisfies it returns the index (in array)
                                                             #if fftfreq[np.where bla bla] will give values array
    eeg_band_fft[band] = np.mean(fft_vals[freq_ix])
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-26 10:47:23

该代码已经在使用带通滤波器提取阿尔法频率。现在,要在特定频率上找到信噪比,您只需将该频率上的值平方除以其余的频率,并取20对数的除法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54840842

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档