One gain mechanism: frames analysed in their own units, the gain applied where a photon count is assumed
The gain of an input in detector units (SMV, marCCD, XTC, the XFEL formats) is measured once, before anything reads the frames (RugnuxMeasureGain: photon-peak spacing and background variance per unit mean), or given with --gain, and handed to the integration and the spot finding by one function (ApplyRugnuxPixelGain). The rotation pre-scan no longer measures it, and the stills reader no longer converts frames of a detector whose photons are not resolved: SACLA MPCCD, Rayonix and CCD frames are integrated in ADU at the gain, rotation and stills alike. Where a photon count was assumed, it is now taken at the gain (bit-identical at gain 1): - integration: the background clip's one-photon floor, the sigma floor (one photon), the profile fit's background floor (0.01 photon), and a still's overload kept as a lower bound, which was left in ADU while every other reflection left the integrator in photons - the cause of the earlier loss of the engine route on clipped CCD stills (merged low resolution inflated by the gain, the rocking-width fit's bandwidth collapsing); CPU and CUDA, Metal through the shared CPU code; - the adaptive spot threshold (Poisson arm and its one-photon floor), CPU and GPU; - the pre-scan spot-width measurement (strong-spot SNR, the ring clip) behind the stills bandwidth and the rotation signal radius; - the hot/dead pixel tests, CPU and GPU; the empty-aperture ring clip. BackgroundPixelGain is gone: one pixel_gain. A detector whose background resolves single photons (photon peaks: JUNGFRAU in keV, AGIPD) is a photon counter and its frames are still counted in whole photons as read: analysed in keV at the gain instead, a photon-counting still set lost 0.008 R-free (fewer spots, a noisier beam-centre trial) - the rounding is the detector's own discrimination. --gain sets the value, the background still says which kind. Validation, against rc178: photon-counting and g<=1 rotation p.hkl md5-identical (lyso, thau, cytc, myob, insu, a small-molecule set, 5reo, 6cee, 6i3j, 2xfw, 6s1u, 8v4j); CCD g>1 at or within noise of rc178 (5uth R_meas 0.113 -> 0.108). Stills R-free (0-cycle REFMAC): MPCCD sets 0.184 -> 0.185 and 0.199 -> 0.196, Rayonix identical, photon-resolving sets back on their rc178 numbers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu (cherry picked from commit da8dbfc8147354b63e375f2d9521dffb80938b6d)
This commit is contained in:
1 parent
15793a6bc2
commit
711f902aa7
30 files changed
+341
-267
No files matched your search
@@ -93,19 +93,31 @@ TEST_CASE("AdaptiveThreshold_RingThreshold", "[SpotFinding]") {
|
||||
for (const float mean: {0.0f, 0.5f, 5.0f, 50.0f}) {
|
||||
for (const float sigma: {0.0f, 1.0f, 7.0f}) {
|
||||
const float gauss = mean + z * std::sqrt(sigma * sigma + READ * READ);
|
||||
CHECK(RingThreshold(mean, sigma, p, z) >= Catch::Approx(gauss).epsilon(1e-6));
|
||||
CHECK(RingThreshold(mean, sigma, p, z, 1.0f) >= Catch::Approx(gauss).epsilon(1e-6));
|
||||
}
|
||||
}
|
||||
CHECK(RingThreshold(0.0f, 0.0f, p, z) >= z * READ);
|
||||
CHECK(RingThreshold(0.0f, 0.0f, p, z, 1.0f) >= z * READ);
|
||||
|
||||
// Non-decreasing in the background mean and in the background scatter.
|
||||
CHECK(RingThreshold(20.0f, 4.0f, p, z) > RingThreshold(2.0f, 4.0f, p, z));
|
||||
CHECK(RingThreshold(5.0f, 9.0f, p, z) > RingThreshold(5.0f, 1.0f, p, z));
|
||||
CHECK(RingThreshold(20.0f, 4.0f, p, z, 1.0f) > RingThreshold(2.0f, 4.0f, p, z, 1.0f));
|
||||
CHECK(RingThreshold(5.0f, 9.0f, p, z, 1.0f) > RingThreshold(5.0f, 1.0f, p, z, 1.0f));
|
||||
|
||||
// Where the background is countable and quiet, Poisson significance is the binding arm: a ring
|
||||
// with mean 1 and no measured scatter must still demand several photons.
|
||||
CHECK(RingThreshold(1.0f, 0.0f, p, z) > 1.0f + z * READ);
|
||||
CHECK(RingThreshold(1.0f, 0.0f, p, z, 1.0f) > 1.0f + z * READ);
|
||||
|
||||
// A ring whose scatter is far above Poisson (flat-field / read excess) is set by the Gaussian arm.
|
||||
CHECK(RingThreshold(10.0f, 30.0f, p, z) == Catch::Approx(10.0f + z * std::sqrt(900.0f + READ * READ)).epsilon(1e-6));
|
||||
CHECK(RingThreshold(10.0f, 30.0f, p, z, 1.0f) == Catch::Approx(10.0f + z * std::sqrt(900.0f + READ * READ)).epsilon(1e-6));
|
||||
}
|
||||
|
||||
TEST_CASE("AdaptiveThreshold_RingThreshold_Gain", "[SpotFinding]") {
|
||||
const double p = 1e-5;
|
||||
const float z = static_cast<float>(NormalQuantile(1.0 - p));
|
||||
// A frame in detector units, g of them to a photon, is thresholded as its photons would be: the same
|
||||
// threshold, g times over, for the background and scatter g times over.
|
||||
for (const float g: {3.0f, 12.0f})
|
||||
for (const float mean: {0.0f, 0.05f, 1.0f, 5.0f, 300.0f})
|
||||
for (const float sigma: {0.0f, 1.0f, 7.0f})
|
||||
CHECK(RingThreshold(g * mean, g * sigma, p, z, g)
|
||||
== Catch::Approx(g * RingThreshold(mean, sigma, p, z, 1.0f)).epsilon(1e-5));
|
||||
}
|
||||
Reference in new issue
Block a user