# Solver¶

Module holding the classes for different numerical Optimizer.

class pyqmri.solver.CGSolver(par, NScan=1, trafo=1, SMS=0)

This Class performs a CG reconstruction on single precission complex input data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). NScan (int) – Number of Scan which should be used internally. Do not need to be the same number as in par[“NScan”] trafo (bool) – Switch between radial (1) and Cartesian (0) fft. SMS (bool) – Simultaneouos Multi Slice. Switch between noraml (0) and slice accelerated (1) reconstruction.
eval_fwd_kspace_cg(y, x, wait_for=None)

Apply forward operator for image reconstruction. :param y: The result of the computation :type y: PyOpenCL.Array :param x: The input array :type x: PyOpenCL.Array :param wait_for: A List of PyOpenCL events to wait for. :type wait_for: list of PyopenCL.Event, None

Returns: A PyOpenCL.Event to wait for. PyOpenCL.Event
run(data, iters=30, lambd=1e-05, tol=1e-08, guess=None, scan_offset=0)

Start the CG reconstruction.

All attributes after data are considered keyword only.

Parameters: data (numpy.array) – The complex k-space data which serves as the basis for the images. iters (int) – Maximum number of CG iterations lambd (float) – Weighting parameter for the Tikhonov regularization tol (float) – Termination criterion. If the energy decreases below this threshold the algorithm is terminated. guess (numpy.array) – An optional initial guess for the images. If None, zeros is used. The result of the image reconstruction. numpy.Array
class pyqmri.solver.CGSolver_H1(prg, queue, par, irgn_par, coils, linops)

This Class performs a CG reconstruction on single precission complex input data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. prg (PyOpenCL Program A PyOpenCL Program containing the) – kernels for optimization. linops (PyQMRI Operator The operator to traverse from) – parameter to data space. coils (PyOpenCL Buffer or empty list) – coil buffer, empty list if image based fitting is used.
power_iteration(x, num_simulations=50)
power_iteration_grad(x, num_simulations=50)
run(guess, data, iters=30)

Start the CG reconstruction.

All attributes after data are considered keyword only.

Parameters: guess (numpy.array) – An optional initial guess for the images. If None, zeros is used. data (numpy.array) – The complex k-space data which serves as the basis for the images. iters (int) – Maximum number of CG iterations The result of the fitting. dict of numpy.Array
setFvalInit(fval)

Set the initial value of the cost function.

Parameters: fval (float) – The initial cost of the optimization problem
updateRegPar(irgn_par)

Update the regularization parameters.

Performs an update of the regularization parameters as these usually vary from one to another Gauss-Newton step.
Parameters: (dic) (irgn_par) –
update_box(outp, inp, par, idx=0, idxq=0, bound_cond=0, wait_for=None)

Primal update of the x variable in the Primal-Dual Algorithm.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
class pyqmri.solver.PDBaseSolver(par, irgn_par, queue, tau, fval, prg, coil, model, DTYPE=<class 'numpy.complex64'>, DTYPE_real=<class 'numpy.float32'>)

Primal Dual splitting optimization.

This Class performs a primal-dual variable splitting based reconstruction on single precission complex input data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimate of the initial step size based on the operator norm of the linear operator. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL Program A PyOpenCL Program containing the) – kernels for optimization. reg_type (string String to choose between "TV" and "TGV") – optimization. data_operator (PyQMRI Operator The operator to traverse from) – parameter to data space. coil (PyOpenCL Buffer or empty list) – coil buffer, empty list if image based fitting is used. model (PyQMRI.Model) – Instance of a PyQMRI.Model to perform plotting
delta

Regularization parameter for L2 penalty on linearization point.

Type: float
omega

Not used. Should be set to 0

Type: float
lambd

Regularization parameter in front of data fidelity term.

Type: float
tol

Relative toleraze to stop iterating

Type: float
stag

Stagnation detection parameter

Type: float
display_iterations

Switch between plotting (true) of intermediate results

Type: bool
mu

