MultiPeakFit with constraints wave

Hello Igor,
I am using igor's multi peak fit (Do_MPFit()) to fit a 2d spectrum automatically. Therefor I extract every single line and hand it in a for loop to the Do_MPFit() Function but I am stuck right now. I think it all boils down to two problems, where I can't find help in the Igor Help Files:

I am using Lorentian or Voigt fit functions. In the Analysis->CurveFitting Dialog there are 4 initial parameters required for lor-Functions. In the MultiPeak Procedure Panel there are only 3 required.
How many Parameters do I need for the Do_MPFit() function to work with Lorentian/Voigt/Gaussian?
I'd like to set constraints for the peak positions but when I give my constraints wave to the Structure used by Do_MPFit(), it stops to do anything and the parameters sty the same. Probably because the constraints are set to the wrong parameters. It would help very much to see the Lorentian or Voigt Function that is beeing used by Igor (MPFXLorenzianPeak) but I can't find it.

I created a minimum working example of my code. There are two peaks beeing created and a multipeak fit should reproduce this function. As I understand ist, there are two peak-functions with increasing K values and a linear background:
* y = K0+K1x
* y = K2+K3/((x-K4)^2+K5)
* y = K6+K7/((x-K8)^2+K9)

Now I can set the constraints for them as K4>950 and K4<1000. Somehow this doesn't seem to work properly. My MWE-Code is attached below.

//minimal working example for use of constraints #pragma rtGlobals=3 #include <Multi-peak fitting 2.0> Menu "Testing" //create menu bar entry "MWE",MPPM() End Function MPPM() String gstrDataFolderCurrent = "root:PLEM" Wave/Z peak65, peak76, peakBG, wavToFit Struct MPFitInfoStruct MPPMfit //Make new working dir NewDataFolder/O/S $gstrDataFolderCurrent //Instantidate peak waves make/O/N=4 peak65 = {0,10,950,100} make/O/N=4 peak76 = {0,10,1090,100} make/O/N=2 peakBG = {0,0} // y = K0+K1x // y = K2+K3/((x-K4)^2+K5) // y = K6+K7/((x-K8)^2+K9) make/O/T/N=6 constraints = {"K0 > 0", "K1 > 0", "K2 > 0", "K4 > 936.12", "K4 < 986.12", "K8 > 1082", "K8 < 1132"} make/O/N=1000 wavToFit SetScale/I x, 900,1300, wavToFit wave wavToFit wavToFit = 1/pi*x*(10)/((x-961.118)^2+(10)^2) + 1/pi*x*(10)/((x-1107.0)^2+(10)^2) //INIT MultipeakFit wave MPPMfit.yWave = wavToFit MPPMfit.NPeaks = 2 MPPMfit.FitCurvePoints = 200 MPPMfit.fitOptions = 4 MPPMfit.ListOfFunctions = "linear;Lorentzian;Lorentzian;" MPPMfit.ListOfCWaveNames = "peakBG;peak65;peak76;" MPPMfit.ListOfHoldStrings = ";;;" // wave/T MPPMfit.constraints = constraints if (MPF2_DoMPFit(MPPMfit, (gstrDataFolderCurrent+":"))) print "Abort due to Error: " + num2str(MPPMfit.fitError) return -1 endif if (MPPMfit.fitQuitReason) print "Abort due to fitQuitReason: " + num2str(MPPMfit.fitQuitReason) endif print "FuncListString: " + MPPMfit.FuncListString print "chi: " + num2str(MPPMfit.chisq) print "Number of Points used in fit:" + num2str(MPPMfit.fitPnts) End
Hello,

I'm not familiar with MPPMfit but your coefficients K0, K2, and K6 are linear dependent. Together with the information about the 3 or 4 required parameters my guess would be that Lorentzian takes no offset (is included in "linear").

HJ
You're right. They are dependent and this is supposedly the reason why there are 4 parameters when fitting with one function and 3 Parameters when fitting with MultiPeak. I changed it to 3 parameters. So there remains the question, how the function that is beeing fit looks like. I'm still trying to find out.

* y1 = K0+K1*x
* y2 = K2/((x-K3)^2+K4)
* y3 = K5/((x-K6)^2+K7)
* y = y1 + y2 + y3

I could also live with defining my own Lor/Gaus/Voigt Fit Function but also don't yet know how to do it inside the MultiPeakFit Environment. Maybe I have to drop the MultiPeakFit Environment and go back to the original FuncFit. At least FuncFit seems to work a bit more transparent.
The fitting functions for MPFit are in PeakFunctions2.ipf. Many of the base functions are actually defined in an XOP, but there are user-defined functions that work the same way as the XOP functions. To see the code, select Windows->Procedure Windows->PeakFunctions2.ipf.

And yes, if each peak function defines its own vertical offset coefficient, they are linearly dependent. Consequently, the peak functions for MPFit2 do not have that coefficient, leaving that instead to the various baseline fit functions.

Setting up the constraint wave for a multipeak fit is pretty difficult. I would recommend setting up one fit in the MPF2 GUI and examining the resulting wave.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com