OSEM#
- class deepinv.optim.OSEM(data_fidelity=None, prior=None, lambda_reg=1.0, g_param=None, sigma_denoiser=None, num_subsets=2, eps=1e-6, max_iter=100, crit_conv='residual', thres_conv=1e-5, early_stop=False, custom_metrics=None, custom_init=None, unfold=False, trainable_params=None, cost_fn=None, params_algo=None, **kwargs)[source]#
Bases:
BaseOptimOrdered-Subsets Expectation-Maximization (OSEM) algorithm for Poisson inverse problems.
OSEM was proposed in [1] to accelerate MLEM [2] by splitting the measurement into ordered subsets. Note that MLEM is a special case of OSEM with only one subset. At each iteration, the algorithm performs multiplicative updates over all subsets of the form:
\[x_{k,l+1} = \frac{x_{k,l}}{A_l^T \mathbf{1}} \odot A_l^T \left(\frac{y_l}{A_l x_{k,l} + b_l}\right),\]where \(A_l\) and \(y_l\) are the corresponding physics and measurement subset, and \(b_l\) is an optional additive background and
lis the subset index.Note
Only
deepinv.physics.Tomography,deepinv.physics.TomographyWithAstraanddeepinv.physics.PETare currently supported for OSEM.Note
The user can provide either the full measurement tensor
yand full tomographyphysics, or pre-split measurements passed as adeepinv.utils.TensorListand pre-split physics passed as adeepinv.physics.StackedLinearPhysics. Seedeepinv.physics.split_physics()anddeepinv.physics.split_measurements().See
deepinv.optim.optim_iterators.OSEMIterationfor the details of one iteration.A regularization can be included by specifying a
prior. This uses One-Step-Late (OS-MAP-OSL) [3], similar to indeepinv.optim.MLEM.Note
By default, the algorithm is initialized with a tensor of ones with the same shape as \(A^T y\). This can be overridden using
custom_init.- Parameters:
num_subsets (int) β number of ordered subsets used when splitting a full physics. It must be positive and is ignored when a pre-split physics is provided. With one subset, OSEM is equivalent to
deepinv.optim.MLEM. Default:2.data_fidelity (deepinv.optim.DataFidelity, list[DataFidelity]) β data fidelity term. If
None, defaults todeepinv.optim.PoissonLikelihood.prior (deepinv.optim.Prior, list[Prior]) β prior term. If
None, no prior is used. Default:None.lambda_reg (float) β regularization parameter \(\lambda\). Default:
1.0.g_param (float) β parameter for the prior. Default:
None.sigma_denoiser (float) β same as
g_param. If bothg_paramandsigma_denoiserare provided,g_paramis used. Default:None.eps (float) β positive value used to clamp denominators in the multiplicative update. Default:
1e-6.max_iter (int) β maximum number of OSEM epochs. Default:
100.crit_conv (str) β convergence criterion, either
"residual"or"cost". Default:"residual".thres_conv (float) β convergence threshold. Default:
1e-5.early_stop (bool) β if
True, the algorithm stops when the convergence criterion is met. Default:False.custom_metrics (dict) β dictionary of custom metrics to compute at each epoch. Default:
None.custom_init (Callable) β custom initialization function. OSEM passes the split measurements and stacked subset physics to this function. Default:
None.unfold (bool) β whether to unfold the algorithm or not. Default:
False.trainable_params (list) β parameters to train if
unfoldisTrue. Default:None.cost_fn (Callable) β custom cost function used for metrics and convergence. OSEM calls it with a
deepinv.optim.StackedPhysicsDataFidelity, split measurements, and stacked subset physics. Default:None.params_algo (dict) β optionally provide the algorithm parameters directly.
- References:
- forward(y, physics, *args, **kwargs)[source]#
Run OSEM with full or pre-split measurements and physics.
- Parameters:
y (torch.Tensor, deepinv.utils.TensorList, list[torch.Tensor]) β Full measurement tensor, or pre-split measurements when
physicsis adeepinv.physics.StackedLinearPhysics.physics (deepinv.physics.Physics) β Full tomography/PET physics or pre-split
deepinv.physics.StackedLinearPhysics.
- Returns:
Reconstructed image, and optionally the metrics dictionary when
compute_metrics=True.- Return type: