OpTomo class: the optomo module

class astra.optomo.OpTomo(proj_id)[source]

Bases: scipy.sparse.linalg.interface.LinearOperator

Object that imitates a projection matrix with a given projector.

This object can do forward projection by using the * operator:

W = astra.OpTomo(proj_id)
fp = W*image
bp = W.T*sinogram

It can also be used in minimization methods of the scipy.sparse.linalg module:

W = astra.OpTomo(proj_id)
output = scipy.sparse.linalg.lsqr(W,sinogram)
Parameters

proj_id (int) – ID to a projector.

BP(s, out=None)[source]

Perform backprojection.

Output must have the right 2D/3D shape. Input may also be flattened.

Output must also be contiguous and float32. This isn’t required for the input, but it is more efficient if it is.

:param : The projection data. :type s: numpy.ndarray :param out: Array to store result in. :type out: numpy.ndarray

FP(v, out=None)[source]

Perform forward projection.

Output must have the right 2D/3D shape. Input may also be flattened.

Output must also be contiguous and float32. This isn’t required for the input, but it is more efficient if it is.

Parameters
  • v (numpy.ndarray) – Volume to forward project.

  • out (numpy.ndarray) – Array to store result in.

reconstruct(method, s, iterations=1, extraOptions=None)[source]

Reconstruct an object.

Parameters
  • method (string) – Method to use for reconstruction.

  • s (numpy.ndarray) – The projection data.

  • iterations (int) – Number of iterations to use.

  • extraOptions (dict) – Extra options to use during reconstruction (i.e. for cfg[‘option’]).

rmatvec(s)[source]

Implements the transpose operator.

Parameters

s (numpy.ndarray) – The projection data.

class astra.optomo.OpTomoTranspose(parent)[source]

Bases: scipy.sparse.linalg.interface.LinearOperator

This object provides the transpose operation (.T) of the OpTomo object.

Do not use directly, since it can be accessed as member .T of an OpTomo object.

rmatvec(v)[source]

Adjoint matrix-vector multiplication.

Performs the operation y = A^H * x where A is an MxN linear operator and x is a column vector or 1-d array.

x{matrix, ndarray}

An array with shape (M,) or (M,1).

y{matrix, ndarray}

A matrix or ndarray with shape (N,) or (N,1) depending on the type and shape of the x argument.

This rmatvec wraps the user-specified rmatvec routine or overridden _rmatvec method to ensure that y has the correct shape and type.