Merge rc167 into the detection-score branch

Both lanes added a per-image scalar to the same eleven files, so every conflict was two
additions competing for one line. All were resolved by keeping both, with three that needed
more than that:

- ScanResultGenerator: rc167 changed the per-image float vectors to resize(n, NAN) so a frame
  that never arrived does not read back as a real 0. v_protein_score and v_ice_score are exactly
  that case - 0 is a real answer ("nothing detected here") - so they take the NAN default too.
- HDF5MetadataSource: rc167 established that NaN in a stored per-image array means "no value" and
  the optional must come back absent. The two detection scores now follow it, which they did not
  before the merge; without the guard a missing score would come back as a NaN that a threshold
  would silently compare against.
- CBORTest: designated initialisers must follow member declaration order, so spindle_blind_fraction
  precedes the two scores in the DataMessage aggregate.

Verified after the merge that every CBOR key that is encoded is also decoded (198 encoded keys,
one intentional exception: the "type" discriminator), that both lanes' fields survive in the
writer, the reader, the plots and the API, and that a stored file still round-trips.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFEJG6WBQv8th4UJFNe53N
This commit is contained in:
2026-09-08 00:13:51 +02:00
co-authored by Claude Opus 5
283 changed files with 10689 additions and 1732 deletions
+20 -11
View File
@@ -43,6 +43,7 @@ void ScanResultGenerator::Add(const DataMessage &message) {
v[image_number].pixel_sum = message.pixel_sum;
v[image_number].collection_efficiency = message.image_collection_efficiency.value_or(1.0);
v[image_number].bkg = message.bkg_estimate;
v[image_number].spindle_blind = message.spindle_blind_fraction;
v[image_number].spot_count = message.spot_count;
v[image_number].indexing_solution = message.indexing_result;
v[image_number].indexed_lattice_count = message.indexing_lattice_count;
@@ -93,27 +94,34 @@ void ScanResultGenerator::FillEndMessage(EndMessage &message) const {
if (n == 0)
return;
// The vectors the loop below fills with value_or(NAN) are sized with NAN, not with the
// value-initialised zero: an image that never reached the loop at all - dropped, never
// arrived, numbered outside the run - has no measurement, and zero is a measurement. A
// blind fraction of 0.0 reads as "this frame lost nothing", a mosaicity of 0.0 as a
// perfect crystal, and a resolution estimate of 0.0 as nothing at all. The counts keep
// their zeros, because a count of zero is a thing that can be true.
message.data_collection_efficiency.resize(n);
message.spot_count.resize(n);
message.spot_count_ice_ring.resize(n);
message.spot_count_ice_control.resize(n);
message.spot_count_ice_control.resize(n, NAN);
message.spot_count_low_res.resize(n);
message.spot_count_indexed.resize(n);
message.image_indexed.resize(n);
message.v_bkg_estimate.resize(n);
message.profile_radius.resize(n);
message.mosaicity.resize(n);
message.bFactor.resize(n);
message.resolution_estimate.resize(n);
message.v_bkg_estimate.resize(n, NAN);
message.v_spindle_blind_fraction.resize(n, NAN);
message.profile_radius.resize(n, NAN);
message.mosaicity.resize(n, NAN);
message.bFactor.resize(n, NAN);
message.resolution_estimate.resize(n, NAN);
message.min_viable_pixel_value.resize(n);
message.max_viable_pixel_value.resize(n);
message.saturated_pixel_count.resize(n);
message.error_pixel_count.resize(n);
message.image_scale_factor.resize(n);
message.image_scale_cc.resize(n);
message.ice_ring_score.resize(n);
message.v_protein_score.resize(n);
message.v_ice_score.resize(n);
message.image_scale_factor.resize(n, NAN);
message.image_scale_cc.resize(n, NAN);
message.ice_ring_score.resize(n, NAN);
message.v_protein_score.resize(n, NAN);
message.v_ice_score.resize(n, NAN);
message.integrated_reflections.resize(n);
message.niggli_class.resize(n);
message.pixel_sum.resize(n);
@@ -135,6 +143,7 @@ void ScanResultGenerator::FillEndMessage(EndMessage &message) const {
message.spot_count_indexed[number] = static_cast<int32_t>(value_or_zero(e.spot_count_indexed));
message.image_indexed[number] = static_cast<uint8_t>(e.indexing_solution.value_or(0));
message.v_bkg_estimate[number] = e.bkg.value_or(NAN);
message.v_spindle_blind_fraction[number] = e.spindle_blind.value_or(NAN);
message.profile_radius[number] = e.profile_radius.value_or(NAN);
message.mosaicity[number] = e.mosaicity.value_or(NAN);
message.bFactor[number] = e.b_factor.value_or(NAN);