Commit e406487
committed
REF: Refactor gradient data checks in DWI data class
Refactor gradient data checks in DWI data class: PR
https://github.com/nipreps/nifreeze/pull/325/files introduced the
row-major convention for gradient data in NiFreeze. However, gradient
loading was not tested thoroughly. This resulted in some execution flows
that would not guarantee a row-major internal convention or would crash
under some circumstances/
This commit refactors the gradient data checks and adds thorough
testing:
- Define all error or warning messages as global variables so that they
can be checked exactly in tests.
- Ensure that gradients conform to the row-major convention when
instantiating the DWI class directly. This allows to separate the
gradient reformatting from the dimensionality check with the DWI
volume sequence. This simplifies the flow, as the gradient
reformatting to the row-major convention does not depend on the number
of volumes in the DWI sequence. Also, this makes the flow more
consistent with the refactored checks of the NIfTI file-based loading
utility function (`from_nii`).
- Ensure that the gradients conform to the row-major convention
immediately after loading the gradients file in the NIfTI file-based
loading utility function (`from_nii`). As opposed to the previous
implementation, this allows to load the gradients from a file where
data follows either column-major or row-major convention. e.g. In the
previous implementation the `if grad.shape[1] < 2:` was making an
assumption about the layout and/or one that was wrong because we
require 4 columns (direction (x,y,z) + b-value) or rows (if in
column-major). The new implementation simplifies the execution flow.1 parent fd64c14 commit e406487
2 files changed
+413
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
66 | 85 | | |
67 | 86 | | |
68 | 87 | | |
| |||
84 | 103 | | |
85 | 104 | | |
86 | 105 | | |
87 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
88 | 113 | | |
89 | 114 | | |
90 | 115 | | |
| |||
94 | 119 | | |
95 | 120 | | |
96 | 121 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
103 | 125 | | |
104 | | - | |
105 | | - | |
| 126 | + | |
106 | 127 | | |
107 | 128 | | |
108 | 129 | | |
| |||
381 | 402 | | |
382 | 403 | | |
383 | 404 | | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
389 | 414 | | |
390 | 415 | | |
391 | 416 | | |
| |||
398 | 423 | | |
399 | 424 | | |
400 | 425 | | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 426 | + | |
419 | 427 | | |
420 | 428 | | |
421 | 429 | | |
| |||
0 commit comments