proteinScore and iceScore are saturating scores in [0,1] that answer presence, not quality: a superb crystal and a barely-diffracting one both read near 1, and neither the spot count nor the resolution enters either of them as a term. iceRingScore already reports a magnitude - a ratio, unbounded - which is not a number that can be thresholded; these are. The protein score counts distinct d SHELLS above 5 A rather than spots, so a parasitic ring in the low-resolution band cannot accumulate evidence, and weights each spot against the frame's own median so a scattering of the weakest detections cannot fill a shell either. The ice score carries two channels and takes the stronger: a radial one over the azimuthal profile, which runs the hexagonal and the CUBIC phase as separate hypotheses and decides between them at the end (flash-cooled loops show cubic or stacking-disordered ice at least as often as hexagonal, the two share only three lines, and dropping the cubic hypothesis costs about 5 pp on iced loops), and a spot one that reads an excess on the ice radii against the same band slid to every ice-free offset, which is what catches ice arriving as discrete crystallites and leaving the radial profile flat. Both read d out of the geometry, so both move with a beam-centre error; the centre is not fitted here, and the one they were computed with is written beside them as scoreBeamCenterX/Y so a later rescoring can tell an algorithm disagreement from a geometry one. Ported from validated prototypes and checked against them frame by frame on stored data: mean absolute difference 2.7e-5 (protein), 1.3e-8 (ice radial) and 3.4e-4 (ice spots). On a 41-loop battery the protein score reaches 98.4% of confirmed-protein frames and 0.00% of water frames, and finds no cluster on any water or ice raster. Cost is 0.01 ms/frame for the protein score and 0.08-0.32 ms/frame for the ice score. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFEJG6WBQv8th4UJFNe53N
73 lines
2.4 KiB
C++
73 lines
2.4 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include "HDF5DataFilePlugin.h"
|
|
#include "../common/AutoIncrVector.h"
|
|
|
|
class HDF5DataFilePluginMX : public HDF5DataFilePlugin {
|
|
const size_t max_spots;
|
|
const size_t max_extra_lattices;
|
|
const bool indexing;
|
|
// spots
|
|
std::vector<float> spot_x;
|
|
std::vector<float> spot_y;
|
|
std::vector<float> spot_int;
|
|
std::vector<int8_t> spot_indexed;
|
|
std::vector<int8_t> spot_ice_ring;
|
|
std::vector<int8_t> spot_lattice;
|
|
std::vector<int32_t> spot_h;
|
|
std::vector<int32_t> spot_k;
|
|
std::vector<int32_t> spot_l;
|
|
std::vector<float> spot_dist_ewald;
|
|
|
|
AutoIncrVector<float> beam_corr_x{NAN};
|
|
AutoIncrVector<float> beam_corr_y{NAN};
|
|
|
|
AutoIncrVector<uint32_t> npeaks;
|
|
AutoIncrVector<uint32_t> strong_pixel_count;
|
|
|
|
AutoIncrVector<uint32_t> spot_count_total;
|
|
AutoIncrVector<uint32_t> spot_count_ice;
|
|
AutoIncrVector<float> spot_count_ice_control{NAN};
|
|
AutoIncrVector<uint32_t> spot_count_indexed;
|
|
AutoIncrVector<uint32_t> spot_count_low_res;
|
|
|
|
// indexing
|
|
AutoIncrVector<uint8_t> indexed;
|
|
AutoIncrVector<uint32_t> indexing_lattice_count;
|
|
std::vector<float> indexed_lattice;
|
|
std::vector<float> extra_lattices; // [nimages, max_extra_lattices, 9], NaN-filled
|
|
|
|
// crystal
|
|
AutoIncrVector<float> profile_radius{NAN};
|
|
AutoIncrVector<float> mosaicity_deg{NAN};
|
|
AutoIncrVector<float> b_factor{NAN};
|
|
|
|
// bkg_estimate
|
|
AutoIncrVector<float> bkg_estimate{NAN};
|
|
AutoIncrVector<float> ice_ring_score{NAN};
|
|
AutoIncrVector<float> protein_score{NAN};
|
|
AutoIncrVector<float> ice_score{NAN};
|
|
|
|
// resolution_estimation
|
|
AutoIncrVector<float> resolution_estimate{NAN};
|
|
|
|
AutoIncrVector<uint32_t> niggli_class;
|
|
AutoIncrVector<std::string> bravais_lattice;
|
|
|
|
AutoIncrVector<int64_t> integrated_reflections;
|
|
|
|
// scaling
|
|
bool image_scale_present = false;
|
|
AutoIncrVector<float> image_scale_factor{NAN};
|
|
AutoIncrVector<float> image_scale_cc{NAN};
|
|
AutoIncrVector<float> image_scale_mosaicity{NAN};
|
|
public:
|
|
explicit HDF5DataFilePluginMX(const StartMessage& msg);
|
|
void OpenFile(HDF5File &data_file, const DataMessage& msg, size_t images_per_file) override;
|
|
void Write(const DataMessage& msg, uint64_t image_number) override;
|
|
void WriteFinal(HDF5File &data_file) override;
|
|
};
|