Suggestions for Multipeakfit2
| chozo | May 27, 2010 - 05:37 | ||
|---|---|---|---|
|
I am using the Multipeakfit package to fit relatively complicated spectra with overlapping peaks and have some suggestions for it. At first there are some "bugs" I want to address: Now some annoyances I have constantly: the values which parameters are on hold should be saved (maybe in a separate wave for easy readout) and set on resume results should be displayed differently (in a table at best with selectable digit count for display) have more than one revert or have a checkpoint button possibility to constrain to only negative or only positive peaks possibility to load peaks from one set into another Ok, that was long, but I’m not finished yet. I have even some cool features to suggest to you: have area, fwhm etc. as parameters link parameters of different peaks together Thanks for reading this wall of text. |
|||

Joined: 2007-06-29
Location: United States
Chozo-
I started a response to your posting, but got interrupted. I still have it in mind!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2010-05-14
Location: Germany
If the topic is not dead yet, I'd like to add some things:
A bug, if a MultiPeakFit graph is open with the attached external control panel containing many peaks:
- When the focus is on another window (another graph, table, etc.) clicking & dragging the scroll bar of the external panel containing the peak list will result in a additional list generated in the graph window and scrolling this list instead of the one in the external panel
- It would make things quicker if its possible to easily get rid of all (or most of) the peaks to start over. Maybe a button ' delete all peaks' would be the easiest way. Ok, maybe the reply to this is to just start a new set, but I hate to have my experiment cluttered with useless stuff, so I use exactly one set per wave.
Joined: 2007-06-29
Location: United States
- When the focus is on another window (another graph, table, etc.) clicking & dragging the scroll bar of the external panel containing the peak list will result in a additional list generated in the graph window and scrolling this list instead of the one in the external panel
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2010-05-14
Location: Germany
Thanks for looking into this.
Meanwhile I think I have found something regarding this issue:
if the scaling delta of a wave is negative, after adding the first peaks the function generates an error (Make error: number of points must be between 0 and 2147 million) when attempting to generate and display the fit wave (the sum wave in blue). I think somehow the calculation of the needed wavepoints will be infinite for negative deltas, but I haven't had the time to look deeper into the code to find it.
...
In the function MPF2_AddFitCurveToGraph is this written:
The xleft and xright values are grabbed from the beginning and end of the wave, but with negative scaling delta xleft will be bigger than xright. This means the following npnts calculation will come out negative, thus breaking the make command. Ok, an
abs()will solve this, but there may be other cases where the normal direction of the wave scaling is assumed. When I find the time I may change this and see if I find other errors.Joined: 2007-06-29
Location: United States
In fact, in my development copy of Multipeak Fit 2, I have this:
I think it's great that you're willing to help me debug the package, but I suggest that you get the latest version of Igor 6.20B03 so that you can avoid fixing things that are already fixed.
I still haven't forgotten about your great list of comments above!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2010-05-14
Location: Germany
Sorry, I was hesitating to update because I support 4 PCs with one being an actual experiment control device and having different versions usually generates problems. But ok, I have updated Igor and hope the new version will be standard soon.
Now, moving on to my other 'bug' (now with Igor 6.20):
I think, the cause is
Make/O/D/N=1 $(DFPath+":'Baseline Coefs'")in the BuildMultiPeak2Panel function which munches away all existing coefs but the first while generating the panel. This destroys all baselines with more than one coef.Joined: 2007-06-29
Location: United States
OK- I just understood this report and I can reproduce it. I'm working on it; I will look into your hint.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2007-06-29
Location: United States
OK- you were, of course, correct. The proper fix wasn't to simply remove it or add a conditional at that spot. It wasn't really the correct place to have the creation of the wave. I moved it to a more correct place, plus added conditionals to make sure it didn't wipe out a pre-existing wave. I have attached a copy of the fixed procedure file.
Understood. But if you make changes to code, it's best to do it with the latest version. The extra complication makes life more interesting :)
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2010-05-14
Location: Germany
Great! Thanks a lot.
Joined: 2007-06-29
Location: United States
For now, I have to go through all peaks after resume and reset the various hold checkboxes (if I still remember them all correctly and don't forget one). If I want to extract the information which parameters are on hold (maybe to show it to someone or just have an overview) I have to get this indirect. Currently I have a procedure to generate a table with the information I need (see next point why) and label the fields with error info +/-0 as hold.
Fixed.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2007-06-29
Location: United States
This is really annoying for me, because I want to fit similar spectra. I want to have the same peaks for a different set to begin the fit and work out the differences, but how do I get them in? I have to manually add the peaks and copy/paste or dial in all the values. Lucky me, that I don’t do fits with 50 peaks. To achieve this I even can’t use the standard result output formats (notepad -> bloated, tab-delimited -> data missing), so I copy the parameters form my generated table.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2010-05-14
Location: Germany
Awesome, new features every day!
Now the usage report for the latest version (in the order I notice it / get it reproduced):
a) When starting fresh the manual adding of a peak seems broken.
a1) Manual add of a peak before doing anything results in 'While executing a wave read, the following error occurred: Index out of range for wave "EditPeakList"', but the peak still gets added.
a2) After one click on Auto-Locate and then trying to add a peak results in 'While executing a wave read, the following error occurred: Index out of range for wave "HoldStrings"', but the peak gets added.
b) Ok, thats nothing new but I keep wondering why:
b1) A wave 'SavedCoefWave' is created and changed when clicking the hold checkboxes and contains the coefs of the clicked peak. Does this wave have any purpose? And if yes, then why isn't it generated in the set folder?
b2) A following error message (e.g. before a fit was made) after clicking on 'Peak Results' changes the current folder to the MPFset folder. The info message probably prevents the correct reset to 'root'. There may be other situations, when a different function exit causes this. I keep looking.
c) I still can't get the hold values remembered correctly. I guess, when the hold bits are written in the 'HoldStrings' wave everything gets loaded fine again. I try to watch the 'HoldStrings' values while playing around with the checkboxes, but so far the only option to actually write something there is to use the right-click menu and choose one of the two options. Simply clicking the checkbox or every other button does't update the values at all.
d) The initialization feature is cool, even gives a new way to get rid of all peaks to start over.
d1) Currently, when a set is started with the peaks panel open clicking on continue in the Start Multi-Peak Fit panel just gives focus to the graph. Wouldn't it be even more useful now (with the new initialize feature) to rebuild the panel with the new settings (i.e. automatically close the peak panel and rebuild / update everything with the new settings)? Just a tiny thing to get working more smooth.
d2) Loading a set for another wave currently doesn't work, because there is a name check in place, giving the error 'The Y wave you selected (...) is not the same as the one previously used with this graph. ...'. I think the intention was to copy over the the data to the new set associated with this graph an use the information as a starting point, but at the moment merely a set folder and a graph gets created.
Joined: 2007-06-29
Location: United States
Chozo-
Thank you for the comments. I'm sure you've figured out that you're the guinea pig for the new features :)
Some of the comments you made are a result of incomplete implementation- you are absolutely right, of course, that the option to initialize from another set should ignore the fact that the waves are different. I confess that I tested by making two graphs of the same data. My only excuse was that I was trying to work fast and get on to my next big project :{
I will probably not get back to the fixes for this stuff until Monday.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2007-06-29
Location: United States
OK- the next try!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2007-06-29
Location: United States
a1) Manual add of a peak before doing anything results in 'While executing a wave read, the following error occurred: Index out of range for wave "EditPeakList"', but the peak still gets added.
a2) After one click on Auto-Locate and then trying to add a peak results in 'While executing a wave read, the following error occurred: Index out of range for wave "HoldStrings"', but the peak gets added.
b) Ok, thats nothing new but I keep wondering why:
b1) A wave 'SavedCoefWave' is created and changed when clicking the hold checkboxes and contains the coefs of the clicked peak. Does this wave have any purpose? And if yes, then why isn't it generated in the set folder?
b2) A following error message (e.g. before a fit was made) after clicking on 'Peak Results' changes the current folder to the MPFset folder. The info message probably prevents the correct reset to 'root'. There may be other situations, when a different function exit causes this. I keep looking.
c) I still can't get the hold values remembered correctly. I guess, when the hold bits are written in the 'HoldStrings' wave everything gets loaded fine again. I try to watch the 'HoldStrings' values while playing around with the checkboxes, but so far the only option to actually write something there is to use the right-click menu and choose one of the two options. Simply clicking the checkbox or every other button does't update the values at all.
d) The initialization feature is cool, even gives a new way to get rid of all peaks to start over.
d1) Currently, when a set is started with the peaks panel open clicking on continue in the Start Multi-Peak Fit panel just gives focus to the graph. Wouldn't it be even more useful now (with the new initialize feature) to rebuild the panel with the new settings (i.e. automatically close the peak panel and rebuild / update everything with the new settings)? Just a tiny thing to get working more smooth.
d2) Loading a set for another wave currently doesn't work, because there is a name check in place, giving the error 'The Y wave you selected (...) is not the same as the one previously used with this graph. ...'. I think the intention was to copy over the the data to the new set associated with this graph an use the information as a starting point, but at the moment merely a set folder and a graph gets created.
When I’m fitting the data I often try different things to get it right, for example adding a peak or varying some of the parameters. Sometimes the fit will fail then or some peaks will be unreasonable large or negative. This will often destroy my peak set, even if I had an almost good solution at some point. Now the ‘revert to guesses’ button only reverts one step which is seldom enough recover the fit. It would really help to have more ‘undo’ to play around. I understand, that this may be difficult to implement (where to save all the info), but then maybe a checkpoint button helps? Even if it’s only one checkpoint, I can then decide what is a good point to revert to and what not.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2010-05-14
Location: Germany
That is great! There are some bugs still, but the overall usability is way better now.
I try to write a new report, when I have more time. It seems that there are some edge cases where the checkpoint system fails, but good thing it's possible to always reload it via the main menu.
Hopefully you will find the time to work a little more on this project.
EDIT:
ok, some things I have found:
Checkpoint Feature:
- When I choose 'restore checkpoint' the checkpoint sometimes fails to load. The cause is in the function MPF2_CheckpointMenuProc(s). The
SVARnamed 'gname' is referenced as the graph name, but later on the variable gets killed by theKillDataFolder $DFpathand giving a null string to the following MPF2_StartNewMPFit- sometimes it works somehow (maybe the folder removal fails at some point)
Initialization Feature:
- I was misled by the 'start fresh' option, which currently doesn't get rid of the peaks as I thought but generates a completely new set. Currently, for my taste it's too easy to end up generating new sets and too difficult to resume present sets (at the moment at least the graph has to remain open or a recreation macro has to be prepared). I have no cool suggestions for this at the moment. I try to come up with a idea to simplify the start menu while ease up things. Maybe reversing the order of options is better? Currently its like
{specify wave} -> graph:{old}/{new} -> init: {empty}/{old}/{set1}/{set2}...
but working from the view of sets would be like:
choose set: {new}/{set1}/{set2}
-> if previous set -> init: {delete peaks}/{old peaks}
-> if new set -> {specify wave} -> init: {empty}/{set1}/{set2}
Peak Adding Error:
Some more situations for the infamous 'HoldStrings'-issue:
In the function MPF2_SortAutoPeakWave after adding the first peak, this fails:
because holdwave (= HoldStrings) has only one point and the 4. line generates the error. And more occasions, where HoldStrings is referenced with too high counters:
in function MPF2_EditOrAddDoneButtonProc(s) and
in function MPF2_RefreshHoldStrings(PanelWin)
Joined: 2007-06-29
Location: United States
You are really great with the feedback!
I have copied your comments to a notes file, and will address them soon.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2007-06-29
Location: United States
- When I choose 'restore checkpoint' the checkpoint sometimes fails to load. The cause is in the function MPF2_CheckpointMenuProc(s). The
SVARnamed 'gname' is referenced as the graph name, but later on the variable gets killed by theKillDataFolder $DFpathand giving a null string to the following MPF2_StartNewMPFit- sometimes it works somehow (maybe the folder removal fails at some point)
Yuck. Easy mistake to make! It didn't fail on my Macintosh. I tried stepping through it in the debugger- when you step over the KillDataFolder command, the debugger shows the gname string as null, but when you step into MPF2_StartNewMPFit function, it magically gets the right contents! I suspect that Igor is not actually killing the variables in the data folder, but just moving them to a "graveyard". We use that technique frequently to protect against crashes caused by stale pointers to data structures. It would be really nice if that caused a run-time error!
Anyway, it's fixed now.
- I was misled by the 'start fresh' option, which currently doesn't get rid of the peaks as I thought but generates a completely new set.
Hm. "Start fresh" should be just like starting from a completely new data set. It should come up with a blank list, no peak traces, and the annoying message that covers the Do Fit button. I see that I failed to remove the peak traces from the graph, so there are peak traces that don't reflect any actual peaks. I have fixed that.
{specify wave} -> graph:{old}/{new} -> init: {empty}/{old}/{set1}/{set2}...
but working from the view of sets would be like:
choose set: {new}/{set1}/{set2}
-> if previous set -> init: {delete peaks}/{old peaks}
-> if new set -> {specify wave} -> init: {empty}/{set1}/{set2}
Well, I think a new user is going to think about his problem from the point of view of data set waves, so I think the present method is the right one- choose data sets, then a graph, then a previous fit set if you want. Using a previous fit set to initialize a new fit is a somewhat advanced feature...
I agree that it is a bit cumbersome.
Some more situations for the infamous 'HoldStrings'-issue:
In the function MPF2_SortAutoPeakWave after adding the first peak, this fails:
because holdwave (= HoldStrings) has only one point and the 4. line generates the error. And more occasions, where HoldStrings is referenced with too high counters:
in function MPF2_EditOrAddDoneButtonProc(s) and
in function MPF2_RefreshHoldStrings(PanelWin)
These errors may yet kill me...
I've fixed those. I didn't run into any more myself, but it's become evident that my testing isn't realistic!
Thank you for all your efforts!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2010-05-14
Location: Germany
Thanks a lot!
Works very well so far. I will update if I find something.
EDIT:
I tried to use the init feature today. When I have a set (e.g. set 1), I try to set this as init for another wave. Everything gets loaded, but when I try to do a fit, the procedure fits the wave from the initial set (=1) and not the wave in the graph I want to fit (= set 2). In the new set (2) folder are fit_, Res_, and Bkg_ for both the old and the new wave and both versions are loaded in the graph. So the transfer feature is broken, since the new wave gets ignored by the fitting process.
Joined: 2007-06-29
Location: United States
Hi, Chozo. I just got back from a week away. I will check into your latest report soon. I don't know why this is being so difficult!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2007-06-29
Location: United States
This one should be perfect...
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2010-05-14
Location: Germany
Cool thing. I play around with this.
Now, I can imagine you have other things to do, especially since the betas are rolling out, but I'd like to bug you a bit more with ideas for a changed results export.
I think the results table is a nice overview and one can sort the data too. How about a button to get a table generated (maybe in the root folder or whatever) with the contents and the sorting of the overview?
I even wonder how many people would then go for the tab-delimited output, since the table export from Igor itself gets this done too (and more).
Thanks a lot!
Joined: 2008-01-21
Location: Germany
This one should be perfect...
Er, I just came across this and downloaded to join the game --- the new package looks very nice!
I hope it's okay to report errors here. If you prefer e-mails, please tell me. The first thing happening were two "index out of range" errors (thanks to #pragma rtglobals=3 ? I use IP6.2.0.3 on Win7).
1) Upon invoking "Start New Multi-peak Fit" from the Analysis/Multi-peak Fit> submenu "a wave read error" occurred for
wsmFactinFunction/C EstPeakNoiseAndSmfact(w,pBegin,pEnd)in PeakAutoFind.ipf (using version 5.06).
2) I then set up my wave
dum1as the y wave and pressed the "Auto-locate peaks now" button. I think this is when I first got the error message** a wave write gave error: Index out of range for wave "Res_dum1".
but I could not reproduce this the second time round when I started writing this comment. Mayhap it was due to the way I tried to follow up on the first error.
3) When trying to restore a previously saved Checkpoint, I always get an error
** KillDataFolder gave error: can't kill a wave that is part of a graph, table or user function or is in use by an XOP
Cheers,
Wolfgang
PS I absolutely love the improved result reporting in its various forms. Do you presage a mechanism to "customize" it (eg user-defined functions or some such?)
Wolfgang Harneit
Joined: 2007-06-29
Location: United States
I hope it's okay to report errors here. If you prefer e-mails, please tell me.
1) Upon invoking "Start New Multi-peak Fit" from the Analysis/Multi-peak Fit> submenu "a wave read error" occurred for
wsmFactinFunction/C EstPeakNoiseAndSmfact(w,pBegin,pEnd)in PeakAutoFind.ipf (using version 5.06).
To try to reproduce the rest of your errors, I used the waves 'my y data' and 'my x data' from the Multipeak Fit 2 Demo experiment.
dum1as the y wave and pressed the "Auto-locate peaks now" button. I think this is when I first got the error message** a wave write gave error: Index out of range for wave "Res_dum1".
but I could not reproduce this the second time round when I started writing this comment. Mayhap it was due to the way I tried to follow up on the first error.
** KillDataFolder gave error: can't kill a wave that is part of a graph, table or user function or is in use by an XOP
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2007-06-29
Location: United States
Wolfgang Harneit sent me an e-mail to support@wavemetrics.com with a very nice recipe to reproduce his problems. Here's the next installment in this apparently never-ending saga. Note that this time there are TWO files attached.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2008-01-21
Location: Germany
The last two files work fine for me, but I have to tested them to the ultimate limit due to time constraints. Anyway, thanks for your fine work, John!
Wolfgang Harneit
Joined: 2007-06-29
Location: United States
Thank you for the feedback, Wolfgang. If you find any problems, I know that you know what to do!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2010-05-14
Location: Germany
Ok, I think I find some time again to play around with MPF2. Is there a newer version yet (maybe the bugs I find already vanished long ago)?
For now, I stick with the posted version and report bugs as I find them.
The fitting process can produce peaks (peakwaves) with negative delta, e.g. when a peak grows unreasonable big and grows outside to the left of the fitting area.
Then the tag-adding function in MPF2_AddPeaksToGraph gets a problem:
calculates the attachpoint wrong so that the value isn't inside the peak range. The Cause: When center is below XStart, the first line gives XEnd instead XStart for some reason (bug in chain conditionals?).
Joined: 2007-06-29
Location: United States
You are correct as usual. It needs some parentheses:
This fix will be included with the 6.20 release, which is coming Any Day Now.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Joined: 2012-05-02
Location: United States
Was there a solution to this? I can't find an option for it.
Thanks for Multipeakfit, it rocks!
Joined: 2011-07-06
Location: United States
Constraints have been very recently added to multipeak fit 2.0. It will be available in the next version of Igor 6.3, which is still in beta. Special for you I make it available here. In return you have to promise to find all the bugs and report them to me. (I kid. I'm hopeful that there's no major bugs, but if you do find something email it to support@wavemetrics.com.) I've attached the new Mult-Peak Fitting 2.0.ipf and .ihf (Igor help file). To use it do:
1) back up your experiment and close Igor.
2) open your Igor Pro Folder (If Igor were open you could go to menu item Help->Show Igor Pro Folder - maybe do 2) before 1)...)
3) navigate to [Igor Pro Folder]->WaveMetrics Procedures->Analysis->Peak Fitting
4) make a backup of the old Multi-peak Fitting 2.0.ipf and .ihf - copy them into a folder outside the Igor Pro Folder (and outside the Igor Pro User Files folder)
5) copy the new Multi-peak Fitting 2.0 files into the Peak Fitting folder
6) open Igor and launch your experiment
The new MPF 2.0 will be compiled into your experiment. Click the "Apply Constraints" checkbox, select one of your peaks and set the min value of its height to be 0. Then right click on the min value box and choose to apply the same value to all common peaks. This will apply the minimum value to the height coefficient of all peaks of the same type.
Good Luck!
Nate
Nate Hyde
WaveMetrics New Guy
Nate Hyde
Joined: 2012-05-02
Location: United States
Someone, quick, hire this guy!
:)
Joined: 2007-06-21
Location: United States
Too late. We already did :)