Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global reference domain for offline analysis #2154

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading