Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

bandpass filtering signal in MATLAB

Status
Not open for further replies.

thomas_oelund

Newbie level 2
Joined
Apr 1, 2011
Messages
2
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,300
Hey guys

I have a problem with filtering a biological EEG signal. The frequency band
of interest is 2-7 Hz, so
I've created a passband filter using the FDA toolbox, it looks like this:
The input (data) is my signal.

function DataFilt = bandpass(data)
%UNTITLED Returns a discrete-time filter object.

%
% M-File generated by MATLAB(R) 7.6 and the Signal Processing Toolbox 6.9.1.
%
% Generated on: 31-Mar-2011 17:04:23
%

% Equiripple Bandpass filter designed using the FIRPM function.

% All frequency values are in Hz.
Fs = 200; % Sampling Frequency

N = 1000; % Order
Fstop1 = 1.5; % First Stopband Frequency
Fpass1 = 2; % First Passband Frequency
Fpass2 = 7; % Second Passband Frequency
Fstop2 = 7.5; % Second Stopband Frequency
Wstop1 = 10; % First Stopband Weight
Wpass = 1; % Passband Weight
Wstop2 = 10; % Second Stopband Weight
dens = 20; % Density Factor

% Calculate the coefficients using the FIRPM function.
b = firpm(N, [0 Fstop1 Fpass1 Fpass2 Fstop2 Fs/2]/(Fs/2), [0 0 1 1 0 ...
0], [Wstop1 Wpass Wstop2], {dens});
Hd = dfilt.dffir(b);
DataFilt=filter(Hd,data);
end

When comparing my filtered signal (DataFilt) with the original signal it
looks like the beginning of the filtered signal is overdamped. What am I
doing wrong or lacks to understand?

You can use this example:
t=linspace(0,20,4493);
plot(t,2*cos(5*pi*t)+sin(2*pi*t))
DataFilt=bandpass(2*cos(5*pi*t)+sin(2*pi*t));
figure
plot(t,DataFilt)

Thanks in advance

Thomas
 

Seems to me the effect you are seeing is the startup transient of your filter. One option would be to tweak the weights of your filter manually. Quicker fix, however, would be to use the filtfilt() command instead of the filter() command. This does the filtering first from the beginning of the end of the signal and then backwards. This gives you zero phase distortion and also helps with possible beginning/end transients.

So essentially try changing the line
DataFilt=filter(Hd,data);
to
DataFilt = filtfilt(b,1,data);
and see if that helps.

(if you do a lot of work with EEG data i'd suggest checking out the EEGLAB toolbox for matlab. It has been a life saver for me :p )

-va
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top