pytomography.callbacks.callback#

Module Contents#

Classes#

Callback

Abstract class used for callbacks. Subclasses must redefine the __init__ and run methods. If a callback is used as an argument in an iterative reconstruction algorihtm, the __run__ method is called after each subiteration.

MultiCallback

Class for combining multiple callbacks into a single callback. This is useful for passing multiple callbacks to an iterative reconstruction algorithm.

class pytomography.callbacks.callback.Callback[source]#

Abstract class used for callbacks. Subclasses must redefine the __init__ and run methods. 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

finalize(object)[source]#

Abstract method for run.

Parameters:

object (torch.Tensor[Lx, Ly, Lz]) – Reconstructed object (all iterations/subsets completed)

class pytomography.callbacks.callback.MultiCallback(callbacks)[source]#

Bases: Callback

Class 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

finalize(object)[source]#

Finalizes the callback

Parameters:

object (torch.Tensor) – Reconstructed object