We have seen the design and application of filtering on sinusoids and now we are going to filter a real signal. We are going to work on the first channel of the signal we read at the chapter on European Data Format. In that chapter we saved a file called `signals' as a variable of Scilab. It is a huge file but we can recover easily the signals that constitute the recording.
Our objective is to filter the first channel by eliminating frequencies above 4 Hz. The first channel is a `Fpz-M2' derivation and we are trying to extract activities in delta band. We know that the signal has been sampled at 100 Hz. The next code uses `iir'. Since sampling frequency is 100 Hz and we want to extract components under 4 Hz, we adjust the cut-off frequency at 0.04 (4/100).
stacksize(20000000);
load signals;
base = signals(1);
t = [1:length(base)]*.01; // adjust time
lisys1 = iir (10,'lp','butt',[.04 0],[0 0]); // designs lp filter
resul1 = flts(base,lisys1); // applies lp filter
lisys2 = iir (10,'hp','butt',[.04 0],[0 0]); // designs hp filter
resul2 = flts(base,lisys2); // applies hp filter
xsetech([0,0,1,1/3]);
plot2d(t(1:500),base(1:500),1,"011"," ",[0,-1500,5,1500]);
xtitle ('original signal');
xsetech([0,1/3,1,1/3]);
plot2d(t(1:500),resul1(1:500),1,"011"," ",[0,-1500,5,1500]);
xtitle ('low pass filtered');
xsetech([0,2/3,1,1/3]);
plot2d(t(1:500),resul2(1:500),1,"011"," ",[0,-1500,5,1500]);
xtitle('high pass filtered');
First of all, we increase the size of the stack and read the signals. Since we are going to work on the first channel, we extract this signal (we call it `base'). Afterwards, we design a low pass filter with a cut-off of 4 Hz (0.04) and apply the filter on `base' to get the low pass filtered signal. We store the result in the array `result1'. Then we repeat the process but designing a high pass filter. Finally we plot the signals and this is the result.
![]() |
Since we adjusted the time scale, the whole signal spans 5 seconds. Each division in x-axis is 0.5 s. So, if our process has functioned properly, the middle frame should not contain waves lasting less than 0.25 s and the bottom frame should not contain any wave lasting less than 0.25 s. The filter seems to have worked correctly.