Skip to content

Commit

Permalink
Resolution of merge of master to dev
Browse files Browse the repository at this point in the history
Resolution of content merged to dev initially omitted from #3061.
- #2693 (completely omitted)
- #3005 (partial propagation / independent address of some common issues on both branches)
- #3001 (completely omitted)
- #2908 (completely omitted)
- #2955 (completely omitted)
- #2600 (completely omitted)
- #2962 (completely omitted)
- #2935 (completely omitted)
- #2923 (completely omitted)
- #2910 (completely omitted)
- #2638 (completely omitted)
- #2698 (completely omitted)
- #2721 (completely omitted)
- #2794 (completely omitted)
- #2768 (completely omitted; required modification to conform to other dev changes)
- #2713 (residual compilation errors following adf8fdd, including resolution against changes in #2437 on dev.
  • Loading branch information
Lestropie committed Jan 15, 2025
1 parent adf8fdd commit eb4e8e1
Show file tree
Hide file tree
Showing 24 changed files with 83 additions and 52 deletions.
2 changes: 1 addition & 1 deletion cpp/cmd/dwi2tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,14 @@ void run() {
Header header(dwi);
header.datatype() = DataType::Float32;
header.ndim() = 4;
DWI::stash_DW_scheme(header, grad);
PhaseEncoding::clear_scheme(header);

Image<value_type> predict;
opt = get_options("predicted_signal");
if (!opt.empty())
predict = Image<value_type>::create(opt[0][0], header);

DWI::stash_DW_scheme(header, grad);
header.size(3) = 6;
auto dt = Image<value_type>::create(argument[1], header);

Expand Down
2 changes: 2 additions & 0 deletions cpp/cmd/mrcalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,8 @@ void run() {
++n;
else if (opt->is("force") || opt->is("info") || opt->is("debug") || opt->is("quiet"))
continue;
else if (opt->is("config"))
n+=2;

#define SECTION 3
#include "mrcalc.cpp"
Expand Down
16 changes: 12 additions & 4 deletions cpp/cmd/mrdegibbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,19 @@ void usage() {
" you should run denoising before this command to not alter the noise structure,"
" which would impact on dwidenoise's performance."

+ "For best results, any form of filtering performed by the scanner should be disabled,"
" whether performed in the image domain or k-space."
" This includes elliptic filtering and other filters "
" that are often applied to reduce Gibbs ringing artifacts."
" While this method can still safely be applied to such data,"
" some residual ringing artefacts may still be present in the output."

+ "Note that this method is designed to work on images acquired with full k-space coverage."
" Running this method on partial Fourier ('half-scan')"
" or filtered data may not remove all ringing artefacts."
" Users are encouraged to acquired full-Fourier data where possible,"
" and disable any form of filtering on the scanner.";
" If this method is executed on data acquired with partial Fourier (eg. \"half-scan\") acceleration,"
" it may not fully remove all ringing artifacts,"
" and you may observe residuals of the original artifact in the partial Fourier direction."
" Nonetheless, application of the method is still considered safe and worthwhile."
" Users are however encouraged to acquired full-Fourier data where possible.";


ARGUMENTS
Expand Down
2 changes: 1 addition & 1 deletion cpp/cmd/mrgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void usage() {
" to match the specified reference image grid."
" This operation ignores differences in image transformation"
" between input and reference image.")
+ Argument ("reference image").type_image_in()
+ Argument ("reference_image").type_image_in()

+ Option ("uniform", "pad or crop the input image"
" by a uniform number of voxels on all sides")
Expand Down
2 changes: 1 addition & 1 deletion cpp/cmd/mrinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const OptionGroup FieldExportOptions = OptionGroup ("Options for exporting image

void usage() {

AUTHOR = "J-Donald Tournier ([email protected])"
AUTHOR = "J-Donald Tournier ([email protected])"
" and Robert E. Smith ([email protected])";

SYNOPSIS = "Display image header information,"
Expand Down
20 changes: 15 additions & 5 deletions cpp/core/adapter/reslice.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,21 @@ typename std::enable_if<!std::is_same<value_type, bool>::value && std::is_integr
return value_type(std::round(sum * norm));
}

template <typename value_type>
typename std::enable_if<std::is_floating_point<value_type>::value, value_type>::type inline normalise(
const default_type sum, const default_type norm) {
return (sum * norm);
// Standard implementation for floating point (either real or complex)
template <typename value_type, typename summing_type>
typename std::enable_if<!std::is_same<value_type, bool>::value && !std::is_integral<value_type>::value, value_type>::type
inline normalise (const summing_type sum, const default_type norm) {
return value_type (sum * norm);
}

// If summing complex numbers, use double precision complex;
// otherwise, use double precision real
template <typename value_type> struct summing_type {
using type = double;
};
template <typename value_type> struct summing_type<is_complex<value_type>> {
using type = std::complex<double>;
};
} // namespace

extern const transform_type NoTransform;
Expand Down Expand Up @@ -175,7 +185,7 @@ class Reslice : public ImageBase<Reslice<Interpolator, ImageType>, typename Imag
using namespace Eigen;
if (oversampling) {
Vector3d d(x[0] + from[0], x[1] + from[1], x[2] + from[2]);
default_type sum(0.0);
typename summing_type<value_type>::type sum(0);
Vector3d s;
for (uint32_t z = 0; z < OS[2]; ++z) {
s[2] = d[2] + z * inc[2];
Expand Down
5 changes: 5 additions & 0 deletions cpp/core/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ std::string underline(const std::string &text, bool ignore_whitespace = false) {

const char *argtype_description(ArgType type) {
switch (type) {
case Boolean:
return ("boolean");
case Integer:
return ("integer");
case Float:
Expand Down Expand Up @@ -450,6 +452,9 @@ std::string Argument::usage() const {
case Undefined:
assert(0);
break;
case Boolean:
stream << "BOOL";
break;
case Integer: {
const auto int_range = std::get<IntRange>(limits);
stream << "INT " << int_range.min << " " << int_range.max;
Expand Down
2 changes: 1 addition & 1 deletion cpp/core/dwi/fmls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void load_fmls_thresholds(Segmenter &segmenter) {
}
}

opt = get_options("fmls_merge_ratio");
opt = get_options("fmls_lobe_merge_ratio");
if (!opt.empty())
segmenter.set_lobe_merge_ratio(default_type(opt[0][0]));
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/core/file/dicom/select_cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ std::vector<std::shared_ptr<Series>> select_cmdline(const Tree &tree) {
}
std::cerr << "? ";
std::cin >> buf;
if (buf[0] == 'q' || buf[0] == 'Q')
if (!std::cin || buf[0] == 'q' || buf[0] == 'Q')
throw CancelException();
if (isdigit(buf[0])) {
int n = to<int>(buf) - 1;
Expand Down Expand Up @@ -138,7 +138,7 @@ std::vector<std::shared_ptr<Series>> select_cmdline(const Tree &tree) {
}
std::cerr << "? ";
std::cin >> buf;
if (buf[0] == 'q' || buf[0] == 'Q')
if (!std::cin || buf[0] == 'q' || buf[0] == 'Q')
throw CancelException();
if (isdigit(buf[0])) {
int n = to<int>(buf) - 1;
Expand Down Expand Up @@ -179,7 +179,7 @@ std::vector<std::shared_ptr<Series>> select_cmdline(const Tree &tree) {
}
std::cerr << "? ";
std::cin >> buf;
if (buf[0] == 'q' || buf[0] == 'Q')
if (!std::cin || buf[0] == 'q' || buf[0] == 'Q')
throw CancelException();
if (isdigit(buf[0])) {
std::vector<uint32_t> seq;
Expand Down
3 changes: 2 additions & 1 deletion cpp/core/file/mmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ MMap::MMap(const Entry &entry, bool readwrite, bool preload, int64_t mapped_size

if (fsbuf.f_type == 0xff534d42 /* CIFS */ || fsbuf.f_type == 0x6969 /* NFS */ ||
fsbuf.f_type == 0x65735546 /* FUSE */ || fsbuf.f_type == 0x517b /* SMB */ ||
fsbuf.f_type == 0x47504653 /* GPFS */ || fsbuf.f_type == 0xbd00bd0 /* LUSTRE */
fsbuf.f_type == 0x47504653 /* GPFS */ || fsbuf.f_type == 0xbd00bd0 /* LUSTRE */ ||
fsbuf.f_type == 0x1021997 /* 9P (WSL) */

#ifdef MRTRIX_MACOSX
|| fsbuf.f_type == 0x0017 /* OSXFUSE */
Expand Down
1 change: 0 additions & 1 deletion cpp/core/file/png.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ void Writer::save(uint8_t *data) {
row_pointers[row] = to_write + row * row_bytes;
png_write_image(png_ptr, row_pointers.get());
png_write_end(png_ptr, info_ptr);
delete [] row_pointers;
};

if (data_type == DataType::UInt8 || data_type == DataType::UInt16BE) {
Expand Down
8 changes: 5 additions & 3 deletions cpp/core/file/png.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ template <typename T>
void Writer::fill(uint8_t *in_ptr, uint8_t *out_ptr, const DataType data_type, const size_t num_elements) {
auto fetch_func = __set_fetch_function<default_type>(data_type);
for (size_t i = 0; i != num_elements; ++i)
Raw::store_BE<T> (std::min (default_type(std::numeric_limits<T>::max()), //
std::max (0.0, std::round(multiplier * fetch_func (in_ptr, i, 0.0, 1.0)))), //
out_ptr, i); //
Raw::store_BE<T> (std::min (default_type(std::numeric_limits<T>::max()), //
std::max (0.0, std::round(multiplier * fetch_func (in_ptr, 0)))), //
out_ptr, i); //
in_ptr += data_type.bytes();
out_ptr += sizeof(T);
};

} // namespace MR::File::PNG
Expand Down
3 changes: 2 additions & 1 deletion cpp/core/formats/pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ bool Pipe::check(Header &H, size_t num_axes) const {
return false;

if (isatty(STDOUT_FILENO))
throw Exception("attempt to pipe image to standard output (this will leave temporary files behind)");
throw Exception ("cannot create output piped image: " //
"no command connected at other end of pipe to receive that image"); //

H.name() = File::create_tempfile(0, "mif");

Expand Down
3 changes: 0 additions & 3 deletions cpp/core/formats/png.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ bool PNG::check(Header &H, size_t num_axes) const {
axis_to_zero = 1;
} else if (H.size(0) == 1) {
axis_to_zero = 0;
width_axis = 1;
} else {
// If image is 3D, and all three axes have size greater than one, and we
// haven't used the square-bracket notation, we can't export genuine 3D data
Expand All @@ -184,8 +183,6 @@ bool PNG::check(Header &H, size_t num_axes) const {
if (axis < 0)
throw Exception("Cannot export 4D image to PNG format if all three spatial axes have size greater than 1 and "
"square-bracket notation is not used");
if (!axis_to_zero)
width_axis = 1;
break;
default:
throw Exception("Cannot generate PNG file(s) from image with more than 4 axes");
Expand Down
2 changes: 1 addition & 1 deletion cpp/core/progressbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ bool ProgressBar::set_update_method() {
// unable to determine nature of stderr; assuming socket
stderr_to_file = false;
else
stderr_to_file = S_ISREG(buf.st_mode);
stderr_to_file = S_ISREG(buf.st_mode) || S_ISFIFO(buf.st_mode);

if (stderr_to_file) {
ProgressBar::display_func = display_func_redirect;
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/dirrotate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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
22 changes: 11 additions & 11 deletions docs/reference/commands/dwi2mask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Ricardo Rios ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -276,7 +276,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -390,7 +390,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -485,7 +485,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -584,7 +584,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Warda Syeda ([email protected]) and Robert E. Smith ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -675,7 +675,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -761,7 +761,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -852,7 +852,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Warda Syeda ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -960,7 +960,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected]) and Arshiya Sangchooli ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -1064,7 +1064,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Ruobing Chen ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 @@ -1162,7 +1162,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Warda Syeda ([email protected]) and Robert E. Smith ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 docs/reference/commands/dwibiascorrect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected]) and Arshiya Sangchooli ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 docs/reference/commands/dwibiasnormmask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected]) and Arshiya Sangchooli ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 docs/reference/commands/dwinormalise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Robert E. Smith ([email protected]) and Arshiya Sangchooli ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 docs/reference/commands/mask2glass.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch

**Author:** Remika Mito ([email protected]) and Robert E. Smith ([email protected])

**Copyright:** Copyright (c) 2008-2024 the MRtrix3 contributors.
**Copyright:** Copyright (c) 2008-2025 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 docs/reference/commands/mrdegibbs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ By default, the original 2D slice-wise version is used. If the -mode 3d option i

This command is designed to run on data directly after it has been reconstructed by the scanner, before any interpolation of any kind has taken place. You should not run this command after any form of motion correction (e.g. not after dwifslpreproc). Similarly, if you intend running dwidenoise, you should run denoising before this command to not alter the noise structure, which would impact on dwidenoise's performance.

For best results, any form of filtering performed by the scanner should be disabled, whether performed in the image domain or k-space. This includes elliptic filtering and other filters that are often applied to reduce Gibbs ringing artifacts. While this method can still safely be applied to such data, some residual ringing artefacts may still be present in the output.
For best results, any form of filtering performed by the scanner should be disabled, whether performed in the image domain or k-space. This includes elliptic filtering and other filters that are often applied to reduce Gibbs ringing artifacts. While this method can still safely be applied to such data, some residual ringing artefacts may still be present in the output.

Note that this method is designed to work on images acquired with full k-space coverage. If this method is executed on data acquired with partial Fourier (eg. "half-scan") acceleration, it may not fully remove all ringing artifacts, and you may observe residuals of the original artifact in the partial Fourier direction. Nonetheless, application of the method is still considered safe and worthwhile. Users are however encouraged to acquired full-Fourier data where possible.

Expand Down
Loading

0 comments on commit eb4e8e1

Please sign in to comment.