pytomography.callbacks#
Callbacks can be used to compute various metrics on a reconstructed object throughout each iteration in an iterative reconstruction algorithm. For example, you may want to look at the noise in the liver as a function of iteration number in OSEM. A callback is simply a class which can take in an object and perform an operation. Callbacks are optional input to reconstruction algorithms; the run method of a callback is called after each subiteration of an iterative reconstruction algorithm. All user-defined callbacks should inherit from the base class CallBack. A subclass of this class could be used to compute noise-bias curves provided the __init__ method was redefined to take in some ground truth, and the run method was redefined to compare the obj to the ground truth.
Submodules#
Package Contents#
Classes#
Abstract class used for callbacks. Subclasses must redefine the |
|
Class for combining multiple callbacks into a single callback. This is useful for passing multiple callbacks to an iterative reconstruction algorithm. |
|
Callback that stores the object and forward projection at each iteration |
- class pytomography.callbacks.Callback[source]#
Abstract class used for callbacks. Subclasses must redefine the
__init__andrunmethods. If a callback is used as an argument in an iterative reconstruction algorihtm, the__run__method is called after each subiteration.- abstract run(object, n_iter)[source]#
Abstract method for
run.- Parameters:
object (torch.Tensor[Lx, Ly, Lz]) – Object at current iteration/subset in the reconstruction algorithm
n_iter (int) – The iteration number
- Returns:
Modified object from callback. This must be returned by all callbacks (if the callback doesn’t change the object, then the passed object is returned)
- Return type:
torch.Tensor
- class pytomography.callbacks.MultiCallback(callbacks)[source]#
Bases:
CallbackClass for combining multiple callbacks into a single callback. This is useful for passing multiple callbacks to an iterative reconstruction algorithm.
- Parameters:
callbacks (list[Callback]) –
- run(object, n_iter, n_subset)[source]#
Runs the callbacks sequentially
- Parameters:
object (torch.Tensor) – Object at current iteration/subset in the reconstruction algorithm
n_iter (int) – Iteration number
n_subset (int) – Subset number
- Returns:
Modified object from callback. This must be returned by all callbacks (if the callback doesn’t change the object, then the passed object is returned)
- Return type:
torch.Tensor
- class pytomography.callbacks.DataStorageCallback(likelihood, object_initial)[source]#
Bases:
pytomography.callbacks.callback.CallbackCallback that stores the object and forward projection at each iteration
- Parameters:
likelihood (Likelihood) – Likelihood function used in reconstruction
object_initial (torch.Tensor[Lx, Ly, Lz]) – Initial object in the reconstruction algorithm