LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filter behaviour and improving its working

Solved!
Go to solution

Hello,

I am acquiring a pulse signal using DAQ unit and filtering that using digital filter from here http://wwwp.cord.edu/faculty/jensen/LabVIEW/Simulations/Simulation%20Pages/DigitalFiltering.html . The filter cutoff frequencies are set as 1Hz and 11Hz , but here I don’t understand why the output of filter(image attached) shows the frequency of 0.9Hz (sometimes 1Hz) which(0.9Hz) should be actually filtered by the filter as the higher cutoff frequency is 1Hz(0.9Hz<1Hz).

In general, the heart rate (BeatsPerMinute) is calculated from pulse signals i.e., by calculating number of beats measured in 1 minute.

So, to calculate the heart rate

1) What values of lower and higher cutoff frequencies should be provided as input to the filter (currently using)

2) But the pulse signal will be having harmonic frequency components as shown in the attached image(multitone).which value of frequency from these frequency components(measured using multion tone) should be used to calculate heart rate  form incoming pulse signal.

3)Is there any other filtering method other than the one currently used to get the heart rate.

Can someone help me with  this.

0 Kudos
Message 1 of 20
(4,680 Views)

Well, in hte first place, filters are not brick walls.

 

Yes 0.9 is less than 1.0 - by a 1/10 of a Hz. I guarantee you that this filter is not going to have a cutoff that sharp.

 

Beyond that, anything you can do to clean up your signal before it is sampled will help matters a lot. The "raw signal" has a lot of noise in it that you need to get rid of in hardware before you do your sampling. Do you use in your system one of the NI terminal boards that includes a small breadboarding area? If so a simple RC filter built there would be a good place to start.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 20
(4,648 Views)

Thanks for your suggestions and I will try to filter the signal using analog filters.

But I am confused with the multitone and singletone.

As in general, heartrate(beatsperminute) is calculated by number of beats measured in 1  min.If the HR is to be measured after every 5 seconds then the number of beats found in 5secs multiplied by 12 will  be heartrate.

So,I wonder if I want to calculate heartrate after evry 5secs can I multiply singletone freq measured for a 5sec signal duration  using 'extract single tone measurments' as shown in the above attached image(Multi_tone_Measurments).

Or should I use anything from the multiple frequencies measured using 'multitone frequencym measurments' as shown in the attached image(Multi_tone_Measurments). 

Can someone help me understanding this.

Thanks.

0 Kudos
Message 3 of 20
(4,624 Views)
Solution
Accepted by topic author GoviRe

Hi GoviRe,

   I have run into this issue when trying to FFT filter as shown in your vi as well as the filtering vi you based your code on. That code tricks you a little bit by using the same sampling rate (hz) and number of samples, which are both 1000. The ratio of these values determine the frequency increment, or distance in frequency between succesive values in the FFT array. So in the example you downloaded, the increment is 1 hz. This allows you to put zero's into the FFT as if the index of the array were measured in hz. In reality, your signal is probably much longer and has a different sampling rate and hence a different frequency increment. It's easy to fix though. Divide your sampling rate, which appears to be 500 hz in your vi by the length of your signal array to calculate the frequency increment. Lets say the increment is 0.1 hz, for instance if you had a signal with a length of 5000 sampled values. If you want the lower cutoff to be 10 hz, that corresponds to an index of 100 in the array. Essentially: divide your cutoff frequencies by the frequency increment to convert them to indexes in your FFT array. This leads to an important point though. To use FFT filtering, you need to judiciously choose your sampling rate and length.

 

A better approach is to filter using an FIR bandpass filter.

 

FIR Filtering And Response Example

 

I also suggest you take a look at these examples which may help you with your broader application of detecting heartbeats...

 

Build Your Own Heart Rate Monitor

Pulse and Transition Measurements

 

Definetly look at this one if you ignore everything else I wrote:

Using LV For Heart Rate Analysis

 

Good luck!

-Gabe

Message 4 of 20
(4,599 Views)

Extract (Single or Multiple) Tone Information VIs do not use filters. They use FFT (Fourier Transform) techniques to locate and estimate the predominate tone(s) in the input signal.  The Multiple Tone version first finds the tone with the largest amplitude, gets its frequency, then removes it from the input signal and repeats for the next largest tone. SIngle tone just finds the biggest tone. 

 

For HR there is no reason to use Multiple Tone because no other component is likely to be larger than the HR, assuming that your signal is derived from a pulse or ECG measurement. The images suggest that you are using a poorly shielded pulse measurement which is badly corrupted by power line frequency interference.

 

As Mike suggested, you need to clean up your acquistion process.   Differential amplifiers and analog filters to eliminate the power line frequency components before digitizing are the first things to consider. Notice that the power spectrum in your filter behavior image shows that the 50 Hz component is 10 db greater than the HR signal! You should not rely on post-digitizing processing to eliminate all of that. While it may be possible to clean it up, the amount of processing required may be substantial and may introduce hard to quantify errors.

 

The FFT - select components - Inverse FFT concept has some validity but the way you implement it has flaws.

1. The frequency bins are not likely integers as required by the for loop 1,0 multiplier process. Read the Detailed Help for FFT.vi. The frequency interval between bins, df, is given by fs/N.  fs is apparently 500 Hz = 1/dt. N is determined by the setting on Collector, which appears to be 2000. Thus, df = 500/2000 = 0.25 Hz. If you set the cutoff frequency inputs to 1 and 11, then you get bins 1..11, which represent frequencies 0.25 .. 2.75 Hz.

