简体   繁体   English

如何用黄油 function 在 Matlab 中构建带通滤波器?

[英]How to build a bandpass filter in Matlab with the butter function?

I am trying to extract the mu suppression values from my EEG dataset, which doesn't allow using EEGLab.我正在尝试从我的 EEG 数据集中提取 mu 抑制值,这不允许使用 EEGLab。 I did most of the steps, but I need to add a bandpass filter and I am not sure how.我做了大部分步骤,但我需要添加一个带通滤波器,但我不确定如何。

The frequency band I would need is 8-13, my sampling rate is 1000 and I was told I would need an order of between 8 and 10.我需要的频段是 8-13,我的采样率是 1000,有人告诉我我需要 8 到 10 之间的阶数。

The MATLAB documentations lists this example: MATLAB 文档列出了此示例:

[A,B,C,D] = butter(10,[500 560]/750); 
d = designfilt('bandpassiir','FilterOrder',20, ... 'HalfPowerFrequency1',500,'HalfPowerFrequency2',560, ... 'SampleRate',1500);

However, I am not sure, what parameters I need to use for my case except for sampling rate and filter order.但是,我不确定除了采样率和过滤器顺序外,我需要使用哪些参数。 Also, it is not clear to me what is [A,B,C,D].另外,我不清楚 [A,B,C,D] 是什么。 I would appreciate any input.我会很感激任何意见。

I usually go over the individual functions themselves -- you did a little mix-up.我通常 go 超过个别功能本身 - 你做了一点混淆。 The first input to butter is already the filter order (so you have specified order 10 and tried to specify order 20 in the desginfilt function...). desginfilt butter ...中指定顺序 20)。 For the Butterworth -filter, MATLAB recommends to use the zero-pole-gain formulation rather than the standard a - b coefficients.对于巴特沃斯滤波器,MATLAB 建议使用零极点增益公式,而不是标准a - b系数。 Here is an example:这是一个例子:

f_low = 100; % Hz
f_high = 500; % Hz
f_sampling = 10e3; % 10kHz

assert(f_low < f_high)


f_nrm_low   = f_low /(f_sampling/2);
f_nrm_high  = f_heigh /(f_sampling/2);

% determine filter coefficients:
[z,p,k] = butter(4,[f_nrm_low f_nrm_high],'bandpass');
% convert to zero-pole-gain filter parameter (recommended)
sos = zp2sos(z,p,k); 
% apply filter
sig_flt = sosfilt(sos,sig);

I have filled with with standard values from my field of working.我已经填写了我工作领域的标准值。 4th order is the overwhelming standard here.四阶是这里的压倒性标准。 In your case, you would simply go with在您的情况下,您只需使用 go

f_low = 200; % Hz
f_high = 213; % Hz
f_sampling = 1000; % 1kHz

f_nrm_low   = f_low /(f_sampling/2);
f_nrm_high  = f_heigh /(f_sampling/2);

% determine filter coefficients:
[z,p,k] = butter(15,[f_nrm_low f_nrm_high],'bandpass');

PS: the type 'bandpath' is not required as the function is aware of this if you specify an array as input;) PS:不需要'bandpath'类型,因为如果您将数组指定为输入,function 就会意识到这一点;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM