LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating signal to noise ratio

Solved!
Go to solution

Hello.

 

I was wondering if it was possible to calculate the SNR of a signal with LabView? I'm using a DAQ device and an accelometer to measure some force.

 

With that being said, is it possible to calculate SNR by looking at the frequency spectrum or wave graph? When there is no g on the accelerometer, there's a signal with some noise... and I can see that in the frequecny spectrum all the way to the cutoff frequency. Is that the noise floor?

 

I'd appreciate any help!

 

Thanks!!

0 Kudos
Message 1 of 13
(6,559 Views)

SINAD Analyzer.vi in the Signal Processing palette?

 

What you see in the spectral display may be the noise floor but it is not always easy to interpret.

 

Is your accelerometer signal periodic? Does it persist long enough to identify its frequency components clearly?  Can you post some data?

 

Lynn

0 Kudos
Message 2 of 13
(6,533 Views)

Hello. Thanks for your input. Not quite sure if SINAD is the way to go as I'm only going for SNR.

 

I got two data. I'm measuring the acceleration of heart by two accelerometers do reduce noise by a factor of 2. (3dB).

 

I will post .lvm file and a .wav file.

 

Sampled at 400Hz.

 

For some reason I cannot attach .lvm files. That's strange... It's a LabView file.

0 Kudos
Message 3 of 13
(6,526 Views)

Either zip the file or change the extension to .txt.  If you change the extension, please tell us what the original extension was.

 

Lynn

0 Kudos
Message 4 of 13
(6,521 Views)

Do you want a frequency spectrum of the signal as well? Noise floor too?

0 Kudos
Message 5 of 13
(6,519 Views)

There's a picture of labview when the accelerometer is idle. Wave graph + frequency spectrum (those at right side are filtererd).

 

There's a wav file and a .lvm file for a heart beat.

0 Kudos
Message 6 of 13
(6,516 Views)

The more data the better.

 

Lynn

0 Kudos
Message 7 of 13
(6,515 Views)

Could figure 🙂 Thanks for the help. It's more than appreciated. Sorry for the Swedish language in those files. 🙂 Hjärta = Heart

0 Kudos
Message 8 of 13
(6,513 Views)
Solution
Accepted by topic author Abraham_E

Abraham_E,

 

Thanks for the data.  Strangely enough the data does not seem to care what language you were using when you collected it.

 

The first column of the data appears to be timing information.  The dt in that is 0.0005 which corresponds to a sampling frequency of 2 kHz.  You mentioned 400 Hz in one of your posts.  The discussion in item 2 below is consistent with a 2 kHz sampling rate.

 

1. You are correct that SINAD will not be very helpful. SINAD assumes that all of the signal power is in the dominant frequency component which is not quite true for ECG.

2. The magnitude of the FFT of the signal shows the dominant signals at 50 and 100 Hz which is likely power line frequency interference. There al also clear lines at 200 adn 250 Hz. You certainly do not want to calculate SNR under the assumption that the desired signal is 50 Hz.  The SINAD VI does calculate the fundamental frequency as 49.97 Hz.

3. If you ignore the 50 Hz and harmonic components, there are no obvious lines in the remaining spectrum. I intepret this to mean that you have significant heart rate variation in the data.  This is equivalent to saying that the heart rate is frequency modulated. Frequency modulation broadens the spectrum.

4. Because there is not dominant feature in the spectrum, it is unlikely that frequency domain techniques will be of any value in determining the SNR.

 

So, what can you do? From looking at the data graph I think that a peak signal to noise voltage ratio might be meaningful. There is some noise, even at the peaks, so this has some problems also.  I divided the data set into 1 second segments. For the heart rate in this data each segment contains one or two beats.  In each segment I found the maximum and minimum values.  I defined the peak to peak value for the segment as the difference. I also calculated the RMS value for the entire segment. Then the SNR is the peak to peak signal divided by the RMS value. It would probably be more accurate to use the RMS value of the QRS and to exclude the QRS parts from the RMS of the noise, but doing both of those is algorithmically and computationally much more difficult. It might also be better to force the segments to contain exactly one beat each. Again this is much more complicated.  I then calculated the mean of the  segment SNR values and call that the Mean SNR.

 

As I point out, this has some problems with the definition (peak to peak/RMS).  If you just want to compare signals within your lab to see what improves things, this should be fine.  If you want to publish data and compare to other published results, you need to find how they define and measure SNR.

 

In the attached VI I read the file one time and saved the values in an array as default. Then I removed the file read VIs and just worked with the data. To try this with other data just insert the Read from File VI in the appropriate place.

 

Lynn

Message 9 of 13
(6,496 Views)

You are correct. I was looking at a wrong numbers. 2kHz is the correct sampling rate from the DAQ interface.

 

But. Wow. I did not expect this much help. I'm sooo totally grateful right now it's just crazy. I wish I could this pay back somehow! I will look at your VI and try to understand it as much as I can. You have been really helpful. Wish I could give 100 kudos!

 

Good luck!

0 Kudos
Message 10 of 13
(6,487 Views)