Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



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 secondorder Butterworth filter) [b, a] = butter(filterOrder, cutOffFreq/(sampleRate/2)); % Generate filter coefficients filteredData = filtfilt(b, a, inputData); % Apply filter to data using zerophase filtering
For this code above to work, the Signal Processing Toolbox is required.
Note that the cutoff 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 cutoff 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



