Methods¶
mumott distinguishes basis sets, projectors, and residual calculators, which can be combined to implement different methods.
Utilities¶
- mumott.methods.utilities.preconditioning.get_largest_eigenvalue(basis_set, projector, weights=None, preconditioner=None, niter=5, seed=None)[source]¶
Calculate the largest eigenvalue of the matrix \(A^{T}*A\) using the power method. Here, \(A\) is the linear forward model defined be the input
Projector
andBasisSet
. The largest eigenvalue can be used to set a safe step size for various optimizers.- Parameters
basis_set (
BasisSet
) – basis set objectprojector (
Projector
) – projector objectweights (
Optional
[ndarray
[Any
,dtype
[float
]]]) – Weights which will be applied to the residual. Default isNone
.preconditioner (
Optional
[ndarray
[Any
,dtype
[float
]]]) – A preconditioner which will be applied to the gradient. Default isNone
.niter (
int
) – number of iterations. Default is 5seed (
Optional
[int
]) – Seed for random generation as starting state. Used for testing.Returns. –
------- – An estimate of the matrix norm (largest singular value)
- Return type
- mumott.methods.utilities.preconditioning.get_sirt_preconditioner(projector, cutoff=0.1)[source]¶
Retrieves the SIRT preconditioner, which can be used together with the SIRT weights to condition the gradient of tomographic calculations for faster convergence and scaling of the step size for gradient descent.
Notes
The preconditioner normalizes the gradient according to the number of data points that map to each voxel in the computation of the projection adjoint. This preconditioner scales and conditions the gradient for better convergence. It is best combined with the SIRT weights, which normalize the residual for the number of voxels. When used together, they condition the reconstruction sufficiently well that a gradient descent optimizer with step size unity can arrive at a good solution. Other gradient-based solvers can also benefit from this preconditioning.
In addition, the calculation of these preconditioning terms makes it easy to identify regions of the volume or projections that are rarely probed, allowing them to be masked from the solution altogether.
If the projection operation is written in sparse matrix form as
\[P_{ij} X_{j} = Y_i\]where \(P_{ij}\) is the projection matrix, \(X_j\) is a vector of voxels, and \(Y_i\) is the projection, then the preconditioner can be understood as
\[C_{jj} = \frac{I(n_j)}{\sum_i P_{ij}}\]where \(I(n_j)\) is the identity matrix of the same size as \(X_j\). Similarly, the weights (of
get_sirt_weights()
) are computed as\[W_{ii} = \frac{I(n_i)}{\sum_j P_{ij}}.\]Here, any singularities in the system (e.g., where \(\sum_j P_{ij} = 0\)) can be masked out by setting the corresponding weight to zero. We thus end up with a weighted least-squares system
\[\text{argmin}_X(\Vert W_{ii}(P_{ij}X_{j} - D_{i})\Vert^2_2)\]where \(D_{i}\) is some data, which we can solve iteratively by preconditioned gradient descent,
\[X_j^{k + 1} = X_j^k - C_{jj}P_{ji}^TW_{ii}(P_ij X_j^k - D_i)\]As mentioned, we can add additional regularization terms, and because the preconditioning scales the problem appropriately, computing an optimal step size is not a requirement, although it can speed up the solution. This establishes a very flexible system, where quasi-Newton solvers such as LBFGS can be seamlessly combined with less restrictive gradient descent methods.
A good discussion of the algorithmic properties of SIRT can be found in this article by Gregor et al., while this article by van der Sluis et al. discusses SIRT as a least-squares solver in comparison to the conjugate gradient (CG) method.
- Parameters
projector (
Projector
) – A projector object which is used to calculate the weights. The computation of the weights is based on the geometry attached to the projector.cutoff (
float
) – The minimal number of rays that need to map to a voxel for it to be considered valid. Default is0.1
. Invalid voxels will be masked from the preconditioner.
- Return type
- mumott.methods.utilities.preconditioning.get_sirt_weights(projector, cutoff=0.1)[source]¶
Retrieves the SIRT weights, which can be used together with the SIRT preconditioner to weight the residual of tomographic calculations for faster convergence and scaling of the step size for gradient descent.
Notes
See
get_sirt_preconditioner()
for theoretical details.- Parameters
projector (
Projector
) – A projector object which is used to calculate the weights. The computation of the weights is based on the geometry attached to the projector.cutoff (
float
) – The minimal number of voxels that need to map to a point for it to be considered valid. Default is0.1
. Invalid pixels will be masked.
- Return type
- mumott.methods.utilities.preconditioning.get_tensor_sirt_preconditioner(projector, basis_set, cutoff=0.1)[source]¶
Retrieves the SIRT preconditioner for tensor representations, which can be used together with the tensor SIRT weights to condition the gradient of tensor tomographic calculations for faster convergence and scaling of the step size for gradient descent.
Notes
The preconditioner is computed similarly as in the scalar case, except the underlying system of equations is
\[P_{ij} X_{jk} U_{kl} = Y_{il}\]where \(X_{jk}\) is a vector of tensor-valued voxels, and \(Y_{il}\) is the projection into measurement space. The preconditioner then corresponds to
\[C_{jjkk} = \frac{I(n_j) \otimes I(n_k)}{\sum_{i,l} P_{ij} U_{kl}},\]where \(I(n_j)\) is the identity matrix of the same size as \(X_j\). Similarly, the weights (of
get_tensor_sirt_weights()
) are computed as\[W_{iill} = \frac{I(n_j) \otimes I(n_k)}{\sum_{j, k} P_{ij} U_{kl}}.\]Here, any singularities in the system (e.g., where \(\sum_j P_{ij} = 0\)) can be masked out by setting the corresponding weight to zero. We thus end up with a weighted least-squares system
\[\text{argmin}_X(\Vert W_{iill}(P_{ij} X_{jk} U_{kl} - D_{il})\Vert^2_2),\]where \(D_{il}\) is some data. This problem can be solved iteratively by preconditioned gradient descent,
\[X_j^{k + 1} = X_j^k - C_{jjkk}P_{ji}^TW_{iill}(P_ij X_{jk}^k U_{kl} - D_{il}).\]- Parameters
projector (
Projector
) – A projector object which is used to calculate the weights. The computation of the weights is based on the geometry attached to the projector.basis_set (
BasisSet
) – A basis set object which is used to calculate the weights. The tensor-space-to-detector-space transform uses the basis set. Should use a local representation.cutoff (
float
) – The minimal number of rays that need to map to a voxel for it to be considered valid. Default is0.1
. Invalid voxels will be masked from the preconditioner.
- Return type
- mumott.methods.utilities.preconditioning.get_tensor_sirt_weights(projector, basis_set, cutoff=0.1)[source]¶
Retrieves the tensor SIRT weights, which can be used together with the SIRT preconditioner to weight the residual of tensor tomographic calculations for faster convergence and scaling of the step size for gradient descent.
Notes
See
get_tensor_sirt_preconditioner()
for theoretical details.- Parameters
projector (
Projector
) – A projector object which is used to calculate the weights. The computation of the weights is based on the geometry attached to the projector.basis_set (
BasisSet
) – A basis set object which is used to calculate the weights. The tensor-space-to-detector-space transform uses the basis set. Should use a local representation.cutoff (
float
) – The minimal number of voxels that need to map to a point for it to be considered valid. Default is0.1
. Invalid pixels will be masked.
- Return type