Home

Awesome

PeakFit

PeakFit provides a tool to fit spectral data with a linear combination of symmetric peak functions such as Gaussian or Lorentzian. The background component of the spectra can be optionally taken into account by specifying the related parameter. In which case, the algorithm will attempt to fit the background with a polynomial function of the given order.

The fit model is given by:

f(x) ~ peak1(x) + peak2(x) + ... + peakN(x) + polynomial(x)

Each peak function is characterized by three fit coefficients: Center, Width, and either one of Area and Height. The polynomial function is characterized by n+1 fit coefficients, where n is the order of the polynomial.

Licensing

This software is licensed under the GNU General Public License (version 3).

Tested On

Requirements

Setting Up

  1. Download or git-clone this repository and other repositories listed in the Requirements.
  2. Add the repositories to the MATLAB's search path via addpath(genpath( ... )) OR this version control system.

Usage

Construct the PeakFit object in the following ways, and the fit results will be populated in the object's public properties.

obj = PeakFit(Data, ... Name-Value ...)

OR

obj = PeakFit(XData, YData, ... Name-Value ...)

OR

% Create an empty PeakFit object.
obj = PeakFit();

% Specify the data points and peak-fit settings via property assignments.
obj.XData = ... ;
obj.YData = ... ;
obj.Property1Name = Value1;
obj.Property2Name = Value2;
...

% Perform the peak fitting by reinstantiating the PeakFit object.
obj = PeakFit(obj);

Data must be specified as a two-column (or two-row) matrix where the first column (or first row) is the X data points and the second column (or second row) is the Y data points. In the alternative syntax, XData and YData are respectively the X and the Y data points, specified as vectors, of the curve to be fitted.

The peak-fit settings can be specified after the mandatory arguments in Name-Value syntax, e.g. PeakFit(Data, 'Window', [100,900], 'NumPeaks', 3). If no settings are specified, the algorithm will attempt to fit all peaks in the data using the default settings. The default behavior may not be optimal for noisy data. See Best Practices for recommendations in making an optimal fit.

Name-Value Pair Arguments

Any of the public properties can be specified as arguments in Name-Value syntax during the object construction. Specifying other things as Name-Value arguments will return an error.

Examples

Default Behavior

If the PeakFit is called without specifying the number of peaks, start points, or lower or upper bounds, then the algorithm will attempt to fit all peaks that it can guess. The following image is a photoluminescence spectrum of Er<sup>3+</sup> in Y<sub>2</sub>SiO<sub>5</sub> at near-liquid N<sub>2</sub> temperature. The spectrum was fitted using the command:

Fit = PeakFit(Data, 'PeakShape', 'Lorentzian');

The full code is given in Examples/Er_PL_in_YSO.m. It can be seen that many of the peaks were not resolved properly, and only the tallest peaks were correctly identified.

Er PL in YSO

Best Practices

The PeakFit algorithm works best if the lower and upper bound of the peak Center, the upper bound of the peak Width, and the baseline polynomial order are specified, as done in the following example. The following Raman spectrum of VO<sub>2</sub>, taken at near-liquid N<sub>2</sub> temperature (Lim2014), was fitted using the command:

Fit = PeakFit(Data, 'PeakShape', 'Lorentzian', ...
    'CenterLow', [...], ...
    'CenterUp', [...], ...
    'WidthUp', [...], ...
    'BaselinePolyOrder', n);

The full code is given in Examples/VO2_Raman.m. Constructing the constraints for the fitting often require guess work, but the constraints do not have to be narrow to get a good accuracy. In some cases, the approximate locations of the peaks are known in the literature, and the fit constraints can be defined from this knowledge.

VO2 Raman

Public Properties

Fit Results

Fitting Start Points

Fitting Lower Bounds

Fitting Upper Bounds

Algorithm Parameters

Public Methods

Static Methods

See Also