Batch fitting with MultiPeak fitting

After going through the previous posts about batch fitting I got it going using the MPF2_AutoMPFit

I am using Voigt function and what I need urgently is FWHM with error (along with area +/- error and location +/- error, if possible). If I get the Gauss width and the Lorentz width with errors still fine, I can do further calculation on it. How to get the value from the Peak Coefs.
1. So, I have issues understanding the result. In the image attached , first value is location, then width, height and shape (my guesses) under PeakCoef_n . This is my guess.
But the values from MultiPeakFit GUI are more detailed ( more calculation is done to report those values ). How to get the final values as there.

2. Can I force the MPF2_AutoMPFit to fit only one peak in the input ywave.

finally, 3. How to display the fit wave along with the original wave. ( recreate the fit wave based on the coefs, but how.)



ankit7540 wrote:
After going through the previous posts about batch fitting I got it going using the MPF2_AutoMPFit
Good job! It's not the easiest thing to work with.
Quote:
I am using Voigt function and what I need urgently is FWHM with error (along with area +/- error and location +/- error, if possible). If I get the Gauss width and the Lorentz width with errors still fine, I can do further calculation on it. How to get the value from the Peak Coefs.

If you update to Igor 6.36, you will get a version of MPF2_AutoMPFit that adds optional parameters to have it compute the "derived" coefficients (like FWHM), and the various fit curve waves. The function invocation will look like
MPF2_AutoMPFit(... lots of inputs ..., doDerivedResults=1, doFitCurves=1)
See the comments above the function definition in the Multi-peak Fitting 2.0.ipf file.
Quote:
1. So, I have issues understanding the result. In the image attached , first value is location, then width, height and shape (my guesses) under PeakCoef_n . This is my guess.
But the values from MultiPeakFit GUI are more detailed ( more calculation is done to report those values ). How to get the final values as there.

If the third input is, for instance, "Peak%d", then the fit solution coefficients will be in waves called "Peak0", "Peak1", etc., one for each peak. The errors for the coefficients will be in W_sigma_N, where N is, again, the peak number. If you use the doDerivedResults=1, then you also get "Peak0DER" containing derived results.
Quote:
2. Can I force the MPF2_AutoMPFit to fit only one peak in the input ywave.

You will need to provide your own initial guess with just one peak. You can do that using InitialGuessOptions 0,1, or 2.
Quote:
finally, 3. How to display the fit wave along with the original wave. ( recreate the fit wave based on the coefs, but how.

Use the latest revision, and doFitCurves=1. You will get the fit curves as part of the result, one set of fit curves in each of the result data folders. See the comments above MPF2_AutoMPFit for the names of these waves.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thank you very much for your prompt reply. I had ver 6.36 and updated my procedure. Gives the results as expected.

//******************************************

function BatchFitter_auto()
string/g ywavelist = wavelist("*_",";","") 
Variable nywaves = ItemsInList(ywavelist)
print ywavelist
print nywaves ;
string xList="RamanShift_Axis"
string xAxis="RamanShift_Axis" ; variable i
    for ( i=1;i<nywaves ; i=i+1)
        //print i
        sprintf xList "%s;%s"xAxis,xList
    endfor
//print xList
string FolderName="Fit_"

MPF2_AutoMPFit(FolderName, "Voigt", "PeakCoefs%d","Linear","Baseline_coef", ywavelist,xList, 0,doDerivedResults=1, doFitCurves=1 )
end

//******************************************


1. For giving initial guesses I first fit once, and then remove the PeakCoefs_n (and other ones with 'n') which I do not want to be fit from the first folder 'Fit__0'. Then run again on full data set. I hope this approach is okay.

2.   doDerivedResults      works as expected. Nice . {I have a query, the derived data generated has few rows, what do they mean. First is location, then 'inf' ?? After that is Peak Area, then later in following rows should be FWHM ; but the values I get are very low in magnitude. (or maybe I read them wrong !) } Please check the image attached.

3. doFitCurves     works fine.
-Ankit
Screenshot 2015-03-28 11.59.52.png (24.01 KB)
If you display dimension labels in your table, you will see labels that tell you what the derived coefficients represent. The first column is the value, the second is the error associated, which is calculated by standard propagation of errors. The blank for the error on the FWHM is because it is an approximate formula for which we feel the error bar is not appropriate.

I think your FWHM is small because the Lorentz width is negative. I'm not sure how the Lorentz width could be negative. It would be negative if either the shape or the original "width" coefficient (which is related to width, but isn't width) were negative. I think either way, it might be an indication that the Voigt shape isn't really appropriate.

Quote:
1. For giving initial guesses I first fit once, and then remove the PeakCoefs_n (and other ones with 'n') which I do not want to be fit from the first folder 'Fit__0'. Then run again on full data set. I hope this approach is okay.

So you are using the fit to one peak from your first fit as the initial guess for the batch fit, right? That should be OK as long as any additional peaks in the data set are well away from the location of the peak you are interested in. It may be better to fit all the peaks and then only pay attention to the "right" one.
Quote:
{I have a query, the derived data generated has few rows, what do they mean. First is location, then 'inf' ??

That inf is the height. The height of the peak involves exp(cw[3]^2) which is the "height" from the fit. It may have been so large that the exp() overflowed. That may be the fundamental problem here. You might be able to get around the problem by scaling your data set to make the numbers involved smaller. You will have to adjust the units too, of course.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com