Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Butterworth Filtering EEG signal
Replies: 1   Last Post: Feb 22, 2013 4:06 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
William Frane

Posts: 36
Registered: 2/14/12
Re: Butterworth Filtering EEG signal
Posted: Feb 22, 2013 4:06 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

There are a few different ways to apply a Butterworth filter to data using MATLAB. Here's a method I often use:

sampleRate = #; % Hz
cutOffFreq = #; % Hz
filterOrder = #; % Filter order (e.g., 2 for a second-order Butterworth filter)
[b, a] = butter(filterOrder, cutOffFreq/(sampleRate/2)); % Generate filter coefficients
filteredData = filtfilt(b, a, inputData); % Apply filter to data using zero-phase filtering

For this code above to work, the Signal Processing Toolbox is required.

Note that the cut-off frequency is divided by half the sample rate (according to the Nyquist sampling theorem, half the sample rate is the maximum frequency that can be represented in discrete data and thus it is this value that the cut-off frequency is normalized relative to). Also note that using filtfilt (rather than the filter function) doubles the effective order of the filter because filtfilt applies it to the data twice (in opposite directions) to remove phase distortion.

Hope that helps.

Will



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.