When a crystal is doped, heated, or strained, its atomic planes move apart or together, and its X-ray diffraction peaks shift. Materials scientists read those shifts to measure how much a dopant went in. A slightly miscalibrated diffractometer shifts peaks too: a sample sitting a fraction of a millimeter too high, or a detector zero that is a few hundredths of a degree off. Over the angular range of a typical scan, these two sources of shift look nearly the same. This mirrors a familiar problem in computer vision. From one photograph you cannot tell a small nearby object from a large distant one, a failure called monocular scale ambiguity. Vision researchers stopped trying to regress absolute depth directly. Instead they predict depth only up to an unknown scale, then fix the scale with a few trusted measurements, such as a handful of LiDAR points. We propose to handle powder diffraction the same way. A model should name the crystal phase in a way that ignores lattice scale and instrument error. It should then estimate the lattice scale with an explicit physical fit that reports honestly how much that scale is confounded with instrument error. That confound collapses only when a few anchor peaks of known position are present.
The payoff is practical. Current neural pipelines regress lattice parameters or classify phases straight from raw scans. When they meet a doped variant or an uncalibrated instrument, they either misidentify the phase or quietly absorb instrument error into a wrong lattice constant, with no warning. Our claim is that lattice scale cannot be identified from a single uncalibrated pattern beyond a floor we can compute. A method that respects this floor, and uses sparse anchors when available, should beat end-to-end regression on real experimental data. It should also say when it cannot know.
Core Claim
For a phase with interplanar spacings $d_{hkl}$ measured at Bragg angles $\theta_{hkl}$, three small perturbations shift each peak. The first is a uniform lattice strain $\varepsilon$, meaning $d \to (1+\varepsilon)d$. The second is a detector zero offset $z$. The third is a specimen height displacement $s$ on a goniometer of radius $R$. To first order, the combined shift is
$$\Delta 2\theta_{hkl} \approx z \;-\; \frac{2s}{R}\cos\theta_{hkl} \;-\; 2\varepsilon\tan\theta_{hkl}.$$
The first term is constant. The second is the standard displacement error quoted in the research file. The third follows from differentiating Bragg's law, $n\lambda = 2d\sin\theta$. Over a limited scan range the three functions $1$, $\cos\theta$, and $\tan\theta$ are close to linearly dependent. The uncertainty in $\varepsilon$ from a single pattern is therefore set by how ill-conditioned this three-column design matrix is on the observed peaks, not by how powerful the network is. This is the diffraction version of scale ambiguity. The zero offset and displacement play the role of the camera's principal point and focal-length confound, and $\varepsilon$ plays the role of metric depth.
The proposal has three parts. The first is a phase-identification stage that is invariant to $(z, s, \varepsilon)$. The second is a differentiable least-squares fit of those three parameters against the identified reference, which returns a posterior rather than a point estimate. The third is an anchor mechanism: a few peaks of an internal standard, or of a known co-present phase, enter the fit as fixed-$\varepsilon$ constraints and break the degeneracy. Anisotropic strain in low-symmetry cells goes to a small learned residual stage.
Relation to Prior Work
The mechanism comes from geometric vision.
- Stage design. Monocular Visual-Inertial Depth Estimation takes relative depth from an off-the-shelf network, fits a global scale and shift to sparse visual-inertial points, and then learns per-pixel scale corrections. It reports up to 30% lower inverse RMSE than global alignment alone. We reuse this three-stage structure directly. Our "global fit" is the physical shift model above rather than a scale and shift, and our "sparse points" are standard reference peaks.
- How few anchors suffice. LiDARTouch shows that four LiDAR beams, fewer than 100 points per frame, bring KITTI RMSE to 2.504 m against 2.112 m for 64-beam supervision. This motivates our hypothesis that very few anchor peaks should suffice.
- Removing the known part of the confound. Metric3D v2 removes focal-length confounding by rescaling every image into one canonical camera. Its diffraction analogue is converting $2\theta$ to scattering vector or $d$-spacing using the known wavelength. That is routine crystallographic preprocessing, not a contribution, so we adopt it and do not claim it.
- What canonicalization cannot fix. Canonicalization handles only the known part of the confound. Displacement and zero offset are unknown per sample, exactly like the missing-metadata cases where Metric3D v2 is reported to degrade.
- Known objects as scale rigs. Xiaohan Fei et al. use human body size as an in-scene scale reference. This motivates our second anchor type: known matrix phases such as current-collector metals in battery-recycling scans (Yunhao Xiao et al.).
- The same warning applies here. Fei et al. also constrain the design. Size priors fail when the reference object is atypical. Correspondingly, an anchor phase that is itself strained will mislead the fit, so we must detect inconsistent anchors rather than trust them blindly.
On the diffraction side, the closest work regresses crystal structure end to end.
- PXRDGen. PXRDGen pairs a contrastive pattern encoder and flow-matching generator with a lattice-parameter network (CellNet) and a final GSAS-II Rietveld step. It reports an 82% single-sample and 96% twenty-sample match rate on simulated MP-20 patterns.
- XtalNet. XtalNet conditions an equivariant diffusion model on simulated patterns and reports a 90.2% top-10 match on hMOF-100.
- What both leave out. Both assume an ideal simulated instrument. Neither separates lattice strain from instrument error, and neither reports uncertainty on lattice scale. We differ by making that separation explicit and by treating the identifiability floor as a measured quantity, not a nuisance hidden inside the network.
- Evidence the real-data gap matters. Neural network based classification of crystal symmetries finds only 54% space-group accuracy (dense network) and 42% (CNN) on experimental RRUFF data. Vision Transformers for X-ray Diffraction Patterns Analysis finds that CNN and transformer rankings flip between synthetic and real lab mixtures. Both show the real-data gap is large and that synthetic scores mislead model choice.
- A possible explanation. We read the unresolved CNN-versus-dense-versus-transformer disagreement in these papers partly as a symptom. Architectures differ in how much peak-position shift they tolerate, and no paper has controlled the shift sources separately. Our controlled experiments test that reading.
- Datasets that make evaluation possible. opXRD supplies 92,552 experimental patterns from six institutions, of which 912 carry full structure labels. This makes real multi-instrument evaluation possible.
Research Program
Stage one: invariant phase identification. Input patterns are converted to $d$-spacing with the stated wavelength. The model is a retrieval encoder trained on simulated MP-20 structures. We compare two ways of making it ignore nuisances. The first is augmentation with sampled $(z, s, \varepsilon)$. The second is an alignment-invariant loss borrowed from relative-depth training. In that loss, the predicted clean pattern is scored against the target only after the target has been optimally shifted by the three-parameter model, so the network is never penalized for nuisances it cannot see. The output is a short ranked list of reference structures. It includes an explicit "no confident match" option, following the selective-prediction result of Vecsei et al., whose dense network reached 82% accuracy while declining about half of the patterns.
Stage two: nuisance fit with posterior. For each candidate, we fit $(z, s, \varepsilon)$ to peak positions extracted from the pattern. We use weighted least squares with a Laplace approximation to report a covariance, and priors on $z$ and $s$ come from instrument-tolerance ranges. The reported quantity is a credible interval on $\varepsilon$. We also compute the interval width predicted from the design-matrix conditioning alone, so we can check that the empirical error tracks the theoretical floor.
Anchors. When an internal standard such as silicon, or a recognized fixed phase, is present, its peaks enter the same fit with $\varepsilon$ pinned to zero for that phase. This separates $z$ and $s$ from the target's strain. A consistency test flags an anchor whose own residuals exceed tolerance.
Stage three: learned residual. A small network corrects anisotropic lattice changes, meaning different strains along different axes. It sees the stage-two residuals and the candidate's cell, analogous to the local correction network in Wofk et al. This stage is where learning should add value beyond the analytic fit, and it is ablated separately.
Baselines
Naive raw-scan classifier. The do-nothing reference is a network trained on raw $2\theta$ scans with no nuisance handling. For space-group identification on RRUFF, the dense network of Vecsei et al. is the natural choice. Its reported 54% top-1 accuracy on experimental RRUFF patterns is the number to beat on that benchmark. We retrain it on our identical simulated training set so that the difference reflects nuisance handling rather than training data.
Strongest learned competitor. For lattice recovery, this is PXRDGen's CellNet followed by its Rietveld step. It is the only cited system that regresses lattice parameters from powder patterns and then refines them. There is no reported result on Lacuna for CellNet lattice-parameter error. The file gives only PXRDGen's MP-20 structure match rates (82% single sample, 96% with 20 samples). We therefore reimplement it on the same MP-20 split, with the same nuisance-perturbed test patterns, the same encoder size, and the same hyperparameter-search budget. Beating it means lower absolute error on $\varepsilon$ and interval coverage near nominal on perturbed and real patterns, without losing match rate on clean simulated patterns.
Strongest learned competitor for phase identification. For mixtures, the transformer of Vision Transformers for X-ray Diffraction Patterns Analysis reports a real-laboratory MMAE (mean maximum absolute error in phase fraction) of 5.81%. We rerun it under our protocol on the same benchmark.
Oracle classical refinement. This baseline is conventional least-squares refinement of lattice, zero, and displacement given the true phase. It is a ceiling for stages two and three rather than a competitor, and it tells us how much of any gain comes from correct identification versus better fitting.
Ablations. The ablations isolate the key ingredients:
- augmentation versus the alignment-invariant loss in stage one;
- the full pipeline with anchors removed;
- stage two without stage three;
- an end-to-end network given the same anchor peaks as extra input channels, which tests whether explicit physical fitting matters at all.
Why not just…?
Why not just train a standard classifier with heavy augmentation of lattice strain, zero offset, and displacement? This is the most serious threat, and for phase identification alone it may match stage one. Vecsei et al.'s augmented CNN at 42% on RRUFF does not settle the question, because their augmentation did not target these specific shifts. Our ablation compares augmentation against the alignment-invariant loss head to head, and we will report plainly if augmentation ties. Augmentation cannot, however, provide what stages two and three are for. An augmented network learns to ignore strain, so it cannot report strain. A network trained to regress strain from augmented data must commit to one value on a degenerate pattern, and its errors should cluster at the conditioning floor with no signal that anything is wrong. The calibration experiment below tests exactly this.
Why not just run search-match and Rietveld refinement with zero and displacement refined? Stage two is essentially this refinement, and we do not claim to beat it given a correct starting phase; that is the oracle baseline. The claims are narrower. The first is that an invariant identifier supplies correct starting phases more reliably on doped or strained samples than tolerance-window search-match. The second is that refinement packages report parameter correlations, but automated pipelines discard them. PXRDGen notes that refinement is sensitive to the starting model. If search-match with generous tolerances identifies phases as well as stage one on our strained test sets, the identification claim fails and the contribution reduces to the uncertainty analysis.
Why not just convert to scattering vector using the wavelength? We do, as preprocessing. It removes wavelength dependence only. It does nothing about per-sample displacement or zero offset, which are unknown, and the remaining confound between strain and those instrument terms is untouched.
Proposed Experiments
Controlled simulation. From MP-20 we simulate patterns under sampled $(z, s, \varepsilon)$ at several scan ranges. We hold out structures whose strain lies beyond the training range, mimicking heavily doped solid solutions. Metrics are:
- top-1 phase retrieval;
- absolute strain error;
- 90% interval coverage;
- the ratio of empirical strain error to the conditioning-predicted floor.
Anchor sweep. We add zero to five silicon reference peaks and measure how the strain error falls. This is the diffraction counterpart to LiDARTouch's beam-count study.
Real data. We evaluate on the 912 fully labeled opXRD patterns. Lattice parameters are compared against the labeled structures, and results are broken down by contributing institution so instrument differences are visible. We also evaluate space-group accuracy on RRUFF, and on the real laboratory mixture set, reporting MMAE and the relative residual score used by the transformer paper.
Decisive checks. Two results would decide the question.
- Is the floor real? Without anchors, every method's strain error on narrow-range scans should sit at or above the computed floor. If end-to-end regression beats the floor, our identifiability analysis is wrong, perhaps because peak intensities or profile shapes carry scale information the first-order shift model ignores.
- Does the physical fit earn its place? With anchors, our pipeline should cut strain error well below the floor, and should do so more than the end-to-end network given the same anchor peaks. If the anchor-fed end-to-end network matches us, the explicit physical fit is unnecessary and the lesson from vision transfers only as "give the network anchors."
References
- Monocular Visual-Inertial Depth Estimation
- LiDARTouch: Monocular metric depth estimation with a few-beam LiDAR
- Metric3D v2: A Versatile Monocular Geometric Foundation Model for Zero-shot Metric Depth and Surface Normal Estimation
- Single View Physical Distance Estimation using Human Pose
- Doping LiFePO4 with Al3+: Suppression of Anti-Site Defects and Implications for Battery Recycling
- Powder Diffraction Crystal Structure Determination Using Generative Models
- End‐to‐End Crystal Structure Prediction from Powder X‐Ray Diffraction
- Neural network based classification of crystal symmetries from x-ray diffraction patterns
- Vision Transformers for X-ray Diffraction Patterns Analysis
- opXRD: Open Experimental Powder X‐Ray Diffraction Database