Two opt-in tools for weak serial-stills tuning; both default-off, so the default pipeline is bit-identical (verified: a serial-stills reference run reproduces HEAD's 7.85% indexing rate exactly). --local-snr <sigma> (AdaptiveSpotFinderCPU::FilterByLocalSNR): after the loose per-ring adaptive threshold builds connected-component spots, drop any spot that does not stand this many sigmas above its OWN LOCAL background (robust median/MAD of a square annulus), not just the azimuthal ring mean. On structured-background (XFEL) frames the ring mean underestimates the local diffuse level in some sectors, so the ring threshold floods; a real Bragg peak still stands many local sigmas proud. Validated on XFEL stills to separate real peaks from flood at the pixel level (real median local-SNR ~70 vs flood ~2.6; SNR>=5 keeps ~99.8% of real peaks, ~14% of flood). GPU-portable (a per-spot local reduction). NOTE: on the current serial-stills battery it is index-rate/CC1/2 neutral -- the flood that survives as CC clusters overlaps weak-real spots, and only lattice-fit separates those -- but it is the correct tool for genuinely floody data (ice/jet/loosened detector) and the right substrate for the online FPGA path. --min-indexed-fraction <f>: exposes the previously hardcoded 0.20 minimum indexed-spot fraction (AnalyzeIndexing) as a per-run setting. Lowering it admits weaker/sparser crystals; on flooded XFEL data the extra lattices are spurious (pair with --min-image-cc to gate them), on clean synchrotron data there are no marginal frames so it is a no-op -- useful as a gating-experiment primitive. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
86 lines
4.0 KiB
C++
86 lines
4.0 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
enum class IndexingAlgorithmEnum {FFBIDX, FFT, FFTW, Auto, None};
|
|
// Flex = "let the pipeline decide": try several per-image refinements and keep whichever indexes the
|
|
// most spots (CLI -r flex; the legacy -r multi name is still accepted as an alias).
|
|
enum class GeomRefinementAlgorithmEnum {None, OrientationOnly, BeamCenter, Flex};
|
|
|
|
class IndexingSettings {
|
|
IndexingAlgorithmEnum algorithm;
|
|
int64_t fft_num_vectors = 16*1024;
|
|
float fft_max_unit_cell_A = 500.0;
|
|
float fft_min_unit_cell_A = 10.0;
|
|
float fft_max_angle_deg = 150.0;
|
|
float fft_min_angle_deg = 30.0;
|
|
float fft_high_resolution_A = 2.0;
|
|
float indexing_tolerance = 0.1;
|
|
float max_angle_from_ewald_deg = 2.0;
|
|
float unit_cell_dist_tolerance_vs_reference = 0.05; // relative
|
|
static constexpr float unit_cell_angle_tolerance_deg = 5.0; // degree
|
|
int64_t indexing_threads = 4;
|
|
int64_t viable_cell_min_spots = 9;
|
|
// Minimum fraction of the in-resolution spots a candidate lattice must index to be accepted.
|
|
// Lowering it admits weaker/sparser crystals (more real ones on flooded XFEL frames, but also
|
|
// more spurious lattices that a downstream merge-consistency gate must remove).
|
|
float min_indexed_spot_fraction = 0.20f;
|
|
|
|
int64_t max_extra_lattices = 2;
|
|
|
|
bool blocking_behavior = true;
|
|
bool index_ice_rings = false;
|
|
|
|
bool enable_rotation_indexing = false;
|
|
float rotation_indexing_min_angular_range_deg = 20.0;
|
|
float rotation_indexing_angular_stride_deg = 0.5;
|
|
|
|
GeomRefinementAlgorithmEnum refinement = GeomRefinementAlgorithmEnum::BeamCenter;
|
|
public:
|
|
IndexingSettings();
|
|
|
|
IndexingSettings& ViableCellMinSpots(int64_t input);
|
|
IndexingSettings& MinIndexedSpotFraction(float input);
|
|
IndexingSettings& Algorithm(IndexingAlgorithmEnum input);
|
|
IndexingSettings& FFT_MaxUnitCell_A(float input);
|
|
IndexingSettings& FFT_MinUnitCell_A(float input);
|
|
IndexingSettings& FFT_MaxAngle_deg(float input);
|
|
IndexingSettings& FFT_MinAngle_deg(float input);
|
|
IndexingSettings& FFT_NumVectors(int64_t input);
|
|
IndexingSettings& FFT_HighResolution_A(float input);
|
|
IndexingSettings& Tolerance(float input);
|
|
IndexingSettings& IndexingThreads(int64_t input);
|
|
IndexingSettings& UnitCellDistTolerance(float input);
|
|
IndexingSettings& GeomRefinementAlgorithm(GeomRefinementAlgorithmEnum input);
|
|
IndexingSettings& IndexIceRings(bool input);
|
|
IndexingSettings& RotationIndexing(bool input);
|
|
IndexingSettings& RotationIndexingMinAngularRange_deg(float input);
|
|
IndexingSettings& RotationIndexingAngularStride_deg(float input);
|
|
IndexingSettings& BlockingBehavior(bool input);
|
|
IndexingSettings& MaxExtraLattices(int64_t input);
|
|
|
|
[[nodiscard]] int64_t GetViableCellMinSpots() const;
|
|
[[nodiscard]] float GetMinIndexedSpotFraction() const;
|
|
[[nodiscard]] IndexingAlgorithmEnum GetAlgorithm() const;
|
|
[[nodiscard]] GeomRefinementAlgorithmEnum GetGeomRefinementAlgorithm() const;
|
|
[[nodiscard]] float GetFFT_MaxUnitCell_A() const;
|
|
[[nodiscard]] float GetFFT_MinUnitCell_A() const;
|
|
[[nodiscard]] int64_t GetFFT_NumVectors() const;
|
|
[[nodiscard]] float GetFFT_HighResolution_A() const;
|
|
[[nodiscard]] float GetTolerance() const;
|
|
[[nodiscard]] float GetFFT_MinAngle_deg() const;
|
|
[[nodiscard]] float GetFFT_MaxAngle_deg() const;
|
|
[[nodiscard]] int64_t GetIndexingThreads() const;
|
|
[[nodiscard]] float GetUnitCellDistTolerance() const;
|
|
[[nodiscard]] float GetUnitCellAngleTolerance_deg() const;
|
|
[[nodiscard]] bool GetIndexIceRings() const;
|
|
[[nodiscard]] bool GetRotationIndexing() const;
|
|
[[nodiscard]] float GetRotationIndexingMinAngularRange_deg() const;
|
|
[[nodiscard]] float GetRotationIndexingAngularStride_deg() const;
|
|
[[nodiscard]] bool GetBlockingBehavior() const;
|
|
[[nodiscard]] int64_t GetMaxExtraLattices() const;
|
|
};
|