Skip to content

Commit

Permalink
Merge branch 'dev' into clangformat
Browse files Browse the repository at this point in the history
  • Loading branch information
daljit46 committed Jul 19, 2023
2 parents 81e88a9 + 86eb1ea commit 7b2b544
Show file tree
Hide file tree
Showing 29 changed files with 5,986 additions and 815 deletions.
99 changes: 99 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# .git-blame-ignore-revs
# If you want this file to be utilised whener you utilise "git blame" on your local instance of the repository,
# run the following command from its root directory:
# git config blame.ignoreRevsFile .git-blame-ignore-revs

9268f0874fc8b2c3af0a090b8084bd91707a115e
#Author: Daan Christiaens <[email protected]>
#Date: Fri Dec 11 14:41:03 2015 +0100
# Update copyright header in all source files, as discussed in #9 and #31.

3024a116078eabd3b1353fc8329a73144632c86c
#Author: Thijs Dhollander <[email protected]>
#Date: Thu Nov 22 17:01:59 2018 +1100
# Copyright message update for next release (probably 2019-ish)
# Also updated the warranty statement: it appears this was still a formulation left over from the previous GPL license. The new formulation comes directly from the MPL 2.0, but is also more comprehensive; I'm more comfortable with having this more comprehensive. Furthermore, apart from it apparently being quite important to have a warranty statement at the top of source code files, it's apparently also of little value if it's not either very comprehensive, or it also directly refers to the license where the full text can be found. Hence, I added that as a sentence.
# Finally, also of note (and TODO) would be to add the copyright statement and a copy of the license somewhere on our (mrtrix.org) website. The final link is otherwise relatively useless in the context of the copyright and license statement.

6c6c553ed9e9004ca8495ece436fec4db465d82b
#Author: Thijs Dhollander <[email protected]>
#Date: Wed Dec 13 15:09:37 2017 +1100
# Copyright update for upcoming RC which will probably end up around New Year's
# Also includes a change of mention of MRtrix to MRtrix3, in line with the phrase MRtrix3 developers, which was already in there/
# Also includes removal of 2 .s, because they hindered clickability of the links in certain environments.

654b7281c953f1068142d1f8a152f786862d8876
#Author: Thijs Dhollander <[email protected]>
#Date: Wed Jan 25 17:57:11 2017 +1100
# header files

b623e418e36de6884511d9c233b04392ecce89bb
#Author: Thijs Dhollander <[email protected]>
#Date: Wed Jan 25 17:06:35 2017 +1100
# Copyright for 2017 in headers

95b144df3d9eb837fae08129cc292c3fb8490eac
#Author: Robert Smith <[email protected]>
#Date: Tue Oct 8 14:33:10 2019 +1100
# Add copyright notice to non-CPP files
# Also includes some line ending conversions and indentation changes.

be9a46286a9053fd1c1951fe5394206a95b61bfa
#Author: MRtrixBot <[email protected]>
#Date: Thu May 14 11:30:13 2020 +1000
# Initial commit of "update_copyright" changes

5e3112eae6ba4027aba854b3385f032c67dbfedf
#Author: MRtrixBot <[email protected]>
#Date: Mon Feb 7 16:48:14 2022 +0000
# update copyright notice and corresponding docs

e8edf6d946822c8ec23d077c2b1e9eef471b2539
#Author: MRtrixBot <[email protected]>
#Date: Tue Jan 3 13:41:40 2023 +0100
# Update copyright notice

74ff7cf0b76e2c9595b1341a7e4a49fa5491ce2f
#Author: MRtrixBot <[email protected]>
#Date: Wed Jan 6 12:50:54 2021 +0000
# Update copyright notice

65b3ea5e549f3f66a9e3c5d9ebdabb2a9bb462b4
#Author: Thijs Dhollander <[email protected]>
#Date: Thu Nov 22 17:30:36 2018 +1100
# Fixed typo in copyright/warranty statement.

729dd6cfc1a773f0f16592b8533c6e9d89d03ac3
#Author: Thijs Dhollander <[email protected]>
#Date: Mon May 15 10:33:05 2017 +1000
# copyright update and cleanup

76ad4fbb3ea60ea56ec94e3debfce1b7a35a9535
#Author: rtabbara <[email protected]>
#Date: Thu Feb 18 11:55:53 2016 +1100
# User docs: Update commands list with new copyright

6552f6ebe4f9fda441255063230ef9f8d9912591
#Author: J-Donald Tournier <[email protected]>
#Date: Wed Feb 5 12:50:53 2020 +0000
# remove carriage returns

811361d3af3ecfec03e20c2ee0f342634810a9c2
#Author: Thijs Dhollander <[email protected]>
#Date: Tue May 9 09:09:51 2017 +1000
# docs update

