loss_l2_reg#
- mrinufft.extras.optim.loss_l2_reg(image, operator, kspace_data, damp=0.0, x0=None)[source]#
 Compute the regularized least squares loss for MRI reconstruction.
Computes the loss \(\|A x - y\|_2^2 + \gamma^2 \|x - x_0\|_2^2\)
where A is the measurement operator, x is the current image estimate, y is the acquired k-space data, damp (\(\gamma\)) is a regularization parameter, and \(x_0\) is an initial guess.
- Parameters:
 image (NDArray) – Current image estimate. Shape and dtype must be compatible with the operator.
operator (FourierOperatorBase) – The NUFFT (non-uniform FFT) operator used for forward modeling.
kspace_data (NDArray) – Measured k-space data. Shape must match the output of the operator.op(image).
damp (float or None, optional) – Regularization parameter (default=None). If None, no regularization is applied.
x0 (NDArray or None, optional) – Reference image for regularization (default=None).
- Returns:
 norm_res – The computed L2 regularized least squares loss value(s). If batched, shape = (n_batchs,).
- Return type:
 float or NDArray
Notes
Batch dimension is preserved if present.
This function can be used as a callback in cg or lsqr method to keep track of the convergence.
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.