I am looking to automate some fitting via multi peak 2.0 and am examining the MultiPreakBatchFit function. It has three input parameters:datafoldername,ywavelist,xwavelist.
What should the the xwavelist look like for calculated values?
What version of Igor are you running? I don't have a MultiPeakBatchFit() function. I have MPF2_AutoMPFit(). The help file for Multipeak Fit 2 includes documentation of the inputs for MPF2_AutoMPFit(). It says:
xWaveList list of the X waves with peak data to be fit. Any entry in the list that doesn't name an actual wave causes the fit to use "_calculated_"; that is, the X values will be taken from the corresponding Y wave's X scaling.
If xWaveList is set to "", all X waves will be "_calculated_".
The multiPeakBatchFit function is in the help file and I am trying to use it to automate some batch processing. (and you didn't think people actually read the help files did you?)
Ah, I see. I wrote it, but had forgotten about it.
Your right- we tend to assume that people don't read the help. I think we're mostly right, so it's nice to be proven wrong sometimes!
The key is this line: Wave/Z MPStruct.xWave = $StringFromList(i, xwavelist)
The list could be just "" (an empty list) or it could be a list of words that simply aren't names of waves, like "_calculated_". The /Z flag in Wave/Z indicates to Igor's compiler that it's not a mistake for the wave reference to be NULL. The MPF2_DoMPFit() function will interpret the NULL wave reference for the X wave to mean that it should use the Y wave's X scaling for the X data.
Is there some reason to not use MPF2_AutoMPFit()? It's a lot more sophisticated than the example function.
I am looking to automate some fitting via multi peak 2.0 and am examining the MultiPreakBatchFit function. It has three input parameters:datafoldername,ywavelist,xwavelist.
What should the the xwavelist look like for calculated values?
Andy
Hi, could you show me a typical experiment to use the multipeakbatchfit function, I have been trying to use it, but I don't know how. Thank you.
I am looking to automate some fitting via multi peak 2.0 and am examining the MultiPreakBatchFit function. It has three input parameters:datafoldername,ywavelist,xwavelist.
What should the the xwavelist look like for calculated values?
Andy
Hi, could you show me a typical experiment to use the multipeakbatchfit function, I have been trying to use it, but I don't know how. Thank you.
Attached is a an example of what I am working on.
There are a set of small spectra files (Auger spectra) that I loaded up. I have set the wave scaling to set the energy range and I do not need a separate x-wave.
I create a list of the waves to be fit using wavelist. Note: the documentation is not specific but it appears in my fumbling through that a semi-colon delimited string is expected. When I used a comma delimited string nothing would happen nor was there an error message.
To do the batch fit, I use the function included in multi-peak fitting V.2 (make sure it is loaded) and I run the command
MPF2_AuotMPFit("RDF","ExpModGauss","PC%d","Cubic","Fred",ywavelist,"",5) and you can look into the help file for the definitions. I create a string called ywavelist with the wave names.
You can delete the fit folders and rerun the command to see it work.
@ John Weeks. I am trying to do some batch processing with the MPF2_AutoMPFit() function to fit chromatograms with 19 peaks. My approach has been to do a careful manual multi peak fit to develop the peak coefficients and constraints. I know the peak coefficients and constraints text waves are now listed under root:Packages:MultiPeakFit2:MPF_SetFolder_2 along with a number of back up coefficients and various strings/variables. I have gone through and figured out the inputs for the MPF2_AutoMPFit function (shown below).
I believe I would like to use initialOptionsGuess 0 "Do not run the automatic peak picker. Initial guesses will be pre-loaded in coefficient waves in the data folder resultDFBase+"_0". Use those values for every data set." I just am a bit lost on how I should set up a data folder containing the required information, and then how to feed that to the function inputs.
That means that the first of the result data folders must exist before you call MPF2_AutoMPFit(), and you need to copy the coefficient waves from your manual run into that data folder. You might have something like
In that code (which is completely untested!) the complete data folder for a manual multipeak fit is duplicated, giving the duplicate the appropriate name ending in "_0". The the looop renames the coefficients waves from the names used by the MPF2 user interface, to names corresponding to the names specified by the PeakCoefWaveFormat input string.
If you have a baseline as part of the fit, you need to do the same for the baseline coefficient wave. To avoid the loop and renaming waves, you could just use
This simplifies the problem by using the same names as the GUI for MPF2 uses, so you only need to duplicate the data folder, you don't need to rename the waves.
I was able to get it all working. Thanks for the help. I am curious about something. When I go in and do a manual multi-Peak fit to determine the coefficient parameters I can set constraints for the location of each peak. Is that at all incorporated into the MPF2_AutoMPFit function? And if not, how could I incorporate the constraints?
Constraints were added to Multi Peak fit 2 well after MPF2_AutoMPFit() was written. Looking into it how to do it now, its not hard but not quite as easy as it should be. The MPF2 package does not store constraints in the same format used by FuncFit (the foundation of MPF2) to do the fitting. But it shouldn't be difficult to get your constraints to apply to the batch.
You will have to add a parameter to MPF2_AutoMPFit(). I suggest you copy MPF2_AutoMPFit() from Multi-peak Fitting 2.0.ipf, rename it something like MPF2_AutoMPFitCustom() and add a constraints argument. The constraints argument would be in the format that MPF2_DoMPFit() expects in the MPFitInfoStruct structure argument. For details on the constraint text wave format see the help for Fitting With Constraints.
DisplayHelpTopic "Fitting With Constraints"
The custom MPF2AutoPMFitCustom() function defintion would look like the following:
That should be all you need to make MPF2_AutoMPFitCustom work with constraints. Now you just need to define the constraints. You can do it by hand by creating a text wave and defining one constraint per row - following the Constraint Expressions syntax described in Fitting With Constraints. Or you can copy the constraint text wave used by the Multi Peak Fit 2 package. The MPF2 UI text wave is part of a structure, so its scope is limited to the function in which it is instantiated. If, however, you have the MPF2 UI open and the constraints set you can call the following function to make a copy of the constraints wave.
Function getConstraintsWaveCopy(setNumber) Variable setNumber
Note that I have not tested any of this. If you have trouble getting this to work email me at Wavemetrics support. I will be adding constraint functionality to MPF2_AutoMPFit() in the manner I described here, as well as making MPF2_DoMPFit() write reference constraint text waves, for the next Igor version 6 update.
Thanks Nate I will take a crack at that. But I have been having a different more serious issue with the MPF2_auto fit function that I describe in this thread.
Thanks Nate I will take a crack at that. But I have been having a different more serious issue with the MPF2_auto fit function that I describe in this thread. http://www.igorexchange.com/node/5791
Not sure if you are interested in taking a look at that.
I took a look at it and explained what is going on there.
So can I call it like this? is this the right syntax? (i'm getting an error if I use square parentheses and it is asking for an equal sign)
Make/O/T T_Constraints
T_Constraints[0] ={"K3>11.08","K3<11.08"}
variable ret = MPF2_AutoMPFit("peaksframe","Gauss","PeakCoefs%d","Constant","BaselineCoefs",trynamelist,xwaveslist,0, constraints=T_Constraints)
xWaveList list of the X waves with peak data to be fit. Any entry in the list that doesn't name an actual wave causes the fit to use "_calculated_"; that is, the X values will be taken from the corresponding Y wave's X scaling.
If xWaveList is set to "", all X waves will be "_calculated_".
Note that last line.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 16, 2014 at 03:37 pm - Permalink
I am running 6.34a.
The multiPeakBatchFit function is in the help file and I am trying to use it to automate some batch processing. (and you didn't think people actually read the help files did you?)
April 17, 2014 at 09:38 am - Permalink
Your right- we tend to assume that people don't read the help. I think we're mostly right, so it's nice to be proven wrong sometimes!
The key is this line:
Wave/Z MPStruct.xWave = $StringFromList(i, xwavelist)
The list could be just "" (an empty list) or it could be a list of words that simply aren't names of waves, like "_calculated_". The /Z flag in Wave/Z indicates to Igor's compiler that it's not a mistake for the wave reference to be NULL. The MPF2_DoMPFit() function will interpret the NULL wave reference for the X wave to mean that it should use the Y wave's X scaling for the X data.
Is there some reason to not use MPF2_AutoMPFit()? It's a lot more sophisticated than the example function.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 17, 2014 at 02:39 pm - Permalink
Hi, could you show me a typical experiment to use the multipeakbatchfit function, I have been trying to use it, but I don't know how. Thank you.
April 30, 2014 at 06:19 am - Permalink
Attached is a an example of what I am working on.
There are a set of small spectra files (Auger spectra) that I loaded up. I have set the wave scaling to set the energy range and I do not need a separate x-wave.
I create a list of the waves to be fit using wavelist. Note: the documentation is not specific but it appears in my fumbling through that a semi-colon delimited string is expected. When I used a comma delimited string nothing would happen nor was there an error message.
To do the batch fit, I use the function included in multi-peak fitting V.2 (make sure it is loaded) and I run the command
MPF2_AuotMPFit("RDF","ExpModGauss","PC%d","Cubic","Fred",ywavelist,"",5) and you can look into the help file for the definitions. I create a string called ywavelist with the wave names.
You can delete the fit folders and rerun the command to see it work.
April 30, 2014 at 08:56 am - Permalink
MPF2_AutoMPFit(resultDFBase, peakType, PeakCoefWaveFormat, BLType, BLCoefWaveName, yWaveList, xWaveList, InitialGuessOptions [, noiseEst, smFact, noiseEstMult, smFactMult, minAutoFindFraction])
I believe I would like to use initialOptionsGuess 0 "Do not run the automatic peak picker. Initial guesses will be pre-loaded in coefficient waves in the data folder resultDFBase+"_0". Use those values for every data set." I just am a bit lost on how I should set up a data folder containing the required information, and then how to feed that to the function inputs.
June 10, 2014 at 10:50 am - Permalink
String newDFName = resultDFBase+"_0"
String PeakCoefWaveFormat = "myPeak%d"
DuplicateDataFolder root:Packages:MultiPeakFit2:MPF_SetFolder_1, $newDFName
DFREF newdf = $newDFName
Variable i
for (i = 0; i < 19; i += 1)
String wname
sprintf(wname, "Peak %d Coefs", i)
String newname
sprintf(newname, PeakCoefWaveFormat, i)
Rename newdf:$wname, $newname
endfor
MPF2_AutoMPFit(resultDFBase, ..., PeakCoefWaveFormat, ...)
In that code (which is completely untested!) the complete data folder for a manual multipeak fit is duplicated, giving the duplicate the appropriate name ending in "_0". The the looop renames the coefficients waves from the names used by the MPF2 user interface, to names corresponding to the names specified by the PeakCoefWaveFormat input string.
If you have a baseline as part of the fit, you need to do the same for the baseline coefficient wave. To avoid the loop and renaming waves, you could just use
String newDFName = resultDFBase+"_0"
DuplicateDataFolder root:Packages:MultiPeakFit2:MPF_SetFolder_1, $newDFName
MPF2_AutoMPFit(resultDFBase, ..., "Peak %d Coefs", ..., "Baseline Coefs", ...)
This simplifies the problem by using the same names as the GUI for MPF2 uses, so you only need to duplicate the data folder, you don't need to rename the waves.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 10, 2014 at 03:11 pm - Permalink
June 10, 2014 at 05:01 pm - Permalink
You will have to add a parameter to MPF2_AutoMPFit(). I suggest you copy MPF2_AutoMPFit() from Multi-peak Fitting 2.0.ipf, rename it something like MPF2_AutoMPFitCustom() and add a constraints argument. The constraints argument would be in the format that MPF2_DoMPFit() expects in the MPFitInfoStruct structure argument. For details on the constraint text wave format see the help for Fitting With Constraints.
DisplayHelpTopic "Fitting With Constraints"
The custom MPF2AutoPMFitCustom() function defintion would look like the following:
String resultDFBase
String peakType, PeakCoefWaveFormat
String BLType, BLCoefWaveName
String yWaveList, xWaveList
Variable InitialGuessOptions
Variable noiseEst, smFact
Variable noiseEstMult, smFactMult
Variable minAutoFindFraction
Wave /T constraints
...
Then, after the MPFs struct is declared (the "STRUCT MPFitInfoStruct MPFs" line), add the following lines:
if (!ParamIsDefault(constraints))
Wave /T MPFs.constraints=constraints
endif
That should be all you need to make MPF2_AutoMPFitCustom work with constraints. Now you just need to define the constraints. You can do it by hand by creating a text wave and defining one constraint per row - following the Constraint Expressions syntax described in Fitting With Constraints. Or you can copy the constraint text wave used by the Multi Peak Fit 2 package. The MPF2 UI text wave is part of a structure, so its scope is limited to the function in which it is instantiated. If, however, you have the MPF2 UI open and the constraints set you can call the following function to make a copy of the constraints wave.
Variable setNumber
Wave /T constraints = getGlobalConstraintsWave(setNumber)
String conWaveName = "W_Set"+num2str(setNumber)+"_Constraints"
Duplicate /O constraints, $conWaveName
End
Pass the resulting wave to your MPF2_AutoMPFitCustom() function and you should be in business:
Note that I have not tested any of this. If you have trouble getting this to work email me at Wavemetrics support. I will be adding constraint functionality to MPF2_AutoMPFit() in the manner I described here, as well as making MPF2_DoMPFit() write reference constraint text waves, for the next Igor version 6 update.
Good Luck!
Nate Hyde
WaveMetrics
support@wavemetrics.com
June 11, 2014 at 03:44 pm - Permalink
http://www.igorexchange.com/node/5791
Not sure if you are interested in taking a look at that.
Thanks!
June 11, 2014 at 03:53 pm - Permalink
I took a look at it and explained what is going on there.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 12, 2014 at 09:14 am - Permalink
"MPF2_AutoMPFit(resultDFBase, peakType, PeakCoefWaveFormat, BLType, BLCoefWaveName, yWaveList, xWaveList, InitialGuessOptions [, noiseEst, smFact, noiseEstMult, smFactMult, minAutoFindFraction, constraints])"
So can I call it like this? is this the right syntax? (i'm getting an error if I use square parentheses and it is asking for an equal sign)
Make/O/T T_Constraints
T_Constraints[0] ={"K3>11.08","K3<11.08"}
variable ret = MPF2_AutoMPFit("peaksframe","Gauss","PeakCoefs%d","Constant","BaselineCoefs",trynamelist,xwaveslist,0, constraints=T_Constraints)
Thank you for any help.
March 16, 2016 at 12:43 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 17, 2016 at 11:46 am - Permalink