rotation indexer: fix sub-range crash, explicit angle, settings + guards

Running rotation indexing on a sub-range (e.g. images 60-120) segfaulted: the
first pass passed the *global* image number to RotationIndexer::ProcessImage,
which indexes v_ (sized to the run's image count) -> out-of-bounds write.

- ProcessImage now takes an explicit mid-exposure angle (optional; falls back to
  the goniometer at the image index), so the indexer no longer assumes its slot
  index equals the goniometer image index. IndexAndRefine supplies it via
  RotationAngle(), matching the angle used for prediction. Added a bounds guard in
  ProcessImage so a bad index can never corrupt memory.
- JFJochProcess feeds the rotation indexer the local ordinal (not the global
  index), and shifts the goniometer (start += start_image*incr, incr *= stride,
  per-image wedge preserved) so local index i maps to the angle of original image
  start+i*stride - fixing rotation angles for the whole sub-range pipeline
  (prediction, refinement, output), not just the indexer.
- Expose "Rotation images" (number used for the first pass) in the job dialog,
  enabled when rotation indexing is on. (Count > available is already clamped by
  select_equally_spaced_image_ordinals.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 15:59:21 +02:00
co-authored by Claude Opus 4.8
parent 67ad43a2b2
commit c86beeb393
7 changed files with 54 additions and 6 deletions
+16 -1
View File
@@ -99,6 +99,21 @@ ProcessResult JFJochProcess::Run(JFJochProcessObserver *observer) {
if (full)
experiment_.Compression(CompressionAlgorithm::BSHUF_LZ4);
// The pipeline indexes images 0..N-1 within this run; if we process a sub-range/strided
// selection, shift the goniometer so local index i maps to the angle of original image
// start+i*stride (keeping the per-image rotation wedge), otherwise rotation angles would be
// wrong for any start_image != 0.
if (const auto g = experiment_.GetGoniometer();
g.has_value() && (start_image != 0 || config_.stride != 1)) {
const float incr = g->GetIncrement_deg();
GoniometerAxis shifted(g->GetName(),
g->GetStart_deg() + incr * static_cast<float>(start_image),
incr * static_cast<float>(config_.stride),
g->GetAxis(), g->GetHelicalStep());
shifted.ScreeningWedge(g->GetScreeningWedge().value_or(incr));
experiment_.Goniometer(shifted);
}
AzimuthalIntegrationMapping mapping(experiment_, pixel_mask_);
JFJochReceiverPlots plots;
@@ -165,7 +180,7 @@ ProcessResult JFJochProcess::Run(JFJochProcessObserver *observer) {
if (cancelled_) break;
const int image_idx = start_image + ordinal * config_.stride;
DataMessage msg{};
msg.number = image_idx;
msg.number = ordinal; // index into the rotation indexer (0..images_to_process-1)
msg.original_number = image_idx;
try {
if (config_.reuse_rotation_spots) {