[Eeglablist] Problem with eegfilt()

Uri Maoz uri_maoz at hotmail.com
Sat Jan 23 21:53:24 PST 2016


Hello EEGLab users,
The filter that eegfilt() creates with its default parameters seems to sometimes introduce a drift into the data. To see this, run the following Matlab code:
t=0:.001:2; x=[zeros(size(t(t<1))),ones(size(t(t>=1)))]; figure; plot(t,x,'.-'); y=eegfilt(x,1000,0,10); hold on; plot(t,y,'.-'); legend('original data','filtered data');
This creates a step function and then filters it. As you can see, the filter introduces a shift in the value of the data when tracking the non-zero part of the step function. Another way to see how the filtered data drifts away from the original signal is this code:
t=0:.001:2; x=t.^2+sin(2*pi*5.*t)+randn(size(t)).*0.1; figure; plot(t,x,'.-'); y=eegfilt(x,1000,0,10); hold on; plot(t,y,'.-'); legend('original data','filtered data');
In the latest EEGLab version, the developers note that using the default fir-filter type, firls, to estimate figure parameters is problematic. Therefore, do not use the default firls; use fir1 instead. Indeed, if you try the code below with fir1, there will be no drift:
t=0:.001:2; x=[zeros(size(t(t<1))),ones(size(t(t>=1)))]; figure; plot(t,x,'.-'); y=eegfilt(x,1000,0,10,0,0,0,'fir1'); hold on; plot(t,y,'.-');
t=0:.001:2; x=t.^2+sin(2*pi*5*t)+randn(size(t)).*0.1; figure; plot(t,x,'.-'); y=eegfilt(x,1000,0,10,0,0,0,'fir1'); hold on; plot(t,y,'.-');
Best wishes,
Uri Maoz
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20160124/fbab40eb/attachment.html>


More information about the eeglablist mailing list