-
Notifications
You must be signed in to change notification settings - Fork 10
04. Peak Fitting
Peakaboo employs characteristic models for each element to fit the K, L, and M peaks observed in XRF spectra. These models are based on physical data that describe the electronic transitions occurring during the XRF process. With default settings, each transition line is convolved with a pseudo-Voigt peak shape. Each pseudo-Voigt shape includes the energy loss broadening that contributes to most of the background that occurs in XRF spectra.
When fitting peaks in XRF spectra, the detector type significantly influences the spectral features. For instance, in a Silicon Diode Detector (SDD), interactions between incoming X-rays and silicon can emit Si K-shell electrons, creating escape peaks by reducing the X-ray's energy by 1.74 keV. Such escape peaks appear for major elements.
To tailor escape peak fitting to your detector, go to the
Advanced Options dialog. Under the Detector section, you can select
Silicon or Germanium based on your detector type, or toggle escape peaks off
if it is unnecessary. Silicon is the default setting.
The characteristic XRF peak's curve shape (lineshape) is, by default, represented using a Pseudo-Voigt function, a mix of Gaussian and Lorentzian shapes. This choice offers a good balance between computational speed and accuracy, effectively handling peak tailing from scattering and detector effects.
In the
Advanced Options dialog in the Curve Fitting
section, you can select the function for peak fitting. While the Pseudo-Voigt is
the default for its efficiency, options for the slower, more precise Convolving
Voigt, and the original Lorentzian and Gaussian functions are also available.
For detailed peak fitting, multiple functions overlay to represent the various
transitions within each K, L, and M-shell XRF transition. To visualize these
transitions within the composite lineshape, toggle
View →
Transition Lines and each transition will be marked by a solid line,
indicating its contribution to the overall peak shape

Spectral Fitting of multi element sample showing individual lines
Solid-state detectors, such as the Silicon Diode Detector (SDD), produce spectra
in which peak width combines a constant intrinsic width and fluctuations from
electronic detector noise. To model the broadening introduced by different detectors,
noise can be customized from the
Energy menu. Notably, the
width of characteristic XRF peaks decreases linearly with increasing peak
energy, a factor integrated into the fitting algorithm.
The database for peak fitting, including positions and relative intensities for
each K, L, or M XRF elemental transition, is sourced from reputable tabulations
to ensure accuracy and currency. The majority of fittings are based on the
Xraylib project, supplemented by Krause’s
contributions for high Z elements' K series transitions. These fittings are
fine-tuned for 20keV irradiation.
To fit your data, four different tools are available. Access these by clicking
the
Add Fittings button located at the top of the Peak Fitting tab.
The "Elemental Lookup" feature allows you to easily match K, L, or M lineshapes of known elements to peaks in your spectrum. Locate an element by scrolling or by filtering by its name or atomic symbol, then select the transition you wish to fit. Purple provisional lineshapes will appear on the spectrum, with the atomic symbol marking the most intense component. This visual aid assists in verifying whether the selected element aligns with the spectral peaks under examination.
If the provisional fit doesn't align, either click the
Cancel
button to undo or deselect the element to adjust your selection. If the fit
seems appropriate, confirm by clicking
OK.

The elemental lookup fitting controls
For optimal results, start fitting elements from those with lower atomic numbers, progressing to higher ones. Prioritize fitting K lines before L lines to avoid confusion from spectral overlaps. You can annotate the spectrum by double-clicking the element in the list, adding brief notes next to each elemental line label.
"Guided Fitting" helps identifying peaks by just clicking on the spectrum. To use it:
- Click on the desired peak. The software automatically fits it with a recommended element, showing other possibilities in a dropdown list on the sidebar.
- To fit additional peaks, click the
Addbutton below the list and select another peak. - If you need to modify any fitting, use the
Editbutton. - Once satisfied with the fittings, finalize by clicking
OKto add them to your analysis.

