@@ -161,6 +161,23 @@ AnalysisTool::AnalysisTool(Preferences& prefs) : preferences_(prefs) {
161161
162162 connect (ui_->group_analysis_combo , qOverload<int >(&QComboBox::currentIndexChanged), this ,
163163 &AnalysisTool::group_analysis_combo_changed);
164+
165+ // when one is checked, turn the other off, connect these first
166+ connect (ui_->show_difference_to_predicted_scalar , &QPushButton::clicked, this , [this ]() {
167+ if (ui_->show_difference_to_predicted_scalar ->isChecked ()) {
168+ ui_->show_predicted_scalar ->setChecked (false );
169+ }
170+ });
171+ connect (ui_->show_predicted_scalar , &QPushButton::clicked, this , [this ]() {
172+ if (ui_->show_predicted_scalar ->isChecked ()) {
173+ ui_->show_difference_to_predicted_scalar ->setChecked (false );
174+ }
175+ });
176+
177+ connect (ui_->show_difference_to_predicted_scalar , &QPushButton::clicked, this ,
178+ &AnalysisTool::handle_samples_predicted_scalar_options);
179+ connect (ui_->show_predicted_scalar , &QPushButton::clicked, this ,
180+ &AnalysisTool::handle_samples_predicted_scalar_options);
164181}
165182
166183// ---------------------------------------------------------------------------
@@ -280,6 +297,9 @@ void AnalysisTool::set_session(QSharedPointer<Session> session) {
280297 ui_->group2_button ->setChecked (false );
281298 update_difference_particles ();
282299
300+ ui_->show_predicted_scalar ->setChecked (false );
301+ ui_->show_difference_to_predicted_scalar ->setChecked (false );
302+
283303 connect (ui_->show_good_bad , &QCheckBox::toggled, session_.data (), &Session::set_show_good_bad_particles);
284304}
285305
@@ -1091,6 +1111,11 @@ void AnalysisTool::reset_stats() {
10911111 ui_->pca_scalar_combo ->addItem (QString::fromStdString (feature));
10921112 }
10931113 }
1114+ bool has_scalars = ui_->pca_scalar_combo ->count () > 0 ;
1115+ if (!has_scalars) {
1116+ ui_->show_difference_to_predicted_scalar ->setChecked (false );
1117+ }
1118+ ui_->show_difference_to_predicted_scalar ->setEnabled (has_scalars);
10941119
10951120 ui_->shape_scalar_groupbox ->setVisible (ui_->pca_scalar_combo ->count () > 0 );
10961121}
@@ -1303,6 +1328,15 @@ std::string AnalysisTool::get_display_feature_map() {
13031328 }
13041329 }
13051330
1331+ if (get_analysis_mode () == AnalysisTool::MODE_ALL_SAMPLES_C &&
1332+ ui_->show_difference_to_predicted_scalar ->isChecked ()) {
1333+ return " predicted_scalar_diff" ;
1334+ }
1335+
1336+ if (get_analysis_mode () == AnalysisTool::MODE_ALL_SAMPLES_C && ui_->show_predicted_scalar ->isChecked ()) {
1337+ return " predicted_scalar" ;
1338+ }
1339+
13061340 return feature_map_;
13071341}
13081342
@@ -1763,6 +1797,11 @@ void AnalysisTool::change_pca_analysis_type() {
17631797 ui_->pca_predict_scalar ->setEnabled (ui_->pca_scalar_shape_only ->isChecked ());
17641798 ui_->pca_predict_shape ->setEnabled (ui_->pca_scalar_only ->isChecked ());
17651799
1800+ if (ui_->pca_predict_scalar ->isChecked ()) {
1801+ // set the feature map to the target feature
1802+ session_->set_feature_map (ui_->pca_scalar_combo ->currentText ().toStdString ());
1803+ }
1804+
17661805 compute_stats ();
17671806 Q_EMIT pca_update ();
17681807}
@@ -1785,6 +1824,30 @@ Eigen::VectorXd AnalysisTool::construct_mean_shape() {
17851824 return mean_shape;
17861825}
17871826
1827+ // ---------------------------------------------------------------------------
1828+ void AnalysisTool::handle_samples_predicted_scalar_options () {
1829+ if (ui_->show_difference_to_predicted_scalar ->isChecked () || ui_->show_predicted_scalar ->isChecked ()) {
1830+ // iterate over all samples, predict scalars, compute the difference and store as a new scalar field
1831+ auto shapes = session_->get_non_excluded_shapes ();
1832+ for (auto & shape : shapes) {
1833+ auto particles = shape->get_particles ();
1834+ auto target_feature = ui_->pca_scalar_combo ->currentText ();
1835+ auto predicted =
1836+ ShapeScalarJob::predict_scalars (session_, target_feature, particles.get_combined_global_particles ());
1837+
1838+ // load the mesh and feature
1839+ shape->get_meshes (session_->get_display_mode (), true );
1840+ shape->load_feature (session_->get_display_mode (), target_feature.toStdString ());
1841+ auto scalars = shape->get_point_features (target_feature.toStdString ());
1842+ // compute difference
1843+ auto diff = predicted - scalars;
1844+ shape->set_point_features (" predicted_scalar_diff" , diff);
1845+ shape->set_point_features (" predicted_scalar" , predicted);
1846+ }
1847+ }
1848+ Q_EMIT update_view ();
1849+ }
1850+
17881851// ---------------------------------------------------------------------------
17891852void AnalysisTool::reconstruction_method_changed () {
17901853 ui_->reconstruction_options ->setVisible (ui_->distance_transform_radio_button ->isChecked ());
0 commit comments