08-14-2019 05:06 AM - edited 08-14-2019 05:32 AM
Hi all,
I'm using the Gaussian Peak Fit vi to fit to extracted frequency information in a series of images, but I'm having a lot of problems getting a stable/sensible signal out.After pre-processing the data, I'm left with something that looks very visually like a simple Gaussian:
A good fit example, where the Gaussian fits satisfactorily
A similar input signal, but a shifted gaussian
However, as you can see on the right - some frames will not fit to this data so nicely (this fitted Gaussian is at the minimum amplitude and maximum centre values allowed by the set parameter bounds). The fit also seems to amplify the small amounts of noise that are present in the signal - jumping back and forth between different fits.
As you an see in the image above, I've increased the tolerance, selected least absolute residual, and constructed dynamic parameter bounds based off of the input data.
At one point, I was feeding the final values of the fit to the prior image as the initial guess (in a hope to remove the jitter previously mentioned), but this worsened the behaviour where the VI would get "stuck" providing bad estimates.
What I should be doing to get more robust performance out of this VI? I'm currently using LabView 2018, but am writing for 2017 as well.
08-14-2019 09:12 AM - edited 08-14-2019 09:14 AM
The best way to make the fit consistent is to use good initial guesses. You already have code for parameter bounds. Why not pick the middle of your bounds as your initial guess? Your current initial guess is NaN for all parameters.
-Jim
08-14-2019 09:30 AM
fI you want us to troubleshhoot, please also attach the good and bad dataset shown in your picture. (Maybe both as diagram constants)
(The code for the gaussian fit is too opaque for me because the core is hidden inside a dll. Hard to tell where it goes off track..)
08-14-2019 11:36 AM
As Jim said, the key here is that you aren't providing any initial guess. Some pointers for generating this guess:
08-14-2019 11:52 AM
We cannot peak inside the code, but assuming that the bad guess gets immediately coerced into the parameter bounds, the actual guess would probably be good enough. Hard to tell....
08-14-2019 06:56 PM
Thanks!
I previously had a construction of an initial guess - but it didn't seem to do any better than the default behaviour of the VI if I left the terminal unwired.
One offline suggestion that I have received is that the fit was over-fitting to the flat section preceding the peak. I've since given it really simple weights (weighting each point by local amplitude/maximum amplitude) and this seems to have improved the behaviour.
If anyone is knows more, I've attached the VI with some data that produces an erroneous result, even with this weighting.
08-14-2019 08:49 PM
One of your two data arrays has no default data saved. Could you repost your VI?