Files
Jungfraujoch/image_analysis/indexing/AnalyzeIndexing.h
T
leonarski_f 680c36c20d
Build Packages / Unit tests (push) Successful in 1h22m15s
Build Packages / build:windows:nocuda (push) Successful in 18m0s
Build Packages / build:windows:cuda (push) Successful in 20m30s
Build Packages / build:viewer-tgz:cpu (push) Successful in 10m32s
Build Packages / build:viewer-tgz:cuda (push) Successful in 11m39s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 8m55s
Build Packages / build:rugnux:windows (push) Successful in 11m25s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 20m6s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 16m27s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 20m19s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 15m34s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 20m25s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 19m36s
Build Packages / build:rpm (rocky8) (push) Successful in 17m43s
Build Packages / build:rpm (rocky9) (push) Successful in 13m34s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 21m28s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 18m19s
Build Packages / DIALS test (push) Successful in 12m36s
Build Packages / XDS test (durin plugin) (push) Successful in 6m56s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 6m48s
Build Packages / XDS test (neggia plugin) (push) Successful in 6m7s
Build Packages / Generate python client (push) Successful in 11s
Build Packages / Build documentation (push) Successful in 36s
Build Packages / Create release (push) Skipped
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 5m11s
v1.0.0-rc.166 (#76)
* `rugnux --mode calibration` writes `<prefix>.json` beside the `.poni`, whose `dataset_settings` member is a `jfjoch_broker` `dataset_settings` body as it stands.
* `rugnux` and `jfjoch_viewer` read PILATUS miniCBF sweeps natively, without conversion.
* Masters written by other facilities open, including Eiger 1.x and third-party NXmx variants.
* `rugnux` measures the beam centre on every run, and indexes with it when the file's value indexes nothing.
* A detector swung out on a 2theta arm is placed where the file says it stands, and the calibration can hold the tilt fixed.
* `rugnux` writes the unmerged MTZ by default, and a P1 merge beside it, so a wrong space group can be re-merged without reprocessing.
* Significant improvements to symmetry handling in `rugnux`: the lattice, the point group, the setting and the systematic absences.
* The `rugnux` report gives the resolution the CC1/2 fit reached, beside the range the reflections were written to.
* The `rugnux` report gives the twinning statistics measured before the space group was decided, beside the ones measured after.
* The `rugnux` report gives the strong-direction diffraction limit, and warns when CC1/2 is not monotone with resolution.
* `rugnux` ranks screw axes on the evidence their absences carry, rather than on how many control reflections a candidate happens to have.
* Twinning is no longer reported when the L-test contradicts it.
* The `rugnux` report gives the detector tilt, the measured tilt and the direct beam beside the beam centre, and a post-refined beam centre is judged against the run's own measurement rather than the file's.
* `--no-refine-tilt` holds the detector tilt at the value in the file, instead of zeroing it, when the calibration starts from the spots.
* The `jfjoch_viewer` grid scan view draws the cells in the proportion of the scan steps, so the map has the shape of the scanned area.

Reviewed-on: #76
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-09-02 21:17:31 +02:00

55 lines
3.6 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "../../common/CrystalLattice.h"
#include "../../common/DiffractionExperiment.h"
#include "../../common/JFJochMessages.h"
// Minimum fraction of a frame's in-resolution spots that must lie on a candidate lattice for the
// frame to be that crystal's. See the frame gate in AnalyzeIndexing, which is where it is applied.
constexpr float LATTICE_MIN_INDEXED_FRACTION = 0.20f;
// Tally one image's spots by their rank in its intensity-ordered spot list: how many images had a spot
// at that rank at all (`counted`) and on how many of them it lay on the lattice (`indexed`). Ice spots
// are skipped, as they are in the frame gate. Both are added to, and their length bounds the ranks
// considered. Counts rather than weights so that the tally is exact whatever order the images are
// summed in, which is what makes the budget below independent of the thread schedule.
void AddSpotBudgetEvidence(const std::vector<SpotToSave> &spots, bool index_ice_rings,
std::vector<int64_t> &indexed, std::vector<int64_t> &counted);
// How far the fall from the peak must exceed the counting noise of the spots for the peak to be one.
//
// Under the null - the spots lie on the lattice at the same rate at every depth - the running sum
// below is a driftless random walk in the counted spots: each is worth 1 - g with probability g and
// -g otherwise, so its step has mean zero and variance g(1-g). The MAXIMUM of such a walk is positive
// whatever the data, so an argmax taken on its own cuts every dataset, including one with nothing to
// cut. What is acted on is the FALL from the peak to the end of the list, which is the maximum of the
// same walk read backwards from the end, and the reflection principle gives that maximum's null law
// exactly: P(fall > z sqrt(g(1-g)T)) = 2(1 - Phi(z)) over T counted spots in all. The search over the
// ranks is therefore already paid for and no further multiple-comparison correction is due. z is set
// for one false cut in a thousand measurements, which over a corpus the size of a rotation test set
// (tens of crystals, a measurement per pass) expects none at all.
constexpr float SPOT_BUDGET_SIGNIFICANCE_Z = 3.29f; // 2(1 - Phi(z)) = 0.001
// The spot budget those tallies support: the rank at which indexed - LATTICE_MIN_INDEXED_FRACTION *
// counted, summed over the ranks down to it, peaks. Each spot that lies on the lattice is worth
// 1 - LATTICE_MIN_INDEXED_FRACTION and each one that does not costs LATTICE_MIN_INDEXED_FRACTION - the
// same weighing the frame gate applies to a spot list as a whole - so the sum rises exactly while the
// spots at that depth are on the lattice more often than the gate's floor. Deeper than the peak they
// are not: they are no longer this crystal's reflections, and they can only push a frame towards
// rejection while adding nothing the lattice recognises.
//
// Zero - keep the whole list - when the fall from that peak to the end of the list is no larger than
// the counting noise above, which is the case whenever the spots go on lying on the lattice at the
// same rate all the way down, and the case a bare argmax gets wrong.
int64_t SpotBudgetFromEvidence(const std::vector<int64_t> &indexed, const std::vector<int64_t> &counted);
bool AnalyzeIndexing(DataMessage &message,
const DiffractionExperiment &experiment,
const CrystalLattice &latt,
const std::vector<CrystalLattice> &extra_lattices = {});