Skip to content

Commit bb525af

Browse files
test : add unit test for B0 map upsampling in MRIFourierCorrected (#261)
* test : add unit test for B0 map upsampling in MRIFourierCorrected * refactor: move upscale test with other orc tests --------- Co-authored-by: Pierre-antoine Comby <[email protected]>
1 parent fe2d95d commit bb525af

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/test_offres_exp_approx.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from mrinufft._array_compat import CUPY_AVAILABLE
1313
from mrinufft._utils import get_array_module
1414
from mrinufft.operators.off_resonance import MRIFourierCorrected
15-
15+
from mrinufft import get_operator
1616

1717
from helpers import to_interface, assert_allclose
1818
from helpers.factories import _param_array_interface
@@ -106,3 +106,34 @@ def test_zmap_coeff(zmap, mask, array_interface):
106106
)
107107
actual = calculate_approx_offresonance_term(B, C)
108108
assert_allclose(actual, expected, atol=1e-3, rtol=1e-3, interface=array_interface)
109+
110+
111+
def test_b0_map_upsampling_warns_and_matches_shape():
112+
"""Test that MRIFourierCorrected upscales the b0_map and warns if shape mismatch exists."""
113+
114+
shape_target = (16, 16, 16)
115+
b0_shape = (8, 8, 8)
116+
117+
b0_map = np.ones(b0_shape, dtype=np.float32)
118+
kspace = np.zeros((10, 3), dtype=np.float32)
119+
smaps = np.ones((1, *shape_target), dtype=np.complex64)
120+
readout_time = np.ones(10, dtype=np.float32)
121+
122+
nufft = get_operator("finufft")(
123+
samples=kspace,
124+
shape=shape_target,
125+
n_coils=1,
126+
smaps=smaps,
127+
density=False,
128+
)
129+
130+
with pytest.warns(UserWarning):
131+
op = MRIFourierCorrected(
132+
nufft,
133+
b0_map=b0_map,
134+
readout_time=readout_time,
135+
)
136+
137+
# check that no exception is raised and internal shape matches
138+
assert op.B.shape[1] == len(readout_time)
139+
assert op.shape == shape_target

0 commit comments

Comments
 (0)