Commit 630680b4 authored by Tobias Weber's avatar Tobias Weber

Merge branch 'gui_cleanup' into 'develop'

Tidying up some GUI elements

Closes #150

See merge request !144
parents 0315cacc 34a438c7
Pipeline #24256 passed with stage
in 28 minutes and 32 seconds
......@@ -57,6 +57,7 @@ AutoIndexer::AutoIndexer() : _solutions(), _handler(nullptr)
void AutoIndexer::autoIndex(const std::vector<Peak3D*>& peaks)
{
_params.log(Level::Info);
// Find the Q-space directions along which the projection of the the Q-vectors
// shows the highest periodicity
computeFFTSolutions(peaks);
......@@ -76,7 +77,6 @@ void AutoIndexer::autoIndex(const std::vector<Peak3D*>& peaks)
void AutoIndexer::autoIndex(PeakCollection* peaks)
{
nsxlog(Level::Info, "AutoIndexer::autoindex: indexing PeakCollection", peaks->name());
_params.log(Level::Info);
std::vector<Peak3D*> peak_list = peaks->getPeakList();
autoIndex(peak_list);
}
......
......@@ -91,8 +91,11 @@ void IntegrationHandler::integratePeaks(
std::vector<Peak3D*> peaks = peak_collection->getFilteredPeakList();
const DataMap* data = _data_handler->getDataMap();
integrator->setNNumors(data->size());
int n_numor = 1;
for (DataMap::const_iterator it = data->begin(); it != data->end(); ++it) {
integrator->integrate(peaks, peak_collection->shapeLibrary(), it->second);
integrator->integrate(peaks, peak_collection->shapeLibrary(), it->second, n_numor);
++n_numor;
}
}
......@@ -111,8 +114,11 @@ void IntegrationHandler::integratePredictedPeaks(
std::vector<Peak3D*> peaks = peak_collection->getFilteredPeakList();
const DataMap* data = _data_handler->getDataMap();
integrator->setNNumors(data->size());
int n_numor = 1;
for (DataMap::const_iterator it = data->begin(); it != data->end(); ++it) {
integrator->integrate(peaks, shape_library, it->second);
integrator->integrate(peaks, shape_library, it->second, n_numor);
++n_numor;
}
}
......@@ -120,9 +126,13 @@ void IntegrationHandler::integrateFoundPeaks(std::string integrator_name, PeakFi
{
nsxlog(Level::Info, "IntegrationHandler::integrateFoundPeaks");
IPeakIntegrator* integrator = getIntegrator(integrator_name);
const DataMap* data = _data_handler->getDataMap();
integrator->setNNumors(data->size());
int n_numor = 1;
for (sptrDataSet data : peak_finder->currentData()) {
integrator->integrate(peak_finder->currentPeaks(), nullptr, data);
integrator->integrate(peak_finder->currentPeaks(), nullptr, data, n_numor);
++n_numor;
}
}
......@@ -135,11 +145,15 @@ ShapeLibrary& IntegrationHandler::integrateShapeLibrary(
integrator.setParameters(params);
const DataMap* data = _data_handler->getDataMap();
integrator.setNNumors(data->size());
// TODO: (zamaan) change numors to a argument of buildShapeLibrary
// Right now, there is no metadata for which DataSet was used to
// Generate the peak collection
for (auto const& [key, data] : *data)
integrator.integrate(fit_peaks, shape_library, data);
int n_numor = 1;
for (auto const& [key, data] : *data) {
integrator.integrate(fit_peaks, shape_library, data, n_numor);
++n_numor;
}
return *shape_library;
}
......
......@@ -254,11 +254,15 @@ void PeakFinder::mergeCollidingBlobs(const DataSet& data, std::map<int, Blob3D>&
void PeakFinder::findPrimaryBlobs(
const DataSet& data, std::map<int, Blob3D>& blobs, nsx::EquivalenceList& equivalences,
size_t begin, size_t end)
size_t begin, size_t end, int n_numor)
{
int n_numors = _current_data.size();
std::ostringstream oss;
oss << "Finding blobs for numor " << n_numor+1 << " of " << n_numors;
// update via handler if necessary
if (_handler) {
_handler->setStatus("Finding blobs...");
_handler->setStatus(oss.str().c_str());
_handler->setProgress(0);
}
......@@ -628,7 +632,7 @@ void PeakFinder::find(const DataList numors)
// find blobs within the current frame range
nsxlog(Level::Debug, "PeakFinder::find: findPrimary from", loop_begin, "to", loop_end);
findPrimaryBlobs(*numor, local_blobs, local_equivalences, loop_begin, loop_end);
findPrimaryBlobs(*numor, local_blobs, local_equivalences, loop_begin, loop_end, i);
// merge adjacent blobs
nsxlog(Level::Debug, "PeakFinder::find: mergeBlobs");
......
......@@ -78,7 +78,7 @@ class PeakFinder {
void findPrimaryBlobs(
const DataSet& data, std::map<int, Blob3D>& blobs, EquivalenceList& equivalences,
size_t begin, size_t end);
size_t begin, size_t end, int n_numor);
void findCollisions(
const DataSet& data, std::map<int, Blob3D>& blobs, EquivalenceList& equivalences) const;
......
......@@ -57,17 +57,21 @@ const std::vector<Intensity>& IPeakIntegrator::rockingCurve() const
}
void IPeakIntegrator::integrate(
std::vector<nsx::Peak3D*> peaks, ShapeLibrary* shape_library, sptrDataSet data)
std::vector<nsx::Peak3D*> peaks, ShapeLibrary* shape_library, sptrDataSet data,
int n_numor)
{
// integrate only those peaks that belong to the specified dataset
auto it = std::remove_if(peaks.begin(), peaks.end(), [&](const Peak3D* peak) {
return peak->dataSet() != data;
});
peaks.erase(it, peaks.end());
std::ostringstream oss;
std::string status = "Integrating " + std::to_string(peaks.size()) + " peaks...";
oss << "Integrating " << peaks.size() << " peaks in numor "<< n_numor
<< " of " << _n_numors;
nsxlog(Level::Info, "IPeakIntegrator::integrate: integrating", peaks.size(), "peaks");
if (_handler) {
_handler->setStatus(status.c_str());
_handler->setStatus(oss.str().c_str());
_handler->setProgress(0);
}
......@@ -174,4 +178,9 @@ void IPeakIntegrator::setParameters(const IntegrationParameters& params)
_params.log(Level::Info);
}
void IPeakIntegrator::setNNumors(int n_numors)
{
_n_numors = n_numors;
}
} // namespace nsx
......@@ -48,7 +48,8 @@ class IPeakIntegrator {
//! @param peak_end Peak boundary (in sigma)
//! @param bkg_begin Background beginning (in sigma)
//! @param bkg_end Background end (in sigma)
void integrate(std::vector<nsx::Peak3D*> peaks, ShapeLibrary* shape_library, sptrDataSet data);
void integrate(std::vector<nsx::Peak3D*> peaks, ShapeLibrary* shape_library,
sptrDataSet data, int n_numor);
//! Returns the mean background.
Intensity meanBackground() const;
//! Returns the integrated intensity.
......@@ -57,6 +58,8 @@ class IPeakIntegrator {
const std::vector<Intensity>& rockingCurve() const;
//! Sets the progress handler.
void setHandler(sptrProgressHandler handler);
//! Set the number of numors for progress handler
void setNNumors(int n_numors);
protected:
//! Mean local background of peak. The uncertainty is the uncertainty of the
......@@ -70,6 +73,8 @@ class IPeakIntegrator {
sptrProgressHandler _handler;
//! Container for user-defined integration parameters
IntegrationParameters _params;
//! Number of numors in the dataset to be integrated
int _n_numors;
public:
double peakEnd() const { return _params.peak_end; };
......
......@@ -39,7 +39,7 @@ PeakFilter::PeakFilter()
_unit_cell_tolerance = 0.2;
_strength = {1.0, 1000000.};
_d_range = {1.5, 50.0};
_frameRange = {1.0, 10.0};
_frameRange = {0.0, 10.0};
_significance = 0.9900;
_sparse = 100;
resetFilterFlags();
......
......@@ -110,7 +110,7 @@ void SubframeFilterPeaks::setInputUp()
exp_label->setAlignment(Qt::AlignRight);
_input_grid->addWidget(exp_label, 0, 0, 1, 1);
QLabel* list_label = new QLabel("Data-set");
QLabel* list_label = new QLabel("Peak collection");
list_label->setAlignment(Qt::AlignRight);
_input_grid->addWidget(list_label, 1, 0, 1, 1);
......@@ -303,12 +303,12 @@ void SubframeFilterPeaks::setFrameRangeUp()
frame_range_layout->addWidget(max_label, 1, 0, 1, 1);
_frame_min = new QDoubleSpinBox();
_frame_min->setMaximum(100);
_frame_min->setMaximum(10000);
_frame_min->setDecimals(0);
_frame_min->setValue(0.0000);
_frame_max = new QDoubleSpinBox();
_frame_max->setMaximum(100);
_frame_max->setMaximum(10000);
_frame_max->setDecimals(0);
_frame_max->setValue(10.00000);
......@@ -706,7 +706,6 @@ void SubframeFilterPeaks::filterPeaks()
std::ostringstream oss;
oss << n_caught << " of " << n_peaks << " peaks caught by filter";
QString new_title = QString::fromUtf8(oss.str().c_str());
std::cout << n_caught << " of " << n_peaks << " peaks caught by filter" << std::endl;
_preview_panel->setTitle(new_title);
refreshPeakTable();
......
......@@ -129,7 +129,6 @@ void PeakFinderFrame::setDataUp()
connect(
_exp_combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
[=]() {
qDebug() << "PeakFinderFrame::_exp_combo currentIndexChanged";
grabFinderParameters();
grabIntegrationParameters();
updateDatasetList();
......@@ -562,7 +561,6 @@ void PeakFinderFrame::grabFinderParameters()
void PeakFinderFrame::setFinderParameters()
{
qDebug() << "PeakFinderFrame::setFinderParameters";
nsx::PeakFinder* finder =
gSession->experimentAt(_exp_combo->currentIndex())->experiment()->peakFinder();
......
......@@ -13,6 +13,7 @@
// ***********************************************************************************************
#include "gui/subframe_index/SubframeAutoIndexer.h"
#include "base/utils/Logger.h"
#include "base/utils/ProgressHandler.h"
#include "base/utils/Units.h"
#include "core/algo/AutoIndexer.h"
......@@ -92,7 +93,7 @@ void SubframeAutoIndexer::setInputUp()
exp_label->setAlignment(Qt::AlignRight);
_input_grid->addWidget(exp_label, 0, 0, 1, 1);
QLabel* list_label = new QLabel("Data-set");
QLabel* list_label = new QLabel("Peak collection");
list_label->setAlignment(Qt::AlignRight);
_input_grid->addWidget(list_label, 1, 0, 1, 1);
......@@ -171,6 +172,11 @@ void SubframeAutoIndexer::setParametersUp()
para_grid->addWidget(label_ptr, 8, 0, 1, 1);
label_ptr->setSizePolicy(*_size_policy_widgets);
label_ptr = new QLabel("Frequency tol.:");
label_ptr->setAlignment(Qt::AlignRight);
para_grid->addWidget(label_ptr, 9, 0, 1, 1);
label_ptr->setSizePolicy(*_size_policy_widgets);
_gruber = new QDoubleSpinBox();
_niggli = new QDoubleSpinBox();
_only_niggli = new QCheckBox("Find Niggli cell only");
......@@ -180,6 +186,7 @@ void SubframeAutoIndexer::setParametersUp()
_number_subdivisions = new QSpinBox();
_min_cell_volume = new QDoubleSpinBox();
_indexing_tolerance = new QDoubleSpinBox();
_frequency_tolerance = new QDoubleSpinBox();
_gruber->setMaximumWidth(1000);
_gruber->setMaximum(100000);
......@@ -211,6 +218,10 @@ void SubframeAutoIndexer::setParametersUp()
_indexing_tolerance->setMaximum(100000);
_indexing_tolerance->setDecimals(6);
_frequency_tolerance->setMaximumWidth(1000);
_frequency_tolerance->setMaximum(1);
_frequency_tolerance->setDecimals(3);
_gruber->setSizePolicy(*_size_policy_widgets);
_niggli->setSizePolicy(*_size_policy_widgets);
_only_niggli->setSizePolicy(*_size_policy_widgets);
......@@ -220,6 +231,7 @@ void SubframeAutoIndexer::setParametersUp()
_number_subdivisions->setSizePolicy(*_size_policy_widgets);
_min_cell_volume->setSizePolicy(*_size_policy_widgets);
_indexing_tolerance->setSizePolicy(*_size_policy_widgets);
_frequency_tolerance->setSizePolicy(*_size_policy_widgets);
para_grid->addWidget(_gruber, 0, 1, 1, 1);
para_grid->addWidget(_niggli, 1, 1, 1, 1);
......@@ -230,6 +242,7 @@ void SubframeAutoIndexer::setParametersUp()
para_grid->addWidget(_number_solutions, 6, 1, 1, 1);
para_grid->addWidget(_min_cell_volume, 7, 1, 1, 1);
para_grid->addWidget(_indexing_tolerance, 8, 1, 1, 1);
para_grid->addWidget(_frequency_tolerance, 9, 1, 1, 1);
_para_box->setContentLayout(*para_grid, true);
_para_box->setSizePolicy(*_size_policy_box);
......@@ -362,6 +375,7 @@ void SubframeAutoIndexer::grabIndexerParameters()
_number_solutions->setValue(parameters.nSolutions);
_max_cell_dimension->setValue(parameters.maxdim);
_indexing_tolerance->setValue(parameters.indexingTolerance);
_frequency_tolerance->setValue(parameters.frequencyTolerance);
_min_cell_volume->setValue(parameters.minUnitCellVolume);
}
......@@ -382,6 +396,7 @@ void SubframeAutoIndexer::setIndexerParameters() const
parameters.nSolutions = _number_solutions->value();
parameters.maxdim = _max_cell_dimension->value();
parameters.indexingTolerance = _indexing_tolerance->value();
parameters.frequencyTolerance = _frequency_tolerance->value();
parameters.minUnitCellVolume = _min_cell_volume->value();
auto_indexer->setParameters(parameters);
......@@ -410,7 +425,7 @@ void SubframeAutoIndexer::runAutoIndexer()
try {
auto_indexer->autoIndex(collection->getPeakList());
} catch (const std::exception& e) {
// gLogger->log("[ERROR] AutoIndex: " + QString::fromStdString(e.what()));
nsx::nsxlog(nsx::Level::Info, e.what());
return;
}
......
......@@ -111,6 +111,7 @@ class SubframeAutoIndexer : public QWidget {
QDoubleSpinBox* _max_cell_dimension;
QDoubleSpinBox* _min_cell_volume;
QDoubleSpinBox* _indexing_tolerance;
QDoubleSpinBox* _frequency_tolerance;
QSpinBox* _number_vertices;
QSpinBox* _number_solutions;
......
......@@ -317,19 +317,14 @@ void ShapeLibraryDialog::build()
params.bkg_end = bkg_end_val;
integrator.setParameters(params);
int n_numor = 1;
for (nsx::sptrDataSet data : _data) {
// gLogger->log(
// "[INFO]Fitting profiles in dataset " + QString::fromStdString(data->filename()));
integrator.integrate(fit_peaks, &_library, data);
integrator.integrate(fit_peaks, &_library, data, n_numor);
++n_numor;
}
// gLogger->log("[INFO]Done fitting profiles");
_library = *integrator.library();
// gLogger->log("[INFO]Updating peak shape model...");
_library.updateFit(1000); // This does nothing!! - zamaan
// gLogger->log("[INFO]Done, mean pearson is " + QString::number(_library.meanPearson()));
}
void ShapeLibraryDialog::calculate()
......
......@@ -100,7 +100,7 @@ void SubframePredictPeaks::setInputUp()
exp_label->setAlignment(Qt::AlignRight);
_input_grid->addWidget(exp_label, 0, 0, 1, 1);
QLabel* list_label = new QLabel("Data-set");
QLabel* list_label = new QLabel("Peak collection");
list_label->setAlignment(Qt::AlignRight);
_input_grid->addWidget(list_label, 1, 0, 1, 1);
......
......@@ -82,7 +82,7 @@ TEST_CASE("test/integrate/Test_6_12_38.cpp", "")
params.bkg_begin = 3.0;
params.bkg_end = 4.0;
integrator.setParameters(params);
integrator.integrate(peaks, nullptr, dataf);
integrator.integrate(peaks, nullptr, dataf, 1);
CHECK(peak.enabled() == true);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment