Skip to content

Commit 23f1c9a

Browse files
authored
Merge pull request #2181 from SCIInstitute/deepssm_phase2
Studio DeepSSM Phase 2/3
2 parents 2a86c50 + 1976354 commit 23f1c9a

File tree

99 files changed

+5995
-4280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+5995
-4280
lines changed

Applications/shapeworks/Commands.cpp

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,7 @@ bool Example::execute(const optparse::Values &options, SharedCommandData &shared
4141
}
4242
#endif
4343

44-
static void setup_callbacks(bool show_progress, bool xml_status) {
45-
if (show_progress) {
46-
auto progress_callback = [](double progress, std::string message) {
47-
// show status message and percentage complete
48-
std::cout << fmt::format("{} ({:.1f}%) \r", message, progress);
49-
std::cout.flush();
50-
};
51-
Logging::Instance().set_progress_callback(progress_callback);
52-
}
5344

54-
if (xml_status) {
55-
auto progress_callback = [](double progress, std::string message) {
56-
// print status message and percentage complete
57-
std::cout << fmt::format("<xml><status>{}</status><progress>{:.1f}</progress></xml>\n", message, progress);
58-
std::cout.flush();
59-
};
60-
Logging::Instance().set_progress_callback(progress_callback);
61-
62-
auto error_callback = [](std::string message) {
63-
std::cout << fmt::format("<xml><error>{}</error></xml>\n", message);
64-
std::cout.flush();
65-
};
66-
Logging::Instance().set_error_callback(error_callback);
67-
}
68-
}
6945