1eb36099870a0fffbc307ac40523dd8b6e35436f
#Author: Thijs Dhollander <[email protected]>
#Date: Thu Feb 2 12:26:20 2017 +1100
# standardise number of blank lines between copyright header and the rest of a file (was getting a bit out of hand for some files; now it's 2 blank lines for all)

e8edf6d946822c8ec23d077c2b1e9eef471b2539
#Author: MRtrixBot <[email protected]>
#Date: Tue Jan 3 13:41:40 2023 +0100
# Update copyright notice

aad44d847ac48d02bb7f8badf801dbfaa0ccdac0
#Author: MRtrixBot <[email protected]>
#Date: Tue Jan 3 13:42:58 2023 +0100
# Update Copyright notice in command docs
8 changes: 5 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ name: checks
on:
pull_request:
types: [opened, synchronize]
branches:
- master
- dev
branches: [ master, dev ]
merge_group:
types: [checks_requested]
branches: [ master ]




Expand Down
34 changes: 20 additions & 14 deletions bin/population_template
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,23 @@ DEFAULT_NL_LMAX = [ 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4

REGISTRATION_MODES = ['rigid', 'affine', 'nonlinear', 'rigid_affine', 'rigid_nonlinear', 'affine_nonlinear', 'rigid_affine_nonlinear']

AGGREGATION_MODES = ["mean", "median"]
AGGREGATION_MODES = ['mean', 'median']

IMAGEEXT = 'mif nii mih mgh mgz img hdr'.split()
IMAGEEXT = ['mif', 'nii', 'mih', 'mgh', 'mgz', 'img', 'hdr']

def usage(cmdline): #pylint: disable=unused-variable
cmdline.set_author('David Raffelt ([email protected]) & Max Pietsch ([email protected]) & Thijs Dhollander ([email protected])')

cmdline.set_synopsis('Generates an unbiased group-average template from a series of images')
cmdline.add_description('First a template is optimised with linear registration (rigid and/or affine, both by default), then non-linear registration is used to optimise the template further.')
cmdline.add_argument("input_dir", nargs='+', help='Input directory containing all images used to build the template')
cmdline.add_argument("template", help='Corresponding output template image. For multi-contrast registration, provide multiple paired input_dir and template arguments. Example: WM_dir WM_template.mif GM_dir GM_template.mif')
cmdline.add_argument('input_dir', nargs='+', help='Directory containing all input images of a given contrast')
cmdline.add_argument('template', help='Output template image')

cmdline.add_example_usage('Multi-contrast registration',
'population_template input_WM_ODFs/ output_WM_template.mif input_GM_ODFs/ output_GM_template.mif',
'When performing multi-contrast registration, the input directory and corresponding output template '
'image for a given contrast are to be provided as a pair, '
'with the pairs corresponding to different contrasts provided sequentially.')

options = cmdline.add_argument_group('Multi-contrast options')
options.add_argument('-mc_weight_initial_alignment', help='Weight contribution of each contrast to the initial alignment. Comma separated, default: 1.0')
Expand Down Expand Up @@ -979,7 +985,7 @@ def execute(): #pylint: disable=unused-variable
elif cns.n_volumes[cid] == 1:
run.function(copy, avh4d, 'average_header' + cns.suff[cid] + '.mif')
else:
run.command('mrcat ' + ' '.join([avh3d] * cns.n_volumes[cid]) + ' -axis 3 average_header' + cns.suff[cid] + '.mif')
run.command(['mrcat', [avh3d] * cns.n_volumes[cid], '-axis', '3', 'average_header' + cns.suff[cid] + '.mif'])
run.function(os.remove, avh3d)
run.function(os.remove, avh4d)
else:
Expand Down Expand Up @@ -1075,7 +1081,7 @@ def execute(): #pylint: disable=unused-variable
datatype_option)
progress.increment()
# update average space of first contrast to new extent, delete other average space images
run.command('mraverageheader ' + ' '.join([inp.ims_transformed[cid] + '_translated.mif' for inp in ins]) + ' average_header_tight.mif')
run.command(['mraverageheader', [inp.ims_transformed[cid] + '_translated.mif' for inp in ins], 'average_header_tight.mif'])
progress.done()

