Skip to content

Commit

Permalink
Merge branch 'dev' into cmake_app_bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
bjeurissen authored Feb 19, 2024
2 parents 52f8769 + 205dd53 commit 48d8997
Show file tree
Hide file tree
Showing 1,010 changed files with 2,757 additions and 2,736 deletions.
16 changes: 16 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Checks: >
-*,
bugprone-*,
clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
misc-*,
performance-*,
portability-*,
readability-*,
-bugprone-easily-swappable-parameters,
-cppcoreguidelines-avoid-magic-numbers,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-magic-numbers,
HeaderFilterRegex: '*.(h|hpp)'
18 changes: 10 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ jobs:
-D MRTRIX_BUILD_TESTS=ON
-D MRTRIX_STL_DEBUGGING=ON
-D MRTRIX_WARNINGS_AS_ERRORS=ON
-D CMAKE_C_COMPILER=clang
-D CMAKE_CXX_COMPILER=clang++
- name: build
run: cmake --build build

- name: unit tests
run: cd build && ctest -R unit
run: cd build && ctest -R unit --output-on-failure

- name: binary tests
run: cd build && ctest -R bin
run: cd build && ctest -R bin --output-on-failure

linux-gcc-build:

Expand Down Expand Up @@ -101,10 +103,10 @@ jobs:
run: cmake --build build

- name: unit tests
run: cd build && ctest -R unit
run: cd build && ctest -R unit --output-on-failure

- name: binary tests
run: cd build && ctest -R bin
run: cd build && ctest -R bin --output-on-failure

macos-build:

Expand Down Expand Up @@ -152,10 +154,10 @@ jobs:
run: cmake --build build

- name: unit tests
run: cd build && ctest -R unit
run: cd build && ctest -R unit --output-on-failure

- name: binary tests
run: cd build && ctest -R bin
run: cd build && ctest -R bin --output-on-failure

- name: check command documentation
run: ./docs/generate_user_docs.sh --build-dir ./build && git diff --exit-code docs/
Expand Down Expand Up @@ -222,10 +224,10 @@ jobs:
run: cmake --build build

- name: unit tests
run: cd build && ctest -R unit
run: cd build && ctest -R unit --output-on-failure

- name: binary tests
run: cd build && ctest -R bin
run: cd build && ctest -R bin --output-on-failure

secondary-checks:
runs-on: ubuntu-latest
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: clang-tidy-review

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: ZedThree/[email protected]
id: review
with:
apt_packages: g++,libqt5opengl5-dev,libqt5svg5-dev,libglvnd-dev,libeigen3-dev,zlib1g-dev,libfftw3-dev,ninja-build
cmake_command: cmake . -DCMAKE_EXPORT_COMPILE_COMMANDS=on
config_file: .clang-tidy

- uses: ZedThree/clang-tidy-review/[email protected]
id: upload-review
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)

project(mrtrix3 VERSION 3.0.4)
project(mrtrix3 LANGUAGES CXX VERSION 3.0.4)

include(GNUInstallDirs)

string(TIMESTAMP CURRENT_YEAR "%Y")
Expand Down Expand Up @@ -29,8 +30,6 @@ else()
set(QT_MAJOR_VERSION 5)
endif()

