tomopy.recon.algorithm

Module for reconstruction algorithms.

Functions:

recon(tomo, theta[, center, sinogram_order, …]) Reconstruct object from projection data.
tomopy.recon.algorithm.recon(tomo, theta, center=None, sinogram_order=False, algorithm=None, init_recon=None, ncore=None, nchunk=None, **kwargs)[source]

Reconstruct object from projection data.

Parameters:
  • tomo (ndarray) – 3D tomographic data.

  • theta (array) – Projection angles in radian.

  • center (array, optional) – Location of rotation axis.

  • sinogram_order (bool, optional) – Determins whether data is a stack of sinograms (True, y-axis first axis) or a stack of radiographs (False, theta first axis).

  • algorithm ({str, function}) – One of the following string values.

    ‘art’

    Algebraic reconstruction technique [Kak:98].

    ‘bart’

    Block algebraic reconstruction technique.

    ‘fbp’

    Filtered back-projection algorithm.

    ‘gridrec’

    Fourier grid reconstruction algorithm [Dowd:99], [Rivers:06].

    ‘mlem’

    Maximum-likelihood expectation maximization algorithm [Dempster:77].

    ‘osem’

    Ordered-subset expectation maximization algorithm [Hudson:94].

    ‘ospml_hybrid’

    Ordered-subset penalized maximum likelihood algorithm with weighted linear and quadratic penalties.

    ‘ospml_quad’

    Ordered-subset penalized maximum likelihood algorithm with quadratic penalties.

    ‘pml_hybrid’

    Penalized maximum likelihood algorithm with weighted linear and quadratic penalties [Chang:04].

    ‘pml_quad’

    Penalized maximum likelihood algorithm with quadratic penalty.

    ‘sirt’

    Simultaneous algebraic reconstruction technique.

    ‘tv’

    Total Variation reconstruction technique [Chambolle:11].

    ‘grad’

    Gradient descent method with a constant step size

  • num_gridx, num_gridy (int, optional) – Number of pixels along x- and y-axes in the reconstruction grid.

  • filter_name (str, optional) – Name of the filter for analytic reconstruction.

    ‘none’

    No filter.

    ‘shepp’

    Shepp-Logan filter (default).

    ‘cosine’

    Cosine filter.

    ‘hann’

    Cosine filter.

    ‘hamming’

    Hamming filter.

    ‘ramlak’

    Ram-Lak filter.

    ‘parzen’

    Parzen filter.

    ‘butterworth’

    Butterworth filter.

    ‘custom’

    A numpy array of size next_power_of_2(num_detector_columns)/2 specifying a custom filter in Fourier domain. The first element of the filter should be the zero-frequency component.

    ‘custom2d’

    A numpy array of size num_projections*next_power_of_2(num_detector_columns)/2 specifying a custom angle-dependent filter in Fourier domain. The first element of each filter should be the zero-frequency component.

  • filter_par (list, optional) – Filter parameters as a list.

  • num_iter (int, optional) – Number of algorithm iterations performed.

  • num_block (int, optional) – Number of data blocks for intermediate updating the object.

  • ind_block (array of int, optional) – Order of projections to be used for updating.

  • reg_par (float, optional) – Regularization parameter for smoothing.

  • init_recon (ndarray, optional) – Initial guess of the reconstruction.

  • ncore (int, optional) – Number of cores that will be assigned to jobs.

  • nchunk (int, optional) – Chunk size for each core.

Returns:

ndarray – Reconstructed 3D object.

Warning

Filtering is not implemented for fbp.

Example

>>> import tomopy
>>> obj = tomopy.shepp3d() # Generate an object.
>>> ang = tomopy.angles(180) # Generate uniformly spaced tilt angles.
>>> sim = tomopy.project(obj, ang) # Calculate projections.
>>> rec = tomopy.recon(sim, ang, algorithm='art') # Reconstruct object.
>>>
>>> # Show 64th slice of the reconstructed object.
>>> import pylab
>>> pylab.imshow(rec[64], cmap='gray')
>>> pylab.show()

Example using the ASTRA toolbox for recontruction

For more information, see http://sourceforge.net/p/astra-toolbox/wiki/Home/ and https://github.com/astra-toolbox/astra-toolbox. To install the ASTRA toolbox with conda, use:

conda install -c https://conda.binstar.org/astra-toolbox astra-toolbox

>>> import tomopy
>>> obj = tomopy.shepp3d() # Generate an object.
>>> ang = tomopy.angles(180) # Generate uniformly spaced tilt angles.
>>> sim = tomopy.project(obj, ang) # Calculate projections.
>>>
>>> # Reconstruct object:
>>> rec = tomopy.recon(sim, ang, algorithm=tomopy.astra,
>>>       options={'method':'SART', 'num_iter':10*180,
>>>       'proj_type':'linear',
>>>       'extra_options':{'MinConstraint':0}})
>>>
>>> # Show 64th slice of the reconstructed object.
>>> import pylab
>>> pylab.imshow(rec[64], cmap='gray')
>>> pylab.show()
tomopy.recon.algorithm.init_tomo(tomo, sinogram_order, sharedmem=True)[source]