if voxel_size is None:
Expand Down Expand Up @@ -1235,12 +1241,12 @@ def execute(): #pylint: disable=unused-variable
# - If one subject's registration fails, this will affect the average and therefore the template which could result in instable behaviour.
# - The template appearance changes slightly over levels, but the template and trafos are affected in the same way so should not affect template convergence.
if not app.ARGS.linear_no_drift_correction:
run.command('transformcalc ' + ' '.join([os.path.join('linear_transforms_initial', inp.uid + '.txt') for _inp in ins]) +
' average linear_transform_average_init.txt -quiet', force=True)
run.command('transformcalc ' + ' '.join([os.path.join('linear_transforms_%02i' % level, inp.uid + '.txt') for _inp in ins]) +
' average linear_transform_average_%02i_uncorrected.txt -quiet' % level, force=True)
run.command('transformcalc linear_transform_average_%02i_uncorrected.txt invert ' % level +
'linear_transform_average_%02i_uncorrected_inv.txt -quiet' % level, force=True)
run.command(['transformcalc', [os.path.join('linear_transforms_initial', inp.uid + '.txt') for _inp in ins],
'average', 'linear_transform_average_init.txt', '-quiet'], force=True)
run.command(['transformcalc', [os.path.join('linear_transforms_%02i' % level, inp.uid + '.txt') for _inp in ins],
'average', 'linear_transform_average_%02i_uncorrected.txt' % level, '-quiet'], force=True)
run.command(['transformcalc', 'linear_transform_average_%02i_uncorrected.txt' % level,
'invert', 'linear_transform_average_%02i_uncorrected_inv.txt' % level, '-quiet'], force=True)

transform_average_init = matrix.load_transform('linear_transform_average_init.txt')
transform_average_current_inv = matrix.load_transform('linear_transform_average_%02i_uncorrected_inv.txt' % level)
Expand All @@ -1259,8 +1265,8 @@ def execute(): #pylint: disable=unused-variable
matrix.save_transform(os.path.join('linear_transforms_%02i' % level, inp.uid + '.txt'), transform_updated, force=True)

# compute average trafos and its properties for easier debugging
run.command('transformcalc ' + ' '.join([os.path.join('linear_transforms_%02i' % level, _inp.uid + '.txt') for _inp in ins]) +
' average linear_transform_average_%02i.txt -quiet' % level, force=True)
run.command(['transformcalc', [os.path.join('linear_transforms_%02i' % level, _inp.uid + '.txt') for _inp in ins],
'average', 'linear_transform_average_%02i.txt' % level, '-quiet'], force=True)
run.command('transformcalc linear_transform_average_%02i.txt decompose linear_transform_average_%02i.dec' % (level, level), force=True)


Expand Down
46 changes: 44 additions & 2 deletions cmd/fixelconnectivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/

#include "command.h"
#include "dwi/tractography/weights.h"
#include "fixel/fixel.h"
#include "fixel/helpers.h"
#include "fixel/index_remapper.h"
#include "fixel/matrix.h"

#define DEFAULT_ANGLE_THRESHOLD 45.0
Expand Down Expand Up @@ -63,12 +63,37 @@ void usage() {
+ Option("mask",
"provide a fixel data file containing a mask of those fixels to be computed; fixels outside the mask "
"will be empty in the output matrix") +
Argument("file").type_image_in()

+ DWI::Tractography::TrackWeightsInOption

+ OptionGroup("Options for additional outputs to be generated")

+ Option("count", "export a fixel data file encoding the number of connections for each fixel") +
Argument("path").type_image_out()

+
Option("extent", "export a fixel data file encoding the extent of connectivity (sum of weights) for each fixel") +
Argument("path").type_image_out();

+Option("mask",
"provide a fixel data file containing a mask of those fixels to be computed; fixels outside the mask "
"will be empty in the output matrix") +
Argument("file").type_image_in();
}

using value_type = float;
using Fixel::index_type;

template <class WriterType> void set_optional_outputs(WriterType &writer) {
auto opt = get_options("count");
if (opt.size())
writer.set_count_path(opt[0][0]);
opt = get_options("extent");
if (opt.size())
writer.set_extent_path(opt[0][0]);
}

void run() {
const value_type connectivity_threshold =
get_option_value("connectivity", value_type(DEFAULT_CONNECTIVITY_THRESHOLD));
Expand Down Expand Up @@ -96,7 +121,24 @@ void run() {
fixel_mask.value() = true;
}

auto connectivity_matrix = Fixel::Matrix::generate(argument[1], index_image, fixel_mask, angular_threshold);
if (get_options("tck_weights_in").size()) {

auto connectivity_matrix =
Fixel::Matrix::generate_weighted(argument[1], index_image, fixel_mask, angular_threshold);

Fixel::Matrix::Writer<Fixel::Matrix::InitMatrixWeighted> writer(connectivity_matrix, connectivity_threshold);
set_optional_outputs(writer);
writer.save(argument[2]);

} else {

auto connectivity_matrix =
Fixel::Matrix::generate_unweighted(argument[1], index_image, fixel_mask, angular_threshold);

Fixel::Matrix::Writer<Fixel::Matrix::InitMatrixUnweighted> writer(connectivity_matrix, connectivity_threshold);
set_optional_outputs(writer);
writer.save(argument[2]);
}

Fixel::Matrix::normalise_and_write(connectivity_matrix, connectivity_threshold, argument[2]);
}
Loading

0 comments on commit 7b2b544

Please sign in to comment.