NUCLID is an advanced, automated, and AI-powered gamma spectroscopy analysis system designed to address the challenges of modern radiation metrology, isotopic identification, and peak-fit visualization. Built using modular Python libraries and an interactive Streamlit user interface, NUCLID bridges the gap between hardware-level multichannel analyzers (MCAs) and scientific decision support. The system implements a complete data pipeline starting from raw pulse count acquisition, through SNIP/ALS background subtraction, Continuous Wavelet Transform (CWT) peak search, constrained Gaussian/Voigt peak-fitting, multi-point energy calibration, isotopic library matching, and random forest-based secondary ML classification.
Gamma-ray spectroscopy is fundamental to nuclear security, radioactive waste categorization, environmental monitoring, and medical physics. However, traditional analysis pipelines are heavily bottlenecked by manual workflows. Analysts must manually select regions-of-interest (ROIs), adjust polynomial background thresholds, perform manual energy calibration fits, and visually check for spurious peaks or Compton edges. In low-statistics spectra, high Compton backgrounds and detector drift frequently lead to false positives and incorrect isotope classification. There is an urgent need for an open-source, automated, and mathematically rigorous pipeline that integrates advanced signal processing with modern machine learning to automate these tasks with quantifiable statistical confidence.
Gamma-ray spectroscopy is the quantitative study of the energy spectra of gamma-ray sources [1, 2]. Gamma rays are high-energy electromagnetic radiation (photons) emitted from unstable atomic nuclei during radioactive decay. By measuring the distribution of photon energies and intensities, nuclear physicists can determine the elemental and isotopic composition of the emitting material.
The rate of decay is proportional to the number of radioactive nuclei \(N(t)\) present at time \(t\) [2]:
Integrating this yields the fundamental radioactive decay equation:
Photons interact with the detector crystal via three principal mechanisms [2]:
1. Photoelectric Effect: The photon transfers its entire energy to a bound inner-shell electron of the absorber atom. Probability \(\tau \propto Z^n / E_\gamma^{3.5}\), making Sodium Iodide (NaI) and Lead shielding highly effective.
2. Compton Scattering: A photon scatters off a free electron. The scattered photon energy \(E_\gamma'\) is defined as:
Defining the Compton Edge boundary at \(\theta = 180^\circ\):
The MCA digitizes shaped pulse heights from an amplifier and increments a histogram counter. Spectrum features include photopeaks (full-energy absorption), Compton continuums, backscatter peaks, and escape lines.
NUCLID parses ASCII CSV/TXT, ORTEC SPE files, and TKA files. Double columns containing channels and counts or metadata-tagged headers are processed seamlessly.
The counts recorded in a gamma spectrum are the sum of the full-energy photopeaks and a baseline background [1, 2]. This baseline is caused by the Compton continuum of high-energy gammas, cosmic rays, and natural radioactivity in surrounding walls (e.g., Radon-222, Th-232, K-40) [26]. Removing this background is essential to isolate net peak counts and determine correct peak intensities [1, 28].
The SNIP algorithm operates by performing clipping operations in a log-log space. This compresses peak amplitudes while preserving the baseline contour.
For iteration parameter \(p = 1, 2, \dots, p_{max}\), values are updated as:
The inverse transformation converts back to baseline counts:
ALS applies a second-difference smoothness penalty while weighting values above and below the baseline asymmetrically to prevent peak values from pulling up the baseline.
Where \(w_i\) is adjusted iteratively: \(w_i = p\) if \(y_i > z_i\) else \(1-p\).
Fits a polynomial of degree \(d\) through selected peak-free background anchor points:
Computes background via morphological opening (erosion followed by dilation) using a structuring element \(S\) representing a ball of radius \(R\):
Draws a straight line directly connecting the left boundary \(x_{lo}\) and right boundary \(x_{hi}\) of the ROI window:
Linear blend of SNIP and manual baseline to handle sharp Compton boundary edges:
Detects photopeak candidates using prominence thresholds and Signal-to-Noise Ratio (SNR) significance testing:
Rejects fake peaks or Compton continuums using width, asymmetry, and background-to-height ratio filters.
Accurate quantification requires fitting analytical peak shapes on top of baseline backgrounds.
Standard symmetric profile for photopeak representation:
Net peak area is extracted as: \(N_{net} = A\sigma\sqrt{2\pi}\).
For semiconductor detectors exhibiting asymmetric tailing on the low-energy side:
Convolution of Gaussian resolution broadening and natural Lorentzian lifetime broadening:
Fast linear approximation weight of Lorentzian and Gaussian profiles:
Sum of overlapping peaks within a single fitting window region:
Translates channel index \(x\) into physical energy \(E\) using ordinary least squares regression [1, 2, 33].
The linear calibration equation is defined as [2]:
Where \(m\) represents the calibration slope (gain in keV/channel) and \(c\) represents the zero-energy channel intercept offset in keV.
For quadratic calibration (to adjust for minor detector/ADC non-linearities) [1]:
Matches detected peak energies against reference library values within a set tolerance window. Identification confidence is computed based on emission abundance matching ratios:
The absolute activity \(A\) (in Bq) is calculated as:
Where \(D\) is the decay correction factor: \(D = \exp(-\lambda T_{\text{elapsed}})\).
Relative uncertainty is computed from constituent parameters according to GUM guidelines:
NUCLID separates business logic into a modular python package (`nuclid/`), containing dedicated sub-packages for calibration, library management, and report generation, while pages/ contains routing layouts for Streamlit.
Streams, sessions, and plotting elements (Plotly) are optimized using session caching techniques to ensure fast updates on large spectra arrays.
To reduce dependence on manual threshold settings, NUCLID implements a deep Feed-Forward Multi-Layer Perceptron (MLP) binary classifier [8, 13] that scans the spectrum to distinguish between true photopeaks (\(Y=1\)) and random baseline noise fluctuations (\(Y=0\)).
For each candidate channel \(c\), the classifier extracts a localized window of half-width \(hw=7\) (totaling 15 channels). The 48-dimensional feature vector \(\mathbf{X}\) is constructed by concatenating:
NUCLID uses an ensemble Random Forest model [11, 12] to resolve isotopic identification, capturing correlations among multiple peak energies simultaneously.
A query list of detected peak energies \(\{ E_k \}\) and peak intensities \(\{ A_k \}\) is mapped onto a normalized, 400-dimensional fingerprint vector \(\mathbf{F} \in \mathbb{R}^{400}\) representing 5 keV bins from 0 to 2000 keV. To handle calibration uncertainty, each peak is modeled with a Gaussian smearing kernel:
Where \(\sigma_{\text{cal}} = 2.0 \text{ keV}\) is the calibration noise simulator.
To explain the classification decisions of the models, Shapley values \(\phi_i\) are computed to estimate the marginal contribution of each input feature \(i\) across all possible subsets \(S \subseteq F \setminus \{ i \}\):
Supports exports to Excel spreadsheets, JSON files, and publication-ready PDF summaries complete with embedded spectra and fit statistics tables.
Fits on experimental spectra achieved \(R^2 > 0.998\) and calibration margins within \(0.5 \text{ keV}\) deviation across full dynamic ranges.
Key limits include low counts statistical resolution, overlapping peak multiplets in low-resolution detectors, and ambient temperature-induced gain drift.
Roadmaps feature absolute efficiency calibration modeling, automatic drift stabilization using background K-40 peaks, and cloud hosting APIs.
NUCLID provides a robust, production-ready, and open-source platform for gamma spectroscopy. It integrates advanced signal processing math and clean interactive dashboards to simplify nuclear metrology workflows.