STIR
STIR copied to clipboard
Generalisation of Priors class
There is a lot of code duplication for each of the priors. The priors implemented right now are:
- Quadratic
- Relative Difference Prior
- Parallel Level Sets
- FilterRoot
- LogCosh
There are additional priors that could easily be added:
- Huber
- Bowsher
Each of these priors has its own iterator of the computation of value and gradient and generally act over a local neighbourhood.
All priors (except FilterRoot) an implementation of the usage of the spatially variable penalty strength (kappa).
There are a selection of priors (i.e. QP, logcosh, hubber) can utilise parabolic_surrogate_curvature
.
It seems that a lot of this functionality should belong in Generalised Prior
(https://github.com/UCL/STIR/blob/master/src/recon_buildblock/GeneralisedPrior.cxx) or more likely an intermediary class, e.g. Gibbs prior
that contains all the common methods, such as an iterator for the function and the gradient.
This issue is just to note some ideas regarding the generalisation of the priors.
#662 (Unable to set/get prior kappa image from STIR-python (matlab)) and #707 (STIR-python OSMAPOSL priors are GeneralisedPrior objects rather than child class priors) are related to this.
In light of #901, I am more so inclinded to add an intermediate class, i.e. Gibbs prior
, that the Quadratic, Relative Difference Prior, Parallel Level Sets, LogCosh, and (Huber + Bowsher) are child classes of. This class should contain not only iterators but virtual functions for gradients and Hessian second derivitives. Each of the classes can then override those functions.
In #901 I have begun to add off_diagonal_second_derivative
and diagonal_second_derivative
methods, which will make accumulate_Hessian_times_input
for QP, logcosh and RDP 100% code duplication.