diff --git a/common/PixelMask.cpp b/common/PixelMask.cpp index 42e8e9ee..c62a1d52 100644 --- a/common/PixelMask.cpp +++ b/common/PixelMask.cpp @@ -159,27 +159,24 @@ void PixelMask::LoadDetectorBadPixelMask(const DiffractionExperiment &experiment CalcEdgePixels(experiment); } - PixelMaskStatistics PixelMask::GetStatistics() const { PixelMaskStatistics ret{}; for (const auto &i: mask) { - - if (mask[i] & (1 << ModuleGapPixelBit)) + if (i & (1 << ModuleGapPixelBit)) ret.module_gap_pixel++; else { - if (mask[i] != 0) + if (i != 0) ret.total_masked++; - if (mask[i] & (1 << ErrorPixelBit)) + if (i & (1 << ErrorPixelBit)) ret.error_pixel++; - if (mask[i] & (1 << NoisyPixelBit)) + if (i & (1 << NoisyPixelBit)) ret.noisy_pixel++; - if (mask[i] & (1 << UserMaskedPixelBit)) + if (i & (1 << UserMaskedPixelBit)) ret.user_mask++; - if (mask[i] & ((1 << ChipGapPixelBit) | (1 << ModuleEdgePixelBit))) + if (i & ((1 << ChipGapPixelBit) | (1 << ModuleEdgePixelBit))) ret.chip_gap_pixel++; } } - return ret; } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e1c6a134..a5951b82 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,8 @@ This is an UNSTABLE release and not recommended for production use (please use r * jfjoch_broker: For DECTRIS detectors add dark data collection during initialization for bad pixel mask * jfjoch_broker: Refactor of calibration logic for more clear code (likely to introduce problems) +* jfjoch_viewer: Add option to handle user pixel mask (experimental) +* jfjoch_viewer: More options for ROI ## 1.0.0-rc.96 This is an UNSTABLE release. diff --git a/viewer/JFJochViewerImageROIStatistics.cpp b/viewer/JFJochViewerImageROIStatistics.cpp index 8c2a7028..a4013603 100644 --- a/viewer/JFJochViewerImageROIStatistics.cpp +++ b/viewer/JFJochViewerImageROIStatistics.cpp @@ -7,7 +7,7 @@ JFJochViewerImageROIStatistics::JFJochViewerImageROIStatistics(QWidget *parent) : QWidget(parent) { - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); box_radio = new QRadioButton("Box", this); layout->addWidget(box_radio); @@ -27,8 +27,10 @@ JFJochViewerImageROIStatistics::JFJochViewerImageROIStatistics(QWidget *parent) connect(box_radio, &QRadioButton::clicked, this, &JFJochViewerImageROIStatistics::BoxButtonClicked); connect(circle_radio, &QRadioButton::clicked, this, &JFJochViewerImageROIStatistics::CircleButtonClicked); - connect(box_settings, &JFJochViewerImageROIStatistics_Box::Updated, this, &JFJochViewerImageROIStatistics::BoxButtonClicked); - connect(circle_settings, &JFJochViewerImageROIStatistics_Circle::Updated, this, &JFJochViewerImageROIStatistics::CircleButtonClicked); + connect(box_settings, &JFJochViewerImageROIStatistics_Box::Updated, this, + &JFJochViewerImageROIStatistics::BoxButtonClicked); + connect(circle_settings, &JFJochViewerImageROIStatistics_Circle::Updated, this, + &JFJochViewerImageROIStatistics::CircleButtonClicked); circle_settings->Disable(); box_radio->setChecked(true); @@ -37,12 +39,12 @@ JFJochViewerImageROIStatistics::JFJochViewerImageROIStatistics(QWidget *parent) roi_label = new QLabel("", this); layout->addWidget(roi_label); - QPushButton* add_button = new QPushButton("Add ROI to user mask", this); - connect(add_button, &QPushButton::clicked, [this] () {emit AddROIToUserMask(); }); + QPushButton *add_button = new QPushButton("Add ROI to user mask", this); + connect(add_button, &QPushButton::clicked, [this]() { emit AddROIToUserMask(); }); layout->addWidget(add_button); - QPushButton* sub_button = new QPushButton("Subtract ROI from user mask", this); - connect(sub_button, &QPushButton::clicked, [this] () {emit SubtractROIFromUserMask(); }); + QPushButton *sub_button = new QPushButton("Subtract ROI from user mask", this); + connect(sub_button, &QPushButton::clicked, [this]() { emit SubtractROIFromUserMask(); }); layout->addWidget(sub_button); } @@ -57,11 +59,12 @@ void JFJochViewerImageROIStatistics::loadImage(std::shared_ptr(roi->sum) / roi_npixel; double variance = static_cast(roi->sum_square) / roi_npixel - roi_mean_val * roi_mean_val; - QString text = QString("Sum %1 Mean %2 Var %3 Max %4") - .arg(roi->sum) - .arg(QString::number(roi_mean_val, 'f', 3)) - .arg(QString::number(variance, 'f', 3)) - .arg(roi->max_count); + QString text = QString("Sum %1 Mean %2 Var %3 Max %4 Pixels %5") + .arg(roi->sum) + .arg(QString::number(roi_mean_val, 'f', 3)) + .arg(QString::number(variance, 'f', 3)) + .arg(roi->max_count) + .arg(roi->pixels); roi_label->setText(text); } else { roi_label->setText(""); @@ -96,4 +99,3 @@ void JFJochViewerImageROIStatistics::CircleButtonClicked() { auto tmp = circle_settings->GetROICircle(); emit ROICircleConfigured(tmp.x, tmp.y, tmp.r); } - diff --git a/viewer/JFJochViewerImageStatistics.cpp b/viewer/JFJochViewerImageStatistics.cpp index 1b2b50b1..5ea4d178 100644 --- a/viewer/JFJochViewerImageStatistics.cpp +++ b/viewer/JFJochViewerImageStatistics.cpp @@ -111,6 +111,9 @@ JFJochViewerImageStatistics::JFJochViewerImageStatistics(QWidget *parent) : QWid valid_values = new QLabel(this); layout->addRow(new QLabel("Valid values:"), valid_values); + masked_pixels = new QLabel(this); + layout->addRow(new QLabel("Masked pixels:"), masked_pixels); + spots = new QLabel(this); layout->addRow(new QLabel("Spots:"), spots); @@ -162,6 +165,8 @@ void JFJochViewerImageStatistics::loadImage(std::shared_ptrsetText(""); profile_radius->setText(""); res_estimate->setText(""); + masked_pixels->setText(""); + masked_pixels->setToolTip(""); return; } @@ -256,6 +261,25 @@ void JFJochViewerImageStatistics::loadImage(std::shared_ptrsetText("N/A"); } + float total_pixels = image->Dataset().experiment.GetPixelsNum(); + if (total_pixels == 0) + total_pixels = 1; + + auto mask_stats = image->Dataset().pixel_mask.GetStatistics(); + text = QString("%1").arg(mask_stats.total_masked); + masked_pixels->setText(text); + masked_pixels->setToolTip( + QString( + "Error pixels: %1 (%2 %)
Noisy pixels: %3 (%4 %)
User mask: %5 (%6 %)
" + "Chip gaps: %7 (%8 %)
" + "Non active area (module gap and fill): %9 (%10 %)") + .arg(mask_stats.error_pixel).arg(QString::number(mask_stats.error_pixel / total_pixels * 100.0, 'f', 1)) + .arg(mask_stats.noisy_pixel).arg(QString::number(mask_stats.noisy_pixel / total_pixels * 100.0, 'f', 1)) + .arg(mask_stats.user_mask).arg(QString::number(mask_stats.user_mask / total_pixels * 100.0, 'f', 1)) + .arg(mask_stats.chip_gap_pixel).arg(QString::number(mask_stats.chip_gap_pixel / total_pixels * 100.0, 'f', 1)) + .arg(mask_stats.module_gap_pixel).arg(QString::number(mask_stats.module_gap_pixel / total_pixels * 100.0, 'f', 1)) + ); + if (!image->Dataset().indexing_result.empty()) { QString tooltip; diff --git a/viewer/JFJochViewerImageStatistics.h b/viewer/JFJochViewerImageStatistics.h index e78fc2b4..c7d47d98 100644 --- a/viewer/JFJochViewerImageStatistics.h +++ b/viewer/JFJochViewerImageStatistics.h @@ -22,6 +22,7 @@ class JFJochViewerImageStatistics : public QWidget { QLabel *indexed; QLabel *bkg_estimate; QLabel *res_estimate; + QLabel *masked_pixels; QLabel *b_factor; QLabel *profile_radius;