|
11 | 11 | #include <Job/NetworkAnalysisJob.h> |
12 | 12 | #include <Job/ParticleNormalEvaluationJob.h> |
13 | 13 | #include <Job/StatsGroupLDAJob.h> |
| 14 | +#include <Job/StatsGroupDWDJob.h> |
14 | 15 | #include <Libs/Application/Job/PythonWorker.h> |
15 | 16 | #include <Groom/GroomParameters.h> |
16 | 17 | #include <Logging.h> |
@@ -168,6 +169,12 @@ AnalysisTool::AnalysisTool(Preferences& prefs) : preferences_(prefs) { |
168 | 169 | connect(group_lda_job_.data(), &StatsGroupLDAJob::progress, this, &AnalysisTool::handle_lda_progress); |
169 | 170 | connect(group_lda_job_.data(), &StatsGroupLDAJob::finished, this, &AnalysisTool::handle_lda_complete); |
170 | 171 |
|
| 172 | + ui_->dwd_graph->hide(); |
| 173 | + ui_->dwd_hint_label->hide(); |
| 174 | + group_dwd_job_ = QSharedPointer<StatsGroupDWDJob>::create(); |
| 175 | + connect(group_dwd_job_.data(), &StatsGroupDWDJob::progress, this, &AnalysisTool::handle_dwd_progress); |
| 176 | + connect(group_dwd_job_.data(), &StatsGroupDWDJob::finished, this, &AnalysisTool::handle_dwd_complete); |
| 177 | + |
171 | 178 | connect(ui_->show_difference_to_mean, &QPushButton::clicked, this, &AnalysisTool::show_difference_to_mean_clicked); |
172 | 179 |
|
173 | 180 | connect(ui_->group_analysis_combo, qOverload<int>(&QComboBox::currentIndexChanged), this, |
@@ -1620,6 +1627,24 @@ void AnalysisTool::update_lda_graph() { |
1620 | 1627 | } |
1621 | 1628 | } |
1622 | 1629 |
|
| 1630 | +//--------------------------------------------------------------------------- |
| 1631 | +void AnalysisTool::update_dwd_graph() { |
| 1632 | + if (groups_active()) { |
| 1633 | + if (!dwd_computed_ && !group_dwd_job_running_) { |
| 1634 | + group_dwd_job_running_ = true; |
| 1635 | + ui_->dwd_label->show(); |
| 1636 | + ui_->dwd_progress->setValue(0); |
| 1637 | + ui_->dwd_progress->setMaximum(0); |
| 1638 | + ui_->dwd_progress->update(); |
| 1639 | + group_dwd_job_->set_stats(stats_); |
| 1640 | + app_->get_py_worker()->run_job(group_dwd_job_); |
| 1641 | + } |
| 1642 | + } else { |
| 1643 | + ui_->dwd_graph->setVisible(false); |
| 1644 | + ui_->dwd_hint_label->setVisible(false); |
| 1645 | + } |
| 1646 | +} |
| 1647 | + |
1623 | 1648 | //--------------------------------------------------------------------------- |
1624 | 1649 | void AnalysisTool::update_difference_particles() { |
1625 | 1650 | if (!stats_ready_) { |
@@ -1679,7 +1704,10 @@ void AnalysisTool::group_changed() { |
1679 | 1704 | stats_ready_ = false; |
1680 | 1705 | group_pvalue_job_ = nullptr; |
1681 | 1706 | lda_computed_ = false; |
| 1707 | + dwd_computed_ = false; |
1682 | 1708 | compute_stats(); |
| 1709 | + // Re-trigger LDA/DWD if currently visible |
| 1710 | + group_analysis_combo_changed(); |
1683 | 1711 | } |
1684 | 1712 |
|
1685 | 1713 | //--------------------------------------------------------------------------- |
@@ -1909,12 +1937,64 @@ void AnalysisTool::handle_lda_complete() { |
1909 | 1937 | QString left_group = ui_->group_left->currentText(); |
1910 | 1938 | QString right_group = ui_->group_right->currentText(); |
1911 | 1939 |
|
| 1940 | + if (!group_lda_job_->succeeded()) { |
| 1941 | + ui_->lda_graph->setVisible(false); |
| 1942 | + if (left_group == right_group) { |
| 1943 | + ui_->lda_hint_label->setText("LDA requires two distinct groups."); |
| 1944 | + } else { |
| 1945 | + ui_->lda_hint_label->setText("LDA computation failed. Check log for details."); |
| 1946 | + } |
| 1947 | + ui_->lda_hint_label->setVisible(true); |
| 1948 | + QTimer::singleShot(0, this, &AnalysisTool::resize_tab_to_current); |
| 1949 | + return; |
| 1950 | + } |
| 1951 | + |
1912 | 1952 | group_lda_job_->plot(ui_->lda_graph, left_group, right_group); |
1913 | 1953 | ui_->lda_graph->setVisible(true); |
1914 | 1954 | ui_->lda_hint_label->setVisible(true); |
1915 | 1955 | QTimer::singleShot(0, this, &AnalysisTool::resize_tab_to_current); |
1916 | 1956 | } |
1917 | 1957 |
|
| 1958 | +//--------------------------------------------------------------------------- |
| 1959 | +void AnalysisTool::handle_dwd_progress(double progress) { |
| 1960 | + if (progress > 0) { |
| 1961 | + ui_->dwd_progress->setMaximum(100); |
| 1962 | + } else { |
| 1963 | + ui_->dwd_progress->setMaximum(0); |
| 1964 | + } |
| 1965 | + ui_->dwd_progress_widget->setVisible(progress < 1); |
| 1966 | + ui_->dwd_progress->setValue(progress * 100); |
| 1967 | + ui_->dwd_progress->update(); |
| 1968 | +} |
| 1969 | + |
| 1970 | +//--------------------------------------------------------------------------- |
| 1971 | +void AnalysisTool::handle_dwd_complete() { |
| 1972 | + ui_->dwd_progress_widget->setVisible(false); |
| 1973 | + ui_->dwd_label->setVisible(false); |
| 1974 | + group_dwd_job_running_ = false; |
| 1975 | + dwd_computed_ = true; |
| 1976 | + |
| 1977 | + QString left_group = ui_->group_left->currentText(); |
| 1978 | + QString right_group = ui_->group_right->currentText(); |
| 1979 | + |
| 1980 | + if (!group_dwd_job_->succeeded()) { |
| 1981 | + ui_->dwd_graph->setVisible(false); |
| 1982 | + if (left_group == right_group) { |
| 1983 | + ui_->dwd_hint_label->setText("DWD requires two distinct groups."); |
| 1984 | + } else { |
| 1985 | + ui_->dwd_hint_label->setText("DWD computation failed. Check log for details."); |
| 1986 | + } |
| 1987 | + ui_->dwd_hint_label->setVisible(true); |
| 1988 | + QTimer::singleShot(0, this, &AnalysisTool::resize_tab_to_current); |
| 1989 | + return; |
| 1990 | + } |
| 1991 | + |
| 1992 | + group_dwd_job_->plot(ui_->dwd_graph, left_group, right_group); |
| 1993 | + ui_->dwd_graph->setVisible(true); |
| 1994 | + ui_->dwd_hint_label->setVisible(true); |
| 1995 | + QTimer::singleShot(0, this, &AnalysisTool::resize_tab_to_current); |
| 1996 | +} |
| 1997 | + |
1918 | 1998 | void AnalysisTool::handle_network_analysis_progress(int progress) { |
1919 | 1999 | if (progress > 0) { |
1920 | 2000 | ui_->network_progress->setMaximum(100); |
@@ -1960,6 +2040,9 @@ void AnalysisTool::group_analysis_combo_changed() { |
1960 | 2040 | if (ui_->group_analysis_stacked_widget->currentWidget() == ui_->lda_page) { |
1961 | 2041 | update_lda_graph(); |
1962 | 2042 | } |
| 2043 | + if (ui_->group_analysis_stacked_widget->currentWidget() == ui_->dwd_page) { |
| 2044 | + update_dwd_graph(); |
| 2045 | + } |
1963 | 2046 | } |
1964 | 2047 | // Recalculate tab height since analysis content changed |
1965 | 2048 | QTimer::singleShot(0, this, &AnalysisTool::resize_tab_to_current); |
|
0 commit comments