Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 16m43s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 28m46s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 32m5s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 39m44s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m7s
Build Packages / Create release (push) Successful in 8s
Build Packages / Build documentation (push) Successful in 49s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 22m30s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 31m54s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 11m29s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 23m51s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 26m7s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 29m38s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 28m6s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 29m44s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 33m22s
Build Packages / Generate python client (push) Successful in 47s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 34m6s
Build Packages / Unit tests (push) Successful in 1h2m47s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 35m59s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 34m8s
Build Packages / Validation Battery (push) Successful in 38m31s
* Rugnux: Refinement several times faster, one protocol on the CPU and the GPU, parts of it on the Apple GPU; its random draws are the same on every platform. * Rugnux: Refinement follows common practice: the free set decides only the restraint weights and the displacement model (isotropic, TLS or anisotropic, by Hamilton's test), everything else is decided on the working set; lower R-free for placed and predicted models. * Rugnux: Restraint dictionaries via `--restraints` (or among the inputs) and more built-in ligands; a model whose space group is a subgroup of the data's is refined in its own group; reflections plus a model select `--mode refine` on their own. * Rugnux: `-C` fixes the crystal system on the axes as typed; `-S` alone fixes the space group only, the cell is still found and reduced; a space group or cell stored in the input file is ignored, with a line in the log. * Rugnux: More reliable multi-sweep merging; `--mode scale` merges several stills runs as one; `_plot.txt` and the report name each input; a second crystal form is reported for stills given a cell. * jfjoch_broker (experimental): Live Rugnux on FPGA detectors (JUNGFRAU) takes the same path as a DECTRIS stream, rotation and serial alike, model step included, with analysis threads per GPU; frames waiting for the analysis can be viewed; no host stage drops a frame - a source faster than the analysis is held at the card. * jfjoch_broker: Summation of more than 256 frames per image is split between the card and the host (`summation_mode` is then `hybrid`), and live Rugnux runs on such collections; pedestal runs take a receiver of their own. * jfjoch_broker (experimental): `stills_downsample` analyses 1 of every N serial images (chosen by a hash; the first 2000 all; the others written without analysis; reset to 1 by `/initialize`); `max_spot_count` left out means 250 for per-image indexing and up to 1000 for live stills; the live status gives the merge before the model work, the fitted resolution and the anomalous peak height of each unexplained blob. * jfjoch_broker: Without a `pcie` entry the broker runs on a mock of the card instead of the HLS simulation; its spot, ROI and azimuthal results are zero then. * Web frontend: Redesigned Rugnux live page; Vite 8, TypeScript 6, Mol* 5.13 and dependency security updates. * Tools: `jfjoch_fpga_stills_test` measures live stills on the cards with a stored dataset; `jfjoch_fpga_test` loses the HLS-simulation option. * Other: FFTW no longer fetched or linked (the CPU FFT indexer keeps the name `FFTW`); PCIe driver now GPL-2.0-or-later and third-party notices complete; several crash fixes. Reviewed-on: #98 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
314 lines
11 KiB
C++
314 lines
11 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "JFJochViewerImageListWindow.h"
|
|
|
|
#include <QVBoxLayout>
|
|
#include <QHeaderView>
|
|
#include <QCloseEvent>
|
|
#include <QMenu>
|
|
|
|
namespace {
|
|
constexpr int ScaleSortRole = Qt::UserRole + 1;
|
|
constexpr double ScaleNotAvailableSortValue = -1.0e100;
|
|
// The Yes/No columns, filtered from the header's context menu.
|
|
constexpr int IndexColumn = 2;
|
|
constexpr int MergedColumn = 3;
|
|
const QStringList YesNoValues = {"Yes", "No", "N/A"};
|
|
}
|
|
|
|
void ImageListFilterModel::SetFilter(int column, const QSet<QString> &values) {
|
|
allowed[column] = values;
|
|
invalidateFilter();
|
|
}
|
|
|
|
void ImageListFilterModel::ClearFilter(int column) {
|
|
allowed.remove(column);
|
|
invalidateFilter();
|
|
}
|
|
|
|
bool ImageListFilterModel::Allows(int column, const QString &value) const {
|
|
return !allowed.contains(column) || allowed[column].contains(value);
|
|
}
|
|
|
|
bool ImageListFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
|
|
for (auto it = allowed.cbegin(); it != allowed.cend(); ++it)
|
|
if (!it.value().contains(sourceModel()->index(source_row, it.key(), source_parent).data().toString()))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
JFJochViewerImageListWindow::JFJochViewerImageListWindow(QWidget *parent) : JFJochHelperWindow(parent) {
|
|
|
|
QWidget *centralWidget = new QWidget(this);
|
|
setCentralWidget(centralWidget);
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout(centralWidget);
|
|
|
|
tableView = new QTableView(this);
|
|
|
|
tableModel = new QStandardItemModel(this);
|
|
setupTableModel();
|
|
|
|
proxyModel = new ImageListFilterModel(this);
|
|
proxyModel->setSourceModel(tableModel);
|
|
proxyModel->setSortRole(ScaleSortRole);
|
|
|
|
tableView->setModel(proxyModel);
|
|
tableView->sortByColumn(0, Qt::AscendingOrder);
|
|
tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
tableView->setSortingEnabled(true);
|
|
tableView->verticalHeader()->setVisible(false);
|
|
tableView->horizontalHeader()->setSectionsClickable(true);
|
|
tableView->horizontalHeader()->setSortIndicatorShown(true);
|
|
|
|
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
layout->addWidget(tableView);
|
|
|
|
setWindowTitle("Image statistics");
|
|
resize(800, 600);
|
|
|
|
connect(tableView, &QTableView::doubleClicked, this, &JFJochViewerImageListWindow::onTableRowDoubleClicked);
|
|
|
|
// A click on a header sorts; its context menu filters the Yes/No columns.
|
|
tableView->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
connect(tableView->horizontalHeader(), &QHeaderView::customContextMenuRequested,
|
|
this, &JFJochViewerImageListWindow::onHeaderMenu);
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::onHeaderMenu(const QPoint &pos) {
|
|
const int column = tableView->horizontalHeader()->logicalIndexAt(pos);
|
|
if (column != IndexColumn && column != MergedColumn)
|
|
return;
|
|
|
|
QMenu menu(this);
|
|
for (const QString &value : YesNoValues) {
|
|
QAction *action = menu.addAction(value);
|
|
action->setCheckable(true);
|
|
action->setChecked(proxyModel->Allows(column, value));
|
|
}
|
|
menu.addSeparator();
|
|
QAction *all = menu.addAction("Show all");
|
|
QAction *chosen = menu.exec(tableView->horizontalHeader()->mapToGlobal(pos));
|
|
if (!chosen)
|
|
return;
|
|
|
|
QSet<QString> values;
|
|
if (chosen != all)
|
|
for (QAction *action : menu.actions())
|
|
if (action->isCheckable() && action->isChecked())
|
|
values.insert(action->text());
|
|
if (chosen == all || values.size() == YesNoValues.size())
|
|
proxyModel->ClearFilter(column);
|
|
else
|
|
proxyModel->SetFilter(column, values);
|
|
|
|
const QString name = column == IndexColumn ? "Index" : "Merged";
|
|
tableModel->setHeaderData(column, Qt::Horizontal, proxyModel->IsFiltered(column) ? name + " *" : name);
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::setupTableModel()
|
|
{
|
|
tableModel->setColumnCount(9);
|
|
tableModel->setHeaderData(0, Qt::Horizontal, "#");
|
|
tableModel->setHeaderData(1, Qt::Horizontal, "Bkg");
|
|
tableModel->setHeaderData(2, Qt::Horizontal, "Index");
|
|
tableModel->setHeaderData(3, Qt::Horizontal, "Merged");
|
|
tableModel->setHeaderData(4, Qt::Horizontal, "Spots");
|
|
tableModel->setHeaderData(5, Qt::Horizontal, "Res. [A]");
|
|
tableModel->setHeaderData(6, Qt::Horizontal, "Max val");
|
|
tableModel->setHeaderData(7, Qt::Horizontal, "Scale factor");
|
|
tableModel->setHeaderData(8, Qt::Horizontal, "Scale CC");
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::addDataRow(int imageNumber, double backgroundEstimate,
|
|
const QString& indexingResult,
|
|
const QString& mergeResult,
|
|
int spotCount,
|
|
double resolutionEstimate,
|
|
int64_t max_value,
|
|
double image_scale_factor,
|
|
double image_scale_cc_percent) {
|
|
QList<QStandardItem*> rowItems;
|
|
|
|
QStandardItem *imageItem = new QStandardItem();
|
|
imageItem->setData(imageNumber, Qt::DisplayRole);
|
|
imageItem->setData(imageNumber, ScaleSortRole);
|
|
rowItems.append(imageItem);
|
|
|
|
QStandardItem *bgItem = new QStandardItem();
|
|
bgItem->setData(backgroundEstimate, Qt::DisplayRole);
|
|
bgItem->setData(backgroundEstimate, ScaleSortRole);
|
|
rowItems.append(bgItem);
|
|
|
|
for (const QString &result : {indexingResult, mergeResult}) {
|
|
QStandardItem *item = new QStandardItem(result);
|
|
if (result == "Yes")
|
|
item->setData(1, ScaleSortRole);
|
|
else if (result == "No")
|
|
item->setData(0, ScaleSortRole);
|
|
else
|
|
item->setData(-1, ScaleSortRole);
|
|
rowItems.append(item);
|
|
}
|
|
|
|
QStandardItem *spotItem = new QStandardItem();
|
|
spotItem->setData(spotCount, Qt::DisplayRole);
|
|
spotItem->setData(spotCount, ScaleSortRole);
|
|
rowItems.append(spotItem);
|
|
|
|
QStandardItem *resolutionItem = new QStandardItem();
|
|
resolutionItem->setData(QString::number(resolutionEstimate, 'f', 2), Qt::DisplayRole);
|
|
resolutionItem->setData(resolutionEstimate, ScaleSortRole);
|
|
rowItems.append(resolutionItem);
|
|
|
|
QStandardItem *maxValueItem = new QStandardItem();
|
|
maxValueItem->setData(static_cast<int32_t>(max_value), Qt::DisplayRole);
|
|
maxValueItem->setData(static_cast<int32_t>(max_value), ScaleSortRole);
|
|
rowItems.append(maxValueItem);
|
|
|
|
QStandardItem *scaleFactorItem = new QStandardItem();
|
|
if (std::isfinite(image_scale_factor)) {
|
|
scaleFactorItem->setData(image_scale_factor, Qt::DisplayRole);
|
|
scaleFactorItem->setData(image_scale_factor, ScaleSortRole);
|
|
} else {
|
|
scaleFactorItem->setData("N/A", Qt::DisplayRole);
|
|
scaleFactorItem->setData(ScaleNotAvailableSortValue, ScaleSortRole);
|
|
}
|
|
rowItems.append(scaleFactorItem);
|
|
|
|
QStandardItem *scaleCCItem = new QStandardItem();
|
|
if (std::isfinite(image_scale_cc_percent)) {
|
|
scaleCCItem->setData(QString::number(image_scale_cc_percent, 'f', 1) + "%", Qt::DisplayRole);
|
|
|
|
scaleCCItem->setData(image_scale_cc_percent, ScaleSortRole);
|
|
} else {
|
|
scaleCCItem->setData("N/A", Qt::DisplayRole);
|
|
scaleCCItem->setData(ScaleNotAvailableSortValue, ScaleSortRole);
|
|
}
|
|
rowItems.append(scaleCCItem);
|
|
|
|
tableModel->appendRow(rowItems);
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::clearAllData() {
|
|
tableModel->removeRows(0, tableModel->rowCount());
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::datasetLoaded(std::shared_ptr<const JFJochReaderDataset> in_dataset) {
|
|
dataset = std::move(in_dataset);
|
|
|
|
// One row of nine QStandardItems per image, arriving on every dataset tick of a live
|
|
// acquisition. Not worth doing for a window nobody has open.
|
|
if (!isVisible()) {
|
|
pending_fill = true;
|
|
return;
|
|
}
|
|
fillTable();
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::showEvent(QShowEvent *event) {
|
|
JFJochHelperWindow::showEvent(event);
|
|
if (pending_fill) {
|
|
pending_fill = false;
|
|
fillTable();
|
|
}
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::fillTable() {
|
|
clearAllData();
|
|
highlighted_row = -1;
|
|
|
|
if (!dataset)
|
|
return;
|
|
|
|
for (int i = 0; i < dataset->experiment.GetImageNum(); i++) {
|
|
float bkg_estimate = 0;
|
|
if (dataset->bkg_estimate.size() > i)
|
|
bkg_estimate = dataset->bkg_estimate[i];
|
|
|
|
int32_t spot_count = 0;
|
|
if (dataset->spot_count.size() > i)
|
|
spot_count = dataset->spot_count[i];
|
|
|
|
float res_estimation = 0.0f;
|
|
if (dataset->resolution_estimate.size() > i)
|
|
res_estimation = dataset->resolution_estimate[i];
|
|
|
|
QString indexing_result = "N/A";
|
|
if (dataset->indexing_result.size() > i) {
|
|
if (dataset->indexing_result[i] == 0)
|
|
indexing_result = "No";
|
|
else
|
|
indexing_result = "Yes";
|
|
}
|
|
|
|
QString merge_result = "N/A";
|
|
if (dataset->merge_result.size() > i)
|
|
merge_result = dataset->merge_result[i] == 0 ? "No" : "Yes";
|
|
|
|
int64_t max_value = 0;
|
|
if (dataset->max_value.size() > i)
|
|
max_value = dataset->max_value[i];
|
|
|
|
double image_scale_factor = NAN;
|
|
if (dataset->image_scale_factor.size() > i)
|
|
image_scale_factor = dataset->image_scale_factor[i];
|
|
|
|
double image_scale_cc_percent = NAN;
|
|
if (dataset->image_scale_cc.size() > i)
|
|
image_scale_cc_percent = dataset->image_scale_cc[i] * 100.0;
|
|
|
|
addDataRow(i + 1,
|
|
bkg_estimate,
|
|
indexing_result,
|
|
merge_result,
|
|
spot_count,
|
|
res_estimation,
|
|
max_value,
|
|
image_scale_factor,
|
|
image_scale_cc_percent);
|
|
}
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::setRowBackground(int row, const QBrush &brush) {
|
|
if (row < 0 || row >= tableModel->rowCount())
|
|
return;
|
|
for (int col = 0; col < tableModel->columnCount(); ++col) {
|
|
if (QStandardItem *item = tableModel->item(row, col))
|
|
item->setBackground(brush);
|
|
}
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::imageLoaded(std::shared_ptr<const JFJochReaderImage> image) {
|
|
int curr_row = -1;
|
|
if (image)
|
|
curr_row = image->ImageData().number;
|
|
|
|
if (curr_row == highlighted_row)
|
|
return;
|
|
|
|
// Only the row losing the highlight and the row gaining it change. Repainting every cell
|
|
// emitted dataChanged for the whole model - and a proxy re-sort - on each frame.
|
|
setRowBackground(highlighted_row, QBrush()); // back to the palette's own
|
|
// A translucent wash of the palette's highlight, so the text keeps its own colour and stays
|
|
// readable on the light and the dark palette alike.
|
|
QColor wash = palette().color(QPalette::Highlight);
|
|
wash.setAlpha(90);
|
|
setRowBackground(curr_row, wash);
|
|
highlighted_row = curr_row;
|
|
}
|
|
|
|
void JFJochViewerImageListWindow::onTableRowDoubleClicked(const QModelIndex &index) {
|
|
if (!index.isValid())
|
|
return;
|
|
|
|
QModelIndex sourceIndex = proxyModel->mapToSource(index);
|
|
int imageNumber = tableModel->item(sourceIndex.row(), 0)->data(Qt::DisplayRole).toInt();
|
|
emit imageSelected(imageNumber - 1, 1);
|
|
}
|