Author |
Topic  |
|
Nai
Canada
Posts |
Posted - 07/11/2005 : 3:39:17 PM
|
Origin Version (Originpro V7.5870): Operating System: WinXp
I'm updating my auto fitting program because I realized that setting arbitrary initial amplitudes and widths (nlsf.p3, nlsf.p4, nlsf.p6, nlsf.p7, etc.) is not as accurate as Origin's own built-in amplitude/width autoinitialization routine during a manual multi-peak fit on a histogram (analyis->fit multipeaks -> Gaussian -> 2 or 3 -> origin guesses widths and amplitudes applied to all of the curves).
What function does origin use and is there an easy way to implement them in origin c/NLSF
Thanks
(this is the code segment that I am currently using) NLSF.Init(); // Initialize the fitter NLSF.msgPrompt = 0; //suppress error prompts // NLSF.pasteToPlot = 0; //do not paste results into plot NLSF.Func$ = "gauss"; // Assign fitting function
NLSF.numreplica = 2; //assume 3 peaks
NLSF.p1=0; //y0 NLSF.v1=0; //no vary NLSF.p2=xc1; //xc1 NLSF.p3=0.1; //w1 (need a non-arbitrary estimate) NLSF.p4=10; //A1(need a non-arbitrary estimate)
NLSF.p5=xc2; //xc2 NLSF.p6=0.1; //w2(need a non-arbitrary estimate) NLSF.p7=10; //A2(need a non-arbitrary estimate) NLSF.p8=xc3; //xc3 NLSF.p9=0.1; //w3(need a non-arbitrary estimate) NLSF.p10=10; //A3(need a non-arbitrary estimate)
NLSF.Iterate(100); |
|
easwar
USA
1965 Posts |
Posted - 07/11/2005 : 3:56:04 PM
|
Hi Nai,
There is an NLSF method nlsf.Execute("parainit"); which calls the parameter initialization code associated with the function that is stored in the FDF (you can see the code by going to the Scripts->Parameter Initialization page of the NLSF dialog).
However, that call works only when there are no replicas - it assumes only one instance of the function and treats the data as a whole.
When you perform the multipeak gaussian fit from the menu, a different code is run which is contained in the script file fits.ogs which brings up dialog to ask user for peak width estimates and peak location for the replicas.
So if you wish to assign good estimates to your replicate peaks you will need to write some code that asks for user input similar to the code in the OGS fie, or write some code in LT or OC that analyzes the data to come up with good numbers using calls similar to what is used in the original para init code for the function.
Easwar OriginLab
Easwar OriginLab
|
 |
|
Nai
Canada
Posts |
Posted - 07/11/2005 : 4:54:36 PM
|
You may remember from a while back (when you in fact helped me out) that I did write code to accept user input for the peaks xc1,xc1,xc3, etc.... I could do the same with the amplitudes and widths, but when I use Origin Pro to manually fit multiple peaks, it invokes some algorithms that automatically 'guesses' a width that it displays in a user-changeable input box. What I was is the code that performs this initial width 'guess' for a multipeak fit.
Thank again,
|
 |
|
easwar
USA
1965 Posts |
Posted - 07/11/2005 : 5:06:35 PM
|
Hi,
Looking at [FitNPeaks] subsection of the fit.ogs which deals with this multifit menu command, I see that what we are doing is to perform an integration of the data to generate oveall area and width values for the entire dataset and then simply divide the ovarll width by the number of peaks to get an initial estimate for the peak widths.
If this works on your data from the menu item, you could use the same technique in your code.
You can find this OGS file in the Origin exe path, or can pop it up by holding down the CTRL and Shift keys when issuing the menu command.
Easwar OriginLab
|
 |
|
easwar
USA
1965 Posts |
Posted - 07/11/2005 : 5:12:36 PM
|
Hi,
I have an additional comment. Some approximate width value should work fine - the minimization routine "should" find the optimal values.
One thing I would recommend is to repeat the iteration calls a couple of times: NLSF.Iterate(100); NLSF.Iterate(100); NLSF.Iterate(100);
This is equivalent to clicking the 100Iter button three times - it is possible the minimization routine quit the first call too soon, and the second call will then ensure it proceeds further. If convergence is acheived, all of 100 iterations will not be done and so this would not result in a lot of extra time spent and is worth trying.
You may also want to contact tech support directly with a sample dataset and your initial estimates for a case where the fit does not converge well, and they could look at this with your data.
Easwar OriginLab
|
 |
|
|
Topic  |
|
|
|