diff --git a/docs/CPU_DATA_ANALYSIS_IMAGE.md b/docs/CPU_DATA_ANALYSIS_IMAGE.md index 5b525d361..c97bdcd6c 100644 --- a/docs/CPU_DATA_ANALYSIS_IMAGE.md +++ b/docs/CPU_DATA_ANALYSIS_IMAGE.md @@ -240,8 +240,12 @@ within 2 %. The outcomes: the spots on itself over its own wrong-spindle null that exceeds the file's by more than the binomial noise of the two (z = 3.29). Where that does not adopt it, the file's centre is kept for the first pass and, on a two-pass run, both centres are carried to the merge (next paragraph). - Whichever cell a centre brings, the long-axis and sub-lattice hypotheses then test it on its own - spots, so a centre is not refused for the harmonic it first indexed. + Where the volumes are **not** related by such a factor, the centre has not doubled an axis but + smeared the cloud into an unrelated cell (measured on short wedges whose header centre was 34 px + out: 0.9-10x the true volume, rarely an integer); nothing before the merge arbitrates two unrelated + cells, so on a two-pass run both centres are carried to the merge. Whichever cell a centre brings, + the long-axis and sub-lattice hypotheses then test it on its own spots, so a centre is not refused + for the harmonic it first indexed. 5. **The file's centre does not index.** Nothing defends it, so: - where the measured centre indexes, it is **adopted**; - where it does not, the rotation-axis sign is flipped **at the measured centre**, since each of the @@ -267,7 +271,9 @@ every reflection is strong and a consistent merge reads close to 1. The measured - the arms ended on different lattices, and its search-merge $\mathrm{CC}_{1/2}$ is higher by more than 0.05. -Otherwise, or where the measured arm does not complete, the run keeps the file's centre. The log lines +Where the file's centre carried the measured one forward and then fails before it merges, the measured +arm is run just the same, and the measured centre is adopted where it merges; the run fails only where +both arms do. Otherwise, or where the measured arm does not complete, the run keeps the file's centre. The log lines are `Beam centre check: running the first pass again at the measured centre …` followed by `… the run adopts the measured centre and the lattice it finds` or `the measured centre does not win`. diff --git a/docs/RUGNUX_CLI.md b/docs/RUGNUX_CLI.md index b050c2656..0e8230707 100644 --- a/docs/RUGNUX_CLI.md +++ b/docs/RUGNUX_CLI.md @@ -224,7 +224,7 @@ subgroup of the data's, against the data expanded to it). | Option | Description | | --- | --- | -| `--beam-center-check[=off]` | Measure the beam centre from the isotropy of the scattered background on **every** run, report how far the file's value is from it (against how right this geometry needs it to be), and on rotation data index a **second first pass** at the measured centre. The fit reads the projection `--detect-beam-stop` already builds, so it costs no extra frames. **On by default**; `=off` disables it, and with it the measured centre's part in the post-refinement bound. The measured centre is adopted where the file's centre indexes nothing and the measured one indexes a majority; where the two return cells related by an integer volume factor (2 to 4) and the pre-scan's point-symmetry capture (where its margin is at least 1.5 %) lies nearer the measured centre - without an informative capture, where the measured centre's cell, larger or smaller, carries materially more of the pooled validation spots against its own chance level, and otherwise the two centres are judged on the merge; and, on a two-pass run, where the first pass is run at both centres and the measured one merges better — done where the two give the same cell in different metric symmetries, where they agree only once less of each frame is read, and where they agree but lie further apart than the geometry absorbs and the file's centre merges inconsistently in the lowest-resolution shell. Otherwise the file's centre is kept. On stills, where there is no first pass, the file's centre, the measured one and the point-symmetry capture's are each indexed on a sample of frames and the one putting materially more spots on the lattice is taken; with `-C`, or after the geometry refinement has fitted a cell de novo, the detector distance is searched too (30-3000 mm, the file's value one hypothesis). Still runs when `--beam-x`/`--beam-y` are given. See [§1.4](CPU_DATA_ANALYSIS_IMAGE.md) | +| `--beam-center-check[=off]` | Measure the beam centre from the isotropy of the scattered background on **every** run, report how far the file's value is from it (against how right this geometry needs it to be), and on rotation data index a **second first pass** at the measured centre. The fit reads the projection `--detect-beam-stop` already builds, so it costs no extra frames. **On by default**; `=off` disables it, and with it the measured centre's part in the post-refinement bound. The measured centre is adopted where the file's centre indexes nothing and the measured one indexes a majority; where the two return cells related by an integer volume factor (2 to 4) and the pre-scan's point-symmetry capture (where its margin is at least 1.5 %) lies nearer the measured centre - without an informative capture, where the measured centre's cell, larger or smaller, carries materially more of the pooled validation spots against its own chance level, and otherwise the two centres are judged on the merge; where the two return cells not related by such a factor, the two are judged on the merge; and, on a two-pass run, where the first pass is run at both centres and the measured one merges better — done where the two give the same cell in different metric symmetries, where they agree only once less of each frame is read, and where they agree but lie further apart than the geometry absorbs and the file's centre merges inconsistently in the lowest-resolution shell. A file's centre that carried the measured one forward and then fails before it merges loses to a measured centre that merges. Otherwise the file's centre is kept. On stills, where there is no first pass, the file's centre, the measured one and the point-symmetry capture's are each indexed on a sample of frames and the one putting materially more spots on the lattice is taken; with `-C`, or after the geometry refinement has fitted a cell de novo, the detector distance is searched too (30-3000 mm, the file's value one hypothesis). Still runs when `--beam-x`/`--beam-y` are given. See [§1.4](CPU_DATA_ANALYSIS_IMAGE.md) | ### Spot finding diff --git a/rugnux/RugnuxFirstPassRescues.cpp b/rugnux/RugnuxFirstPassRescues.cpp index 1b868ee85..d5a370f67 100644 --- a/rugnux/RugnuxFirstPassRescues.cpp +++ b/rugnux/RugnuxFirstPassRescues.cpp @@ -896,11 +896,20 @@ auto Rugnux::FirstPassRun::CentresDisagree(FirstPass best, const FirstPass &alt, // file's centre was kept and the run ended on a cell 1.6 % long. Rather than decide on that, carry // the measured centre forward and judge the two arms on their merges (RunAllPasses), as the // same-cell case above does. - if (!adopted_measured && !decided_by_capture && integer_harmonic && geometry_prepass) { + // + // Two cells that are NOT related by a harmonic are carried the same way. A centre wrong by tens of + // pixels does not double an axis - it smears the cloud so the FFT builds an unrelated cell: measured + // on 100 short wedges of one crystal whose header centre was 34 px out, the measured centre indexed + // the true cell and the file's one 0.92-9.9x its volume, almost never an integer multiple, and the + // file's was kept on 45 of them. Neither the frame count nor the pooled spots arbitrate two + // unrelated cells any better than a harmonic pair; the merge does. + if (!adopted_measured && !decided_by_capture && geometry_prepass) { rx.beam_center_alternative_ = std::array{measured_x, measured_y}; - logger.Warning("Beam centre check: the pooled spots do not settle which of the two " - "cells is the centre error, so the run keeps the file's centre for now " - "and carries the measured one forward, adopting whichever merges better"); + logger.Warning("Beam centre check: {}, so the run keeps the file's centre for now " + "and carries the measured one forward, adopting whichever merges better", + integer_harmonic ? "the pooled spots do not settle which of the two cells is the centre error" + : "the two cells are not harmonics of each other, which nothing before the " + "merge arbitrates"); } else if (!adopted_measured && !decided_by_capture) logger.Warning("Beam centre check: the run keeps the file's centre. The " "frame counts cannot arbitrate this - a cell twice as long " diff --git a/rugnux/RugnuxPasses.cpp b/rugnux/RugnuxPasses.cpp index 344c5ecaa..6784500dd 100644 --- a/rugnux/RugnuxPasses.cpp +++ b/rugnux/RugnuxPasses.cpp @@ -286,8 +286,10 @@ bool ArmsHoldSameLattice(const ProcessResult &a, const ProcessResult &b) { } std::string MeasuredCentreWins(const ProcessResult &file_arm, const ProcessResult &measured_arm) { - if (!file_arm.has_merge_statistics || !measured_arm.has_merge_statistics) + if (!measured_arm.has_merge_statistics) return {}; + if (!file_arm.has_merge_statistics) + return "the file's centre merged nothing and the measured one merges"; // Same lattice: which geometry is the more accurate, read off the signal each arm measured - the // statistic the two-pass quality guard found to agree with an external arbiter where CC1/2 did not // (RefinedPassIsWorse). Without its margin: that margin covers what the header and refined passes @@ -392,7 +394,19 @@ ProcessResult Rugnux::RunAllPasses(RugnuxObserver *observer) { lattice_arm_check_.reset(); logger.Info("Rotation two-pass geometry post-refinement: first pass (header geometry)"); - auto pass1 = RunPipeline(observer, /*write_output=*/true, /*geometry_prepass=*/true); + // Where the first pass carried the measured centre forward as a hypothesis, a file's centre that + // fails before it merges has not answered the question - it has lost it. The measured arm below + // then runs as it would have, and the run fails only where that arm fails too. + ProcessResult pass1; + std::exception_ptr file_centre_error; + try { + pass1 = RunPipeline(observer, /*write_output=*/true, /*geometry_prepass=*/true); + } catch (const std::exception &e) { + if (IsFatalResourceError(e) || !beam_center_alternative_) + throw; + logger.Warning("Beam centre check: the first pass at the file's centre did not complete ({})", e.what()); + file_centre_error = std::current_exception(); + } pass1.pass_number = 1; pass1.pass_count = 2; if (cancelled_) return pass1; @@ -595,6 +609,8 @@ ProcessResult Rugnux::RunAllPasses(RugnuxObserver *observer) { "{:.3f} on the search merge) - the run keeps the file's centre", alt.search_merge_strong_reflections, pass1.search_merge_strong_reflections, alt.search_merge_cc_half, pass1.search_merge_cc_half); + if (file_centre_error) + std::rethrow_exception(file_centre_error); note("beam centre: the file's centre kept, the measured one does not merge better"); keep_file_centre(); }