06-25-2012 11:24 AM
I am having problems in fitting a 2d gaussian curve.
I have a set of data: with 3 columns and N rows. For example
x y Intensity.
.. .. ..
N is same for all 3 columns. I am trying to create an intensity plot out of this data and fit a 2D gaussian to it.
I tryed making a polynomial interpolation of the intensity data over the x-y range and make an intensity plot (Don't know if there is a better way of doing it ! Please Suggest if there is any other way.).
Then I use Levenberg-Marquardt method to fit this data. For some reason, it is not doing any iteration with the initial guess. The best fit value is same as initial guess. it is shoing error: NI_Gmath.lvlib:LM get new coefficients.vi:1. (see attached vis)
Can anyone help me with this !
Thanks.
Solved! Go to Solution.
06-25-2012 12:25 PM
You don't need to interpolate the data into a regular grid, all you need is fit for the existing points.
Have a look at my old example here (look for the "random" option.
Your attachment is missing quite a few subVIs. can you attach them too? Thanks!
06-25-2012 01:00 PM - edited 06-25-2012 01:30 PM
OK, I quickly modified my old example and it seems to easily fit your raw data. See attached (LV2010). Modify as needed.
(Note that I define the width as "width at half heigh", your definition might differ.)
08-13-2013 01:18 PM
The new gaussian peak fit vi has several nice features such as choice of fitting algorithm, entering pre-determined parameters or bounds, etc. Would it be possible to use it in your gaussian fit program and if so, could you show how to make the modification?
Thanks, very useful and efficient code!
08-13-2013 02:11 PM
@Tim_W wrote:
The new gaussian peak fit vi has several nice features such as choice of fitting algorithm, entering pre-determined parameters or bounds, etc. Would it be possible to use it in your gaussian fit program and if so, could you show how to make the modification?
Which "new gaussian peak fit" are you talking about?
You would enter paramter guesses in the controls already given.
If you want to set paramter bounds, substitute Constrained Nonlinear Curve Fit VI and add a control for the additional inputs.
What other fitting algorithms do you have in mind?
08-13-2013 02:31 PM
Under Math VI\Fitting VI\Gaussian Peak VI. I'm not sure how new it is-it's new to me, but may have been around for awhile.
08-13-2013 02:46 PM
@Tim_W wrote:
Under Math VI\Fitting VI\Gaussian Peak VI. I'm not sure how new it is-it's new to me, but may have been around for awhile.
This is only for a plain 1D gaussian, not 2D as in my example above.
The "Constrained Nonlinear Curve Fit" mentioned above also has inputs for the "method", so you should be able to do whatever you want (method, paramter bounds, etc.) once you supply a model.
08-13-2013 06:09 PM - edited 08-13-2013 06:13 PM
I have the same kind of data that babu126 has.
I'm trying to open your vi. but what is on the 3D tab is not loading.
What can I do?
Actually, because I couldn't manege how to use your .vi, I did an other post with the same question and another one.
08-13-2013 06:29 PM
@MateusV wrote:
I'm trying to open your vi. but what is on the 3D tab is not loading.
What can I do?
What is "not loading"? Can you be more specific?
We should keep all this in one place, so let's continue the discussion here.
07-30-2014 12:25 PM
Dear altenbach
I come across your post and I tryied it on with my spot image after replacing your simaluted data with the 2d image.
but I could not get it to work. did I miss something or not use it correctly?
attached please find the test code. would very appreciate your help.
cheers
xg