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.
![]() |