Skip to content

Tolerance for dw_scheme differences on header merge#3027

Merged
jdtournier merged 2 commits intomasterfrom
header_merge_dwscheme
Feb 12, 2025
Merged

Tolerance for dw_scheme differences on header merge#3027
jdtournier merged 2 commits intomasterfrom
header_merge_dwscheme

Conversation

@Lestropie
Copy link
Member

Closes #3015.

As part of this change, I decided that the "b=0 threshold" is more appropriate in dwi/gradient.h rather than dwi/shells.h, since it may be applied to individual volumes rather than shells. Here it's used to say "if two images both have a b=0 volume here, then their diffusion gradient tables are compatible; I don't care if their unit directions are different".

Also fixed some transitive includes in the process.

The new tests should hopefully demonstrate the fix:

  • Without this PR, the two "dw_scheme" entries only have to differ by one least significant digit to result in the whole diffusion gradient table being discarded.
  • But conversely, if two images undergo an operation and their diffusion gradient tables are totally incompatible, it'll still be dropped.

(They also neatly demonstrate why having just a list of tests per command is restrictive;
with ctest I'll be able to name these tests according to what they are actually evaluating,
which isn't specific to any one command)

This prevents the diffusion gradient table from being discarded when merging the key-value contents of two image headers (eg. mrcalc, mrmath) due to inconsequential differences in their string representations from floating-point imprecision.
Closes #3015.
@Lestropie Lestropie added the bug label Oct 22, 2024
@Lestropie Lestropie added this to the 3.0.5 updates milestone Oct 22, 2024
@Lestropie Lestropie requested a review from a team October 22, 2024 03:47
@Lestropie Lestropie self-assigned this Oct 22, 2024
@jdtournier jdtournier added this pull request to the merge queue Feb 12, 2025
Merged via the queue into master with commit f95eb89 Feb 12, 2025
@jdtournier jdtournier deleted the header_merge_dwscheme branch February 12, 2025 10:28
Lestropie added a commit that referenced this pull request Jun 5, 2025
Following #3027 in version 3.0.5, commands could produce an erroneous warning whenever concatenating images along the volume axis where those images contained diffusion gradient tables that did not match. Where concatenation occurrs along the volume axis, the gradient table itself gets concatenated rows. This was operating correctly, but underlying function Header::merge_keyval() was issuing erroneous earnings regarding an inability to merge the gradient tables directly prior to the concatenation operation taking place. This could occur if using the multi-file numbered image capability acorss volumes, or if concatenating across image series that contain different gradient tables.
Lestropie added a commit that referenced this pull request Aug 26, 2025
Following #3027 in version 3.0.5, commands could produce an erroneous warning whenever concatenating images along the volume axis where those images contained diffusion gradient tables that did not match. Where concatenation occurrs along the volume axis, the gradient table itself gets concatenated rows. This was operating correctly, but underlying function Header::merge_keyval() was issuing erroneous earnings regarding an inability to merge the gradient tables directly prior to the concatenation operation taking place. This could occur if using the multi-file numbered image capability acorss volumes, or if concatenating across image series that contain different gradient tables.
@Lestropie Lestropie restored the header_merge_dwscheme branch August 26, 2025 08:11
@Lestropie Lestropie deleted the header_merge_dwscheme branch August 27, 2025 00:22
@Lestropie Lestropie mentioned this pull request Sep 2, 2025
Lestropie added a commit that referenced this pull request Sep 3, 2025
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tolerance to gradient table mismatch on header merge

2 participants