Strong convecity parameter (inverse of delta).

Type: float
tau

Estimated step size based on operator norm of regularization.

Type: float
beta_line

Ratio between dual and primal step size

Type: float
theta_line

Line search parameter

Type: float
unknwons_TGV

Number of T(G)V unknowns

Type: int
unknowns_H1

Number of H1 unknowns (should be 0 for now)

Type: int
unknowns

Total number of unknowns (T(G)V+H1)

Type: int
num_dev

Total number of compute devices

Type: int
dz

Ratio between 3rd dimension and isotropic 1st and 2nd image dimension.

Type: float
model

The model which should be fitted

Type: PyQMRI.Model
modelgrad

The partial derivatives evaluated at the linearization point. This variable is set in the PyQMRI.irgn Class.

Type: PyOpenCL.Array or numpy.Array
min_const

list of minimal values, one for each unknown

Type: list of float
max_const

list of maximal values, one for each unknown

Type: list of float
real_const

list if a unknown is constrained to real values only. (1 True, 0 False)

Type: list of int
static factory(prg, queue, par, irgn_par, init_fval, coils, linops, model, reg_type='TGV', SMS=False, streamed=False, imagespace=False, DTYPE=<class 'numpy.complex64'>, DTYPE_real=<class 'numpy.float32'>)

Generate a PDSolver object.

Parameters: prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. init_fval (float) – Estimate of the initial cost function value to scale the displayed values. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. linops (list of PyQMRI Operator) – The linear operators used for fitting. model (PyQMRI.Model) – The model which should be fitted reg_type (string, "TGV") – String to choose between “TV” and “TGV” optimization. SMS (bool, false) – Switch between standard (false) and SMS (True) fitting. streamed (bool, false) – Switch between streamed (1) and normal (0) reconstruction. imagespace (bool, false) – Switch between k-space (false) and imagespace based fitting (true). DTYPE (numpy.dtype, numpy.complex64) – Complex working precission. DTYPE_real (numpy.dtype, numpy.float32) – Real working precission.
power_iteration(x, data_shape, num_simulations=50)
run(inp, data, iters)

Optimization with 3D T(G)V regularization.

Parameters: (numpy.array) (x) – Initial guess for the unknown parameters (numpy.array) – The complex valued data to fit. iters (int) – Number of primal-dual iterations to run A tupel of all primal variables (x,v in the Paper). If no streaming is used, the two entries are opf class PyOpenCL.Array, otherwise Numpy.Array. tupel
setFvalInit(fval)

Set the initial value of the cost function.

Parameters: fval (float) – The initial cost of the optimization problem
updateRegPar(irgn_par)

Update the regularization parameters.

