Multipeak Fit: Use experimental data for Tougaard background

The new Multipeak Fit package (version 3) features the Tougaard parametric background function both as two-parameter and three-parameter variants. But what if you want to use *real* experimental data instead of the parametric approach or want to provide your own loss curve to the fit? This can be easily done by hijacking the GenerateTougaardCSHelper() function as shown below. Just provide a valid path to a wave for the PATH_TO_EXPDATA placeholder. This can also be programmed in a more fancy way by writing your own wave reference function and plugging it in here. The provided wave should ideally be have a x range starting from zero and have a range at least as wide as your data you want to fit; endpoints will be repeatedly used otherwise. The example code uses the two available fit parameters to do some additional modifications of the input data. You can of course choose to just use the data as is.

After putting the code in your experiment, start / load a fit set and choose the Tougaard_Two background. The calculated background might look totally off at first because of the rather large default values for B and C. Enter 1 for B and 0 for C. With below code, B is now a scaling factor for your provided data, and C is the x shift. You can choose to hold the values now (check the Hold checkbox) to use the data as is, or let the fit decide scaling and shift or only one of both. Now the background should be a much more accurate description of your spectrum, provided you have a calibrated spectrum and the correct input data.

If you choose to remove the dependency on s.cWave from below code, make sure to always Hold both B and C or the fit will not work!

#pragma TextEncoding = "UTF-8"
#pragma IgorVersion = 9.00
#pragma DefaultTab = {3,20,4}
#pragma rtGlobals = 1       // a setting of 1 makes x-shifts less bothersome
#include <Multipeak Fitting>
#include <MPF_TougaardBackground>

Override Function GenerateTougaardCSHelper(STRUCT MPF2_BLFitStruct &s, DFREF MPF2SetFolder)
    Make/D/O/N=(500) MPF2SetFolder:Bkg_TougaardCS /WAVE=CSdata
    Variable left   = pnt2x(s.yWave,0)
    Variable right  = pnt2x(s.ywave,numpnts(s.ywave)-1)
        left    = s.xWave[0]
        right   = s.xWave[numpnts(s.xWave)-1]
    SetScale/I x 0, abs(left-right), CSdata // cross section data needs to be properly scaled from zero
    Wave/Z exptData = PATH_TO_EXPDATA   // write a valid path to your data here
    if (WaveExists(exptData))
        CSdata = s.cWave[0]*exptData(x-s.cWave[1])  // here B and C parameters are used for scaling and shifting the data
        CSdata = NaN
    return 0


MPF - Tougaard Data.ipf




Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More