Top Hat Filter – Peak Locator

Category: Data Processing and Evaluation – Spectra
Description: Script to take a profile or spectrum and locate the peaks and troughs using a top hat filter. The dialog provides access to the top hat filter parameters, which can be tailored to suit the sensitivity and peak shapes being measured. The foremost spectrum can then be measured with the 'Measure' button. The peaks are marked with ROIs, and their positions saved as tags. This data can be printed out to the results window by pressing the 'Report' button. How the data are reported is controlled by the radio buttons. Max's, Min's and All selects whether peaks, troughs or all are reported. If the 'Save as tabbed text' option is selected then the data are also written as x and y tabbed text to a new text window and the option to save is given. This text file can be directly read into Excel, Kaleidagraph etc. If the 'Label peaks in plot' option is selected then the X and Y values of each ROI in the plot will be labelled. Note the script seems better at picking maxima than minima, since the former tend to be more symmetrical. // Tested on DM versions 3.7, 3.8 and 3.9
Comments: Not super fast, but it gets there. Tested on DM versions 3.7, 3.8 and 3.9. Assmetric peaks may be found offcentre. Adjust the top hat parameters (make the hat smaller) to correct this. Alternatively, read the wrong peak positions and manually edit the text file of results. There seems to be a bug when lineplots of different sizes are measured. Re-launch the script in that case.
Acknowledgements: Thanks to B. Schaffer for some suggestions to improve this script.
Script version: 1.3
DM/GMS version: 3.9.0
Script written as a function: No
Source: Show code
Download Source Code: Download
Download Zip File: Download