Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chaithyagr committed Dec 20, 2024
1 parent 9917045 commit 119ee92
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/mrinufft/density/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ def normalize_weights(weights):
def normalize_density(kspace_loc, shape, density, backend, **kwargs):
"""Normalize the density to ensure that the reconstruction is stable."""
from mrinufft import get_operator

xp = np
if backend == "cufinufft":
import cupy as cp
xp = cp
test_op = get_operator(backend)(samples=kspace_loc, shape=shape, **kwargs)
test_im = np.ones(shape, dtype=test_op.cpx_dtype)
test_im = xp.ones(shape, dtype=test_op.cpx_dtype)
test_im_recon = test_op.adj_op(density * test_op.op(test_im))
density /= np.mean(np.abs(test_im_recon))
density /= xp.mean(xp.abs(test_im_recon))
return density

0 comments on commit 119ee92

Please sign in to comment.