Commit eecba2a
committed
REF: Refactor gradient data checks in DWI data class
Refactor gradient data checks in DWI data class: PR
#325 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 997df63 commit eecba2a
2 files changed
+414
-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 | | |
| |||
86 | 105 | | |
87 | 106 | | |
88 | 107 | | |
89 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
90 | 115 | | |
91 | 116 | | |
92 | 117 | | |
| |||
96 | 121 | | |
97 | 122 | | |
98 | 123 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
105 | 127 | | |
106 | | - | |
107 | | - | |
| 128 | + | |
108 | 129 | | |
109 | 130 | | |
110 | 131 | | |
| |||
383 | 404 | | |
384 | 405 | | |
385 | 406 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
391 | 416 | | |
392 | 417 | | |
393 | 418 | | |
| |||
400 | 425 | | |
401 | 426 | | |
402 | 427 | | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 428 | + | |
421 | 429 | | |
422 | 430 | | |
423 | 431 | | |
| |||
0 commit comments