From eaee11c935619d7698d8cc316cb3e38da697a339 Mon Sep 17 00:00:00 2001 From: leonarski_f Date: Fri, 6 Mar 2026 11:23:52 +0100 Subject: [PATCH] RotationIndexer: Retry indexing at 2x and 3x images --- image_analysis/RotationIndexer.cpp | 18 +++++++++++++----- image_analysis/RotationIndexer.h | 8 +++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/image_analysis/RotationIndexer.cpp b/image_analysis/RotationIndexer.cpp index 28dd687a..ab957426 100644 --- a/image_analysis/RotationIndexer.cpp +++ b/image_analysis/RotationIndexer.cpp @@ -24,10 +24,12 @@ RotationIndexer::RotationIndexer(const DiffractionExperiment &x, IndexerThreadPo if (x.GetImageNum() < min_images_for_indexing) { // For short measurements - only indexing at the end first_image_to_try_indexing = INT64_MAX; + next_image_to_try_indexing = INT64_MAX; image_stride = 1; } else { first_image_to_try_indexing = std::max(min_images_for_indexing, x.GetIndexingSettings().GetRotationIndexingMinAngularRange_deg() / angle_norm_deg); + next_image_to_try_indexing = first_image_to_try_indexing; image_stride = std::ceil(x.GetIndexingSettings().GetRotationIndexingAngularStride_deg() / angle_norm_deg); if (image_stride == 0) image_stride = 1; @@ -37,8 +39,6 @@ RotationIndexer::RotationIndexer(const DiffractionExperiment &x, IndexerThreadPo } void RotationIndexer::TryIndex() { - indexing_tried = true; - // Index std::vector v_sel; std::vector coords_sel; @@ -101,8 +101,16 @@ void RotationIndexer::TryIndex() { indexed_lattice = data.latt; updated_geom_ = data.geom; axis_ = data.axis; + return; } } + + if (indexing_range_multiplier < max_indexing_range_multiplier) { + indexing_range_multiplier++; + next_image_to_try_indexing = first_image_to_try_indexing * indexing_range_multiplier; + } else { + next_image_to_try_indexing = INT64_MAX; + } } std::optional RotationIndexer::ProcessImage(int64_t image, const std::vector &spots) { @@ -115,7 +123,7 @@ std::optional RotationIndexer::ProcessImage(int64_t image const float angle_deg = axis_->GetAngle_deg(image) + axis_->GetWedge_deg() / 2.0f; const auto rot = axis_->GetTransformationAngle(angle_deg); - if (!indexing_tried && image >= last_accumulated_image + image_stride) { + if (!indexed_lattice && image >= last_accumulated_image + image_stride) { v_.reserve(v_.size() + spots.size()); coords_.reserve(coords_.size() + spots.size()); @@ -129,7 +137,7 @@ std::optional RotationIndexer::ProcessImage(int64_t image accumulated_images++; last_accumulated_image = image; - if (accumulated_images >= min_images_for_indexing && image >= first_image_to_try_indexing) + if (accumulated_images >= min_images_for_indexing && image >= next_image_to_try_indexing) TryIndex(); } if (!indexed_lattice) @@ -152,4 +160,4 @@ std::optional RotationIndexer::GetLattice() { .geom = updated_geom_, .axis = axis_ }; -} +} \ No newline at end of file diff --git a/image_analysis/RotationIndexer.h b/image_analysis/RotationIndexer.h index 7259496f..facda160 100644 --- a/image_analysis/RotationIndexer.h +++ b/image_analysis/RotationIndexer.h @@ -31,9 +31,9 @@ class RotationIndexer { constexpr static int64_t max_spots = 10000; constexpr static int64_t min_images_for_indexing = 10; + constexpr static int64_t max_indexing_range_multiplier = 3; const bool index_ice_rings; - bool indexing_tried = false; float angle_norm_deg = 1.0f; std::vector v_; @@ -48,8 +48,10 @@ class RotationIndexer { int64_t last_accumulated_image = -1; int64_t accumulated_images = 0; - int64_t image_stride; - int64_t first_image_to_try_indexing; + int64_t image_stride = 1; + int64_t first_image_to_try_indexing = INT64_MAX; + int64_t next_image_to_try_indexing = INT64_MAX; + int64_t indexing_range_multiplier = 1; std::optional indexed_lattice; void TryIndex();