cg#
- mrinufft.extras.cg(operator: FourierOperatorBase, kspace_data: NDArray, damp: float = 0.0, x0: NDArray | None = None, x_init: NDArray | None = None, max_iter: int = 10, tol: float = 0.0001, progressbar: bool | tqdm = True, callback: Callable | None = None)[source]#
Perform conjugate gradient (CG) optimization for image reconstruction.
The image is updated using the gradient of a data consistency term, and a velocity vector is used to accelerate convergence.
- Parameters:
nufft (FourierOperatorBase) – The NUFFT operator representing the forward model.
kspace_data (NDArray) – The right-hand side vector. Shape is typically
(n_batchs, n_coils, n_samples).damp (float, optional) – Damping (regularization) parameter. Default is 0.0 (no regularization).
x0 (NDArray or None, optional) – Damping vector. If None, uses zero. Shape is typically
(n_batchs, n_coils or 1, *nufft.shape).x_init (NDArray or None, optional) – Initial guess vector. If ommitted, default to x0. Must have same shape as x0.
callback (Callable, optional) – If provided, a callback function will be called at the end of each iteration with the current estimate. It should have the following signature
callback(operator, kspace_data, damp, x0)max_iter (int, optional) – Maximum number of iterations. Default is 100.
progressbar (bool, optional) – If True (default) display a progress bar to track iterations.
- tol: float
Tolerance for converge check.
- Returns:
Solution vector with shape
(n_batchs, n_coils or 1, *nufft.shape), dtype and device matching input.- Return type:
NDArray
Note
This function uses
numpyfor all CPU arrays, andcupyfor all on-gpu array. It will convert all its array argument to the respective array library. The outputs will be converted back to the original array module and device.See also
This function is part of the optimizer registry,
get_optimizer(). You can find other registered functions in this registry below:Key
Function
"lsqr""lsmr""cg"