05-27-2014 03:33 PM
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
.
05-27-2014 04:03 PM
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:
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
05-27-2014 07:13 PM
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
05-27-2014 07:57 PM - edited 05-27-2014 07:58 PM
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
05-28-2014 04:21 AM
Unfortunately the frequency domain data is all I have. Do you mean that I can use the Treshold Detector on the input signal?
Regards
05-28-2014 01:06 PM
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
05-28-2014 01:25 PM
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
05-28-2014 01:37 PM
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
05-29-2014 03:18 PM
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
05-29-2014 03:32 PM
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