简体   繁体   中英

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. 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.

The MATLAB documentations lists this example:

[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]. I would appreciate any input.

I usually go over the individual functions themselves -- you did a little mix-up. 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...). For the Butterworth -filter, MATLAB recommends to use the zero-pole-gain formulation rather than the standard a - b coefficients. 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

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;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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