Skip to content

Commit 0b5edd9

Browse files
authored
Merge pull request #259 from femaleprog/fix/b0map-shape-handling
Fix: Automatically upsample b0_map in MRIFourierCorrected if shapes m…
2 parents f24240c + bb02d78 commit 0b5edd9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/mrinufft/operators/off_resonance.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from .base import FourierOperatorBase
1414

1515
from .interfaces.utils import is_cuda_array
16+
import warnings
17+
from scipy.ndimage import zoom
1618

1719
if CUPY_AVAILABLE:
1820
import cupy as cp
@@ -238,7 +240,18 @@ def __init__(
238240
self.shape = fourier_op.shape
239241
self.smaps = fourier_op.smaps
240242
self.autograd_available = fourier_op.autograd_available
241-
243+
if b0_map is not None:
244+
b0_map = np.asarray(b0_map, dtype=np.float32)
245+
if b0_map.shape != self.shape:
246+
warnings.warn(
247+
f"B0 map shape {b0_map.shape} does not match operator \
248+
shape {self.shape}. "
249+
"Upsampling will be performed automatically.\
250+
Please ensure orientation is correct.",
251+
UserWarning,
252+
)
253+
zoom_factors = tuple(t / c for t, c in zip(self.shape, b0_map.shape))
254+
b0_map = zoom(b0_map, zoom_factors, order=1)
242255
if B is not None and tl is not None:
243256
self.B = self.xp.asarray(B)
244257
self.tl = self.xp.asarray(tl)

0 commit comments

Comments
 (0)