From 637b3ad9a695c4dd62934591b452bc927d9b0d7e Mon Sep 17 00:00:00 2001 From: Asma TANABENE <121893894+AsmaTANABEN@users.noreply.github.com> Date: Fri, 17 Jan 2025 09:56:56 +0100 Subject: [PATCH] Fixes for normalization issues (#214) * Fixes #211: Adjust normalization of density compensation coefficients. Add Cufinufft Pipe function authored by Chaithya G.R. * black style fix * deleting changes for cufinufft * writing style fix --------- Co-authored-by: Chaithya G R Co-authored-by: Asma TANABENE --- src/mrinufft/operators/interfaces/gpunufft.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mrinufft/operators/interfaces/gpunufft.py b/src/mrinufft/operators/interfaces/gpunufft.py index b5d65af6..57371299 100644 --- a/src/mrinufft/operators/interfaces/gpunufft.py +++ b/src/mrinufft/operators/interfaces/gpunufft.py @@ -590,12 +590,12 @@ def pipe( The oversampling factor the volume shape normalize: bool Whether to normalize the density compensation. - We normalize such that the energy of PSF = 1 """ if GPUNUFFT_AVAILABLE is False: raise ValueError( "gpuNUFFT is not available, cannot " "estimate the density compensation" ) + original_shape = volume_shape volume_shape = (np.array(volume_shape) * osf).astype(int) grid_op = MRIGpuNUFFT( samples=kspace_loc, @@ -607,11 +607,10 @@ def pipe( max_iter=num_iterations ) if normalize: - spike = np.zeros(volume_shape) - mid_loc = tuple(v // 2 for v in volume_shape) - spike[mid_loc] = 1 - psf = grid_op.adj_op(grid_op.op(spike)) - density_comp /= np.linalg.norm(psf) + test_op = MRIGpuNUFFT(samples=kspace_loc, shape=original_shape, **kwargs) + test_im = np.ones(original_shape, dtype=np.complex64) + test_im_recon = test_op.adj_op(density_comp * test_op.op(test_im)) + density_comp /= np.mean(np.abs(test_im_recon)) return density_comp.squeeze() def get_lipschitz_cst(self, max_iter=10, tolerance=1e-5, **kwargs):