viewer: calibrate the whole dataset from "Analyze dataset"
Build Packages / build:viewer-tgz:cpu (push) Successful in 11m45s
Build Packages / build:viewer-tgz:cuda (push) Successful in 17m11s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 18m59s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 21m9s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 24m51s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 25m1s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 21m32s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 17m49s
Build Packages / build:rpm (rocky8) (push) Successful in 23m8s
Build Packages / build:rpm (rocky9) (push) Successful in 20m8s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 20m4s
Build Packages / XDS test (durin plugin) (push) Successful in 10m53s
Build Packages / Generate python client (push) Successful in 28s
Build Packages / Create release (push) Skipped
Build Packages / Build documentation (push) Successful in 1m30s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 23m22s
Build Packages / DIALS test (push) Successful in 18m9s
Build Packages / XDS test (neggia plugin) (push) Successful in 7m55s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 8m56s
Build Packages / Unit tests (push) Successful in 1h54m52s
Build Packages / build:windows:nocuda (push) Canceled after 0s
Build Packages / build:windows:cuda (push) Canceled after 0s

The powder panel could only calibrate the image on screen. Calibration is now a
third page beside MX and AzInt, so the dataset button runs it over every image the
same way it runs the other two - which is the point, since a powder ring is
measured far better by summing a run than by one frame.

The page carries the calibrant and the method (rings or spots); the interactive
Guess/Refine buttons stay where they were and now share the one calibrant
selection, so there is no second combo to drift. analyzeDataset() carries the
ProcessMode rather than a bool: a third state was coming, and two bools would have
had one combination that cannot be valid.

The calibrant list gains ICE, which it could not offer before: the widget worked
in unit cells, and hexagonal ice has none that generates its rings correctly
(P6_3/mmc would include systematically absent ones). FindCenter now takes the ring
list its first line used to derive, so the interactive path gets ice as well.

The result window leads with the residual rms rather than the fitted sigma. The
sigma is a formal scatter estimate and understates a bad fit badly - measured on
ice, 0.215 px reported against a 1.70 px residual - while the rms separates a
usable fit from one that has locked onto the wrong thing.

A rings run needs the profile binned in azimuth; below four sectors it returns
nothing at all. The viewer raises the count to 32 exactly as the CLI does, and
says so in the panel and in the job dialog rather than doing it silently.