Performs an update of the regularization parameters as these usually vary from one to another Gauss-Newton step.
Parameters: (dic) (irgn_par) –
update_Kyk2(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Precompute the v-part of the Adjoint Linear operator.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_primal(outp, inp, par, idx=0, idxq=0, bound_cond=0, wait_for=None)

Primal update of the x variable in the Primal-Dual Algorithm.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_r(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Update the data dual variable r.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_v(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Primal update of the v variable in Primal-Dual Algorithm.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z1(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z1 variable in Primal-Dual Algorithm for TGV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z1_tv(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z1 variable in Primal-Dual Algorithm for TV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z2(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z2 variable in Primal-Dual Algorithm for TGV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
class pyqmri.solver.PDSoftSenseBaseSolver(par, pdsose_par, queue, tau, fval, prg, coils, DTYPE=<class 'numpy.complex64'>, DTYPE_real=<class 'numpy.float32'>)

Primal Dual Soft-SENSE optimization.

This Class performs a primal-dual algorithm for solving a Soft-SENSE reconstruction on complex input data

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). pdsose_par (dict) – A python dict containing the required parameters for the regularized Soft-SENSE reconstruction. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimate of the initial step size based on the operator norm of the linear operator. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL Program A PyOpenCL Program containing the) – kernels for optimization. coil (PyOpenCL Buffer or empty list) – The coils used for reconstruction.
lambd

Regularization parameter in front of data fidelity term.

Type: float
tol

Relative toleraze to stop iterating

Type: float
stag

Stagnation detection parameter

Type: float
adaptive_stepsize

Type: bool
tau

Estimated step size based on operator norm of regularization.

Type: float
unknowns_TGV

Number of T(G)V unknowns

Type: int
unknowns

Total number of unknowns –> Reflects the number of cmaps for Soft-SENSE

Type: int
num_dev

Total number of compute devices

Type: int
dz

Ratio between 3rd dimension and isotropic 1st and 2nd image dimension.

Type: float
extrapolate_v(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Extrapolation step of the v variable in the Primal-Dual Algorithm.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
extrapolate_x(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Extrapolation step of the x variable in the Primal-Dual Algorithm.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
static factory(prg, queue, par, pdsose_par, init_fval, coils, linops, reg_type='TGV', streamed=False, DTYPE=<class 'numpy.complex64'>, DTYPE_real=<class 'numpy.float32'>)

Generate a PDSoftSenseSolver object.

Parameters: prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). pdsose_par (dict) – A python dict containing the parameters for the regularized Soft-SENSE reconstruction init_fval (float) – Estimate of the initial cost function value to scale the displayed values. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. linops (list of PyQMRI Operator) – The linear operators used for fitting. reg_type (string, "TGV") – String to choose between “TV” and “TGV” optimization. streamed (bool, false) – Switch between streamed (1) and normal (0) reconstruction. DTYPE (numpy.dtype, numpy.complex64) – Complex working precission. DTYPE_real (numpy.dtype, numpy.float32) – Real working precission.
run(inp, data, iters)

Optimization with 3D T(G)V regularization.

Parameters: (numpy.array) (data) – Initial guess for the reconstruction (numpy.array) – The complex valued (undersampled) kspace data. (int) (iters) – Number of primal-dual iterations to run Primal variable x. If no streaming is used, the two entries are opf class PyOpenCL.Array, otherwise Numpy.Array. tupel
set_fval_init(fval)

Set the initial value of the cost function.

Parameters: fval (float) – The initial cost of the optimization problem
set_sigma(sigma)

Set the step size for the dual update.

Parameters: sigma (float) – Step size for the dual update
set_tau(tau)

Set the step size for the primal update.

Parameters: tau (float) – Step size for the primal update
update_Kyk2(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Precompute the v-part of the Adjoint Linear operator.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_v(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Primal update of the v variable in Primal-Dual Algorithm for TGV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_x(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Primal update of the x variable in the Primal-Dual Algorithm.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_x_tgv(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Primal update of the x variable in the Primal-Dual Algorithm for TGV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_y(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Update the data dual variable y.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z1_tgv(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z1 variable in Primal-Dual Algorithm for TGV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z2_tgv(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z2 variable in Primal-Dual Algorithm for TGV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z_tv(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z variable in Primal-Dual Algorithm for TV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
class pyqmri.solver.PDSoftSenseBaseSolverStreamed(par, pdsose_par, queue, tau, fval, prg, coils, **kwargs)

Streamed version of the PD Soft-SENSE Solver.

This class is the base class for the streamed array optimization.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). pdsose_par (dict) – A python dict containing the required parameters for the regularized Soft-SENSE reconstruction. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction.
unknown_shape

Size of the unknown array

Type: tuple of int
grad_shape

Size of the finite difference based gradient

Type: tuple of int
symgrad_shape

Size of the finite difference based symmetrized gradient. Defaults to None in TV based optimization.

Type: tuple of int, None
data_shape

Size of the data to be fitted

Type: tuple of int
data_trans_axes

Order of transpose of data axis, requried for streaming

Type: list of int
data_shape_T

Size of transposed data.

Type: tuple of int
class pyqmri.solver.PDSoftSenseSolverStreamedTGV(par, ss_par, queue, tau, fval, prg, linop, coils, **kwargs)

Streamed PD Soft-SENSE TGV version.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). pdsose_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction.
alpha_0

alpha0 parameter for TGV regularization weight

Type: float
alpha_1

alpha1 parameter for TGV regularization weight

Type: float
symgrad_shape

Type: tuple of int
class pyqmri.solver.PDSoftSenseSolverStreamedTV(par, ss_par, queue, tau, fval, prg, linop, coils, **kwargs)

Streamed PD Soft-SENSE TV version.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). pdsose_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction.
class pyqmri.solver.PDSoftSenseSolverTGV(par, pdsose_par, queue, tau, fval, prg, linop, coils, **kwargs)

Primal Dual splitting optimization for TGV.

This Class performs a primal-dual variable splitting based reconstruction on single precission complex input data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). pdsose_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction.
alpha

TV regularization weight

Type: float
class pyqmri.solver.PDSoftSenseSolverTV(par, pdsose_par, queue, tau, fval, prg, linop, coils, **kwargs)

Primal Dual splitting optimization for TV.

This Class performs a primal-dual variable splitting based reconstruction on single precission complex input data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). pdsose_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction.
class pyqmri.solver.PDSolverICTGV(par, irgn_par, queue, tau, fval, prg, linop, coils, model, **kwargs)

Primal Dual splitting optimization for IC-TV.

This Class performs a primal-dual variable splitting based reconstruction on single precission complex input data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. model (PyQMRI.Model) – The model which should be fitted
alpha

TV regularization weight

Type: float
update_primal(outp, inp, par, idx=0, idxq=0, bound_cond=0, wait_for=None)

Primal update of the x variable in the Primal-Dual Algorithm.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z1_ictgv(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z1 variable in Primal-Dual Algorithm for TV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z2_ictgv(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z1 variable in Primal-Dual Algorithm for TV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z_sympart(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z variable for the symmetrized gradient in Primal-Dual Algorithm forg TV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
class pyqmri.solver.PDSolverICTV(par, irgn_par, queue, tau, fval, prg, linop, coils, model, **kwargs)

Primal Dual splitting optimization for IC-TV.

This Class performs a primal-dual variable splitting based reconstruction on single precission complex input data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. model (PyQMRI.Model) – The model which should be fitted
alpha

TV regularization weight

Type: float
update_primal(outp, inp, par, idx=0, idxq=0, bound_cond=0, wait_for=None)

Primal update of the x variable in the Primal-Dual Algorithm.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z1_ictv(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z1 variable in Primal-Dual Algorithm for TV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
update_z2_ictv(outp, inp, par=None, idx=0, idxq=0, bound_cond=0, wait_for=None)

Dual update of the z1 variable in Primal-Dual Algorithm for TV.

Parameters: outp (PyOpenCL.Array) – The result of the update step inp (PyOpenCL.Array) – The previous values of x par (list) – List of necessary parameters for the update idx (int) – Index of the device to use idxq (int) – Index of the queue to use bound_cond (int) – Apply boundary condition (1) or not (0). wait_for (list of PyOpenCL.Events, None) – A optional list for PyOpenCL.Events to wait for A PyOpenCL.Event to wait for. PyOpenCL.Event
class pyqmri.solver.PDSolverStreamed(par, irgn_par, queue, tau, fval, prg, coils, model, imagespace=False, **kwargs)

Streamed version of the PD Solver.

This class is the base class for the streamed array optimization.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. model (PyQMRI.Model) – The model which should be fitted imagespace (bool, false) – Switch between imagespace (True) and k-space (false) based fitting.
unknown_shape

Size of the unknown array

Type: tuple of int
model_deriv_shape

Size of the partial derivative array of the unknowns

Type: tuple of int
grad_shape

Size of the finite difference based gradient

Type: tuple of int
symgrad_shape

Size of the finite difference based symmetrized gradient. Defaults to None in TV based optimization.

Type: tuple of int, None
data_shape

Size of the data to be fitted

Type: tuple of int
data_trans_axes

Order of transpose of data axis, requried for streaming

Type: list of int
data_shape_T

Size of transposed data.

Type: tuple of int
class pyqmri.solver.PDSolverStreamedTGV(par, irgn_par, queue, tau, fval, prg, linop, coils, model, imagespace=False, SMS=False, **kwargs)

Streamed TGV optimization.

This class performes streamd TGV optimization.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. model (PyQMRI.Model) – The model which should be fitted imagespace (bool, false) – Switch between imagespace (True) and k-space (false) based fitting. SMS (bool, false) – Switch between SMS (True) and standard (false) reconstruction.
alpha

alpha0 parameter for TGV regularization weight

Type: float
beta

alpha1 parameter for TGV regularization weight

Type: float
symgrad_shape

Type: tuple of int
class pyqmri.solver.PDSolverStreamedTGVSMS(par, irgn_par, queue, tau, fval, prg, linop, coils, model, imagespace=False, **kwargs)

Streamed TGV optimization for SMS data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. model (PyQMRI.Model) – The model which should be fitted imagespace (bool, false) – Switch between imagespace (True) and k-space (false) based fitting. SMS (bool, false) – Switch between SMS (True) and standard (false) reconstruction.
alpha

alpha0 parameter for TGV regularization weight

Type: float
beta

alpha1 parameter for TGV regularization weight

Type: float
symgrad_shape

Type: tuple of int
class pyqmri.solver.PDSolverStreamedTV(par, irgn_par, queue, tau, fval, prg, linop, coils, model, imagespace=False, SMS=False, **kwargs)

Streamed TV optimization.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. model (PyQMRI.Model) – The model which should be fitted imagespace (bool, false) – Switch between imagespace (True) and k-space (false) based fitting. SMS (bool, false) – Switch between SMS (True) and standard (false) reconstruction.
alpha

alpha0 parameter for TGV regularization weight

Type: float
symgrad_shape

Type: tuple of int
class pyqmri.solver.PDSolverStreamedTVSMS(par, irgn_par, queue, tau, fval, prg, linop, coils, model, imagespace=False, **kwargs)

Streamed TV optimization for SMS data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. model (PyQMRI.Model) – The model which should be fitted imagespace (bool, false) – Switch between imagespace (True) and k-space (false) based fitting.
alpha

alpha0 parameter for TGV regularization weight

Type: float
symgrad_shape

Type: tuple of int
class pyqmri.solver.PDSolverTGV(par, irgn_par, queue, tau, fval, prg, linop, coils, model, **kwargs)

TGV Primal Dual splitting optimization.

This Class performs a primal-dual variable splitting based reconstruction on single precission complex input data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. model (PyQMRI.Model) – The model which should be fitted
alpha

alpha0 parameter for TGV regularization weight

Type: float
beta

alpha1 parameter for TGV regularization weight

Type: float
class pyqmri.solver.PDSolverTV(par, irgn_par, queue, tau, fval, prg, linop, coils, model, **kwargs)

Primal Dual splitting optimization for TV.

This Class performs a primal-dual variable splitting based reconstruction on single precission complex input data.

Parameters: par (dict) – A python dict containing the necessary information to setup the object. Needs to contain the number of slices (NSlice), number of scans (NScan), image dimensions (dimX, dimY), number of coils (NC), sampling points (N) and read outs (NProj) a PyOpenCL queue (queue) and the complex coil sensitivities (C). irgn_par (dict) – A python dict containing the regularization parameters for a given gauss newton step. queue (list of PyOpenCL.Queues) – A list of PyOpenCL queues to perform the optimization. tau (float) – Estimated step size based on operator norm of regularization. fval (float) – Estimate of the initial cost function value to scale the displayed values. prg (PyOpenCL.Program) – A PyOpenCL Program containing the kernels for optimization. linops (list of PyQMRI Operator) – The linear operators used for fitting. coils (PyOpenCL Buffer or empty list) – The coils used for reconstruction. model (PyQMRI.Model) – The model which should be fitted
alpha

TV regularization weight

Type: float