Repository navigation
analysis_tools
Offline tools are deliberately separate from live acquisition. Loading a file or refreshing a frozen spectrum does not start, stop, clear, or reconfigure the hardware measurement that produced it.
Open Tools → MCA Energy Calibration… after the MCA has collected a useful spectrum. Select the channel and use Replace with current spectrum to copy a stopped snapshot into the workspace. The calibration tool does not need to keep the acquisition running.
To build a calibration:
- Double-click each known full-energy peak to create a draggable reference seed. Place it near the intended peak; the seed itself is not used as the calibration coordinate.
- Choose a centroid-fit half-width that contains the peak and enough local background without admitting unrelated structure. The default is 300 raw channels.
- Enter a short label and the accepted reference energy in keV. Clear Use to exclude a questionable line without deleting it.
- Inspect the fitted Centroid ch., Gaussian-plus-linear-background curve, observed-minus-fit count residuals, and convergence state. A failed local fit blocks application instead of silently using the seed.
- Select a Linear or Quadratic model. Two enabled references are the minimum for a linear fit and three are the minimum for a quadratic fit.
- Inspect every value in the energy Residual column as well as the RMS and maximum residual below the table. Apply the result only after the point assignments and fit quality have been checked.
The residual for a line is
reference energy - fitted energy at its channel. A positive value
means that the fitted curve predicts too little energy at that point; a
negative value means it predicts too much. A large or structured
residual can indicate a misplaced centroid, a wrongly identified line,
pile-up, gain drift, or a calibration model that is too simple.
A two-point linear calibration is exactly determined, so both residuals are zero apart from floating-point rounding. That does not independently prove linearity. Add a third or later verified line to test the linear model. The same caution applies to a quadratic fit made from exactly three points.
The view below uses a stopped CH0 spectrum acquired by IIO histogram
polling on 192.168.10.135:30431. A CAEN generator supplied artificial
signals that represent the Na-22 511 and 1274.537 keV lines; this was a
functional software test, not a radioactive-source or dose measurement.
The run used negative polarity, raw trigger -512, a 64 ns baseline, a
1024 ns window, and MCA binning 128. It accumulated 78,534 counts
across the full two-line spectrum without using or changing the PSU; the
stopped MCA view reported zero energy overranges.
Independent Gaussian-plus-linear-background fits placed the two
generated peak centroids at raw channels 609.114 and 5628.753.
Assigning those positions to 511.000 keV and 1274.537 keV gives the
illustrative linear mapping
energy [keV] = 418.34772 + 0.15210994 × MCA channel

The displayed residuals are approximately zero because exactly two
references define this linear fit; the tiny values around 10^-13 keV
are numerical rounding, not a measurement of detector linearity.
A spectrum copied while the MCA is running is labelled a live, non-atomic snapshot. Applying calibration changes no FPGA register, bin, ROI, or raw record. Raw channel remains the bottom axis and calibrated keV is added on the top axis. Relevant DSP changes mark the calibration stale; power-of-two MCA binning changes rescale coordinates without invalidating an otherwise matching calibration.
Saved settings and later capture metadata retain reference points, coefficients, residuals, and the energy-processing fingerprint.
Applying the calibration snaps each seed to its fitted centroid and shows the local fit and count-residual overlays. Editing a point, spectrum, fit width, or model hides those applied-fit overlays until the revised calibration is applied. While any channel has a valid applied mapping, the persistent ENERGY CALIBRATED status-bar badge lists the channels in its tooltip; double-click it to reopen the calibration workspace.
After a valid fit, Download report… creates a new report directory rather than overwriting an existing one. The two-page PDF and accompanying CSV/JSON data preserve every copied spectrum, seed, fitted centroid and local curve, count residual, calibration point, energy residual, setting, provenance field, and the typeset centroid and energy-calibration equations.
Open Tools → MCA Peak Analysis Workbench…. It works on frozen copies of live MCA spectra and also imports:
- ordinary or NLab CSV;
- Maestro/ORTEC-style
.Spe; - Tukan
.wdm; - CAEN calibrated
.txt3; - CAEN ROOT
Energyhistograms; - validated ANSI/IEEE N42.42
.n42or.xml, including every spectrum in a multi-measurement document.
N42 import is offline and deterministic: the application uses bundled
NIST base and add-in schemas, disables external entities and external
schema resolution, ignores document schema-location hints, expands
CountedZeroes, and preserves instrument, detector, timing,
measurement-class, and energy- calibration metadata. Documents without a
spectrum can be valid N42 but do not create a workbench entry.
One to three Gaussian components can be combined with none, constant, linear, centred exponential, error-function Compton-step, or logistic Fermi-step backgrounds. Draggable markers seed and bound peak centres. Raw non-negative counts use a Poisson-deviance fit; derived spectra use propagated variance.
Results include centroid, FWHM, area, resolution, uncertainty, reduced fit statistic, AIC/BIC, component curves, residuals, and boundary/covariance warnings. Spectrum arithmetic creates new immutable entries, requires matching coordinate grids, propagates variance, and never interpolates silently.
The Reference lines tab uses the bundled, version-pinned NNDC ENSDF catalogue without a network request. Select one or more parent nuclides and an emission-probability threshold, or restrict candidates to lines inside the explicit fit ROI. Candidate ranking and user-editable favourites are aids to review, not isotope identification. Calibrated overlays are suppressed when the selected spectrum has no valid energy mapping or its calibration is stale.
After a completed fit, Download report… writes a non-overwriting bundle containing a branded two-page PDF, fit curve and components, residuals, peak and parameter tables, fit statistics, provenance, the exact reference overlay, and machine-readable CSV/JSON metadata.
The selected spectrum can also be exported as N42.42, and a completed
fit can be exported as a spectrum plus SpectrumPeakAnalysisResults.
Export requires a current energy calibration and positive real/live
measurement times. It will not invent an identity calibration or export
stale calibration data. Known digitizer endpoint/channel identity is
retained; detector category, material, and geometry remain
Other/unspecified unless the source document explicitly provided them.
The completed fit below uses the same stopped CH0 generator spectrum and the linear calibration above:
- Open Tools → MCA Peak Analysis Workbench… and copy the stopped MCA spectrum, or load an exported spectrum file.
- Drag the shaded fit region around the 511 keV photopeak. This
example uses raw channels
478.973–738.973; avoid including unrelated peaks. - Select one Gaussian peak, a Linear background, and Poisson deviance for non-negative counting data.
- Use Suggest peak positions, adjust the marker if necessary, then choose Fit selected spectrum.
- Inspect the fitted curve, background component, residual trace, parameter uncertainties, reduced chi-square, and warnings together. A plausible centroid alone is not proof of a good model.

