From 16e526fdc04a50768133b70394c4d6ca2a9f807c Mon Sep 17 00:00:00 2001 From: Alan Morris Date: Sat, 21 Oct 2023 00:29:28 -0600 Subject: [PATCH 1/2] Fix mean shape and particle output directory. --- Libs/Analyze/Analyze.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Libs/Analyze/Analyze.cpp b/Libs/Analyze/Analyze.cpp index 033990a21f..2667156a20 100644 --- a/Libs/Analyze/Analyze.cpp +++ b/Libs/Analyze/Analyze.cpp @@ -193,14 +193,17 @@ void Analyze::run_offline_analysis(std::string outfile, float range, float steps for (int d = 0; d < num_domains; d++) { std::string domain_id = std::to_string(d); auto mesh = meshes.meshes()[d]; - std::string filename = "mean_shape_" + domain_id + ".vtk"; - Mesh(mesh->get_poly_data()).write(filename); - mean_meshes.push_back(filename); + std::string vtk_filename = "mean_shape_" + domain_id + ".vtk"; + auto filename = base / boost::filesystem::path(vtk_filename); - filename = "mean_shape_" + domain_id + ".pts"; + Mesh(mesh->get_poly_data()).write(filename.string()); + mean_meshes.push_back(vtk_filename); + + std::string particle_filename = "mean_shape_" + domain_id + ".pts"; + filename = base / boost::filesystem::path(particle_filename); auto local_particles = mean_shape->get_particles().get_local_particles(d); - Particles::save_particles_file(filename, local_particles); - mean_particles.push_back(filename); + Particles::save_particles_file(filename.string(), local_particles); + mean_particles.push_back(particle_filename); } json mean_meshes_item; mean_meshes_item["meshes"] = mean_meshes; From 55f5658032058c13a7b7eace25374648bec2f503 Mon Sep 17 00:00:00 2001 From: Alan Morris Date: Sat, 21 Oct 2023 00:37:55 -0600 Subject: [PATCH 2/2] Use global reference domain for offline analysis --- Libs/Analyze/Analyze.cpp | 8 ++++++++ Libs/Analyze/Analyze.h | 7 +++++++ Studio/Analysis/AnalysisTool.h | 7 +++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Libs/Analyze/Analyze.cpp b/Libs/Analyze/Analyze.cpp index 2667156a20..6e8286e7ea 100644 --- a/Libs/Analyze/Analyze.cpp +++ b/Libs/Analyze/Analyze.cpp @@ -387,6 +387,8 @@ bool Analyze::update_shapes() { SW_LOG("number of subjects: {}", num_subjects); + auto domain_names = project_->get_domain_names(); + for (int i = 0; i < num_subjects; i++) { auto shape = std::make_shared(); shape->set_mesh_manager(mesh_manager_); @@ -421,6 +423,12 @@ bool Analyze::update_shapes() { landmark_definitions = project_->get_landmarks(domain_id); } } + + // set reference domain + auto transform = shape->get_groomed_transform(domain_names.size()); + shape->set_particle_transform(transform); + shape->set_alignment_type(AlignmentType::Global); + shapes_.push_back(shape); } diff --git a/Libs/Analyze/Analyze.h b/Libs/Analyze/Analyze.h index a0aaf79e5f..b2ce4eb957 100644 --- a/Libs/Analyze/Analyze.h +++ b/Libs/Analyze/Analyze.h @@ -15,6 +15,13 @@ namespace shapeworks { class Analyze { public: + + enum AlignmentType { + Global = -2, + Local = -1, + }; + + Analyze(ProjectHandle project); /// Run offline analysis, saving results to outfile diff --git a/Studio/Analysis/AnalysisTool.h b/Studio/Analysis/AnalysisTool.h index 54ec2344dd..525606a8c9 100644 --- a/Studio/Analysis/AnalysisTool.h +++ b/Studio/Analysis/AnalysisTool.h @@ -9,6 +9,7 @@ // ShapeWorks #include +#include // Studio #include @@ -33,10 +34,8 @@ class AnalysisTool : public QWidget { Q_OBJECT; public: - enum AlignmentType { - Global = -2, - Local = -1, - }; + + using AlignmentType = Analyze::AlignmentType; enum GroupAnalysisType { None = 0, Pvalues = 1, NetworkAnalysis = 2, LDA = 3 };