Skip to content

Commit

Permalink
Correct errors in clang-format disabling for CLI code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lestropie committed Feb 26, 2024
1 parent de4de95 commit 895628e
Show file tree
Hide file tree
Showing 21 changed files with 27 additions and 22 deletions.
7 changes: 4 additions & 3 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ aad44d847ac48d02bb7f8badf801dbfaa0ccdac0
#Date: Thu, 17 Aug 2023 15:36:14 +0100
# Apply formatting for C++ using clang-format

0cec87a0e59749d4e14ebf55c288067d29f868f1
#Author: Robert Smith <robert.smith@florey.edu.au>
#Date: Thu Feb 22 01:43:21 2024 +1100
de4de955cd82065135d15383a639dd7f7373d834
#Author: MRtrixBot <gitbot@mrtrix.org>
#Date: Mon Feb 26 13:38:02 2024 +1100
# Disable clang-format for CLI-related code
# When clang-format, introduced in #2652, applied its changes to MRtrix3 code relating to the command-line interface (particularly the way that options and their arguments are concatenated through the addition operator), the resulting code was often quite ugly. This commit replaces code relating to CLI configuration (both the usage() function in cmd/*.cpp, and in definitions of options and option groups utilised by multiple commands) with manually formatted code, and includes comment fields to disable further manipulation of that code by clang-format.
# This commit is a refactor of 0cec87a0e59749d4e14ebf55c288067d29f868f1 generated as part of #2815, with the changes being to omit other modifications to the command documentation that are not directly related to clang-format (those changes are in the parent commit to this commit: 15e253cf6a0af83a9a0f4f9369a256d01cf90ad8), and to change authorship of the commit.
1 change: 1 addition & 0 deletions cmd/dirorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void usage() {
" instead of [az el].");

}
// clang-format on

using value_type = double;

Expand Down
2 changes: 1 addition & 1 deletion cmd/dirstat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
using namespace MR;
using namespace App;