2. The output of FFT.vi is complex and includes both positive and negative frequencies. To get accurate and meaningful reconstruction of the time domain signal, you need to include the negative frequency components for the frequency range of interest as well. This information is also in the Detailed Help.

 

The FFT VIs work best if they have multiple cycles of the signal being measured. 3-5 cyles is minimum and >10 is better. This results in a tradeoff between how fast you can get results and how accurate the results are.  If you are not too concerned about heart rate variablity at the 5-10 seconds level, accumulate longer data sets.

 

Lynn

Message 5 of 20
(4,590 Views)

A couple notes about hardware. Use shielded twisted pair cable, connect both wires to analog inputs and set up the DAQ in differential input mode. If possible get the DAQ closer to your signal source, so the signal is digitized before a lot of noise accumulates along the cable. The new line of USB DAQ's is great for this.

 

Just my opinion, but you will be wasting your time trying to do any analog filtering, like soldering a passive RC circuit into a SCB-68, your time is much better spent studying FIR/IIR filter design. DSP almost always wins these days!

0 Kudos
Message 6 of 20
(4,571 Views)

@GabeG wrote:

...

Just my opinion, but you will be wasting your time trying to do any analog filtering, like soldering a passive RC circuit into a SCB-68, your time is much better spent studying FIR/IIR filter design. DSP almost always wins these days!


All the things that you mention in your first paragraph are important, but the thing you miss is that you have to filter out-of-band energy before you digitally sample the signal. The OP's raw signal shows a lot of high-frequency noise that is clearly not part of the phenomenon that he is trying to measure. I started with introducing the filter because regardless of what you do with everything else, the filter is needed.

 

Perhaps you need to spend some more time learning about sampling theory. In particular, spend some time learning about "anti-aliasing filters", and why they **have** to be done in hardware.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 7 of 20
(4,549 Views)

Hi Mike,

   I was speaking from the perspective of getting rid of line noise and its first few harmonics. In general if your DAQ is reasonably fast (100 - 1000 kS/s), it over samples the bandwidth of your cable, if your using twisted pair, do you agree? Ultimately its important to give the full spectrum due diligence, I agree with you on this. I would suggest getting a piece of coax and using a scope to get the full noise spectrum, with no signal present, at different points between the source and the DAQ. A simple RC filter might be warranted if you have a strong high frequency peak which is getting through. I would suggest a 1590 ohm resistor and a 0.1 uF capacitor based on this document: http://www.users.cloud9.net/~stark/elchap20.pdf. At that point, unless you're broke which is usually not the case if you're buying NI hardware 😉 You can get a nice laboratory preamplifier which has integrated active filtering, like this one: http://www.thinksrs.com/products/SR560.htm.

 

Respectfully,

-Gabe

0 Kudos
Message 8 of 20
(4,524 Views)

Gabe,

 

You always need to limit the bandwidth to the Nyquist limit before digitizing regardless of whether the sampling rate is a few hundred Hz or a MHz. And that must be done in hardware.  Oversampling by a factor of 1000 may reduce the complexity of the anti-alias filter but it also risks exposure to new interfering signals.  For example I live not far from a 50 kW transmitter in the low end of the AM broadcast band. Sampling at 1 MHz from leads attached to a human body, shielded, twisted, or not, likely would pick up some of that radio signal. Depending on the exact frequencies of the transmitter and the sampling rate the RF signal could be aliased into the heart rate frequency band. It is impossible to remove aliased signals after digitizing.

 

The fundamentals of measurements (with which Mike and I  have worked for a long time) are that the priorities in keeping interfering signals and noise out of a measurements are (in order)

1. Reduce the interference by isolating, separating, and shielding the desired signal source from the interfering source. This also includes making sure that proper grounding has been applied.

2. Use differential amplifiers when appropriate to reduce the interference.

3. Use anlaog filters before the digitizer.

 

Proper use of these techniques almost always will reduce the interference to a manageable level. The OP's 50 Hz interference is 10 dB higher than the pulse signal. I would expect that appropriate signal conditioning prior to digitizing could reduce that by 20 dB or more.  His noise floor is about 30 dB lower than the pulse signal. His raw signal also has a DC offset which is about 25 dB larger than the interference. A 16-bit digitizer has a theoretical dynamic range of about 96 dB. He has already sacrificed half of that range by not doing some simple things in hardware first. 

 

This is where DSP falls short. It cannot create resolution that was not in the original data. It cannot remove aliased signals. Narrow bandwidth filters have long transients (which will likely be excited by the interference), introduce phase shifts and delays, and often are poor choices when timing measurements need to be made on the signal.

 

Why would you recommend 1590 ohms (a non-standard value) and 0.1 uF? That produces a filter with a cutoff at 1 kHz which is completely useless for the OP's problems.  A one-pole filter tuned to the geometric mean of the upper passband (11 Hz) and the interfering frequency (50 Hz) would be at 23.4 Hz and would provide about 12 dB of attenuation at 50 Hz. It also has about 1 dB of attenuation at 11 Hz. So that filter is far from adequate for his needs.

 

Lynn

Message 9 of 20
(4,496 Views)

Hi Lynn,

    Thanks for the insight on aliasing from higher frequencies than your sample rate. I'll look into that some more. This problem with power line noise is one I run into all the time. Can you suggest a source for a good inline analog notch filter. I'm thinking something that's maybe powered, but has BNC's or terminals on the sides you can easily just hook your cabling up to right outside the DAQ? I know there must be something from digikey or mouser for instance, but I can never seem to pin it down, even talking to sales reps, and engineers, etc...

 

Thanks,

-Gabe

0 Kudos
Message 10 of 20
(4,486 Views)