From e2084895dbb3fee69d3b25967fa8f1f3a7940726 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Mon, 5 Oct 2026 16:34:31 +0200 Subject: [PATCH] Docs: data-analysis reference brought up to the rc.174 behaviour Space group (13.1): every setting of a chosen rotation set is offered; screws are claimed at 8 nats, with how that bound was set; the P1 search merge is cut where a monotone fit of drops under 1; the operator-homogeneity gate reads the R gap between a subgroup and the rest; a lattice-holohedral group is refused when merging under it narrows the L-test like a twin. Outliers (13.3): the rotation median is weighted at the expected intensity, and the band's systematic part is multiplicative, with its spread measured on the merge's own fulls. Indexing: a sparse lattice is integrated on every frame; pass 1's lattice is a hypothesis against a different re-index, and a pass sent back reuses pass 1's indexing. Image: the flipped axis sign must beat chance; the same-lattice beam-centre retry on an inconsistent merge. Integration: five correction surfaces, not four; the .hkl carries no amplitudes; the fulls' scale is smoothed differently from the partials'. Tutorial: the correction surfaces are cross-validated on the half-set correlation (as the reference says), not on an R_meas-like deviation. Overview: the footprint, the 5 A indexing hypothesis, the centre of symmetry, and the GPU pre-scan. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01K5K8jvPPbmCrbqnWkddTuB --- docs/CPU_DATA_ANALYSIS_DECISIONS.md | 12 +++++++++--- docs/CPU_DATA_ANALYSIS_IMAGE.md | 14 +++++++++++++- docs/CPU_DATA_ANALYSIS_INDEXING.md | 6 +++--- docs/CPU_DATA_ANALYSIS_INTEGRATION.md | 6 +++--- docs/RUGNUX_OVERVIEW.md | 12 ++++++++---- docs/RUGNUX_TUTORIAL.md | 18 ++++++++++-------- 6 files changed, 46 insertions(+), 22 deletions(-) diff --git a/docs/CPU_DATA_ANALYSIS_DECISIONS.md b/docs/CPU_DATA_ANALYSIS_DECISIONS.md index 01a6575de..e803211b1 100644 --- a/docs/CPU_DATA_ANALYSIS_DECISIONS.md +++ b/docs/CPU_DATA_ANALYSIS_DECISIONS.md @@ -28,7 +28,7 @@ $$\frac{I}{\sigma} \;\ge\; \frac{T}{\sqrt{1 + (T/\mathrm{ISa})^2}}$$ The converted cut lies strictly below $\mathrm{ISa}$ for every $\mathrm{ISa}$, so it is always reachable by the reflection the ceiling binds hardest, and it is within 1 % of $T$ on any merge with $\mathrm{ISa} \ge 21$ — a healthy merge is left exactly where it was. Multiplicity is taken as 1 deliberately rather than estimated, for the same reason. Where the merge reports no ISa (or $b = 0$) the cut is used as it stands. -The candidates are enumerated in **every setting the refined cell can host**, not only in the settings the International Tables call the reference one. A setting is a statement about direction — $P112_1$ puts its $2_1$ on $c$ where $P12_11$ puts it on $b$, and both are space group 4 — so a search restricted to reference settings can only ever put a screw or a centring on the axis the convention chose, whatever the data say. Two things bound the widened set. A candidate is offered only if the cell's own metric admits the rotations its setting names ($\alpha=\beta=90^\circ$ for a $2$-fold on $c$), and a candidate predicting exactly the absences another candidate already predicts is dropped as the same hypothesis under a second name. A non-reference setting is additionally refused when its centring class holds no reflection in this merge, since there is then nothing to confirm it with. Because the candidates of a point group all share its rotations, this cannot raise the symmetry: it decides *which axes* carry the screws and the centring, never how many operators there are. The setting found this way is the one the *decisions* are made in. The files are then written in the ITA standard setting (as XDS and POINTLESS write it: $P2_12_12$ with the pure axis on $c$ and $a_*` output. Pass 1's merge exists to give the guard something to judge pass 2 against, so it stops short of the parts of the merge that only fill in a file — the correction surfaces, the twinning and radiation-damage analyses, the R-free flags and the amplitudes — and writes no merged files of its own. diff --git a/docs/CPU_DATA_ANALYSIS_INTEGRATION.md b/docs/CPU_DATA_ANALYSIS_INTEGRATION.md index 5579ebc84..9eb3abfdc 100644 --- a/docs/CPU_DATA_ANALYSIS_INTEGRATION.md +++ b/docs/CPU_DATA_ANALYSIS_INTEGRATION.md @@ -322,7 +322,7 @@ Reflections below a minimum partiality can be rejected from merging to avoid uns ### 10.3 Smoothing of per-frame scales -The per-frame scales $G_i$ are fit by robust (Cauchy) inverse-variance-weighted ratios; there is no explicit $G\approx1$ prior. For rotation datasets, optional smoothing enforces the expectation that scale and mosaicity vary slowly across a sweep: **after** the per-frame fit, $\log G_i$ (and the mosaicity) are replaced by a centred **moving average** over a window spanning a configurable rotation range (XDS DELPHI-like; `--smooth-g`, default 5° for rot3d, off otherwise). It is a post-fit smoothing pass, not a curvature penalty inside the least-squares objective. +The per-frame scales $G_i$ are fit by robust (Cauchy) inverse-variance-weighted ratios; there is no explicit $G\approx1$ prior. For rotation datasets, optional smoothing enforces the expectation that scale and mosaicity vary slowly across a sweep: **after** the per-frame fit, $\log G_i$ (and the mosaicity) are replaced by a centred **moving average** over a window spanning a configurable rotation range (XDS DELPHI-like; `--smooth-g`, default 5° for rot3d, off otherwise). It is a post-fit smoothing pass, not a curvature penalty inside the least-squares objective. (The per-frame scale refitted on the combined fulls, §10.6, is smoothed differently: by a penalised smoother whose smoothness is chosen by cross-validation.) The **crystal orientation** is smoothed the same way, and for the same reason. Geometry is re-refined independently on every frame against that frame's spots alone — as few as a dozen on a sparse crystal — so the per-frame orientation carries a real slow drift (crystal slippage, up to ~1.3° across a sweep) on top of fit noise that scales with spots per frame. Before scaling, the per-frame lattices are de-rotated to a common reference, averaged in frame order, rotated back, and every partial's $\Delta\phi$ — hence its partiality — is recomputed from the smoothed lattice. The window is chosen per dataset by leave-one-out cross-validation (does a frame's neighbours predict its orientation?) rather than fixed, because drift and noise both vary by two orders of magnitude between crystals; it is capped, because the per-frame fit also absorbs a real per-frame systematic that smoothing too wide destroys. Only frames that actually indexed take part: a frame that did not carries an all-zero lattice, which is *finite* and so passes a validity check written as a finite test, and would otherwise be both averaged into its neighbours' orientation and scored in the cross-validation that picks the window. Refining *less* is not an alternative: with per-image refinement off the space group is lost on several crystals. @@ -388,7 +388,7 @@ Before the combine a per-frame scale can also be fitted on the partials themselv How smooth that scale is over the rotation is left to the data rather than to a fixed window. Each round fits every frame on its own fulls against the current reference, giving a scale $G_f$ and its information $D_f=\sum w^2c^2$; the scale is then the curve $x=\log G$ minimising $\sum_f J_f\,(x_f-y_f)^2+\lambda\sum_f(\Delta^2 x)_f^2$, with $y_f$ the frame's own fit in log scale and $J_f$ its information carried there — a penalised (Whittaker–Eilers) smoother, solved as a five-band linear system. $\lambda$ is chosen by cross-validation: blocks of frames one rocking curve wide are left out in turn and predicted from the curve through the rest (neighbours closer than a rocking curve share their measurement, since a full sums those frames). A frame of hundreds of fulls is then followed frame by frame, a frame of two or three is carried by its neighbours, a stretch with none is bridged by a straight line, and a scale that falls a hundredfold over a few degrees — an absorbing crystal turning edge-on — is followed where a window would average across it. Once the curve settles, one free fit is shrunk toward it frame by frame by how much of each frame's deviation its neighbour shares (the lag-1 covariance), which hands back a real per-frame systematic and discards fit noise. -After scale-fulls, four **correction surfaces** are fitted on the combined fulls (rotation path, **on by default**; disable all with `--no-scaling-corrections`), each an alternating multiplicative refinement of the per-full scale against the merged reference: +After scale-fulls, five **correction surfaces** are fitted on the combined fulls (rotation path, **on by default**; disable all with `--no-scaling-corrections`), each an alternating multiplicative refinement of the per-full scale against the merged reference: - **Decay.** Radiation damage weakens later frames more at higher resolution — a resolution×time (Debye–Waller) systematic the resolution-flat per-image scale cannot capture. A single global relative-$B$ rate is fitted, $\ln(I_\mathrm{ref}/I_\mathrm{obs}) = 2\,(\mathrm{d}B/\mathrm{d}n)\,(n-\bar n)\,s^2$ (frame $n$, $s^2 = 1/4d^2$), and folded into the scale. It engages only when the total relative-$B$ over the run exceeds a physical floor (2 Ų); below that the decay is negligible and "correcting" it only spreads symmetry equivalents (same $s^2$, different frames). An optional **per-batch relative-$B$** (`--relative-b[=deg]`, off unless requested; 10°-of-rotation batches by default) extends the single global rate to a smooth $B(n)$ curve — the same $s^2$-weighted decay fit solved independently over short frame batches, curvature-penalized so it cannot over-fit and cross-validated like the surfaces below — for crystals whose decay is non-linear in dose. Its cross-validation splits on **ASU-group parity**, not the frame parity the surfaces below use: a per-batch parameter owns whole frames and so cannot be scored on a held-out frame, whereas splitting the symmetry equivalents tests whether a batch's $B$ generalises to reflections it was not fitted on. - **Absorption.** A smooth multiplicative factor over the diffracted-beam direction expressed in the goniometer (crystal) frame: each full's predicted detector position gives the lab diffracted direction, de-rotated by the spindle so a fixed crystal-frame direction is sampled at many rotation angles and its grid cell is well-determined. Negligible at hard X-rays / thin crystals; it matters at low photon energy. @@ -439,7 +439,7 @@ $ The prior mean is $\Sigma = \varepsilon\,K_\mathrm{shell}\,a(\mathbf{h})$, where $\varepsilon$ is the reflection's epsilon (symmetry-enhancement) multiplicity, $a(\mathbf{h}) = \exp(-\tfrac12\mathbf{s}^\mathsf{T}B\,\mathbf{s})$ carries the deviatoric anisotropy tensor $B$ of §13.5 along the reflection's own direction, and $K_\mathrm{shell} = \sum I/\varepsilon \,/ \sum a$ over its resolution shell, so the priors of a shell still average to its measured Wilson mean. The amplitudes are first made with $a = 1$ at the end of the merge and made again once the tensor has been fitted; only $F$/$\sigma_F$ change, never an intensity. With an isotropic prior the weak direction of an anisotropic crystal gets a prior set mostly by the strong direction, which turns its noise into amplitude; for isotropic data the tensor is near zero and the prior reduces to the shell mean, so it is used whenever a tensor was fitted. A shell whose $K$ is not positive takes that of the nearest lower-resolution shell. As in `ctruncate`, an intensity more than 3.7σ below zero gets no amplitude (the intensity is kept) and does not enter the shell mean. Strong reflections ($I>20\sigma$) short-circuit to $|F|=\sqrt{I}$, where the French–Wilson bias is below 0.3%; a reflection with an unusable $I/\sigma$ falls back to $\sqrt{\max(I,0)}$. The integral is evaluated numerically with a log-shift for stability. -Amplitudes are written as MTZ `F`/`SIGF`, mmCIF `_refln.F_meas_au`/`F_meas_sigma_au`, and appended to the text HKL, alongside the intensity columns. The **same** $|F|$ feed the model-validation step (§14), so the reflection file and the maps use one consistent set of amplitudes. +Amplitudes are written as MTZ `F`/`SIGF` (and `F(+)`/`F(-)`) and mmCIF `_refln.F_meas_au`/`F_meas_sigma_au`, alongside the intensity columns; the SHELX `.hkl` holds intensities only. The **same** $|F|$ feed the model-validation step (§14), so the reflection file and the maps use one consistent set of amplitudes. ### 10.9 Reference data: fixing the space group and resolving the indexing ambiguity diff --git a/docs/RUGNUX_OVERVIEW.md b/docs/RUGNUX_OVERVIEW.md index 64e9b6b10..416b52337 100644 --- a/docs/RUGNUX_OVERVIEW.md +++ b/docs/RUGNUX_OVERVIEW.md @@ -15,7 +15,9 @@ scattered background and compares it with the file's ([§1.4](CPU_DATA_ANALYSIS_ reads how wide this crystal's spots are, which sets the integration radius ([§9.5](CPU_DATA_ANALYSIS_INTEGRATION.md)), and how much longer they are along their radius than across it, which is the beam's bandwidth where the file does not state one -([§9.6](CPU_DATA_ANALYSIS_INTEGRATION.md)). +([§9.6](CPU_DATA_ANALYSIS_INTEGRATION.md)), and how much wider still they grow away from the beam, +which sets the integration footprint ([§9.1](CPU_DATA_ANALYSIS_INTEGRATION.md)). In a GPU build the +pre-scan runs on the card. **Spots.** Every image is decoded — on the GPU straight from the compressed chunk ([§0](CPU_DATA_ANALYSIS_IMAGE.md)) — and one fused pass computes the azimuthal profile and finds @@ -26,8 +28,9 @@ the spots against each image's own per-resolution-ring noise FFT search looks for periodicity over thousands of directions; candidate cells are Niggli-reduced, classified by Bravais lattice, refined both constrained and triclinic, and decided on how many validation frames each actually indexes -([§4–§7](CPU_DATA_ANALYSIS_INDEXING.md)). A failed pass triggers the discrete rescues — the -rotation-axis sign, the beam-centre search — before anything is given up on. +([§4–§7](CPU_DATA_ANALYSIS_INDEXING.md)). A de-novo run also tries a second hypothesis with the +shortest accepted axis lowered from 10 to 5 Å, for small-molecule cells. A failed pass triggers the +discrete rescues — the rotation-axis sign, the beam-centre search — before anything is given up on. **First integration pass.** At the geometry in the file, every frame is predicted ([§8](CPU_DATA_ANALYSIS_INTEGRATION.md)) and profile-fit integrated @@ -44,7 +47,8 @@ pass is the canonical output, and a guard compares the two passes and keeps the **Space group.** On the P1 merge of the final pass, the point group is scored operator by operator on resolution-normalised intensities and the screw axes, glide planes and centring are read from the -systematic absences ([§13.1](CPU_DATA_ANALYSIS_DECISIONS.md)); twinning and translational +systematic absences, with the centre of symmetry from the intensity distribution where the absences +leave it open ([§13.1](CPU_DATA_ANALYSIS_DECISIONS.md)); twinning and translational pseudo-symmetry are checked beside it ([§13.2](CPU_DATA_ANALYSIS_DECISIONS.md)). `CANNOT_DETERMINE` and an enantiomorphic pair are real answers here, not evasions. diff --git a/docs/RUGNUX_TUTORIAL.md b/docs/RUGNUX_TUTORIAL.md index 41c43a5a7..deb76b941 100644 --- a/docs/RUGNUX_TUTORIAL.md +++ b/docs/RUGNUX_TUTORIAL.md @@ -120,7 +120,7 @@ refined pass against, and writes no merged files of its own — no `_01. `--write-process-h5`, each pass still writes its own, so `_01_process.h5` appears beside `_process.h5`.) Disable it with `--rotation-no-postrefine`. -After the per-frame scale-fulls step, rotation scaling applies three **correction surfaces**, **on by +After the per-frame scale-fulls step, rotation scaling applies three kinds of **correction surface**, **on by default** (`--no-scaling-corrections` disables all): - **Decay** — a global Debye–Waller relative-*B* over the run, for the radiation damage that weakens @@ -130,8 +130,9 @@ default** (`--no-scaling-corrections` disables all): (default 10°-of-rotation batches when bare, off otherwise), cross-validated like the surfaces here, for crystals whose decay is non-linear in dose. - **Absorption** — a smooth multiplicative factor over the diffracted-beam direction in the goniometer - frame (path length through the crystal). Negligible at hard X-rays / thin crystals; it matters at - low photon energy. Its benefit shows up most on model-based metrics: a smooth absorption error + frame (path length through the crystal), offered as a grid, as spherical harmonics and as a + surface that also varies with the rotation angle. Negligible at hard X-rays / thin crystals; it + matters at low photon energy and on strongly absorbing crystals. Its benefit shows up most on model-based metrics: a smooth absorption error largely cancels among symmetry mates (little effect on the error model / ISa) but still biases the intensities, so it measurably lowers *R*free. - **Modulation** — a smooth multiplicative factor over the position where a reflection lands on the @@ -142,11 +143,12 @@ default** (`--no-scaling-corrections` disables all): JUNGFRAU data — it lowers *R*meas by several to tens of percent on datasets that carry a detector systematic, while holding or improving CC1/2 and the anomalous signal. -All three are **cross-validated** — fitted on even-numbered frames and kept only if they improve the -held-out odd-frame symmetry-equivalent agreement by a clear margin (and vice versa). The agreement is -scored as a σ-independent, *R*meas-like fractional deviation, so a surface can never pass -cross-validation by merely reshaping the sigmas; where the systematic is absent the surface is a no-op -rather than a source of added noise, which is why they are safe to leave on. +All of them are **cross-validated** — fitted on even-numbered frames and used to merge the odd ones, +and the other way round, and kept only if the correlation between the two half-set means, within +resolution shells, rises over the same halves merged without the surface. The score does not involve +the sigmas, so a surface can never pass by merely reshaping them; where the systematic is absent the +surface is a no-op rather than a source of added noise, which is why they are safe to leave on +([§10.6](CPU_DATA_ANALYSIS_INTEGRATION.md#106-rotation-datasets-combining-partials-into-fulls-3d-integration)). Independently of any correction, a rotation run prints a **radiation-damage report** — the per-image scale correlation-to-merge and mosaicity versus dose, and the relative *B*-factor change over the run