My goal is to build a real-time filter for EEG data. The data are being recorded in 512Hz and I wish to filter it (in a real-time, from 0.5Hz to 30Hz in the most optimal way).

Unfortunately I'm not expert in DSP stuff, so I'm not sure which type of filter I should use, an IIR or FIR? What is the recommended filter type butter, cheb1, or cheb2?

All I understand is there are some properties to set when designing a filter. Among of them are the transition band, the order of the filter, a group delay, Gibbs-effect, linear phase, etc.

Currently, I'm really puzzled about these lists of properties. I also believe that some of the properties mentioned above are dependent on each other. I couldn't find any recipe that is "easy to use " on the web of how to build such a filter and what considerations should be made when building such filters.

  • $\begingroup$ what features of the signal do you need to keep? Do you want to keep the wave shape the same? (Bessel filter), or are you more interested in keeping the frequency response perfectly flat in the passband (Butterworth filter)? $\endgroup$
    – endolith
    Dec 29, 2012 at 18:28
  • $\begingroup$ @endolith. Thanks! I guess that 'keep the wave shape the same' is my preferred choice. + Quite curious to know (and learn) while Bessel filter - 'keep the wave shape the same' & Butterworth filter - ' keeping the frequency response perfectly ' $\endgroup$
    – Dov
    Dec 29, 2012 at 18:38
  • 1
    $\begingroup$ well it depends what you're doing with the EEG signal. some examples here: analogservices.com/effect.htm $\endgroup$
    – endolith
    Dec 29, 2012 at 20:26

1 Answer 1


I'll try to guide your research a bit rather than giving you a direct answer. One-click recipes aren't too good for obtaining optimal results, and this requires some careful insight. After all, you are dealing with biological signals.

To develop a real-time filter you need to process each sample/window before the next one comes up. You need to take into account the CPU time available for your calculations (depending on the platform) and the number of signals you must filter at once (with the subsequent impact in used memory, of course). After all, a digital filter is no more than a bunch of sums and products.

Now you should study the kind of signal you need to filter. You seem to be handling frequencies from delta to beta waves. You need an insight in the characteristics of each signal so that you keep them after the filtering (e.g. if studying brain activity during sleep, you should make sure that you don't miss out k-complexes and spindles during Phase II). This way you can look into some values: the maximum band pass ripple you are allowed, the width of the transition band, etc.

Having this information, after some research (e.g. Digital filter design by Burrus & Parks; Discrete-time signal processing by Oppenheim & Schafer) you can choose the kind of filter you need, and go into further details about implementation.

Fortunately, with a simple google query you can find out lots of things. There are Matlab toolboxes available to aid your filter design:

  • FDATool, Matlab filter design toolbox.

  • you can also take a look on ERPLab, which seems a good starting point.

And lots of free papers: Google query for "EEG filtering".

The higher the order of the filter, the more accurate it is, but the more operations per second it needs. So the main constraint here is that you need to keep it real-time for a bunch of signals.

  • $\begingroup$ Thanks for your answer. However as this is a DSP forum I expected more DSP stuff rather than EEG ...Currently i'm interested in all the EEG bands (as I wrote - i want it to be from 0.5Hz to 30Hz). I would love to hear more about the trade off in the order of the filter, the group delay, the Gibbs-effect and linear phase, etc. $\endgroup$
    – Dov
    Jan 2, 2013 at 6:49
  • 1
    $\begingroup$ I probably misunderstood your question. I tried to give you an overview of the topic, so that you can investigate on your own. I think you should take a look on any of the books I mentioned, or some good reference - other, including e.g. the effects of a non linear phase and then ask back the concrete concepts you don't understand. $\endgroup$
    – Serge
    Jan 2, 2013 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.