option(BUILD_GUI "Build the MRtrix3 GUI" ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down Expand Up @@ -139,4 +138,5 @@ add_custom_target(Github SOURCES
.github/workflows/package-macos-anaconda.yml
.github/workflows/package-macos-native.yml
.github/workflows/package-windows-msys2.yml
.github/workflows/clang-tidy.yml
)
18 changes: 1 addition & 17 deletions check_syntax
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright (c) 2008-2023 the MRtrix3 contributors.
# Copyright (c) 2008-2024 the MRtrix3 contributors.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -64,20 +64,6 @@ for f in $(find cmd core src -type f -name '*.h' -o -name '*.cpp' | $grep -v '_m
# remove quoted strings:
cat .check_syntax2.tmp | perl -pe 's/(")(\\"|.)*?"//g' > .check_syntax.tmp

# detect any instances of std::vector:
res="$res"$(
cat .check_syntax.tmp | \
# match for the parts we're interested in and output just the bits that match:
$grep -Po '(?<!::)std::vector\b'
)


# detect any instances of std::make_shared:
res="$res"$(
cat .check_syntax.tmp | \
# match for the parts we're interested in and output just the bits that match:
$grep -Po '(?<!::)std::make_shared\b'
)

# detect any instances of "using namespace std;":
res="$res"$(
Expand Down Expand Up @@ -126,8 +112,6 @@ else
echo "" >> $LOG
echo "Please check the following syntax requirements:
- Add MEMALIGN() or NOMEMALIGN macro to any class declarations identified above;
- Replace all occurrences of std::vector<> with MR::vector<> (or just vector<>);
- Avoid use of std::make_shared();
- Replace all instances of std::abs() with MR::abs() (or just abs());
- Replace all instances of %zu in print() calls with PRI_SIZET." >> $LOG
exit 1
Expand Down
2 changes: 1 addition & 1 deletion clang-format-all
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/env/python3

# Copyright (c) 2008-2023 the MRtrix3 contributors.
# Copyright (c) 2008-2024 the MRtrix3 contributors.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
2 changes: 1 addition & 1 deletion cmd/5tt2gmwmi.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008-2023 the MRtrix3 contributors.
/* Copyright (c) 2008-2024 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
2 changes: 1 addition & 1 deletion cmd/5tt2vis.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008-2023 the MRtrix3 contributors.
/* Copyright (c) 2008-2024 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
2 changes: 1 addition & 1 deletion cmd/5ttcheck.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008-2023 the MRtrix3 contributors.
/* Copyright (c) 2008-2024 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
2 changes: 1 addition & 1 deletion cmd/5ttedit.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008-2023 the MRtrix3 contributors.
/* Copyright (c) 2008-2024 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
4 changes: 2 additions & 2 deletions cmd/afdconnectivity.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008-2023 the MRtrix3 contributors.
/* Copyright (c) 2008-2024 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -215,7 +215,7 @@ value_type AFDConnectivity::get(const std::string &path) {
if (all_fixels) {

// All fixels contribute to the result
for (vector<AFDConnFixel>::const_iterator i = fixels.begin(); i != fixels.end(); ++i) {
for (std::vector<AFDConnFixel>::const_iterator i = fixels.begin(); i != fixels.end(); ++i) {
if (i->is_selected())
sum_volumes += i->get_FOD();
}
Expand Down
18 changes: 9 additions & 9 deletions cmd/amp2response.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008-2023 the MRtrix3 contributors.
/* Copyright (c) 2008-2024 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -101,8 +101,8 @@ Eigen::Matrix<default_type, 3, 3> gen_rotation_matrix(const Eigen::Vector3d &dir
return R;
}

vector<size_t> all_volumes(const size_t num) {
vector<size_t> result(num);
std::vector<size_t> all_volumes(const size_t num) {
std::vector<size_t> result(num);
for (size_t i = 0; i != num; ++i)
result[i] = i;
return result;
Expand All @@ -112,7 +112,7 @@ class Accumulator {
public:
class Shared {
public:
Shared(int lmax, const vector<size_t> &volumes, const Eigen::MatrixXd &dirs)
Shared(int lmax, const std::vector<size_t> &volumes, const Eigen::MatrixXd &dirs)
: lmax(lmax),
dirs(dirs),
volumes(volumes),
Expand All @@ -122,7 +122,7 @@ class Accumulator {

const int lmax;
const Eigen::MatrixXd &dirs;
const vector<size_t> &volumes;
const std::vector<size_t> &volumes;
Eigen::MatrixXd M;
Eigen::VectorXd b;
size_t count;
Expand Down Expand Up @@ -196,8 +196,8 @@ void run() {
auto header = Header::open(argument[0]);

// May be dealing with multiple shells
vector<Eigen::MatrixXd> dirs_azel;
vector<vector<size_t>> volumes;
std::vector<Eigen::MatrixXd> dirs_azel;
std::vector<std::vector<size_t>> volumes;
std::unique_ptr<DWI::Shells> shells;

auto opt = get_options("directions");
Expand All @@ -207,7 +207,7 @@ void run() {
} else {
auto hit = header.keyval().find("directions");
if (hit != header.keyval().end()) {
vector<default_type> dir_vector;
std::vector<default_type> dir_vector;
for (auto line : split_lines(hit->second)) {
auto v = parse_floats(line);
dir_vector.insert(dir_vector.end(), v.begin(), v.end());
Expand All @@ -230,7 +230,7 @@ void run() {
}
}

vector<uint32_t> lmax;
std::vector<uint32_t> lmax;
uint32_t max_lmax = 0;
opt = get_options("lmax");
if (get_options("isotropic").size()) {
Expand Down
14 changes: 7 additions & 7 deletions cmd/amp2sh.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008-2023 the MRtrix3 contributors.
/* Copyright (c) 2008-2024 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -81,14 +81,14 @@ class Amp2SHCommon {
public:
template <class MatrixType>
Amp2SHCommon(const MatrixType &sh2amp,
const vector<size_t> &bzeros,
const vector<size_t> &dwis,
const std::vector<size_t> &bzeros,
const std::vector<size_t> &dwis,
bool normalise_to_bzero)
: sh2amp(sh2amp), amp2sh(Math::pinv(sh2amp)), bzeros(bzeros), dwis(dwis), normalise(normalise_to_bzero) {}

Eigen::MatrixXd sh2amp, amp2sh;
const vector<size_t> &bzeros;
const vector<size_t> &dwis;
const std::vector<size_t> &bzeros;
const std::vector<size_t> &dwis;
bool normalise;
};

Expand Down Expand Up @@ -175,7 +175,7 @@ void run() {
auto amp = Image<value_type>::open(argument[0]).with_direct_io(3);
Header header(amp);

vector<size_t> bzeros, dwis;
std::vector<size_t> bzeros, dwis;
Eigen::MatrixXd dirs;
auto opt = get_options("directions");
if (opt.size()) {
Expand All @@ -185,7 +185,7 @@ void run() {
} else {
auto hit = header.keyval().find("directions");
if (hit != header.keyval().end()) {
vector<default_type> dir_vector;
std::vector<default_type> dir_vector;
for (auto line : split_lines(hit->second)) {
auto v = parse_floats(line);
dir_vector.insert(dir_vector.end(), v.begin(), v.end());
Expand Down
20 changes: 10 additions & 10 deletions cmd/connectome2tck.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008-2023 the MRtrix3 contributors.
/* Copyright (c) 2008-2024 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -158,9 +158,9 @@ void run() {
Tractography::Properties properties;
Tractography::Reader<float> reader(argument[0], properties);

vector<vector<node_t>> assignments_lists;
std::vector<std::vector<node_t>> assignments_lists;
assignments_lists.reserve(to<size_t>(properties["count"]));
vector<NodePair> assignments_pairs;
std::vector<NodePair> assignments_pairs;
bool nonpair_found = false;
node_t max_node_index = 0;
{
Expand All @@ -172,7 +172,7 @@ void run() {
if (line.empty())
continue;
std::stringstream line_stream(line);
vector<node_t> nodes;
std::vector<node_t> nodes;
while (1) {
node_t n;
line_stream >> n;
Expand Down Expand Up @@ -216,7 +216,7 @@ void run() {
const bool keep_self = get_options("keep_self").size();

// Get the list of nodes of interest
vector<node_t> nodes;
std::vector<node_t> nodes;
opt = get_options("nodes");
bool manual_node_list = false;
if (opt.size()) {
Expand Down Expand Up @@ -256,8 +256,8 @@ void run() {
// Load the node image, get the centres of mass
// Generate exemplars - these can _only_ be done per edge, and requires a mutex per edge to multi-thread
auto image = Image<node_t>::open(opt[0][0]);
vector<Eigen::Vector3f> COMs(max_node_index + 1, Eigen::Vector3f(0.0f, 0.0f, 0.0f));
vector<size_t> volumes(max_node_index + 1, 0);
std::vector<Eigen::Vector3f> COMs(max_node_index + 1, Eigen::Vector3f(0.0f, 0.0f, 0.0f));
std::vector<size_t> volumes(max_node_index + 1, 0);
for (auto i = Loop()(image); i; ++i) {
const node_t index = image.value();
if (index) {
Expand Down Expand Up @@ -344,7 +344,7 @@ void run() {
} else {
// For each node in the list, write one file for an exemplar to every other node
ProgressBar progress("writing exemplars to files", nodes.size() * COMs.size());
for (vector<node_t>::const_iterator n = nodes.begin(); n != nodes.end(); ++n) {
for (std::vector<node_t>::const_iterator n = nodes.begin(); n != nodes.end(); ++n) {
for (size_t i = first_node; i != COMs.size(); ++i) {
generator.write(*n,
i,
Expand All @@ -356,7 +356,7 @@ void run() {
}
} else if (file_format == 1) { // One file per node
ProgressBar progress("writing exemplars to files", nodes.size());
for (vector<node_t>::const_iterator n = nodes.begin(); n != nodes.end(); ++n) {
for (std::vector<node_t>::const_iterator n = nodes.begin(); n != nodes.end(); ++n) {
generator.write(
*n, prefix + str(*n) + ".tck", weights_prefix.size() ? (weights_prefix + str(*n) + ".csv") : "");
++progress;
Expand Down Expand Up @@ -399,7 +399,7 @@ void run() {
INFO("A total of " + str(writer.file_count()) + " output track files will be generated (one for each edge)");
break;
case 1: // One file per node
for (vector<node_t>::const_iterator i = nodes.begin(); i != nodes.end(); ++i)
for (std::vector<node_t>::const_iterator i = nodes.begin(); i != nodes.end(); ++i)
writer.add(*i, prefix + str(*i) + ".tck", weights_prefix.size() ? (weights_prefix + str(*i) + ".csv") : "");
INFO("A total of " + str(writer.file_count()) + " output track files will be generated (one for each node)");
break;
Expand Down
2 changes: 1 addition & 1 deletion cmd/connectomeedit.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008-2023 the MRtrix3 contributors.
/* Copyright (c) 2008-2024 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Loading

0 comments on commit 48d8997

Please sign in to comment.