Need help in understanding the bandstop filter output

Hello,
I want to fitler the frequency components coefficients of particualr range in a signal for which I have used the bandstop filter function here as shown below
subplot(2,1,1),plot(data,'-r');
filtered1 = bandstop_butterworth(data,[.2 .35],100,3);
finalsignal = bandstop_butterworth(filtered1,[.5 4],100,3);
subplot(2,1,2),plot(finalsignal,'-r');
I don't understand why the filter response(shown in the attached m-figure) is something like the sinusoidal which is similar to input signal. I want to filter frequency in these range 1)0.2 to 0.35 2)0.5 to 4Hz
Can someone explain me about the filter output.
Thanks.

Answers (2)

Star Strider
Star Strider on 7 Aug 2014
Edited: Star Strider on 7 Aug 2014
I got the x and y data from your ‘.fig’ file in subplot(2,1,1). The Nyquist frequency of your signal is 0.5 Hz, so your second filter with a stopband of [0.5 4] will have no effect.
The fft of the data in the top subplot has essentially no signal energy in the stopband of your [0.2 0.35] filter:
What do you want to filter out of your signal?

3 Comments

The signal was sampled at 100Hz but I dont why you took the nyquist frequency as 0.5Hz. and I made a frequency plot(figure attached) using the below
Fs=100;
T=1/Fs;
L=length(data);
t=(0:L-1)*T;
NFFT=2^nextpow2(L);
Y=fft(data,NFFT)/L;
f=Fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(Y(1:NFFT/2+1)));
xlabel('Frequency');
ylabel('amplitude');
which differs from your plot
Can I know 1)what is the difference in the plots and can you give out the code used for the frequency spectrum plot. 2)Why my filtered signal in subplot(2,1,2) looks like an sinusoidal which is somewhat similar input.
signal data is also attached.
Thanks
You didn’t specify your sampling frequency in your original post, so I assumed the time vector in your ‘.fig’ file was the time vector that represented your signal sampling times.
I didn’t look in the File Exchange function to see what it did and how it designed its filters, so I don’t know what filters it designed. I had a difficult time designing Butterworth filters to your specifications, and even using the second-order-section implementation to avoid filter instability, it was difficult to get them to work. I finally defaulted to Chebyshev Type II filters, the design and implementation of which I include here:
Fs = 100;
Fn = Fs/2;
% Design First Filter:
Ws1 = [0.2 0.35]/Fn;
n1 = 2; % Filter ORder
R = 20; % Stopband Attenuation
[b1, a1] = cheby2(n1,R,Ws1,'stop'); % Create Filter
[sos1,g1] = tf2sos(b1,a1); % SOS Implementation
figure(5)
freqz(sos1,1001) % Plot Normalised Response
% Design Second Filter:
Ws2 = [0.5 4.0]/Fn;
n2 = 2;
[b2, a2] = cheby2(n2,R,Ws2,'stop');
[sos2,g2] = tf2sos(b2,a2);
figure(6)
freqz(sos2,1001)
% Do Serial Filter Cascade:
YF1 = filtfilt(sos1,g1,YD); % ‘YD’ Is Your Signal in ‘subplot(2,1,1)’
YF2 = filtfilt(sos2,g2,YF1); % Output of Cascaded Filters
The filter responses in the freqz plots look correct to me. I notice that they eliminate most of your actual data, leaving you with essentially a baseline.
I can’t understand what you want to do on the basis of these data and your filter specifications. If you want to discuss that, perhaps we can get the information you want from your data.
Hello Star Strider thanksalot for such a nice information. I am glad that you are willing to help in solving the issue.
To say more.. I am working with pulse sensors which sometimes will be affected by motion artifacts.Can you please share your ideas or methods to make the implementation to remove motion artifacts.

Sign in to comment.

The paper is not the most forthcoming in its details. I have no experience with LMS or other types of adaptive filters — I never needed them and they never were part of my coursework — so I can’t help you with their implementation. I have worked with inexpensive, commercially-available fingertip pulse-oximeters that were more than adequate for my needs, and I successfully filtered out motion (and high-frequency) artifacts with a bandpass filter going from 0.05 Hz to 20 or 100 Hz, depending on what I was doing. I was primarily interested in the waveform (looking at arterial compliance), and the pulse-oximeter internal software gave me all of the rate and SO2 information I needed, as well as the waveform. Much of what the paper filters out — respiratory variation and such — are physiologically important, and I wanted to retain that information rather than discard it. (I would not suggest discarding it, but then I don’t know what you’re studying so you may have requirements I didn’t.)

4 Comments

Hi thanks for the explanation.I just want to get the HeartBeatRate(BPM) from the detected pulse signals which are being affected by motion artifacts(then I came across this material which is doing the similar).
Can you share your ideas if you have any with my required application.
(I should have put my second ‘Answer’ as a comment. I’ll reposition it and your comment and this one later.)
The fingertip pulse oximeter I have (I have to find it) produces the plethysmograph signal as well as SpO2, beat-to-beat heart rate, and some other information. I actually wrote software to connect it directly (USB) to MATLAB and read and display the data. I never noticed that it had problems with motion artifacts, other than to occasionally lose the signal if there was too much motion. No ability to correct for motion artifacts can recover lost signals.
I don’t know what kind of pulse-oximeter you have or what data it produces, so I can’t discuss specifics.
Hi Star,Thankyour for information.

Sign in to comment.

Products

Asked:

on 7 Aug 2014

Commented:

on 9 Aug 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!