For this capture the fit returned raw centroid 608.961 ± 0.208
channels, calibrated centroid 510.977 keV, FWHM 42.406 channels
(6.450 keV), and resolution 1.262%. The Poisson reduced chi-square
was 1.078, and the tool reported no boundary or covariance warning.
These values describe this artificial generator signal, acquisition, selected interval, model, and exactly determined two-point mapping. They are not a detector-resolution measurement or an independent validation of Na-22 source response. Recheck the background model, fit interval, residuals, gain stability, and calibration references before using a fitted result quantitatively.
Open Tools -> Dose Calibration Logger… to record detector response beside a known source/setup and expected dose rate. Select one detector channel, enter the reference fields, choose a new CSV path, and enable only the measurement groups needed for the study. Reference edits become active only when editing finishes, preventing a timer tick from recording a partially typed value.
Every row contains UTC and elapsed timestamps, the actual sample interval, channel and source labels, and the committed dose value/unit. Optional groups add:
- MCA count rate, pulse dead time, and acquisition elapsed time;
- non-negative total and visible-ROI counts added between accumulated MCA snapshots;
- HV/SiPM setpoints and available readbacks;
- detector, ADC, HAT, FPGA, and raw ADS5407 temperatures;
- cumulative PSD integrals above and below the current cut over both the full energy range and the selected PSD ROI.
The logger consumes already-polled snapshots and never starts acquisition or adds hardware reads. The first MCA snapshot establishes the differential baseline; unavailable data remain explicit blanks. Rows are flushed immediately, existing files are never overwritten, and closing or rebuilding the workspace closes the file cleanly. The adjacent plot can show any enabled numeric column against elapsed time, but the CSV is the durable record.
Record source identity, geometry, shielding, stabilization time, detector configuration, and the independent dose-reference instrument with the CSV. The tool aligns those observations; it does not calculate or certify a final dose conversion.
The following capture uses live CH0 MCA snapshots from the same CAEN
generator. The expected dose is deliberately 0 µSv/h, the setup label
states that this is a functional test with no PSU, and only MCA
count-rate/dead-time and differential-integral columns are enabled.
Eight rows were recorded at 750 ms intervals; the adjacent plot shows
the live raw count rate. This demonstrates CSV and plot behaviour only
and must not be used as a dose calibration.

