[Eeglablist] Filtering in EEGLab
Andreas Widmann
widmann at uni-leipzig.de
Wed Jun 1 04:36:43 PDT 2016
Hi Victor,
> Accordingly, my questions are:
> • What equation is used to calculate the filter order?
The filter order defines the spectral resolution, that is, the minimal distance of two frequencies separated into different bands. Practically, if you design a lowpass filter and want to have 30 Hz still in the passband (no attenuation) and 40 Hz in the stopband (full attenuation) you need a spectral resolution or more precisely a transition band width of 10 Hz (with cutoff freq = 35 Hz). For windowed sinc filters you compute filter order m from transition band width df, normalized transition width dF, and sampling frequency fs with:
m = dF / (df / fs)
dF is specific for the window type. You find the equation and values for dF in [1]. For example with fs = 500 and Hamming window (dF = 3.3) you get:
m = 3.3 / (10 Hz / 500 Hz) = 165
Round to next higher even integer! Thus m = 166;
I would like to note that for linear-phase filters (as used here) the filter delay depends on the filter order (m / 2). For steep filter roll-offs the delay can be considerably long (e.g. 825 ms for df = 2 Hz from the example above). If your BCI algorithm does not depend on linear phase relationships and you need steep filter roll-offs you might want to consider minimum-phase FIR or IIR filters.
> • What does it mean pad beginning/end?
Padding is used to avoid DC artifacts at beginning and end of data (or data discontinuities). You must never filter across data discontinuities. Not sure whether this is relevant for your BCI application.
> • Because filtering is done by blocks?
This is only an implementation issue and has no effect on the filter output. If data are filtered in a single block the memory footprint is two times the dataset size. If data are filtered in smaller blocks the memory footprint is dataset size plus block size. This is unrelated to padding. Final conditions are saved for each block and used as initial conditions for the next block. The out-of-memory error problem reports on the list have decreased over the last years, so indeed it might no longer be strictly necessary to use this approach. However, as the computational overhead is surprisingly low I was reluctant so far to remove this from the code.
I hope you find the underlying concepts in more detail here :)
[1] http://www.sciencedirect.com/science/article/pii/S0165027014002866 (there is also a free preprint version here: http://home.uni-leipzig.de/~biocog/eprints/widmann_a2015jneuroscimeth250_34.pdf)
Hope this helps!
Andreas
> Am 30.05.2016 um 22:49 schrieb Victor Flores Benites <suryavf at gmail.com>:
>
> Dear all,
>
> I am working in the developed a BCI online in C++.
> In offline tests EEGLab I have obtained good results with the function pop_eegfiltnew(). I want to apply this filter in the online application.
> I understand that the window FIR filter is Hamming. The order is calculated using an equation.
> The function firfilt() performs filtering. The code starts with pad beginning of data with DC constant and get initial conditions (this indicates the code comments).
> After, filtering is performed by blocks. Finally, pad ending of data with DC constant.
>
> Accordingly, my questions are:
> • What equation is used to calculate the filter order?
> • What does it mean pad beginning/end?
> • Because filtering is done by blocks?
>
> Thank you for your help!
>
> --
> Victor Flores Benites
> Egresado Ingeniería Electrónica
> Practicante Profesional - UTEC
> +(51) 975712054 - RPM: #975712054
> suryavf at gmail.com | vflores at utec.edu.pe | vfloresb at uni.pe
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
More information about the eeglablist
mailing list