Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into mrmath_memleak_fix
Browse files Browse the repository at this point in the history
Conflicts:
	core/misc/voxel2vector.h

Resolves #2781 with #2764.
  • Loading branch information
Lestropie committed Jan 23, 2024
2 parents dae868c + 90a0f53 commit e467385
Show file tree
Hide file tree
Showing 1,007 changed files with 2,647 additions and 2,639 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,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

linux-gcc-build:

Expand Down Expand Up @@ -103,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 @@ -154,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 @@ -224,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
5 changes: 3 additions & 2 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: ZedThree/clang-tidy-review@v0.14.0
- uses: ZedThree/clang-tidy-review@v0.17.0
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: ${{ github.workspace }}/.clang-tidy

- uses: ZedThree/clang-tidy-review/upload@v0.14.0
- uses: ZedThree/clang-tidy-review/upload@v0.17.0
id: upload-review
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
6 changes: 3 additions & 3 deletions cmd/connectomestats.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 @@ -210,7 +210,7 @@ void run() {

// Before validating the contrast matrix, we first need to see if there are any
// additional design matrix columns coming from edge-wise subject data
vector<CohortDataImport> extra_columns;
std::vector<CohortDataImport> extra_columns;
bool nans_in_columns = false;
auto opt = get_options("column");
for (size_t i = 0; i != opt.size(); ++i) {
Expand All @@ -236,7 +236,7 @@ void run() {
CONSOLE("Number of variance groups: " + str(num_vgs));

// Load hypotheses
const vector<Hypothesis> hypotheses = Math::Stats::GLM::load_hypotheses(argument[3]);
const std::vector<Hypothesis> hypotheses = Math::Stats::GLM::load_hypotheses(argument[3]);
const index_type num_hypotheses = hypotheses.size();
if (hypotheses[0].cols() != num_factors)
throw Exception(
Expand Down
6 changes: 3 additions & 3 deletions cmd/dcmedit.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 @@ -82,8 +82,8 @@ inline uint16_t read_hex(const std::string &m) {
}

void run() {
vector<Tag> tags;
vector<uint16_t> VRs;
std::vector<Tag> tags;
std::vector<uint16_t> VRs;

auto opt = get_options("anonymise");
if (opt.size()) {
Expand Down
4 changes: 2 additions & 2 deletions cmd/dcminfo.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 @@ -62,7 +62,7 @@ void run() {
if (opt.size()) {
std::istringstream hex;

vector<Tag> tags(opt.size());
std::vector<Tag> tags(opt.size());
for (size_t n = 0; n < opt.size(); ++n) {
tags[n].group = read_hex(opt[n][0]);
tags[n].element = read_hex(opt[n][1]);
Expand Down
Loading

0 comments on commit e467385

Please sign in to comment.