-
Notifications
You must be signed in to change notification settings - Fork 191
Merge 3.0.5 into dev #3101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge 3.0.5 into dev #3101
Conversation
Where the gradient direction vector is zero, but the b-value is non-zero, when FSL's "eddy" attempts to rotate the directions of b>0 volumes according to subject rotation, this results in corrupted gradient directions. This change prevents such data from reaching "eddy" within dwifslpreproc, by detecting volumes where the gradient vector is zero and the b-value is non-zero but is classified by MRtrix3 as non-zero based on BZeroThreshold and forcing the value within the bvals file to be zero. Relates to #2577.
…ith unsupported transfer syntax This at least allow mrinfo to run. Any operation that attempts to access the voxel data will of course fail.
Co-authored-by: Robert Smith <[email protected]>
Uses an alternative design to f97d3ca / #2768 for supporting complex numbers in the reslice adapter. Specifically in determining the type to use during summation, f97d3ca chooses complex double if the type is not arithmetic, which could hypothetically lead to unexpected behaviour with unexpected template types. This alternative instead utilises the pre-existing is_complex<> SFINAE capability.
…read_with_unsupported_transfer_syntax
If the phase encoding information present in the header is only the phase encoding direction, but not readout time is present, then the constructed phase encoding matrix will possess only three columns, not four. If this happens, but an attempt is then made to cross-reference the readout time in the phase encoding table generated from header content against what the user has specified at the command-line, then an unhandled exception will occur. This change prevents specifically the comparison of readout times from being made if no such information is present. Replacement for erroneous commit faf0788. Also includes additional test that results in an unhandled exception on 3.0.4 but executes successfully with this change.
Whitespace present in name of associated compulsory argument erroneously implies that there are two input arguments expected.
Where a command receives a long list of inputs, while collapsing that set may be preferable from the perspective of user terminal information, it should not be hidden from a raw log of the set of commands executed. This change is not currently of high consequence as there is no mechanism that reads from that log file.
Adapter::Reslice: Alternative resolution of complex summation
Reslice adapter: allow use with complex numbers
- #2968: Absent - #3049: Absent - #2767: Partially absent - # 3027: Almost all absent (the new tests were in place but that was all) - #3047: Absent - #3071: Absent - #3011: Fill in gaps of changes that were applied to #3011 prior to its derivation from #2917. - #2609: Fixed a couple of small omissions. - #2602: Bits and pieces missing.
- Increment version number in CMakeLists.txt to reflect #3101 doing a merge with tag 3.0.5. - Various code features overlooked during writing of 1ebdb39. - Change MR::Axes::permutations_type to be a class rather than typedef in order to define a default uninitialised value, and also make it uint8 rather than size_t given it only has to stores the values 0, 1, 2, and an invalid flag. - Fix check for shuffle being the identity matrix as per #3169.
- dwifslpreproc: Fix F-string with no variable resolution. - mrtrix3.fsl: Update to reflect move from path.name_temporary() to utils.name_temporary(). - Move new test dwscheme_preservation_imprecision from #3027, duplicated for 3.1.0 in 568b28e, to binaries/mrcalc directory: the test is not specific to mrcalc, and so had been placed in the unit_tests/ directory, but it depends on data only available in the binary test data repository.
Some of the attempted manual manipulation of string multi-line formatting either did not work as intended, or yielded a string overflow at compile time for certain compilers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
| bvecs.row(0) = -bvecs.row(0); | ||
| if (header.realignment().orig_transform().linear().determinant() > 0.0) | ||
| bvecs.row(0) *= -1.0; | ||
| Eigen::MatrixXd grad(bvecs.cols(), 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion bool -> 'ssize_t' (aka 'long') [readability-implicit-bool-conversion]
| Eigen::MatrixXd grad(bvecs.cols(), 4); | |
| ssize_t nans_present_bvecs = 0; |
| if (header.realignment().orig_transform().linear().determinant() > 0.0) | ||
| bvecs.row(0) *= -1.0; | ||
| Eigen::MatrixXd grad(bvecs.cols(), 4); | ||
| grad.leftCols<3>().transpose() = header.realignment().orig_transform().linear() * bvecs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion bool -> 'ssize_t' (aka 'long') [readability-implicit-bool-conversion]
| grad.leftCols<3>().transpose() = header.realignment().orig_transform().linear() * bvecs; | |
| ssize_t nans_present_bvals = 0; |
| bool zero_row = false; | ||
| if (std::isnan(grad(n, 3))) { | ||
| if (grad.block<1, 3>(n, 0).squaredNorm() > 0.0) | ||
| // clang-format off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion bool -> 'ssize_t' (aka 'long') [readability-implicit-bool-conversion]
| // clang-format off | |
| nans_present_bvals = 1; |
| } | ||
| if (grad.block<1, 3>(n, 0).hasNaN()) { | ||
| if (grad(n, 3) > 0.0) | ||
| // clang-format off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion bool -> 'ssize_t' (aka 'long') [readability-implicit-bool-conversion]
| // clang-format off | |
| nans_present_bvecs = 1; |
| bvals(0, n) = grad(n, 3); | ||
| Axes::permutations_type order; | ||
| const auto adjusted_transform = File::NIfTI::adjust_transform(header, order); | ||
| Eigen::MatrixXd bvecs = adjusted_transform.inverse().linear() * grad.leftCols<3>().transpose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'Scalar' (aka 'double') -> bool [readability-implicit-bool-conversion]
| Eigen::MatrixXd bvecs = adjusted_transform.inverse().linear() * grad.leftCols<3>().transpose(); | |
| if (bvecs.row(n).squaredNorm() > 0.0 && (bvals[n] != 0.0) && bvals[n] <= bzero_threshold()) { |
|
|
||
| // bvecs format actually assumes a LHS coordinate system even if image is | ||
| // stored using RHS - x axis is flipped to make linear 3x3 part of | ||
| // stored using RHS; first axis is flipped to make linear 3x3 part of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'size_t' (aka 'unsigned long') -> bool [readability-implicit-bool-conversion]
| // stored using RHS; first axis is flipped to make linear 3x3 part of | |
| if (bval_zeroed_count != 0u) { |
| INFO("No need to transform slice encoding information for NIfTI image write:" | ||
| " image is already RAS"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
new_dir[axis] = shuffle.flips[axis] ? -orig_dir[shuffle.permutations[axis]] : orig_dir[shuffle.permutations[axis]];
^| if (one == "variable" || two == "variable") | ||
| return "variable"; | ||
| std::vector<std::string> one_split = split(one, ","); | ||
| std::vector<std::string> two_split = split(two, ","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
| std::vector<std::string> two_split = split(two, ","); | |
| default_type f_one; | |
| default_type f_two; |
| if (one == "variable" || two == "variable") | ||
| return "variable"; | ||
| std::vector<std::string> one_split = split(one, ","); | ||
| std::vector<std::string> two_split = split(two, ","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'f_one' is not initialized [cppcoreguidelines-init-variables]
default_type f_one, f_two;
^this fix will not be applied because it overlaps with another fix
| if (one == "variable" || two == "variable") | ||
| return "variable"; | ||
| std::vector<std::string> one_split = split(one, ","); | ||
| std::vector<std::string> two_split = split(two, ","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'f_two' is not initialized [cppcoreguidelines-init-variables]
default_type f_one, f_two;
^this fix will not be applied because it overlaps with another fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
| if (grad.block<1, 3>(n, 0).squaredNorm() > 0.0) | ||
| // clang-format off | ||
| throw Exception("Corrupt content in bvecs/bvals data" | ||
| " (" + bvecs_path + " & " + bvals_path + ")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
" (" + bvecs_path + " & " + bvals_path + ")"
^| if (grad(n, 3) > 0.0) | ||
| // clang-format off | ||
| throw Exception("Corrupt content in bvecs/bvals data" | ||
| " (" + bvecs_path + " & " + bvals_path + ")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
" (" + bvecs_path + " & " + bvals_path + ")"
^
This is on the clunkier side because of
devnow having both a mass reformatting of code and a re-arrangement on the file system.gitnow outright misses a lot of changes. So there will need to be extra diligence to make sure that changes applied tomasterprior to3.0.5have not been lost in the merging process. Assistance in that for PRs that are not my own would be appreciated.Certainly the DWI metadata handling changes were initially problematic. On my first merge attempt the changes in #3011 disappeared. So what I have done is started with #2917, first brought that up to date with current
dev, and then merged3.0.5onto that, knowing that much of the changes applied tomasterin #3011 were already manually applied based on the contents of #2917. This PR therefore supersedes #2917. I will however need to manually check the contents of #3011 and make sure nothing gets left out.