Skip to content

Commit c817dbb

Browse files
authored
Merge pull request #2168 from SCIInstitute/2bpls
Shape/Scalar Correlation
2 parents 5e27f1f + d841cfa commit c817dbb

38 files changed

+1859
-780
lines changed

Libs/Analyze/Analyze.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace shapeworks {
1414

1515
//---------------------------------------------------------------------------
1616
static json get_eigen_vectors(ParticleShapeStatistics* stats) {
17-
auto values = stats->Eigenvectors();
17+
auto values = stats->get_eigen_vectors();
1818

1919
std::vector<double> vals;
2020
for (size_t i = values.cols() - 1, ii = 0; i > 0; i--, ii++) {
@@ -173,8 +173,8 @@ void Analyze::run_offline_analysis(std::string outfile, float range, float steps
173173
double increment = range / half_steps;
174174

175175
std::vector<double> eigen_vals;
176-
for (int i = stats_.Eigenvalues().size() - 1; i > 0; i--) {
177-
eigen_vals.push_back(stats_.Eigenvalues()[i]);
176+
for (int i = stats_.get_eigen_values().size() - 1; i > 0; i--) {
177+
eigen_vals.push_back(stats_.get_eigen_values()[i]);
178178
}
179179
double sum = std::accumulate(eigen_vals.begin(), eigen_vals.end(), 0.0);
180180

@@ -213,7 +213,7 @@ void Analyze::run_offline_analysis(std::string outfile, float range, float steps
213213
// export modes
214214
std::vector<json> modes;
215215
for (int mode = 0; mode < num_modes; mode++) {
216-
unsigned int m = stats_.Eigenvectors().cols() - (mode + 1);
216+
unsigned int m = stats_.get_eigen_vectors().cols() - (mode + 1);
217217
json jmode;
218218
jmode["mode"] = mode + 1;
219219
double eigen_value = eigen_vals[mode];
@@ -231,8 +231,8 @@ void Analyze::run_offline_analysis(std::string outfile, float range, float steps
231231
jmode["cumulative_explained_variance"] = cumulative_explained_variance;
232232
SW_LOG("explained_variance [{}]: {:.2f}", mode, explained_variance);
233233
SW_LOG("cumulative_explained_variance [{}]: {:.2f}", mode, cumulative_explained_variance);
234-
235-
double lambda = sqrt(stats_.Eigenvalues()[m]);
234+
235+
double lambda = sqrt(stats_.get_eigen_values()[m]);
236236

237237
std::vector<json> jmodes;
238238
for (int i = 1; i <= half_steps; i++) {
@@ -278,7 +278,7 @@ void Analyze::run_offline_analysis(std::string outfile, float range, float steps
278278
}
279279

280280
j["eigen_vectors"] = get_eigen_vectors(&stats_);
281-
j["eigen_values"] = stats_.Eigenvalues();
281+
j["eigen_values"] = stats_.get_eigen_values();
282282
j["modes"] = modes;
283283
j["charts"] = create_charts(&stats_);
284284

@@ -322,7 +322,7 @@ Particles Analyze::get_mean_shape_points() {
322322
return Particles();
323323
}
324324

325-
return convert_from_combined(stats_.Mean());
325+
return convert_from_combined(stats_.get_mean());
326326
}
327327

328328
//---------------------------------------------------------------------------
@@ -336,30 +336,30 @@ ShapeHandle Analyze::get_mean_shape() {
336336

337337
//---------------------------------------------------------------------------
338338
Particles Analyze::get_shape_points(int mode, double value) {
339-
if (!compute_stats() || stats_.Eigenvectors().size() <= 1) {
339+
if (!compute_stats() || stats_.get_eigen_vectors().size() <= 1) {
340340
return Particles();
341341
}
342-
if (mode + 2 > stats_.Eigenvalues().size()) {
343-
mode = stats_.Eigenvalues().size() - 2;
342+
if (mode + 2 > stats_.get_eigen_values().size()) {
343+
mode = stats_.get_eigen_values().size() - 2;
344344
}
345-
346-
unsigned int m = stats_.Eigenvectors().cols() - (mode + 1);
347-
348-
Eigen::VectorXd e = stats_.Eigenvectors().col(m);
349-
350-
double lambda = sqrt(stats_.Eigenvalues()[m]);
345+
346+
unsigned int m = stats_.get_eigen_vectors().cols() - (mode + 1);
347+
348+
Eigen::VectorXd e = stats_.get_eigen_vectors().col(m);
349+
350+
double lambda = sqrt(stats_.get_eigen_values()[m]);
351351

352352
std::vector<double> vals;
353-
for (int i = stats_.Eigenvalues().size() - 1; i > 0; i--) {
354-
vals.push_back(stats_.Eigenvalues()[i]);
353+
for (int i = stats_.get_eigen_values().size() - 1; i > 0; i--) {
354+
vals.push_back(stats_.get_eigen_values()[i]);
355355
}
356356
double sum = std::accumulate(vals.begin(), vals.end(), 0.0);
357357
double cumulation = 0;
358358
for (size_t i = 0; i < mode + 1; ++i) {
359359
cumulation += vals[i];
360360
}
361361

362-
auto temp_shape = stats_.Mean() + (e * (value * lambda));
362+
auto temp_shape = stats_.get_mean() + (e * (value * lambda));
363363

364364
return convert_from_combined(temp_shape);
365365
}
@@ -489,9 +489,9 @@ bool Analyze::compute_stats() {
489489
return false;
490490
}
491491
}
492-
493-
stats_.ImportPoints(points, group_ids);
494-
stats_.ComputeModes();
492+
493+
stats_.import_points(points, group_ids);
494+
stats_.compute_modes();
495495

496496
stats_ready_ = true;
497497
SW_LOG("Computed stats successfully");
@@ -522,7 +522,7 @@ Particles Analyze::convert_from_combined(const Eigen::VectorXd& points) {
522522

523523
//---------------------------------------------------------------------------
524524
void Analyze::initialize_mesh_warper() {
525-
int median = stats_.ComputeMedianShape(-32); //-32 = both groups
525+
int median = stats_.compute_median_shape(-32); //-32 = both groups
526526

527527
if (median < 0 || median >= get_shapes().size()) {
528528
SW_ERROR("Unable to set reference mesh, stats returned invalid median index");
@@ -555,9 +555,9 @@ void Analyze::initialize_mesh_warper() {
555555
int Analyze::get_num_subjects() { return shapes_.size(); }
556556

557557
//---------------------------------------------------------------------------
558-
Eigen::VectorXf Analyze::get_subject_features(int subject, std::string feature_name) {
558+
Eigen::VectorXd Analyze::get_subject_features(int subject, std::string feature_name) {
559559
if (subject >= shapes_.size()) {
560-
return Eigen::VectorXf();
560+
return Eigen::VectorXd();
561561
}
562562

563563
auto shape = shapes_[subject];
@@ -617,8 +617,8 @@ Particles Analyze::get_group_shape_particles(double ratio) {
617617
if (!compute_stats()) {
618618
return Particles();
619619
}
620-
621-
auto particles = stats_.Group1Mean() + (stats_.GroupDifference() * ratio);
620+
621+
auto particles = stats_.get_group1_mean() + (stats_.get_group_difference() * ratio);
622622

623623
return convert_from_combined(particles);
624624
}

Libs/Analyze/Analyze.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Analyze {
5757

5858
ShapeHandle create_shape_from_points(Particles points);
5959

60-
Eigen::VectorXf get_subject_features(int subject, std::string feature_name);
60+
Eigen::VectorXd get_subject_features(int subject, std::string feature_name);
6161

6262
void set_group_selection(std::string group_name, std::string group1, std::string group2);
6363

Libs/Analyze/Shape.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ void Shape::apply_feature_to_points(std::string feature, ImageType::Pointer imag
572572

573573
int num_points = all_locals.size() / 3;
574574

575-
Eigen::VectorXf values(num_points);
575+
Eigen::VectorXd values(num_points);
576576

577577
int idx = 0;
578578
for (int i = 0; i < num_points; ++i) {
@@ -615,7 +615,7 @@ void Shape::load_feature_from_mesh(std::string feature, MeshHandle mesh) {
615615

616616
int num_points = all_locals.size() / 3;
617617

618-
Eigen::VectorXf values(num_points);
618+
Eigen::VectorXd values(num_points);
619619

620620
vtkDataArray* from_array = from_mesh->GetPointData()->GetArray(feature.c_str());
621621
if (!from_array) {
@@ -639,10 +639,10 @@ void Shape::load_feature_from_mesh(std::string feature, MeshHandle mesh) {
639639
}
640640

641641
//---------------------------------------------------------------------------
642-
Eigen::VectorXf Shape::get_point_features(std::string feature) {
642+
Eigen::VectorXd Shape::get_point_features(std::string feature) {
643643
auto it = point_features_.find(feature);
644644
if (it == point_features_.end()) {
645-
return Eigen::VectorXf();
645+
return Eigen::VectorXd();
646646
}
647647

648648
return it->second;
@@ -683,7 +683,7 @@ std::vector<vtkSmartPointer<vtkTransform>> Shape::get_procrustes_transforms() {
683683
}
684684

685685
//---------------------------------------------------------------------------
686-
void Shape::set_point_features(std::string feature, Eigen::VectorXf values) {
686+
void Shape::set_point_features(std::string feature, Eigen::VectorXd values) {
687687
point_features_[feature] = values;
688688

689689
auto group = get_meshes(DisplayMode::Reconstructed);
@@ -778,7 +778,7 @@ void Shape::load_feature_from_scalar_file(std::string filename, std::string feat
778778
floats.push_back(line);
779779
}
780780

781-
Eigen::VectorXf values(floats.size());
781+
Eigen::VectorXd values(floats.size());
782782
for (int i = 0; i < floats.size(); i++) {
783783
values[i] = floats[i];
784784
}

Libs/Analyze/Shape.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ class Shape {
158158

159159
std::shared_ptr<Image> get_image_volume(std::string image_volume_name);
160160

161-
Eigen::VectorXf get_point_features(std::string feature);
161+
Eigen::VectorXd get_point_features(std::string feature);
162162

163-
void set_point_features(std::string feature, Eigen::VectorXf values);
163+
void set_point_features(std::string feature, Eigen::VectorXd values);
164164

165165
void load_feature_from_scalar_file(std::string filename, std::string feature_name);
166166

@@ -198,7 +198,7 @@ class Shape {
198198
std::vector<std::string> global_point_filenames_;
199199
std::vector<std::string> local_point_filenames_;
200200

201-
std::map<std::string, Eigen::VectorXf> point_features_;
201+
std::map<std::string, Eigen::VectorXd> point_features_;
202202
Particles particles_;
203203

204204
std::shared_ptr<shapeworks::Subject> subject_;

Libs/Analyze/StudioMesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void StudioMesh::apply_feature_map(std::string name, ImageType::Pointer image) {
7676

7777
//---------------------------------------------------------------------------
7878
void StudioMesh::interpolate_scalars_to_mesh(std::string name, Eigen::VectorXd positions,
79-
Eigen::VectorXf scalar_values) {
79+
Eigen::VectorXd scalar_values) {
8080
int num_points = positions.size() / 3;
8181
if (num_points == 0) {
8282
return;

Libs/Analyze/StudioMesh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class StudioMesh {
5454
void apply_scalars(MeshHandle mesh);
5555

5656
//! Interpolation scalars at positions to this mesh
57-
void interpolate_scalars_to_mesh(std::string name, Eigen::VectorXd positions, Eigen::VectorXf scalar_values);
57+
void interpolate_scalars_to_mesh(std::string name, Eigen::VectorXd positions, Eigen::VectorXd scalar_values);
5858

5959
//! Return the range of largest axis (e.g. 200 for an object that sits in 100x200x100)
6060
double get_largest_dimension_size();

0 commit comments

Comments
 (0)