LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate Signal-to-noise-ratio (SNR) from array?

Hello All,

 

I need a help in calculating SNR. I have exemplary two data arrays (or graphs) and I'm trying to calculate SNR using Mean and RMS blocks (similar to: http://forums.ni.com/t5/LabVIEW/how-to-calculate-signal-to-noise-ratio-from-the-graph/m-p/813558/hig... but I think it doesn't work properly. In my case the waveform which seems to have the higher value of SNR has the lower value. My question is how is the best solution to separate noise from raw signal and calculate properly SNR?  

 

I post my program. Any help in this case will be appreciated...


Regards

0 Kudos
Message 1 of 10
(7,392 Views)

The smoothing process results in a phase shift. That causes the big peak in the "noise" signal because the peaks in the signals you subtract do not occur at the same times.  I expanded the time axes around the peaks to show the effect:

 

SNR.png

 

The challenge in measuring or calculating SNR is that of separating the signal from the noise.  In communications systems SNR is often defined with a sinusoidal input signal where matching the frequency, phase, and amplitude of the signal is well defined. Your signals, especially Input signal 2, do not seem to be so well defined.

 

You can try to align the peaks of the signal and the smoothed signal. That will help. However, I expect that the waveshape has changed somewhat as well. Note that the peak of Averaged signal is broader and more symmetrical than input signal. Thise differences will show up as part of the "noise" when you subtract.

 

Another approach is to look at the frequency domain. In the graph below the upper trace is the magnitude spectrum of input signal while the lower trace is the spectrum of the averaged signal. The noise level is 20 to 30 dB lower but the periodicity in the spectrum makes quantitative evaluation difficult. That periodicity is probably related to the number of samples averaged.

 

The Savitsky-Golay filter can be used for smoothing, possibly with less waveform changes.

 

What generates the signals? Do you have a mathematical model for the waveshape?

 

Lynn

0 Kudos
Message 2 of 10
(7,384 Views)

Thank you for reply johnsold,

 

I don't have a mathematical model for the waveshape. This waveform is the magnitude spectrum of measured vibrations of cantilever. 
I used the Savitzky-Golay Filter to smooth the signal and it helped. But I don't know exactly how to align the peaks? Do you find the Savitzky-Golay Filter is the best solution for me?

I post the changed program. Thank you very much.

Regards

0 Kudos
Message 3 of 10
(7,360 Views)

It looks like the Savitsky-Golay filter seems to help. The alignment is about as good as you will get.  Notice that input signal has a small peak at 395 which gets smoothed out by the filter resulting in a spike in the noise.

 

Since this is already a spectrum, can you simply use a threshold on the amplitude to separate the signal component from the noise?

 

Can you post the time domain data?

 

Lynn

0 Kudos
Message 4 of 10
(7,349 Views)

Unfortunately the frequency domain data is all I have. Do you mean that I can use the Treshold Detector on the input signal? 

 

Regards

0 Kudos
Message 5 of 10
(7,322 Views)

Yes. I played around with it a little. The SNR seemed to be in the 15-20 dB range when I did that on input signal. I did not try it on Input signal 2.

 

Lynn

0 Kudos
Message 6 of 10
(7,304 Views)

Could you post your program or check mine?  I am not sure whether I use Threshold Detedtor properly.

What should I connect to 'threshold' connector? RMS value? And then, how did you separate the signal component from the noise?

Regards

0 Kudos
Message 7 of 10
(7,298 Views)

I only have a few minutes now so here is the VI. If you have questions after looking at it, I will try to answer them later.

 

Lynn

0 Kudos
Message 8 of 10
(7,293 Views)

Thank you very much johnsold, it's very clever.

I am just wondering it is possible to set "threshold y" and "threshold y 2" values automatically, when we have many waveforms to analyze.

Regards

0 Kudos
Message 9 of 10
(7,268 Views)

Of course it is possible to set them programmatically. The problem is selecting/designing an algorithm to make a good choice.

 

For example 0.05*(max(input signal) - min(input signal)) + min(input signal) produces a value of ~2.2E-5.  This works reasonably well as a threshold. But the same algorithm applied to input signal 2 results in ~1.7E-5. That is much too low for a threshold on that data.

 

Lynn

0 Kudos
Message 10 of 10
(7,262 Views)