Skip to content

Commit

Permalink
Merge pull request #2176 from SCIInstitute/scalars_fix
Browse files Browse the repository at this point in the history
Fix bug where "Inconsistent number of particles" error is raised when using "Scalar Only" mode.
  • Loading branch information
akenmorris committed Dec 11, 2023
2 parents c78f80f + ebce6e9 commit 99c62e8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
5 changes: 2 additions & 3 deletions Studio/Analysis/AnalysisTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ bool AnalysisTool::compute_stats() {
shape->load_feature(DisplayMode::Reconstructed, target_feature);
auto scalars = particles = shape->get_point_features(target_feature);
// combine positions and scalars, interleave 3 positions for every scalar
SW_LOG("positions.size() = {}, scalars.size() = {}", positions.size(), scalars.size());
particles.resize(positions.size() + scalars.size());
int num_particles = positions.size() / 3;
for (int i = 0; i < num_particles; i++) {
Expand Down Expand Up @@ -1426,7 +1425,7 @@ void AnalysisTool::update_difference_particles() {
}

if (all_particles.size() != mean.size()) {
SW_ERROR("Inconsistent number of particles");
SW_ERROR("Inconsistent number of values in particle vector, {} vs. {}", all_particles.size(), mean.size());
return;
}

Expand All @@ -1446,7 +1445,7 @@ Eigen::VectorXd AnalysisTool::get_mean_shape_particles() {
if (pca_shape_plus_scalar_mode()) {
return extract_shape_only(stats_.get_mean());
} else if (pca_scalar_only_mode()) {
SW_LOG("Scalar only mode not implemented yet");
return construct_mean_shape();
}
return stats_.get_mean();
}
Expand Down
6 changes: 0 additions & 6 deletions Studio/Job/ShapeScalarJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ ShapeScalarJob::ShapeScalarJob(QSharedPointer<Session> session, QString target_f

//---------------------------------------------------------------------------
void ShapeScalarJob::run() {
// SW_DEBUG("Running shape scalar job");

try {
py::module np = py::module::import("numpy");

py::module sw = py::module::import("shapeworks");

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

} catch (const std::exception& e) {
SW_ERROR("Exception in shape scalar job: {}", e.what());
Expand Down Expand Up @@ -83,7 +79,6 @@ Eigen::VectorXd ShapeScalarJob::predict_shape(QSharedPointer<Session> session, Q
Eigen::VectorXd ShapeScalarJob::predict(QSharedPointer<Session> session, QString target_feature,
Eigen::MatrixXd target_values, Direction direction) {
// blocking call to predict scalars for given target particles

auto job = QSharedPointer<ShapeScalarJob>::create(session, target_feature, target_values, JobType::Predict);
job->set_quiet_mode(true);
job->set_direction(direction);
Expand All @@ -92,7 +87,6 @@ Eigen::VectorXd ShapeScalarJob::predict(QSharedPointer<Session> session, QString

std::atomic_bool finished(false);
connect(job.data(), &ShapeScalarJob::finished, [&] {
SW_DEBUG("shape scalar predict job finished");
prediction = job->get_prediction();
finished = true;
});
Expand Down

0 comments on commit 99c62e8

Please sign in to comment.