Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

babu126

Member

06-25-2012 11:24 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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.

altenbach

Knight of NI

06-25-2012 12:25 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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!

Solution

Accepted by topic author babu126

altenbach

Knight of NI

06-25-2012 01:00 PM - edited 06-25-2012 01:30 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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.)

Download All

Virus scan in progress. Please wait to download attachments.

Tim_W

Member

08-13-2013 01:18 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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!

altenbach

Knight of NI

08-13-2013 02:11 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@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?

Tim_W

Member

08-13-2013 02:31 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

altenbach

Knight of NI

08-13-2013 02:46 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@Tim_W wrote:

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.

MateusV

Member

08-13-2013 06:09 PM - edited 08-13-2013 06:13 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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.

altenbach

Knight of NI

08-13-2013 06:29 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@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.

xgatc

Member

07-30-2014 12:25 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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