Skip to content

Commit

Permalink
Merge pull request #2141 from SCIInstitute/studio_fixed_domains
Browse files Browse the repository at this point in the history
Studio fixed domains
  • Loading branch information
akenmorris authored Sep 4, 2023
2 parents 86b1678 + 4bbe65f commit ef7dceb
Show file tree
Hide file tree
Showing 29 changed files with 510 additions and 337 deletions.
12 changes: 5 additions & 7 deletions Examples/Python/deep_ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def Run_Pipeline(args):
The required grooming steps are:
1. Load mesh
2. Apply clipping with planes for finding alignment transform
3. Find reflection tansfrom
3. Find reflection transfrom
4. Select reference mesh
5. Find rigid alignment transform
For more information on grooming see docs/workflow/groom.md
Expand Down Expand Up @@ -479,7 +479,8 @@ def Run_Pipeline(args):
transform = [ train_transforms[i].flatten() ]
subject.set_groomed_transforms(transform)
subject.set_constraints_filenames(rel_plane_files)
subject.set_landmarks_filenames([train_local_particles[i]])
subject.set_local_particle_filenames([train_local_particles[i]])
subject.set_world_particle_filenames([train_local_particles[i]])
subject.set_extra_values({"fixed": "yes"})
subjects.append(subject)
# Add new validation shapes
Expand All @@ -500,7 +501,8 @@ def Run_Pipeline(args):
transform = [ val_transforms[i].flatten() ]
subject.set_groomed_transforms(transform)
subject.set_constraints_filenames(rel_plane_files)
subject.set_landmarks_filenames(rel_particle_files)
subject.set_local_particle_filenames(rel_particle_files)
subject.set_world_particle_filenames(rel_particle_files)
subject.set_extra_values({"fixed": "no"})
subjects.append(subject)
project = sw.Project()
Expand All @@ -512,11 +514,7 @@ def Run_Pipeline(args):
parameter_dictionary["procrustes"] = 0
parameter_dictionary["procrustes_interval"] = 0
parameter_dictionary["procrustes_scaling"] = 0
parameter_dictionary["use_landmarks"] = 1
parameter_dictionary["use_fixed_subjects"] = 1
parameter_dictionary["narrow_band"] = 1e10
parameter_dictionary["fixed_subjects_column"] = "fixed"
parameter_dictionary["fixed_subjects_choice"] = "yes"
for key in parameter_dictionary:
parameters.set(key, sw.Variant(parameter_dictionary[key]))
project.set_parameters("optimize", parameters)
Expand Down
11 changes: 5 additions & 6 deletions Examples/Python/ellipsoid_fd.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def Run_Pipeline(args):
rel_particle_files = sw.utils.get_relative_paths([os.getcwd() + "/" + fixed_local_particles[i]], project_location)
subject.set_original_filenames(original_groom_files)
subject.set_groomed_filenames(rel_groom_files)
subject.set_landmarks_filenames(rel_particle_files)
subject.set_local_particle_filenames(rel_particle_files)
subject.set_world_particle_filenames(rel_particle_files)
subject.set_extra_values({"fixed": "yes"})
subjects.append(subject)

Expand All @@ -135,7 +136,8 @@ def Run_Pipeline(args):
rel_particle_files = sw.utils.get_relative_paths([os.getcwd() + "/" + mean_shape_path], project_location)
subject.set_original_filenames(original_groom_files)
subject.set_groomed_filenames(rel_groom_files)
subject.set_landmarks_filenames(rel_particle_files)
subject.set_local_particle_filenames(rel_particle_files)
subject.set_world_particle_filenames(rel_particle_files)
subject.set_extra_values({"fixed": "no"})
subjects.append(subject)

Expand All @@ -160,11 +162,7 @@ def Run_Pipeline(args):
"procrustes_scaling": 0,
"save_init_splits": 0,
"verbosity": 0,
"use_landmarks": 1,
"use_fixed_subjects": 1,
"narrow_band": 1e10,
"fixed_subjects_column": "fixed",
"fixed_subjects_choice": "yes"
}

for key in parameter_dictionary:
Expand All @@ -186,6 +184,7 @@ def Run_Pipeline(args):

# Run optimization
optimize_cmd = ('shapeworks optimize --progress --name ' + spreadsheet_file).split()
print(optimize_cmd)
subprocess.check_call(optimize_cmd)

# If tiny test or verify, check results and exit
Expand Down
20 changes: 10 additions & 10 deletions Libs/Analyze/Shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ void Shape::clear_reconstructed_mesh() { reconstructed_meshes_ = MeshGroup(subje
bool Shape::import_global_point_files(std::vector<std::string> filenames) {
for (int i = 0; i < filenames.size(); i++) {
Eigen::VectorXd points;
if (!Shape::import_point_file(filenames[i], points)) {
throw std::invalid_argument("Unable to import point file: " + filenames[i]);
if (filenames[i] != "") {
if (!Shape::import_point_file(filenames[i], points)) {
throw std::invalid_argument("Unable to import point file: " + filenames[i]);
}
}
global_point_filenames_.push_back(filenames[i]);
particles_.set_world_particles(i, points);
Expand All @@ -160,8 +162,10 @@ bool Shape::import_global_point_files(std::vector<std::string> filenames) {
bool Shape::import_local_point_files(std::vector<std::string> filenames) {
for (int i = 0; i < filenames.size(); i++) {
Eigen::VectorXd points;
if (!Shape::import_point_file(filenames[i], points)) {
throw std::invalid_argument("Unable to import point file: " + filenames[i]);
if (filenames[i] != "") {
if (!Shape::import_point_file(filenames[i], points)) {
throw std::invalid_argument("Unable to import point file: " + filenames[i]);
}
}
local_point_filenames_.push_back(filenames[i]);
particles_.set_local_particles(i, points);
Expand Down Expand Up @@ -307,9 +311,7 @@ bool Shape::store_constraints() {
Eigen::VectorXd Shape::get_global_correspondence_points() { return particles_.get_combined_global_particles(); }

//---------------------------------------------------------------------------
Eigen::VectorXd Shape::get_local_correspondence_points() {
return particles_.get_combined_local_particles();
}
Eigen::VectorXd Shape::get_local_correspondence_points() { return particles_.get_combined_local_particles(); }

//---------------------------------------------------------------------------
int Shape::get_id() { return id_; }
Expand Down Expand Up @@ -699,9 +701,7 @@ void Shape::set_particle_transform(vtkSmartPointer<vtkTransform> transform) {
}

//---------------------------------------------------------------------------
void Shape::set_alignment_type(int alignment) {
particles_.set_alignment_type(alignment);
}
void Shape::set_alignment_type(int alignment) { particles_.set_alignment_type(alignment); }

//---------------------------------------------------------------------------
vtkSmartPointer<vtkTransform> Shape::get_reconstruction_transform(int domain) {
Expand Down
Loading

0 comments on commit ef7dceb

Please sign in to comment.