# Isolate frequency bands of digital signal

#### bioMaynard

Joined Nov 28, 2015
8
Hello all
i have a digital signal which is an overlay of three signals. breathe(10-20/minute, lowest frequency of high energy), at the end of which there is a high frequency signal (snore) and a periodical signal (heart beat 60-80/minute). I need to create filters on matlab to isolate the three signals with almost zero phase distortion.
The signal (wav file) is here sites.google.com/site/wavesignalfile

I am no expert on dsp so all suggestions comments and ideas are very very welcomed. here is what i have done so far. i tried the fft on the signal and after that i filtered the frequency bands. breathe seems legit, heart beat seems not periodical and i do not know how to isolate snoring since i only know that the frequency is "high". feel free to tell me to try stuff but please be descriptive one step at a time.

matlab code:
Code:
clear;
[x, Fs] = audioread('wave.wav'); %Fs Sampling frequency

figure,plot(x);
title(' Wave Signal');
xlabel('Time');
ylabel('Amplitude');

y=fft(x);
f = (0:size(y,1)-1)*Fs/size(y,1); % Frequency vector

figure,plot(f,real(y));
title('Power Spectrum of Wave');
xlabel('Frequency (Hz)');
ylabel('Power');

y1=y; y1(:)=0; %breathe
y2=y; y2(:)=0; %heart beat
y3=y; y3(:)=0; %snore

for i=1:size(y,1)
if(f(i)>0.1666 && f(i)<0.3334) % breathe 10-20/min equals to 0.16-0.33/sec is that correct????
y1(i)=y(i);
elseif(f(i)>1 && f(i)<1.33) %heart
y2(i)=y(i);
%    elseif(f(i)>   && f(i)>  ) %snore
%        y3(i)=y(i);
end
end

x1=ifft(y1,'symmetric');
figure,plot(real(x1));
title(' Breathe Wave Signal');
xlabel('Time');
ylabel('Amplitude');

x2=ifft(y2,'symmetric');
figure,plot(real(x2));
title(' Heart Wave Signal');
xlabel('Time');
ylabel('Amplitude');

%x3=ifft(y3,'symmetric');
%figure,plot(real(x3));
%title(' Snore Wave Signal');
%xlabel('Time ');
%ylabel('Amplitude');

#### Papabravo

Joined Feb 24, 2006
21,253
I think it will be ambitious to isolate signals that are so close to each other in frequency. Filtering can attenuate out of band signals but not eliminate them in a way that could be called isolation. I'm curious about your notion of "phase distortion". Usually there is some phase change in the passband along with the attenuation. It is impossible to eliminate, but it can be controlled.

#### bioMaynard

Joined Nov 28, 2015
8
I see. considering that the goal is filtering to get the best possible results what would you do?
and do you see a way to find the frequency of snoring? even approximaltely

#### Papabravo

Joined Feb 24, 2006
21,253
I guess I would try applying a DFT (Discrete Fourier Transform) to see if there are any identifiable peaks where you expect them to be. In this kind of signal processing it is essential that you use analog means to limit the highest frequency component (anti-aliasing filter) and then sample the signals at a minimum of twice that frequency.

#### bioMaynard

Joined Nov 28, 2015
8
then i suppose that you agree to my matlab code. Truth being said i have trouble identifying peaks where i expect them to be but thank you very much for your comments.
If someone tries my code or any code and finds something of interest please share.

#### Papabravo

Joined Feb 24, 2006
21,253
then i suppose that you agree to my matlab code. Truth being said i have trouble identifying peaks where i expect them to be but thank you very much for your comments.
If someone tries my code or any code and finds something of interest please share.
If you have trouble identifying features then you might want to increase the S/N ratio or increase the sample rate. If the input signal is not going through an analog low pass filter then aliasing may destroy any data you are trying to collect.

#### bioMaynard

Joined Nov 28, 2015
8
thanks a lot for your suggestions. could you please verify that my matlab code for the dft is correct? that is a way to filter specific frequencies right?

#### Papabravo

Joined Feb 24, 2006
21,253
Sorry, but your Matlab script is greek to me.

#### bioMaynard

Joined Nov 28, 2015
8
the frequency 10 per minute is 10/60 =0.1666 per sec = 0.1666Hz on the frequency domain of the dft, right?

#### Papabravo

Joined Feb 24, 2006
21,253
the frequency 10 per minute is 10/60 =0.1666 per sec = 0.1666Hz on the frequency domain of the dft, right?
That arithmetic is correct. I gather your idea is to produce a time domain version of each signal by doing an inverse transform on band limited ranges of the frequency domain data. I don't think the results will be all that satisfying. You're throwing away too much information IMHO. You should do the experiment to see for yourself.

#### bioMaynard

Joined Nov 28, 2015
8
i agree with you but i have to start somewhere. i cant do anything about sampling rate or analog filtering. the signal is digital at 2 khz i have to take it from there. i already uploaded it, would it help if i uploaded plots of the time or frequency domain too?

#### Papabravo

Joined Feb 24, 2006
21,253
I'm not sure, but it couldn't hurt.
I would suggest three parallel bandpass filters but your two lowest signals are just too close together to allow for much of a transition band. Locating the higher frequency stuff should be doable since there is a large transition band from 1.33 Hz to 1 kHz which is the highest frequency you would expect to find at a sample rate of 2 kHz.

We usually speak of the rolloff of a filter, as the ability to attenuate out of band signals, as 20 dB/decade for example. This means if you have two frequencies that are a decade apart, 1 Hz. and 10 Hz. and you ran them through a lowpass filter with a corner frequency of 1 Hz. The 1 Hz. signal would be down by 3 dB and the 10 Hz. signal would be down by 23 dB.

In your example going from .33 Hz. to 1 Hz., that same 20 dB attenuation would require a digital filter with a truly impressive number of taps and a characteristic of maybe 200 dB/decade. These are difficult goals to achieve.

I would use the FFT information to guide you in constructing either digital or analog filters.

Last edited:

#### BR-549

Joined Sep 22, 2013
4,928
How were the 3 signals overlayed on the 2khz digital?

I am not able to view your file.

#### bioMaynard

Joined Nov 28, 2015
8
Sorry im not sure, i dont concern myself with that part. The file is on a standard google site. There is a little blue arrow on the bottom right to download it, and then you can plot it using the first 7 lines of the code (top of the page).

#### BR-549

Joined Sep 22, 2013
4,928

I would put my time and effort into getting three isolated analog signals.

Sorry I could not help.