Bandpass filtering EEG data
36 views (last 30 days)
Show older comments
Hey guys,
I am currently messing around with ways to filter EEG data I have recorded. I am currently trying bandpass filtering my data, but the data after filtering looks funky. The raw data I record is measured in mV, and has mostly "small" values, mainly <0.5 but occasionally >1. After using the bandpass filter below, data look funny, with values become "huge" (y axis goes from -400:400). I am hoping someone can give me some basic pointers on what filter parameters I need to change.
Fstop1 = 0.1; % First Stopband Frequency
Fpass1 = 0.2; % First Passband Frequency
Fpass2 = 95; % Second Passband Frequency
Fstop2 = 100; % Second Stopband Frequency
Astop1 = 60; % First Stopband Attenuation (dB)
Apass = 1; % Passband Ripple (dB)
Astop2 = 80; % Second Stopband Attenuation (dB)
match = 'stopband'; % Band to match exactly
% Construct an FDESIGN object and call its BUTTER method.
bpfilt = fdesign.bandpass(Fstop1,Fpass1,Fpass2,Fstop2,Astop1,Apass,Astop2,Fs);
Hd = design(bpfilt, 'butter', 'MatchExactly', match);
eegdata = filter(Hd,eegdata);
I have attached images on the data plotted before and after using this filter.
0 Comments
Accepted Answer
Star Strider
on 21 Nov 2014
I can’t run your code because I don’t have ‘Fs’. I almost always use the second-order-section implementation of a filter, since those tend to be stable when transfer functions are not.
Before you actually use your filter, be sure to look at the filter passband with freqz. This will tell you how stable it is and what the passband actually looks like.
2 Comments
Star Strider
on 21 Nov 2014
Edited: Star Strider
on 21 Nov 2014
Second-order sections are a bit much to explain here, so I’ll refer you to the documentation on tf2sos. I don’t see an automatic option for second-order section implementation in fdesign. I’m not that familiar with it, since I use the lower-level functions to design my filters.
A ‘transfer function’ is the frequency response of a filter (or network, control system, etc.), usually displayed as a Bode plot with amplitude and phase.
Noted for later:
Fs = 4KHz
It’s the end of my day as well.
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!