Skip to content

Commit 4fa0474

Browse files
authored
fix(smaps): decimated shape rounding for espirit. (#363)
Closes: #362
1 parent 1064f1f commit 4fa0474

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/mrinufft/extras/smaps.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ def cartesian_espirit(
388388

389389
xp = get_array_module(kspace)
390390
n_coils = kspace.shape[0]
391+
decim_shape = shape
391392
if decim > 1:
392393
try:
393394
from skimage.restoration import unwrap_phase
@@ -397,10 +398,12 @@ def cartesian_espirit(
397398
"it along with the [extra] dependencies "
398399
"or using `pip install scikit-image`."
399400
) from err
401+
decim_shape = tuple(sh // decim for sh in shape)
400402
kspace = _crop_or_pad(
401403
kspace,
402-
(kspace.shape[0],) + tuple(sh // decim for i, sh in enumerate(shape)),
404+
(kspace.shape[0],) + decim_shape,
403405
)
406+
404407
calib_shape = (n_coils, *calib_width)
405408
calib = _crop_or_pad(kspace, calib_shape)
406409
calib = _unfold_blocks(calib, kernel_width)
@@ -442,10 +445,15 @@ def cartesian_espirit(
442445
[with_numpy(unwrap_phase)(smap) for smap in xp.angle(Smaps)],
443446
dtype=xp.float32,
444447
)
445-
abs_maps = zoom(abs(Smaps), (1,) + (decim,) * (Smaps.ndim - 1), order=1)
448+
zoom_fac = (1.0,) + tuple(s / ds for s, ds in zip(shape, decim_shape))
449+
abs_maps = zoom(
450+
abs(Smaps),
451+
zoom_fac,
452+
order=1,
453+
)
446454
# Phase zoom with 0 order to prevent residual unwrapping causing artifacts
447-
angle_maps = zoom(unwrapped_phase, (1,) + (decim,) * (Smaps.ndim - 1), order=0)
448-
max_eig = zoom(max_eig.T[0], (1,) + (decim,) * (Smaps.ndim - 1), order=1)
455+
angle_maps = zoom(unwrapped_phase, zoom_fac, order=0)
456+
max_eig = zoom(max_eig.T[0], zoom_fac, order=1)
449457
Smaps = abs_maps * np.exp(1j * angle_maps)
450458
Smaps *= max_eig > crop
451459
# Clean up memory after operations

0 commit comments

Comments
 (0)