Also fixes a CLI inconsistency this comparison exposed: rugnux's calibration
branch never applied the standard offline analysis defaults, so it measured the
rings in a profile built with the file's polarization factor while every other
mode - and the viewer - uses 0.99. Found because the two disagreed by 0.005 px in
PONI x, and confirmed by reproducing the viewer exactly with --polarization 0.99.
With it applied the CLI and the viewer write byte-identical .poni files on LaB6
by rings, LaB6 by spots, and an iced dataset over 1800 images.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-07 10:45:39 +02:00
co-authored by Claude Opus 5
parent 942e978ffc
commit 6194fe6fbf
17 changed files with 420 additions and 81 deletions
+41 -24
View File
@@ -16,6 +16,15 @@ PowderCalibrationWidget::PowderCalibrationWidget(QWidget *parent) : QWidget(pare
calibrantCombo = new QComboBox(this);
updateCalibrantList();
// How a whole-dataset run measures the rings. The two buttons below always work from the spots of
// the image on screen, so this only takes effect for "Analyze dataset".
methodCombo = new QComboBox(this);
methodCombo->addItem("Rings (summed profile)", static_cast<int>(CalibrationMethod::Rings));
methodCombo->addItem("Spots (pooled spot lists)", static_cast<int>(CalibrationMethod::Spots));
methodCombo->setToolTip("How \"Analyze dataset\" measures the powder rings: rings sums the "
"(q x azimuth) azimuthal profile over every image and fits the ring arcs in it; "
"spots pools the found spots and fits those.");
auto findBeamCenterButton = new QPushButton("Guess detector calibration", this);
connect(findBeamCenterButton, &QPushButton::clicked,this, &PowderCalibrationWidget::findBeamCenterClicked);
@@ -24,12 +33,10 @@ PowderCalibrationWidget::PowderCalibrationWidget(QWidget *parent) : QWidget(pare
auto calibrantRingsButton = new QPushButton("Display calibrant rings", this);
connect(calibrantRingsButton, &QPushButton::clicked, this, [this]() {
std::vector<float> rings = CalculateXtalRings(GetCalibrant(), 10);
QVector<float> q_rings;
for (float ring : rings) {
q_rings.append(2 * PI / ring);
}
emit ringsFromCalibration(q_rings);
QVector<float> d_rings;
for (float q : GetCalibrantRings())
d_rings.append(2 * PI / q);
emit ringsFromCalibration(d_rings);
});
auto refine_row = new QGridLayout();
@@ -41,32 +48,41 @@ PowderCalibrationWidget::PowderCalibrationWidget(QWidget *parent) : QWidget(pare
refine_row->addWidget(calibrantRingsButton,2, 0);
refine_row->addWidget(new QLabel("Dataset method:"),3,0);
refine_row->addWidget(methodCombo,3,1);
auto hint = new QLabel("The two buttons fit the image on screen; \"Analyze dataset\" fits the whole "
"run and writes a .poni.", this);
hint->setWordWrap(true);
hint->setStyleSheet("color: gray;");
layout->addLayout(refine_row);
layout->addWidget(hint);
setLayout(layout);
}
UnitCell PowderCalibrationWidget::GetCalibrant() const {
// The combo lists the shared calibrant table (in its order), then the current sample's own cell.
// Ice is skipped: it is a ring list rather than a cell, and this panel works in cells.
int idx = calibrantCombo->currentIndex();
for (const auto &c : Calibrants()) {
if (!c.cell)
continue;
if (idx == 0)
return *c.cell;
idx--;
}
std::vector<float> PowderCalibrationWidget::GetCalibrantRings() const {
// The combo lists the shared calibrant table (in its order), then the current sample's own cell,
// which is not a powder standard but is what a single-crystal image's spots actually sit on.
const int idx = calibrantCombo->currentIndex();
const auto &table = Calibrants();
if (idx >= 0 && idx < static_cast<int>(table.size()))
return CalibrantRings(table[idx].name);
if (sample_cell)
return sample_cell.value();
return *Calibrants().front().cell;
return CalculateXtalRings(sample_cell.value());
return CalibrantRings(table.front().name);
}
CalibrationSelection PowderCalibrationWidget::Selection() const {
return {calibrantCombo->currentText(), GetCalibrantRings(),
static_cast<CalibrationMethod>(methodCombo->currentData().toInt())};
}
void PowderCalibrationWidget::updateCalibrantList() {
calibrantCombo->clear();
for (const auto &c : Calibrants())
if (c.cell)
calibrantCombo->addItem(QString::fromStdString(c.name));
calibrantCombo->addItem(QString::fromStdString(c.name));
if (sample_cell)
calibrantCombo->addItem(QString("Current sample (%1 %2 %3 %4 %5 %6)")
.arg(QString::number(sample_cell->a, 'f', 1))
@@ -85,10 +101,11 @@ void PowderCalibrationWidget::loadImage(std::shared_ptr<const JFJochReaderImage>
}
void PowderCalibrationWidget::findBeamCenterClicked() {
emit findBeamCenter(GetCalibrant(), true);
const std::vector<float> rings = GetCalibrantRings();
emit findBeamCenter(QVector<float>(rings.begin(), rings.end()), true);
}
void PowderCalibrationWidget::optimizeBeamCenterClicked() {
emit findBeamCenter(GetCalibrant(), false);
const std::vector<float> rings = GetCalibrantRings();
emit findBeamCenter(QVector<float>(rings.begin(), rings.end()), false);
}