//clang-format off
// clang-format off
void usage() {

AUTHOR = "J-Donald Tournier (jdtournier@gmail.com)";
Expand Down
2 changes: 1 addition & 1 deletion cmd/fixel2peaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void usage() {
" then the 3-vectors in the output image will be scaled based on the data in that file."
" If the input is instead the fixel directory,"
" or the index or directions file,"
" then all output 3-vectors will possess unit norm.";
" then all output 3-vectors will possess unit norm."

+ Fixel::format_description;

Expand Down
2 changes: 1 addition & 1 deletion cmd/fixelcorrespondence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using Fixel::index_type;

#define DEFAULT_ANGLE_THRESHOLD 45.0

// clang-format on
// clang-format off
void usage() {

AUTHOR = "David Raffelt (david.raffelt@florey.edu.au)";
Expand Down
1 change: 1 addition & 0 deletions cmd/fixelcrop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void usage() {
+ Argument ("output_fixel_directory", "the output directory to store the cropped directions"
" and data files").type_directory_out();
}
// clang-format on

void run() {
const auto in_directory = argument[0];
Expand Down
2 changes: 1 addition & 1 deletion cmd/fod2fixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using namespace App;

using Fixel::index_type;

//clang-format off
// clang-format off
const OptionGroup OutputOptions = OptionGroup ("Metric values for fixel-based sparse output images")

+ Option ("afd",
Expand Down
3 changes: 1 addition & 2 deletions cmd/label2mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ void usage() {
" rather than the default Marching Cubes approach");

}
// coang-format on

// clang-format on

void run() {

Expand Down
2 changes: 1 addition & 1 deletion cmd/mrgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace App;
const char *interp_choices[] = {"nearest", "linear", "cubic", "sinc", NULL};
const char *operation_choices[] = {"regrid", "crop", "pad", NULL};

//clang-format off
// clang-format off
void usage() {

AUTHOR = "Max Pietsch (maximilian.pietsch@kcl.ac.uk)"
Expand Down
4 changes: 2 additions & 2 deletions cmd/peaks2fixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using namespace MR;
using namespace App;

// clang-format on
// clang-format off
void usage() {

AUTHOR = "Robert E. Smith (robert.smith@florey.edu.au)";
Expand All @@ -45,7 +45,7 @@ void usage() {
+ Argument ("path").type_text();

}
// clang-format off
// clang-format on

std::vector<Eigen::Vector3d> get(Image<float> &data) {
data.index(3) = 0;
Expand Down
1 change: 0 additions & 1 deletion cmd/shbasis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ void usage() {
}
// clang-format on


// Perform a linear regression on the power ratio in each order
// Omit l=2 - tends to be abnormally small due to non-isotropic brain-wide fibre distribution
std::pair<float, float> get_regression(const std::vector<float> &ratios) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/shview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void usage() {
REQUIRES_AT_LEAST_ONE_ARGUMENT = false;

}

// clang-format on

void run() {
GUI::DWI::Window window(get_options("response").size());
Expand Down
1 change: 0 additions & 1 deletion cmd/tckdfc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ void usage () {
}
// clang-format on


// This class is similar to Mapping::MapWriter, but doesn't write to a HDD file on close
// Instead, the one timepoint volume generated during this iteration is written
// into the one large buffer that contains the entire TW-dFC time series
Expand Down
2 changes: 1 addition & 1 deletion cmd/tckgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void usage() {
+ DWI::GradImportOptions();

}
// clang-format off
// clang-format on

void run() {

Expand Down
2 changes: 1 addition & 1 deletion cmd/tcksift2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void usage() {
+ SIFT2AlgorithmOption;

}
// clang-format off
// clang-format on

void run() {

Expand Down
2 changes: 1 addition & 1 deletion cmd/voxel2fixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace App;

using Fixel::index_type;

// clang-format on
// clang-format off
void usage() {

AUTHOR = "David Raffelt (david.raffelt@florey.edu.au)";
Expand Down
4 changes: 2 additions & 2 deletions core/math/stats/glm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const char *const column_ones_description =

App::OptionGroup glm_options(const std::string &element_name) {
using namespace App;
// clang-format off
// clang-format off
OptionGroup result =
OptionGroup("Options related to the General Linear Model (GLM)")
+ Option("variance",
Expand All @@ -69,7 +69,7 @@ App::OptionGroup glm_options(const std::string &element_name) {
" (note that the contrast matrix must include an additional column for each use of this option);"
" the text file provided via this option should contain a file name for each subject").allow_multiple()
+ Argument("path").type_file_in();
// clang-format on
// clang-format on
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions core/math/stats/shuffle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const char *error_types[] = {"ee", "ise", "both", nullptr};
App::OptionGroup shuffle_options(const bool include_nonstationarity, const default_type default_skew) {
using namespace App;

// clang-format off
// clang-format off
OptionGroup result =
OptionGroup("Options relating to shuffling of data for nonparametric statistical inference")
+ Option("notest",
Expand Down Expand Up @@ -90,7 +90,7 @@ App::OptionGroup shuffle_options(const bool include_nonstationarity, const defau
" Overrides the -nshuffles_nonstationarity option.")
+ Argument("file").type_file_in();
}
// clang-format off
// clang-format on
return result;
}

Expand Down
3 changes: 3 additions & 0 deletions docs/reference/commands/fixel2peaks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Description

If a fixel data file is provided as input, then the 3-vectors in the output image will be scaled based on the data in that file. If the input is instead the fixel directory, or the index or directions file, then all output 3-vectors will possess unit norm.

Fixel data are stored utilising the fixel directory format described in the main documentation, which can be found at the following link: |br|
https://mrtrix.readthedocs.io/en/3.0.4/fixel_based_analysis/fixel_directory_format.html

Options
-------

Expand Down
1 change: 1 addition & 0 deletions src/gui/mrview/tool/connectome/connectome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ void Connectome::add_commandline_options(MR::App::OptionList &options) {
+ Argument("image").type_image_in()
+ Option("connectome.load", "Load a matrix file into the connectome tool.").allow_multiple()
+ Argument("path").type_file_in();
// clang-format on
}

bool Connectome::process_commandline_option(const MR::App::ParsedOption &opt) {
Expand Down
1 change: 1 addition & 0 deletions testing/tools/testing_diff_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void usage() {
+ Option ("keyval", "also test the contents of the key-value entries in the header");

}
// clang-format on

void run() {
auto in1 = Header::open(argument[0]);
Expand Down

0 comments on commit 895628e

Please sign in to comment.