| Author |
Topic  |
|
|
Nai
Canada
Posts |
Posted - 05/30/2005 : 11:39:13 AM
|
Origin Version (Select Help-->About Origin):7.5 Pro SR5 Operating System: Windows 2000
I recently programmed an automated fitter that uses hard-coded xc1 and xc2 (ALLOWED TO VARY) initial paramets to fit provided data with two gaussian peaks. However, I have noticed that my fitter provides different fits (usually worse) than if I manually fit the data (Analysis-> fit multi peaks -> fit Gaussian) with the same initial xc1/xc2 and width guesses.
In my code I use the NLSF.iterate(100) command to generate the fit (repeated this piece of code extra times does not help).
Any ideas as to how I can implement the 'better' algorithm?
Thanks
Edited by - Nai on 05/30/2005 3:43:16 PM |
|
|
easwar
USA
1965 Posts |
Posted - 05/30/2005 : 2:12:55 PM
|
Hi,
Please send your code and your data to tech support and mention this post.
Easwar OriginLab
|
 |
|
|
Nai
Canada
Posts |
Posted - 05/30/2005 : 3:42:30 PM
|
I just sent the code and data. However, I would like to add that I made a slight error in my previous post: xc1 and xc2 are init parameters that ARE ALLOWED to vary (i.e. not fixed)
Sorry for the confusion. |
 |
|
|
Nai
Canada
Posts |
Posted - 05/30/2005 : 4:53:46 PM
|
I believe that I have isolated the problem: it lies in the initial choice for the areas of each peak.
This leads to a new question: what algorithms (functions) are available by originpro to guess a value for the area of the gaussian fits (also, a n efficient function to guess the other parameters would be helpful as well).
Thanks
|
 |
|
|
Leo_Li
China
Posts |
Posted - 05/31/2005 : 02:28:27 AM
|
These functions have been ready in "OriginC\System\internal.c", in which you can find utility functions such as "area, fwhm, min, sort, smooth" etc. Take "Gauss" for example:
Curve cv(wksData, 0, 1);
using NLSF = LabTalk.NLSF; // Point to the NLSF object NLSF.Init(); // Initialize the fitter NLSF.Func$ = "gauss"; // Assign fitting function
NLSF.p1=0; //y0 NLSF.v1=0; //no vary NLSF.p2=xc1; //xc1 NLSF.p3=0.85*fwhm(cv, NLSF.p1)/2; //w1 NLSF.p4=area(cv, NLSF.p1)/2; //A1
Leo OriginLab Corp. |
 |
|
|
Nai
Canada
Posts |
Posted - 05/31/2005 : 10:00:45 AM
|
| Thanks a lot for those functions, but why are you dividing the width and area by two? |
 |
|
|
Nai
Canada
Posts |
Posted - 05/31/2005 : 10:17:25 AM
|
How does originlab use FWHM and Area to process data intended for a multi-peak fit?
I suppose I could break up the data in a RANDOM (e.g. user-defined) place and then convert each subset into a curve before applying FWHM and AREA, but there must be a better way.
|
 |
|
|
easwar
USA
1965 Posts |
Posted - 06/01/2005 : 2:13:59 PM
|
Hi,
The code that handles multiple gaussian and lorentzian fits from the menu is located in the file fit.ogs which can be found in the Origin EXE path. The section to look at is [FitNPeaks]. LabTalk script is used to get the peak positions that the user click-selects on the graph, and the width is set to user-specified/default value etc.
If you wish to automate with no user interaction, then you will need to first detect where the peaks are in your data which will then yield the centroid location. You could then do some initialization of the width and area parameter by chopping up the data like you mentioned and computing width and area.
Easwar OriginLab
|
 |
|
|
Leo_Li
China
Posts |
Posted - 06/03/2005 : 07:53:20 AM
|
Hi Nai,
>>why are you dividing the width and area by two
I just copied a segment from the code that I sent to you. The original code is supposed to fit a curve by two guassian peaks; this is why I divided fwhm and area by two. Sorry for the confusion.
Leo |
 |
|
| |
Topic  |
|