Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 William Frane Posts: 36 Registered: 2/14/12
Re: Butterworth Filtering EEG signal
Posted: Feb 22, 2013 4:06 PM

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