Radial background: one mechanism for stills and rotation, decided per run on empty apertures (D5)
Wherever the correction is set for the whole run its curve is the frame's peak-excluded ring background (the adaptive spot finder's, whole frame) and the ring's clip follows it - as stills have done since integ-pal - now rotation too. One empty-aperture measurement (BackgroundAperture) decides it for both workflows: - The apertures' corrected difference is now taken as the integrator applies the correction: the clip follows the curve (each ring pixel's threshold raised by the curve's rise from the centre, in whole counts) as well as the kernel correction. Before, the tally clipped flat, so it measured a correction the engine never applies. - Rotation measures the stencils the spot width can give it (r1 = 4, 5, 6 with the ring-area rule, RotationStencil) and decides on the one it gets, and separately on the pre-adaptive stencil the geometry pre-pass and the starvation guard return to. - Stills: on wherever the corrected ring predicts the empty disk better (unchanged rule). Rotation: the frame's curve on every image only where it takes >= 10% of the apertures' mean square error away (ROTATION_RADIAL_MIN_GAIN); otherwise the existing per-image ice gate with the reflections' curve is left exactly as it was. Why a margin on rotation only: a still has no other correction, a sweep has one. Measured over 18 rotation sets (forced on every image): photon-counting sweeps gain 0.1-5% on the apertures (z 3-4) and lose ISa/anomalous signal when corrected (insulin, lysozyme, cytochrome c; 9yzk R-free +0.009 at 1.2%), as the earlier stills-rule trial found; the home-source CCD and smooth-ice runs gain 13-31%. Result (CPU A/B vs 87684012f, 18 rotation sets): 12 .hkl byte-identical (every photon-counting control without ice), 5uth R-free 0.210 -> 0.201 / ISa 10.4 -> 10.8, the ice set neutral; stills: lcls242_s turns the correction on (the clip-following tally), R-free 0.2399 -> 0.2406. No integration kernel changed; the tally is host code. Tests: BackgroundAperture_CorrectedClipFollowsTheCurve, RadialHelps margins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu (cherry picked from commit dd3f3f2da39f5338e7dda1874bbdd535229bce98)
This commit is contained in:
1 parent
134fc56f70
commit
f199f23c54
8 files changed
+195
-49
No files matched your search
@@ -91,9 +91,17 @@ void background_aperture::MeasureFrame(ImagePreprocessorBuffer &image, int width
|
||||
}
|
||||
disk_v /= static_cast<double>(disk.size());
|
||||
disk_b /= static_cast<double>(disk.size());
|
||||
// The curve at the aperture's centre, which the corrected clip measures the ring's rise from.
|
||||
double centre_b = 0.0;
|
||||
if (!rings.empty()) {
|
||||
const auto [px, py] = modules.ImageToPlane(panel, cx[a], cy[a]);
|
||||
centre_b = rings.At(2.0 * PI / geometry.PxlToRes(static_cast<float>(px), static_cast<float>(py)));
|
||||
}
|
||||
|
||||
// Every candidate ring as the integrator reads it: the mean, then one high-side clip pass. The
|
||||
// radial correction is taken over the ring's geometry, as the integrator's kernel is.
|
||||
// Every candidate ring as the integrator reads it: the mean, then one high-side clip pass. With the
|
||||
// radial correction, as the integrator applies it: the clip follows the curve (each pixel's
|
||||
// threshold raised by the curve's rise from the centre to it, in whole counts -
|
||||
// RadialClipOffset), and the correction is taken over the ring's geometry, as the kernel is.
|
||||
std::vector<double> d_plain(r3.size()), d_radial(r3.size());
|
||||
bool measured = true;
|
||||
for (size_t k = 0; k < r3.size() && measured; ++k) {
|
||||
@@ -112,17 +120,24 @@ void background_aperture::MeasureFrame(ImagePreprocessorBuffer &image, int width
|
||||
}
|
||||
const double mean = sum / n;
|
||||
const double thr = mean + clip_nsigma * std::sqrt(gain * std::max(mean, static_cast<double>(gain)));
|
||||
double kept = 0.0;
|
||||
int n_kept = 0;
|
||||
for (const auto &p : ring)
|
||||
if (p.d2 < r3_sq && (clip_nsigma <= 0.0f || p.v <= thr)) {
|
||||
double kept = 0.0, kept_radial = 0.0;
|
||||
int n_kept = 0, n_kept_radial = 0;
|
||||
for (const auto &p : ring) {
|
||||
if (p.d2 >= r3_sq)
|
||||
continue;
|
||||
if (clip_nsigma <= 0.0f || p.v <= thr) {
|
||||
kept += p.v;
|
||||
++n_kept;
|
||||
}
|
||||
measured = n_kept > 0;
|
||||
if (clip_nsigma <= 0.0f || p.v <= thr + static_cast<double>(std::lround(p.b - centre_b))) {
|
||||
kept_radial += p.v;
|
||||
++n_kept_radial;
|
||||
}
|
||||
}
|
||||
measured = n_kept > 0 && n_kept_radial > 0;
|
||||
if (measured) {
|
||||
d_plain[k] = disk_v - kept / n_kept;
|
||||
d_radial[k] = d_plain[k] - (disk_b - sum_b / n);
|
||||
d_radial[k] = disk_v - kept_radial / n_kept_radial - (disk_b - sum_b / n);
|
||||
}
|
||||
}
|
||||
if (!measured)
|
||||
@@ -179,3 +194,9 @@ int background_aperture::Best(const std::vector<double> &mean_square) {
|
||||
return -1;
|
||||
return static_cast<int>(std::min_element(mean_square.begin(), mean_square.end()) - mean_square.begin());
|
||||
}
|
||||
|
||||
bool background_aperture::RadialHelps(const Tally &tally, size_t k, double min_gain) {
|
||||
if (tally.apertures == 0 || tally.apertures_radial != tally.apertures || k >= tally.sum_d2.size())
|
||||
return false;
|
||||
return tally.sum_d2_radial[k] < (1.0 - min_gain) * tally.sum_d2[k];
|
||||
}
|
||||
Reference in new issue
Block a user