Files
Jungfraujoch/broker/gen/model/Spot_finding_settings.h
T
leonarski_fandClaude Opus 5 61a7c91b90 Ice: detect it on two channels, and only handle it when it is there
The per-image ice score was read off the PLAIN azimuthal profile. That profile is a
per-ring mean, so a few strong Bragg reflections landing in a ring's q bin lift it
exactly as ice would. Measured over 37 rotation crystals, that did not merely add
noise - it INVERTED the metric: the two highest-scoring crystals had no ice at all
(4.23 and 4.06), while a clean control read 1.57. A decoy null - the identical
statistic evaluated at q positions where hexagonal ice cannot be - reaches 1.51 at its
99th percentile and 2.70 at its maximum, so that metric cannot support any absolute
threshold whatsoever.

The adaptive spot finder already computes the right input for its own threshold: a
sigma-clipped per-resolution-ring background, in the same bins. A powder ring is
azimuthally smooth and survives the clip; Bragg peaks do not. On the clipped profile
the clean population tightens to 1.00-1.22 and the crystals with confirmed ice sit at
2.08-2.37, against a decoy null that never exceeds 1.29.

That channel is blind to one thing: ice in large crystallites diffracts as DISCRETE
spots and leaves the radial profile flat. So a second channel counts found spots on the
rings against the same q width of ice-free flanks beside them. The two barely overlap -
the smooth-ice crystals read 2.1-2.4 / ~1.0 and the textured ones ~1.1 / 3.8-17.6,
while a clean crystal reads 1.04 on both.

Both are then used as a GATE (--ice-min-score 1.5, --ice-min-spot-ratio 2.0, both
calibrated on the battery, 0 disables): the eleven fixed hexagonal bands cover 16-26 %
of the unique reflections at typical resolutions whether or not the crystal has ice, so
flagging, the exclusion from the scale fit and the merge-time CC1/2 ring mask are now
all skipped when neither channel sees any. The gate is applied in the full pipeline and
in --scale, which reads the stored per-image values back out of the _process.h5.

Also fixes the merge-time mask's control: the shoulder now excludes reflections that
are themselves on an ice ring. The rings are not evenly spaced - 1.947/1.916/1.882 A
sit 0.05-0.06 apart in q - so for those three the [w,3w) shoulder landed squarely on
the neighbours and the test compared ice against ice. Measured, that is the only thing
this changes: it removes firings on those three rings and leaves every other firing's
CC pair identical to three decimals.

And the online ice half-width, which was 0.02 in the API against 0.03 offline, so the
same data got a narrower band online than the measured ~0.06 ring FWHM justifies.

Battery (37 rotation crystals, against the previous behaviour): space groups 34/37 in
both and NO crystal's space group changes; 6 crystals gain unique reflections, 1 loses.
Best of them gains 7082 unique reflections with R_meas 16.0 -> 14.3, CC1/2 95.9 -> 97.3
and ISa 13.7 -> 19.0; another goes R_meas 54.9 -> 42.9, CC1/2 84.0 -> 90.4, ISa
3.9 -> 5.5; a third reaches CC1/2 99.4 from 95.7 at an unchanged reflection count. The
one crystal that loses reflections improves on both R_meas and CC1/2.

Not done here: the ScanResult/API/plot-type/frontend/viewer layers for the new
spot_count_ice_control (they need the OpenAPI regeneration). Message, CBOR, HDF5
write/read and the receiver plots are.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 16:17:23 +02:00

176 lines
8.0 KiB
C++

