Skip to content

Commit 99c62e8

Browse files
authored
Merge pull request #2176 from SCIInstitute/scalars_fix
Fix bug where "Inconsistent number of particles" error is raised when using "Scalar Only" mode.
2 parents c78f80f + ebce6e9 commit 99c62e8

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

Studio/Analysis/AnalysisTool.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,6 @@ bool AnalysisTool::compute_stats() {
513513
shape->load_feature(DisplayMode::Reconstructed, target_feature);
514514
auto scalars = particles = shape->get_point_features(target_feature);
515515
// combine positions and scalars, interleave 3 positions for every scalar
516-
SW_LOG("positions.size() = {}, scalars.size() = {}", positions.size(), scalars.size());
517516
particles.resize(positions.size() + scalars.size());
518517
int num_particles = positions.size() / 3;
519518
for (int i = 0; i < num_particles; i++) {
@@ -1426,7 +1425,7 @@ void AnalysisTool::update_difference_particles() {
14261425
}
14271426

14281427
if (all_particles.size() != mean.size()) {
1429-
SW_ERROR("Inconsistent number of particles");
1428+
SW_ERROR("Inconsistent number of values in particle vector, {} vs. {}", all_particles.size(), mean.size());
14301429
return;
14311430
}
14321431

@@ -1446,7 +1445,7 @@ Eigen::VectorXd AnalysisTool::get_mean_shape_particles() {
14461445
if (pca_shape_plus_scalar_mode()) {
14471446
return extract_shape_only(stats_.get_mean());
14481447
} else if (pca_scalar_only_mode()) {
1449-
SW_LOG("Scalar only mode not implemented yet");
1448+
return construct_mean_shape();
14501449
}
14511450
return stats_.get_mean();
14521451
}

Studio/Job/ShapeScalarJob.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ ShapeScalarJob::ShapeScalarJob(QSharedPointer<Session> session, QString target_f
2525

2626
//---------------------------------------------------------------------------
2727
void ShapeScalarJob::run() {
28-
// SW_DEBUG("Running shape scalar job");
29-
3028
try {
3129
py::module np = py::module::import("numpy");
32-
3330
py::module sw = py::module::import("shapeworks");
3431

3532
if (job_type_ == JobType::MSE_Plot) {
@@ -54,7 +51,6 @@ void ShapeScalarJob::run() {
5451
image.loadFromData((const uchar*)png_raw_bytes.data(), png_raw_bytes.size(), "PNG");
5552
plot_ = QPixmap::fromImage(image);
5653
}
57-
// SW_DEBUG("End shape scalar job");
5854

5955
} catch (const std::exception& e) {
6056
SW_ERROR("Exception in shape scalar job: {}", e.what());
@@ -83,7 +79,6 @@ Eigen::VectorXd ShapeScalarJob::predict_shape(QSharedPointer<Session> session, Q
8379
Eigen::VectorXd ShapeScalarJob::predict(QSharedPointer<Session> session, QString target_feature,
8480
Eigen::MatrixXd target_values, Direction direction) {
8581
// blocking call to predict scalars for given target particles
86-
8782
auto job = QSharedPointer<ShapeScalarJob>::create(session, target_feature, target_values, JobType::Predict);
8883
job->set_quiet_mode(true);
8984
job->set_direction(direction);
@@ -92,7 +87,6 @@ Eigen::VectorXd ShapeScalarJob::predict(QSharedPointer<Session> session, QString
9287

9388
std::atomic_bool finished(false);
9489
connect(job.data(), &ShapeScalarJob::finished, [&] {
95-
SW_DEBUG("shape scalar predict job finished");
9690
prediction = job->get_prediction();
9791
finished = true;
9892
});

0 commit comments

Comments
 (0)