Scripting Resources for DigitalMicrograph™ |
Savitzky-Golay Spectral Filter |
|
Function |
A computationally efficient filter for smoothing spectra while retaining peak shape. |
Version |
version:20160612, v1.0 |
Author |
D. R. G. Mitchell |
Acknowledgements |
For more information on this method see: An introduction, by P. M. Mather and M. Koch, Wiley-Blackwell, Table 9.3. |
Comments |
Low pass filtering to smooth spectra is problematic, due to heavy damping of peaks. The method used here involves moving a window across a 1D data set, in which a polynomial is fitted to the data. The fitted value at the midpoint of the window is substituted for the original data. This computationally expensive method, is made much more efficient by computing a single set of coefficients which are subsequently applied to all the points in the window to compute the least squares fit. This script uses matrix methods for efficient processing. It also computes first derivative and second derivative plots. |
System Requirements |
Tested on GMS 2.x but should be compatible with all recent versions of GMS. |
Known Issues |
This script will only work on 1D data sets such as EELS or EDS spectra. The filtering variables are the window width (points) and the polynomial order (polyorder). These variables can be set at the start of the main section of the script. Larger window widths will produce greater smoothing. This script will only compute 2nd and 3rd order polynomial fits. The third order tends to produce less clipping of small peaks, provided the window width is large enough. The method as implemented here will not compute the fourth order polynomial, as it results in a non-singular matrix which is not amenable to LU Decomposition. Any readers with fixes to this, please contact the author. |
Supported |
Yes |
Included Files |
Source code |
Source Code |
See attached script. |