Scripting Resources for DigitalMicrograph™


Dave Mitchell's DigitalMicrograph™ Scripting Website

Home | Scripts | Examples | Functions | Recent Updates | Tutorials | Resources | Publications | Consulting | Projects | Contact & Bio | Private | Search


Function: Gaussian Fit
This function will fit a Gaussian to a peak (identified by having a region of interest drawn across it). The fitted peak and the various peak parameters are also returned. This is the same functionality as was contained in the 'Gaussian Fit' script (also available here), but rewritten as a function.
version:20111207, v2.0
D. R. G. Mitchell and W. Bertram
EELS Zero Loss Peaks (ZLP) are not particularly good Gaussians - Lorentzians provide a better fit. However, Lorentzian fit libraries run to hundreds of lines of code, so Gaussians it is. The poor Gaussian fit is particularly noticeable in the tails. Two method of dealing with this are provided here: 1. If the width of the fit (defined by the width of the region of interest (ROI) marking the peak) is restricted to perhaps fullwidth tenth maximum then an excellent fit is obtained. A weighting factor is also provided. This weights the channels according to their distance from the centroid. A value of 1 will weight all channels equally, whereas a value of say 6 will weight the near centroid channels much more strongly than those in the tails. If the ROI is wide enought to include the tails, then a weighting value of 4-6 will produce a much better fit than that obtained with a value of 1. It is generally very difficult to get good tail fits, so this function is not good for stripping ZLPs from spectra. However , if you wish to measure peak parameters such as the full width half maximum or peak position, then it will perform well. Peak position determination with this function is preferred to simply taking the maximum, since that can be thrown off by noise. In addition sub-pixel precision is obtained with this method.
System Requirements
Should be compatible with all recent versions of DigitalMicrograph.
Known Issues
Included Files
Main script file.
Source Code

See attached script file.