The guided fitting controls
Automatic Fitting identifies intense peaks throughout the spectrum autonomously. Selecting this tool will propose fittings with identified elements. Approving the proposed fittings will add them to your list. This method offers a quick overview of the spectrum's primary components. However, you should always review the automatic selections to ensure their correctness and completeness.
"Summation Peaks" emerge when signals from intense XRF peaks arrive almost simultaneously, combining their energies into new peaks. By combining already-fitted elements from the Peak Fittings list, you can account for these combined energies, creating new, summed lineshapes on the spectrum for analysis.

The summation fitting controls
In the fittings list, each entry has an associated checkbox to control its active status. Unchecking a box temporarily disables the fitting from the analysis, allowing for easy comparison or refinement of the spectral data. Re-enable the fit by rechecking the box.
When you select a fitting from the list, it's highlighted in blue on the spectrum. This visual cue is particularly helpful for distinguishing between overlapping peaks and understanding the composition of complex lineshapes.
Peakaboo provides several fitting algorithms to match theoretical lineshapes to
your spectral data, accessible via
Advanced Options →
Curve Fitting. The options include:
-
Max-Under-Curve: The default choice, selected for its speed and conservative fitting approach, ensuring no over-fitting within the peak's dimensions. However, it may struggle with noisy or complex spectra.
-
Least Squares: Optimizes fit by minimizing the sum of squared differences between the fitting lineshape and the actual data, making it suitable for noisy data. Its drawback is a tendency to over-fit weaker signals.
-
Optimizing: A modified Least Squares algorithm that penalizes over-fitting, offering a balance between fitting noisy data well and avoiding fitting where there's no significant signal.

Comparison of mapping data treated with Max-Under-Curve (left) and Optimizing (right)
In situations where spectral peaks from multiple elements overlap, it can be
difficult to determine what signal came from which fitting. Peakaboo offers
algorithms to resolve the signal contention, accessible via
Advanced Options → Overlap Solving. Several approaches are
available to deal with this complex fitting scenario:
-
Greedy: As the default solver, it quickly fits peaks from Curve Fitting in the sequence they appear in the Peak Fitting list, adjusting each curve based on the remaining spectrum after subtracting previously fitted curves. This method allows users to influence the fitting order by rearranging elements, helping to manage potential overfitting issues.
-
Optimizing: This enhanced Least Squares method fine-tunes the results of Curve Fitting and minimizes overfitting by penalizing fits against non-existent signals, offering refined solutions for spectra with dense overlaps. It's more comprehensive but slower than the Greedy solver.
-
MultiSampling: Building on the Optimizing approach, MultiSampling averages multiple fitting sequences to mitigate the influence of element ordering, enhancing reliability at the expense of increased computational demand.
Each fitting you add can be annotated to track important context or
caveats for your work. Annotations will be displayed with the fitting’s
Element Name in the plot, and in tool tips in the Peak Fitting
sidebar.
To add an annotation, double-click on the fitting in the Peak Fitting
sidebar. A prompt will appear which will let you add an annotation to
the selected fitting. It can be cleared by double-clicking the entry
again and setting the
To achieve effective peak fitting in Peakaboo, consider the following strategies:
-
After energy calibration, use Automatic Fitting to quickly identify clear peaks. Then, refine with Guided Fitting and Element Lookup for thorough peak identification.
-
Watch carefully for summation peaks, especially under high photon flux with the SDD detector. If you find one, there are likely others. Using Summation Fitting can help account for these additional peak contributions.
-
Consider not using any background subtraction as it might alter peak shapes and affect precise fitting.
-
Aim for the summed fitted spectrum to closely align with the experimental spectrum, particularly in high-signal regions.
-
Minor adjustments to peak width settings (FWHM noise level) can enhance fitting, especially in response to changes in photon flux.
[1] M.O. Krause, C.W. Nestor, C.J. Sparks and E. Ricci, X-Ray Fluorescence Cross Sections for K and L X Rays of the elements, Oak Ridge Report ORNL-5399, 1978.