tomobar.methodsIR_CuPy
#
Reconstruction class for regularised iterative methods using CuPy library.
RecToolsIRCuPy.FISTA()
iterative regularised algorithm [BT2009], [Xu2016]. Implemented using ASTRA’s DirectLink and CuPy, Regularisation Toolkit-CuPy.RecToolsIRCuPy.Landweber()
algorithm.RecToolsIRCuPy.SIRT()
algorithm.RecToolsIRCuPy.CGLS()
algorithm.
- class tomobar.methodsIR_CuPy.RecToolsIRCuPy(DetectorsDimH, DetectorsDimV, CenterRotOffset, AnglesVec, ObjSize, datafidelity='LS', device_projector=0, cupyrun=True)[source]#
Bases:
object
CuPy-enabled iterative reconstruction algorithms using ASTRA toolbox, CCPi-RGL toolkit. Parameters for reconstruction algorithms should be provided in three dictionaries:
_data_
,_algorithm_
, and_regularisation_
. Seetomobar.supp.dicts
function of ToMoBAR’s API reference for all parameters explained.If FISTA is used it will require CuPy-enabled routines of the CCPi-regularisation toolkit. This implementation is typically more than times faster than the one in RecToolsIR, however, please note that the functionality of FISTA is limited compared to the version of FISTA in RecToolsIR. The work is in progress and the current FISTA version is experimental.
- Parameters:
DetectorsDimH (int) – Horizontal detector dimension.
DetectorsDimV (int) – Vertical detector dimension for 3D case, 0 or None for 2D case.
CenterRotOffset (float) – The Centre of Rotation (CoR) scalar or a vector for each angle.
AnglesVec (np.ndarray) – Vector of projection angles in radians.
ObjSize (int) – Reconstructed object dimensions (a scalar).
datafidelity (str, optional) – Data fidelity, choose from LS and PWLS. Defaults to LS.
device_projector (int, optional) – Provide a GPU index of a specific GPU device. Defaults to 0.
cupyrun (bool, optional) – instantiate CuPy modules.
- CGLS(_data_: dict, _algorithm_: dict | None = None) <cp.ndarray> [source]#
Conjugate Gradients Least Squares iterative technique to reconstruct projection data given as a CuPy array. The algorithm aim to solve the system of normal equations \(\mathbf{A}^{\intercal}\mathbf{A}x = \mathbf{A}^{\intercal} b\).
- Parameters:
_data_ (dict) – Data dictionary, where projection data is provided.
_algorithm_ (dict, optional) – Algorithm dictionary where algorithm parameters are provided.
- Returns:
The CGLS-reconstructed volume as a CuPy array.
- Return type:
cp.ndarray
- FISTA(_data_: dict, _algorithm_: dict | None = None, _regularisation_: dict | None = None) <cp.ndarray> [source]#
A Fast Iterative Shrinkage-Thresholding Algorithm [BT2009] with various types of regularisation from the regularisation toolkit [KAZ2019].
All parameters for the algorithm should be provided in three dictionaries:
_data_
,_algorithm_
, and_regularisation_
. Seetomobar.supp.dicts
function of ToMoBAR’s API reference for all parameters explained. Please note that not all of the functionality supported in this CuPy implementation compared toRecToolsIR.FISTA()
fromtomobar.methodsIR
.- Parameters:
_data_ (dict) – Data dictionary, where input data is provided.
_algorithm_ (dict, optional) – Algorithm dictionary where algorithm parameters are provided.
_regularisation_ (dict, optional) – Regularisation dictionary.
- Returns:
FISTA-reconstructed 3D CuPy array
- Return type:
cp.ndarray
- Landweber(_data_: dict, _algorithm_: dict | None = None) <cp.ndarray> [source]#
Using Landweber iterative technique to reconstruct projection data given as a CuPy array. We perform the following iterations: \(x^{k+1} = x^{k} + \tau * \mathbf{A}^{\intercal}(\mathbf{A}x^{k} - b)\).
- Parameters:
_data_ (dict) – Data dictionary, where projection data is provided.
_algorithm_ (dict, optional) – Algorithm dictionary where algorithm parameters are provided.
- Returns:
The Landweber-reconstructed volume as a CuPy array.
- Return type:
cp.ndarray
- SIRT(_data_: dict, _algorithm_: dict | None = None) <cp.ndarray> [source]#
Using Simultaneous Iterations Reconstruction Technique (SIRT) iterative technique to reconstruct projection data given as a CuPy array. We perform the following iterations: \(x^{k+1} = \mathbf{C}\mathbf{A}^{\intercal}\mathbf{R}(b - \mathbf{A}x^{k})\).
- Parameters:
_data_ (dict) – Data dictionary, where projection data is provided.
_algorithm_ (dict, optional) – Algorithm dictionary where algorithm parameters are provided.
- Returns:
The SIRT-reconstructed volume as a CuPy array.
- Return type:
cp.ndarray
- property cupyrun: int#
- property datafidelity: int#
- powermethod(_data_: dict) float [source]#
Power iteration algorithm to calculate the eigenvalue of the operator (projection matrix). projection_raw_data is required for the PWLS fidelity, otherwise will be ignored.
- Parameters:
_data_ (dict) – Data dictionary, where input data is provided.
- Returns:
the Lipschitz constant
- Return type:
float