Open Tools → PSD Event Readback… to reconstruct energy/PSD matrices and projections from:
- NLab NDMA v1/v2;
- CAEN CoMPASS or compatible legacy CAEN binaries;
- NLab HDF5;
- ROOT event trees.
The reader memory-maps binary files, slices HDF5, and iterates ROOT in chunks. Memory therefore stays bounded by batch size rather than total file length. CAEN PSD import requires raw Energy and Energy Short fields. Headerless single-channel extracts are accepted only after conservative structural checks.
The current source path remains visible and its filename appears in the
window title. Set the energy ROI, fit ROI, and two centroid seeds, then
choose Fit double Gaussian for a bounded constant-background fit
using Poisson-deviance residuals. Review both centroids and FWHMs, the
conventional |mu2 - mu1| / (FWHM1 + FWHM2) figure of merit, reduced
deviance, parameter bounds, covariance, and convergence warning
together. Copy table exports the populations and shared diagnostics
as tab-separated text.
After a qualified fit, Download report… creates a file-named directory with a three-page PDF plus the full matrix, projections, cut-separated spectra, fit components, settings, source/digitizer provenance, and JSON metadata. The energy spectra follow the panel’s linear/logarithmic selection. Sparse zero- and one-count matrix bins are transparent for readability; exported counts are unchanged.
Open Tools → Waveform Analysis Workbench… for native NLab Scope NDMA or waveform-bearing CAEN CoMPASS data. NLab fixed frames are memory-mapped directly. Variable-length CAEN files receive a background offset index, and only selected frames are copied for display.
An independently installed nlab-waveform-workbench-base[all] package
provides the same workspace as a standalone application
(nlab-waveform) or an optional Digitizer GUI provider. When installed
in this environment, the GUI uses its public API; otherwise the bundled
workbench remains available. The Digitizer adapter supplies MCA gate
transfer and enables no analysis extensions. Standalone analysis
requires no native libiio runtime or connected hardware. Separate
applications can explicitly load additional analysis packages and use
snapshots of selected raw pulses with their source/frame/timing
provenance.
The workbench provides:
- median or mean baseline removal;
- automatic or explicit pulse polarity;
- draggable integration start, short-end, and long-end gates;
-
Qshort,Qlong, and(Qlong - Qshort) / Qlong; - energy-versus-ratio matrices and linked projections;
- event stride and maximum-event limits;
- debounced previews while gates are dragged;
- comparison with stored CAEN gate sums when available.
The energy projection ROI is preserved when gate changes rebuild the PSD matrix. After a successful double-Gaussian fit, Optimize gates performs a bounded, cancellable local search over the short- and long-gate endpoints while holding the baseline, integration start, energy/fit ROIs, and centroid seeds fixed. Candidates with poor convergence are excluded; the selected gates are then applied to a complete rebuild and fit. Treat the result as a local optimum for the selected data and constraints, not as a detector-independent setting.
Waveform report bundles include the same FOM diagnostics as PSD Event Readback and additionally preserve the exact integration gates and processing context. The current source path and filename remain visible throughout analysis and report generation.
NLab Scope NDMA uses its known 8 ns stored-point period. CoMPASS waveform files do not encode the ADC sample period; verify the operator-entered value for the originating digitizer.
Run examples/mca_gain_drift_diagnostic.py for a repeatable
dual-channel trace of a known photopeak during startup or thermal/bias
settling. It restores the host’s saved MCA and
ADC-temperature-correction configuration, starts fresh MCA
accumulations, and tracks both the differential-spectrum maximum and a
local centroid inside per-channel raw ROIs.
The diagnostic records MCA statistics, correction state, detector/board
temperatures, rails, clocks, standard board hwmon telemetry, power
values, and available HV feedback. It does not write Scope registers.
PSU bias is monitor-only unless --apply-saved-psu is supplied; that
option applies saved per-channel bias and guarantees safe shutdown
cleanup, including on errors. The original MCA state is restored after
capture.
Outputs include time-series CSV, each differential ROI spectrum as compressed NPZ, summary/configuration JSON/YAML, and early/late plus time-series PNG plots. Keep an external supply’s own log when it provides the detector bias. See the command example and option details in the project README.
Use Developer → Validate Two-Channel Timing… with two native NLab MCA files produced from one known pulse split between channels (lower channel in A). The validator scans complete files for backwards timestamps, verifies time overlap, and plots bounded nearest-neighbour delay samples.
A fixed channel-B offset in 8 ns steps can be saved in application settings and YAML. Matching identity metadata or a narrow histogram does not prove shared clock timing; verify against the known split-pulse setup. These nearest-neighbour pairs are diagnostics, not coincidence counts.
The live Coincidence workspace produces prompt, delayed-random, and corrected energy matrices, plus projections and timing diagnostics. Exported HDF5/ROOT matrices preserve raw axes, gates, calibration metadata, and session state. See Coincidence Measurement.
Use these recipes when automation is required. Prefer project readers over hand-written binary offsets because they enforce current NDMA versions, alignment, and bounded-memory behavior.
- Home
- Getting started
- Acquisition
- Showcases
- Files and analysis
- Support
- Internals
- Repository