|
12 | 12 | from mrinufft._array_compat import CUPY_AVAILABLE |
13 | 13 | from mrinufft._utils import get_array_module |
14 | 14 | from mrinufft.operators.off_resonance import MRIFourierCorrected |
15 | | - |
| 15 | +from mrinufft import get_operator |
16 | 16 |
|
17 | 17 | from helpers import to_interface, assert_allclose |
18 | 18 | from helpers.factories import _param_array_interface |
@@ -106,3 +106,34 @@ def test_zmap_coeff(zmap, mask, array_interface): |
106 | 106 | ) |
107 | 107 | actual = calculate_approx_offresonance_term(B, C) |
108 | 108 | 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