/**
* Jungfraujoch
* API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland). Jungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU. Jungfraujoch uses FPGA boards to acquire data at high data rates. # License Clarification While this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply** when this file is used solely to generate OpenAPI clients or when implementing applications that interact with the API. Generated client code and applications using this API definition are not subject to the GPL license requirements and may be distributed under terms of your choosing. This exception is similar in spirit to the Linux Kernel's approach to userspace API headers and the GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that user programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not derivative works of the kernel and are not subject to the terms of the GPL. This exception is intended to allow wider use of this API specification without imposing GPL requirements on applications that merely interact with the API, regardless of whether they communicate through network calls or other mechanisms.
*
* The version of the OpenAPI document: 1.0.0-rc.161
* Contact: filip.leonarski@psi.ch
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Spot_finding_settings.h
*
*
*/
#ifndef Spot_finding_settings_H_
#define Spot_finding_settings_H_
#include <nlohmann/json.hpp>
namespace org::openapitools::server::model
{
/// <summary>
///
/// </summary>
class Spot_finding_settings
{
public:
Spot_finding_settings();
virtual ~Spot_finding_settings() = default;
/// <summary>
/// Validate the current data in the model. Throws a ValidationException on failure.
/// </summary>
void validate() const;
/// <summary>
/// Validate the current data in the model. Returns false on error and writes an error
/// message into the given stringstream.
/// </summary>
bool validate(std::stringstream& msg) const;
/// <summary>
/// Helper overload for validate. Used when one model stores another model and calls it's validate.
/// Not meant to be called outside that case.
/// </summary>
bool validate(std::stringstream& msg, const std::string& pathPrefix) const;
bool operator==(const Spot_finding_settings& rhs) const;
bool operator!=(const Spot_finding_settings& rhs) const;
/////////////////////////////////////////////
/// Spot_finding_settings members
/// <summary>
/// Enable spot finding. This is temporary setting, i.e. can be changed anytime during data collection. Even if disabled spot finding information will still be send and written, though always with zero spots.
/// </summary>
bool isEnable() const;
void setEnable(bool const value);
/// <summary>
/// Enable indexing. This is temporary setting, i.e. can be changed anytime during data collection.
/// </summary>
bool isIndexing() const;
void setIndexing(bool const value);
/// <summary>
///
/// </summary>
float getSignalToNoiseThreshold() const;
void setSignalToNoiseThreshold(float const value);
/// <summary>
///
/// </summary>
int64_t getPhotonCountThreshold() const;
void setPhotonCountThreshold(int64_t const value);
/// <summary>
///
/// </summary>
int64_t getMinPixPerSpot() const;
void setMinPixPerSpot(int64_t const value);
/// <summary>
///
/// </summary>
int64_t getMaxPixPerSpot() const;
void setMaxPixPerSpot(int64_t const value);
/// <summary>
/// High resolution limit for spot finding [Angstrom]. Optional: if omitted, spot finding extends as far as the detector reaches, i.e. the detection is not clipped in resolution.
/// </summary>
float getHighResolutionLimit() const;
void setHighResolutionLimit(float const value);
bool highResolutionLimitIsSet() const;
void unsetHigh_resolution_limit();
/// <summary>
/// Low resolution limit for spot finding [Angstrom]
/// </summary>
float getLowResolutionLimit() const;
void setLowResolutionLimit(float const value);
/// <summary>
/// High resolution threshold to consider spot \&quot;low resolution\&quot; [Angstrom]
/// </summary>
float getHighResolutionLimitForSpotCountLowRes() const;
void setHighResolutionLimitForSpotCountLowRes(float const value);
/// <summary>
/// Quick integration of Bragg spots in diffraction images. If enabled it will likely reduce performance of Jungfraujoch for datasets with a very high indexing rate. (experimental feature)
/// </summary>
bool isQuickIntegration() const;
void setQuickIntegration(bool const value);
/// <summary>
/// Half-width of the ice ring band in q (1/A). Matches the offline default in image_analysis/spot_finding/SpotFindingSettings.h, which was set from a measured ring FWHM of ~0.06; the two must agree or the same data gets a narrower ice band online.
/// </summary>
float getIceRingWidthQRecipA() const;
void setIceRingWidthQRecipA(float const value);
/// <summary>
/// This parameter is used to remove spurious spots at a very high resolution, that sometimes appear due to very low background close to the edge of the detector. If there is a gap in (1/d)-space between spots of at least this size, spots on the side of the gap with high resolution will be discarded. This is optional parameter. This option should be turned OFF for small molecule datasets or for crystals with very low mosaicity, when it is expected to see only few spots in any case.
/// </summary>
float getHighResGapQRecipA() const;
void setHighResGapQRecipA(float const value);
bool highResGapQRecipAIsSet() const;
void unsetHigh_res_gap_Q_recipA();
/// <summary>
/// Self-calibrating spot detection: replace the fixed photon_count_threshold by a per-resolution-ring threshold derived from each image&#39;s own noise, so the same setting works across datasets without per-dataset tuning. photon_count_threshold is then ignored and false_pixels_per_frame sets the operating point instead. Only available on detectors whose images are analysed in software (the DECTRIS/SIMPLON workflow). The JUNGFRAU and EIGER workflows find spots on the FPGA, which applies its own fixed threshold, so enabling this there is rejected rather than silently ignored.
/// </summary>
bool isAdaptiveThreshold() const;
void setAdaptiveThreshold(bool const value);
bool adaptiveThresholdIsSet() const;
void unsetAdaptive_threshold();
/// <summary>
/// Operating point of the adaptive threshold: the number of noise pixels tolerated per frame. About 100 suits a multi-megapixel detector. Ignored unless adaptive_threshold is set.
/// </summary>
float getFalsePixelsPerFrame() const;
void setFalsePixelsPerFrame(float const value);
bool falsePixelsPerFrameIsSet() const;
void unsetFalse_pixels_per_frame();
friend void to_json(nlohmann::json& j, const Spot_finding_settings& o);
friend void from_json(const nlohmann::json& j, Spot_finding_settings& o);
protected:
bool m_Enable;
bool m_Indexing;
float m_Signal_to_noise_threshold;
int64_t m_Photon_count_threshold;
int64_t m_Min_pix_per_spot;
int64_t m_Max_pix_per_spot;
float m_High_resolution_limit;
bool m_High_resolution_limitIsSet;
float m_Low_resolution_limit;
float m_High_resolution_limit_for_spot_count_low_res;
bool m_Quick_integration;
float m_Ice_ring_width_q_recipA;
float m_High_res_gap_Q_recipA;
bool m_High_res_gap_Q_recipAIsSet;
bool m_Adaptive_threshold;
bool m_Adaptive_thresholdIsSet;
float m_False_pixels_per_frame;
bool m_False_pixels_per_frameIsSet;
};
} // namespace org::openapitools::server::model
#endif /* Spot_finding_settings_H_ */