7046
///////////////////////////////////////////////////////////////////////////////
7147
// Seed
@@ -87,7 +63,7 @@ void Seed::buildParser() {
8763
bool Seed::execute(const optparse::Values& options, SharedCommandData& sharedData) {
8864
int value = static_cast<int>(options.get("value"));
8965

90-
ShapeworksUtils::setRngSeed(value);
66+
ShapeWorksUtils::set_rng_seed(value);
9167

9268
return true;
9369
}
@@ -123,7 +99,7 @@ bool OptimizeCommand::execute(const optparse::Values& options, SharedCommandData
12399
bool isProject = StringUtils::hasSuffix(projectFile, "xlsx") || StringUtils::hasSuffix(projectFile, "swproj");
124100

125101
Optimize app;
126-
setup_callbacks(show_progress, xml_status);
102+
ShapeWorksUtils::setup_console_logging(show_progress, xml_status);
127103

128104
if (isProject) {
129105
try {
@@ -161,7 +137,7 @@ bool OptimizeCommand::execute(const optparse::Values& options, SharedCommandData
161137

162138
return success;
163139
} catch (std::exception& e) {
164-
SW_ERROR(e.what());
140+
SW_ERROR("{}", e.what());
165141
return false;
166142
}
167143
} else {
@@ -199,7 +175,7 @@ bool GroomCommand::execute(const optparse::Values& options, SharedCommandData& s
199175
return false;
200176
}
201177

202-
setup_callbacks(show_progress, xml_status);
178+
ShapeWorksUtils::setup_console_logging(show_progress, xml_status);
203179

204180
try {
205181
ProjectHandle project = std::make_shared<Project>();
@@ -226,7 +202,7 @@ bool GroomCommand::execute(const optparse::Values& options, SharedCommandData& s
226202

227203
return success;
228204
} catch (std::exception& e) {
229-
SW_ERROR(e.what());
205+
SW_ERROR("{}", e.what());
230206
return false;
231207
}
232208
}

Applications/shapeworks/MeshCommands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,7 @@ bool WarpMesh::execute(const optparse::Values &options, SharedCommandData &share
14691469
movingPoints.resize(3, numParticles);
14701470
movingPoints.transposeInPlace();
14711471
Mesh output = warper.build_mesh(movingPoints);
1472+
SW_DEBUG("Writing mesh {} with {} points", filenm, output.numPoints());
14721473
output.write(filenm);
14731474
if (warp_along_with_landmarks) {
14741475
std::string warped_landmarks_filename = targetPointsFilenames[i];

Examples/Python/RunUseCase.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import sys
1919
import shutil
2020

21-
#check if current directory is writable
21+
# check if current directory is writable
2222
current_dir = os.getcwd()
23-
if not os.access(current_dir,os.W_OK):
24-
raise OSError("You don't have write permission in the current directory. Please copy the Examples folder to a different location to run the use cases")
25-
23+
if not os.access(current_dir, os.W_OK):
24+
raise OSError(
25+
"You don't have write permission in the current directory. Please copy the Examples folder to a different location to run the use cases")
2626

2727
if __name__ == '__main__':
2828

@@ -31,6 +31,7 @@
3131
import termcolor
3232
import DatasetUtils
3333
import shapeworks as sw
34+
3435
print(f"Using shapeworks module from {sw.__file__}")
3536

3637
# make sure the shapeworks executables can be found
@@ -41,29 +42,35 @@
4142

4243
except ImportError as error:
4344
print("\nError: Unable to import ShapeWorks executables, Python module, or dependencies\n")
44-
print("Users: Please make sure you have run \"source install_shapeworks.sh\" (once) and \"conda activate shapeworks\" (each time)")
45+
print(
46+
"Users: Please make sure you have run \"source install_shapeworks.sh\" (once) and \"conda activate shapeworks\" (each time)")
4547
print("\tSee http://sciinstitute.github.io/ShapeWorks/users/install.html for more information")
4648
print("\nDevelopers: Please make sure you have run \"source ./devenv.sh <SOURCE_DIR> <BUILD_DIR>\"")
47-
sys.exit(1)
4849

50+
print(f"\nError message: {error}")
51+
sys.exit(1)
4952

5053
# parse arguments
5154
parser = argparse.ArgumentParser(description='Example ShapeWorks Pipeline')
5255
parser.add_argument("use_case", help="Must specify which of these use cases to run.",
53-
choices=["ellipsoid", "ellipsoid_evaluate", "ellipsoid_mesh", "ellipsoid_fd", "ellipsoid_cut", "ellipsoid_pca", \
54-
"ellipsoid_multiple_domain","ellipsoid_multiple_domain_mesh", "lumps", "left_atrium", \
55-
"femur_cut","femur_pvalues","deep_ssm", "supershapes_1mode_contour", "thin_cavity_bean",
56-
"peanut_shared_boundary", "incremental_supershapes","hip_multiple_domain"])
56+
choices=["ellipsoid", "ellipsoid_evaluate", "ellipsoid_mesh", "ellipsoid_fd", "ellipsoid_cut",
57+
"ellipsoid_pca", \
58+
"ellipsoid_multiple_domain", "ellipsoid_multiple_domain_mesh", "lumps", "left_atrium", \
59+
"femur_cut", "femur_pvalues", "deep_ssm", "supershapes_1mode_contour",
60+
"thin_cavity_bean",
61+
"peanut_shared_boundary", "incremental_supershapes", "hip_multiple_domain"])
5762
parser.add_argument("--use_subsample", help="Run the pipeline for a subset of data", action="store_true")
5863
parser.add_argument("--num_subsample", help="Size of subset to run on (default: %(default)s)", type=int, default=3)
5964
parser.add_argument("--interactive", help="Run in interactive mode", action="store_true")
60-
parser.add_argument("--use_single_scale", help="Use single scale optimization (default: multi scale)", action="store_true")
61-
parser.add_argument("--mesh_mode", help="Run optimization on meshes rather than distance transforms.",action="store_true")
65+
parser.add_argument("--use_single_scale", help="Use single scale optimization (default: multi scale)",
66+
action="store_true")
67+
parser.add_argument("--mesh_mode", help="Run optimization on meshes rather than distance transforms.",
68+
action="store_true")
6269
parser.add_argument("--tiny_test", help="Run as a short test", action="store_true")
6370
parser.add_argument("--verify", help="Run as a full test", action="store_true")
71+
parser.add_argument("--clean", help="Run from scratch, ignoring intermediate stages", action="store_true")
6472
args = parser.parse_args()
6573

66-
6774
type = ""
6875
if args.tiny_test:
6976
type = "tiny_test_"
@@ -78,8 +85,9 @@
7885
if args.use_subsample:
7986
dataExists = sw.data.dataset_exists_check(args.use_case)
8087
args.use_subsample = args.num_subsample
81-
if(dataExists==False):
82-
print("Please note: For --use_subsample argument the entire dataset will be downloaded. For a quick test use the --tiny_test argument")
88+
if (dataExists == False):
89+
print(
90+
"Please note: For --use_subsample argument the entire dataset will be downloaded. For a quick test use the --tiny_test argument")
8391
input("Press any key to continue")
8492

8593
# import use case and run

0 commit comments

Comments
 (0)