Skip to content

Commit

Permalink
Merge pull request #2154 from SCIInstitute/analysis_fixes
Browse files Browse the repository at this point in the history
Global reference domain for offline analysis
  • Loading branch information
akenmorris authored Oct 24, 2023
2 parents 16aa10b + 55f5658 commit 79c277a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
23 changes: 17 additions & 6 deletions Libs/Analyze/Analyze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -384,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>();
shape->set_mesh_manager(mesh_manager_);
Expand Down Expand Up @@ -418,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);
}

Expand Down
7 changes: 7 additions & 0 deletions Libs/Analyze/Analyze.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions Studio/Analysis/AnalysisTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// ShapeWorks
#include <ParticleShapeStatistics.h>
#include <Analyze/Analyze.h>

// Studio
#include <Analysis/ShapeEvaluationJob.h>
Expand All @@ -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 };

Expand Down

0 comments on commit 79c277a

Please sign in to comment.