-
Notifications
You must be signed in to change notification settings - Fork 198
No .type_choice(std::vector<std::string>) #3379
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
Changes from all commits
8801b88
292ecaa
bdc1e4b
cc5f197
37ab55f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
|
|
||
| #include "adapter/regrid.h" | ||
| #include "algo/copy.h" | ||
| #include "app.h" | ||
| #include "command.h" | ||
| #include "enum.h" | ||
| #include "filter/resize.h" | ||
|
|
@@ -131,9 +132,9 @@ void usage() { | |
| + Argument ("factor").type_sequence_float() | ||
|
|
||
| + Option ("interp", std::string("set the interpolation method to use when reslicing") | ||
| + " (choices: " + join(MR::Interp::interp_choices, ", ") + ";" | ||
| " default: " + MR::Interp::interp_choices[static_cast<ssize_t>(default_interp)] + ").") | ||
| + Argument ("method").type_choice (MR::Interp::interp_choices) | ||
| + " (choices: " + MR::Enum::join<MR::Interp::interp_type>() + ";" | ||
| " default: " + MR::Enum::lowercase_name(default_interp) + ").") | ||
| + Argument ("method").type_choice<MR::Interp::interp_type>() | ||
|
|
||
| + Option ("oversample", | ||
| "set the amount of over-sampling (in the target space) to perform when regridding." | ||
|
|
@@ -221,8 +222,7 @@ void run() { | |
| regrid_filter.set_out_of_bounds_value(out_of_bounds_value); | ||
| size_t resize_option_count = 0; | ||
| size_t template_option_count = 0; | ||
| const MR::Interp::interp_type interp = | ||
| MR::Interp::interp_type(get_option_value("interp", static_cast<ssize_t>(default_interp))); | ||
| const MR::Interp::interp_type interp = get_option_choice<MR::Interp::interp_type>("interp", default_interp); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "MR::App::get_option_choice" is directly included [misc-include-cleaner] const MR::Interp::interp_type interp = get_option_choice<MR::Interp::interp_type>("interp", default_interp);
^ |
||
|
|
||
| // over-sampling | ||
| std::vector<uint32_t> oversample = Adapter::AutoOverSample; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
|
|
||
| #include "algo/loop.h" | ||
| #include "algo/threaded_loop.h" | ||
| #include "app.h" | ||
| #include "command.h" | ||
| #include "enum.h" | ||
| #include "image.h" | ||
|
|
@@ -199,9 +200,9 @@ void usage() { | |
| + Argument ("iteration method").type_choice<space_t>() | ||
|
|
||
| + Option ("interp", std::string("set the interpolation method to use when reslicing") + | ||
| " (choices: nearest, linear, cubic, sinc." | ||
| " Default: " + MR::Interp::interp_choices[static_cast<ssize_t>(default_interp)] + ").") | ||
| + Argument ("method").type_choice(MR::Interp::interp_choices) | ||
| " (choices: " + MR::Enum::join<MR::Interp::interp_type>() + "." | ||
| " Default: " + MR::Enum::lowercase_name(default_interp) + ").") | ||
| + Argument ("method").type_choice<MR::Interp::interp_type>() | ||
|
|
||
| + Option ("metric", | ||
| "define the dissimilarity metric used to calculate the cost." | ||
|
|
@@ -231,8 +232,7 @@ using MaskType = Image<bool>; | |
|
|
||
| void run() { | ||
| const space_t space = get_option_choice<space_t>("space", default_space); | ||
| const MR::Interp::interp_type interp = | ||
| MR::Interp::interp_type(get_option_value<ssize_t>("interp", static_cast<ssize_t>(default_interp))); | ||
| const MR::Interp::interp_type interp = get_option_choice<MR::Interp::interp_type>("interp", default_interp); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "MR::App::get_option_choice" is directly included [misc-include-cleaner] const MR::Interp::interp_type interp = get_option_choice<MR::Interp::interp_type>("interp", default_interp);
^ |
||
|
|
||
| MetricType metric_type = MetricType::MeanSquared; | ||
| const MetricChoice metric_choice = get_option_choice<MetricChoice>("metric", MetricChoice::DIFF); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| #include <filesystem> | ||
| #include <optional> | ||
|
|
||
| #include "app.h" | ||
| #include "command.h" | ||
| #include "dwi/directions/predefined.h" | ||
| #include "dwi/directions/validate.h" | ||
|
|
@@ -402,12 +403,14 @@ void run() { | |
| if (!opt.empty()) { | ||
| if (init_rigid_matrix_set) | ||
| throw Exception("options -rigid_init_matrix and -rigid_init_translation are mutually exclusive"); | ||
| Registration::set_init_translation_model_from_option(rigid_registration, static_cast<int>(opt[0][0])); | ||
| Registration::set_init_translation_model_from_option( | ||
| rigid_registration, MR::Enum::from_name<Registration::init_translation_t>(opt[0][0])); | ||
| } | ||
|
|
||
| opt = get_options("rigid_init_rotation"); | ||
| if (!opt.empty()) | ||
| Registration::set_init_rotation_model_from_option(rigid_registration, static_cast<int>(opt[0][0])); | ||
| Registration::set_init_rotation_model_from_option(rigid_registration, | ||
| MR::Enum::from_name<Registration::init_rotation_t>(opt[0][0])); | ||
|
|
||
| opt = get_options("rigid_scale"); | ||
| if (!opt.empty()) { | ||
|
|
@@ -430,20 +433,8 @@ void run() { | |
| rigid_registration.set_max_iter(parse_ints<uint32_t>(opt[0][0])); | ||
| } | ||
|
|
||
| opt = get_options("rigid_metric"); | ||
| Registration::LinearMetricType rigid_metric = Registration::Diff; | ||
| if (!opt.empty()) { | ||
| switch (static_cast<int>(opt[0][0])) { | ||
| case 0: | ||
| rigid_metric = Registration::Diff; | ||
| break; | ||
| case 1: | ||
| rigid_metric = Registration::NCC; | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| const Registration::LinearMetricType rigid_metric = | ||
| get_option_choice<Registration::LinearMetricType>("rigid_metric", Registration::Diff); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "MR::App::get_option_choice" is directly included [misc-include-cleaner] get_option_choice<Registration::LinearMetricType>("rigid_metric", Registration::Diff);
^ |
||
|
|
||
| if (rigid_metric == Registration::NCC) | ||
| throw Exception("TODO: cross correlation metric not yet implemented"); | ||
|
|
@@ -453,21 +444,7 @@ void run() { | |
| if (!opt.empty()) { | ||
| if (rigid_metric != Registration::Diff) | ||
| throw Exception("rigid_metric.diff.estimator set but cost function is not diff."); | ||
| switch (static_cast<int>(opt[0][0])) { | ||
| case 0: | ||
| rigid_estimator = Registration::L1; | ||
| break; | ||
| case 1: | ||
| rigid_estimator = Registration::L2; | ||
| break; | ||
| case 2: | ||
| rigid_estimator = Registration::LP; | ||
| break; | ||
| case 3: | ||
| rigid_estimator = Registration::None; | ||
| default: | ||
| assert(false); | ||
| } | ||
| rigid_estimator = MR::Enum::from_name<Registration::LinearRobustMetricEstimatorType>(opt[0][0]); | ||
| } | ||
|
|
||
| opt = get_options("rigid_lmax"); | ||
|
|
@@ -534,14 +511,16 @@ void run() { | |
| if (!opt.empty()) { | ||
| if (init_affine_matrix_set) | ||
| throw Exception("options -affine_init_matrix and -affine_init_translation are mutually exclusive"); | ||
| Registration::set_init_translation_model_from_option(affine_registration, static_cast<int>(opt[0][0])); | ||
| Registration::set_init_translation_model_from_option( | ||
| affine_registration, MR::Enum::from_name<Registration::init_translation_t>(opt[0][0])); | ||
| } | ||
|
|
||
| opt = get_options("affine_init_rotation"); | ||
| if (!opt.empty()) { | ||
| if (init_affine_matrix_set) | ||
| throw Exception("options -affine_init_matrix and -affine_init_rotation are mutually exclusive"); | ||
| Registration::set_init_rotation_model_from_option(affine_registration, static_cast<int>(opt[0][0])); | ||
| Registration::set_init_rotation_model_from_option(affine_registration, | ||
| MR::Enum::from_name<Registration::init_rotation_t>(opt[0][0])); | ||
| } | ||
|
|
||
| opt = get_options("affine_scale"); | ||
|
|
@@ -558,20 +537,8 @@ void run() { | |
| affine_registration.set_loop_density(parse_floats(opt[0][0])); | ||
| } | ||
|
|
||
| opt = get_options("affine_metric"); | ||
| Registration::LinearMetricType affine_metric = Registration::Diff; | ||
| if (!opt.empty()) { | ||
| switch (static_cast<int>(opt[0][0])) { | ||
| case 0: | ||
| affine_metric = Registration::Diff; | ||
| break; | ||
| case 1: | ||
| affine_metric = Registration::NCC; | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| const Registration::LinearMetricType affine_metric = | ||
| get_option_choice<Registration::LinearMetricType>("affine_metric", Registration::Diff); | ||
|
|
||
| if (affine_metric == Registration::NCC) | ||
| throw Exception("TODO cross correlation metric not yet implemented"); | ||
|
|
@@ -581,22 +548,7 @@ void run() { | |
| if (!opt.empty()) { | ||
| if (affine_metric != Registration::Diff) | ||
| throw Exception("affine_metric.diff.estimator set but cost function is not diff."); | ||
| switch (static_cast<int>(opt[0][0])) { | ||
| case 0: | ||
| affine_estimator = Registration::L1; | ||
| break; | ||
| case 1: | ||
| affine_estimator = Registration::L2; | ||
| break; | ||
| case 2: | ||
| affine_estimator = Registration::LP; | ||
| break; | ||
| case 3: | ||
| affine_estimator = Registration::None; | ||
| break; | ||
| default: | ||
| assert(false); | ||
| } | ||
| affine_estimator = MR::Enum::from_name<Registration::LinearRobustMetricEstimatorType>(opt[0][0]); | ||
| } | ||
|
|
||
| opt = get_options("affine_niter"); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,9 +15,11 @@ | |
| */ | ||
|
|
||
| #include <iomanip> | ||
| #include <vector> | ||
|
|
||
| #include "command.h" | ||
| #include "datatype.h" | ||
| #include "enum.h" | ||
| #include "image.h" | ||
| #include "image_helpers.h" | ||
| #include "memory.h" | ||
|
|
@@ -108,10 +110,11 @@ void run() { | |
| check_dimensions(mask, header, 0, 3); | ||
| } | ||
|
|
||
| std::vector<std::string> fields; | ||
| std::vector<Stats::field_t> fields; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "std::vector" is directly included [misc-include-cleaner] cpp/cmd/mrstats.cpp:17: + #include <vector> |
||
| opt = get_options("output"); | ||
| fields.reserve(opt.size()); | ||
| for (size_t n = 0; n < opt.size(); ++n) | ||
| fields.push_back(opt[n][0]); | ||
| fields.push_back(MR::Enum::from_name<Stats::field_t>(opt[n][0])); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation] cpp/cmd/mrstats.cpp:113: - for (size_t n = 0; n < opt.size(); ++n)
+ fields.reserve(opt.size());
+ for (size_t n = 0; n < opt.size(); ++n) |
||
|
|
||
| if (App::log_level && fields.empty()) | ||
| Stats::print_header(is_complex); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,11 +21,13 @@ | |
| #include "algo/copy.h" | ||
| #include "algo/loop.h" | ||
| #include "algo/threaded_copy.h" | ||
| #include "app.h" | ||
| #include "command.h" | ||
| #include "debug.h" | ||
| #include "dwi/directions/predefined.h" | ||
| #include "dwi/directions/validate.h" | ||
| #include "dwi/gradient.h" | ||
| #include "enum.h" | ||
| #include "file/matrix.h" | ||
| #include "file/nifti_utils.h" | ||
| #include "filter/reslice.h" | ||
|
|
@@ -156,9 +158,9 @@ void usage() { | |
|
|
||
| + Option ("interp", | ||
| std::string("set the interpolation method to use when reslicing") | ||
| + " (choices: " + join(MR::Interp::interp_choices, ", ") + ";" | ||
| + " default: " + MR::Interp::interp_choices[static_cast<ssize_t>(default_interp)] + ").") | ||
| + Argument ("method").type_choice(MR::Interp::interp_choices) | ||
| + " (choices: " + MR::Enum::join<MR::Interp::interp_type>() + ";" | ||
| + " default: " + MR::Enum::lowercase_name(default_interp) + ").") | ||
| + Argument ("method").type_choice<MR::Interp::interp_type>() | ||
|
|
||
| + Option ("oversample", | ||
| "set the amount of over-sampling (in the target space) to perform when regridding." | ||
|
|
@@ -584,13 +586,9 @@ void run() { | |
| } | ||
|
|
||
| // Interpolator | ||
| MR::Interp::interp_type interp = default_interp; | ||
| opt = get_options("interp"); | ||
| if (!opt.empty()) { | ||
| interp = MR::Interp::interp_type(static_cast<MR::App::ParsedArgument::IntType>(opt[0][0])); | ||
| if (!warp && !template_header) | ||
| WARN("interpolator choice ignored since the input image will not be regridded"); | ||
| } | ||
| const MR::Interp::interp_type interp = get_option_choice<MR::Interp::interp_type>("interp", default_interp); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "MR::App::get_option_choice" is directly included [misc-include-cleaner] const MR::Interp::interp_type interp = get_option_choice<MR::Interp::interp_type>("interp", default_interp);
^ |
||
| if (!get_options("interp").empty() && !warp && !template_header) | ||
| WARN("interpolator choice ignored since the input image will not be regridded"); | ||
|
|
||
| // over-sampling | ||
| std::vector<uint32_t> oversample = Adapter::AutoOverSample; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |||||
|
|
||||||
| #include <set> | ||||||
|
|
||||||
| #include "app.h" | ||||||
| #include "command.h" | ||||||
| #include "image.h" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: included header enum.h is not used directly [misc-include-cleaner]
Suggested change
|
||||||
| #include "thread_queue.h" | ||||||
|
|
@@ -154,9 +155,7 @@ void execute(Image<node_t> &node_image, const node_t max_node_index, const std:: | |||||
| Metric metric; | ||||||
| Tractography::Connectome::setup_metric(metric, node_image); | ||||||
| std::unique_ptr<Tck2nodes_base> tck2nodes(load_assignment_mode(node_image)); | ||||||
| auto opt = get_options("stat_edge"); | ||||||
| const stat_edge statistic = | ||||||
| !opt.empty() ? stat_edge(static_cast<MR::App::ParsedArgument::IntType>(opt[0][0])) : stat_edge::SUM; | ||||||
| const stat_edge statistic = get_option_choice<stat_edge>("stat_edge", stat_edge::SUM); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "MR::App::get_option_choice" is directly included [misc-include-cleaner] const stat_edge statistic = get_option_choice<stat_edge>("stat_edge", stat_edge::SUM);
^ |
||||||
|
|
||||||
| // Prepare for reading the track data | ||||||
| Tractography::Properties properties; | ||||||
|
|
@@ -191,7 +190,7 @@ void execute(Image<node_t> &node_image, const node_t max_node_index, const std:: | |||||
| get_options("symmetric").size(), | ||||||
| get_options("zero_diagonal").size()); | ||||||
|
|
||||||
| opt = get_options("out_assignments"); | ||||||
| auto opt = get_options("out_assignments"); | ||||||
| if (!opt.empty()) | ||||||
| connectome.write_assignments(opt[0][0]); | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "MR::App::get_option_choice" is directly included [misc-include-cleaner]