algotom.rec.reconstruction
¶
Module of FFT-based reconstruction methods in the reconstruction stage: - Filtered back-projection (FBP) method for GPU (using numba and cuda) and CPU. - Direct Fourier inversion (DFI) method. - Wrapper for Astra Toolbox reconstruction (optional) - Wrapper for Tomopy-gridrec reconstruction (optional)
Functions:
- algotom.rec.reconstruction.apply_ramp_filter(sinogram, ramp_win=None, filter_name=None, pad=None, pad_mode='edge')[source]¶
Apply the ramp filter to a sinogram with the option of adding a smoothing filter.
- Parameters
sinogram (array_like) – 2D rray. Sinogram image.
ramp_win (complex ndarray or None) – Ramp window in the Fourier space.
filter_name (*{None, “hann”, “bartlett”, “blackman”, “hamming”, “nuttall”,*) – “parzen”, “triang”} Name of a smoothing window used.
pad (int or None) – To apply padding before the FFT. The value is set to 10% of the image width if None is given.
pad_mode (str) – Padding method. Full list can be found at numpy.pad documentation.
- Returns
array_like – Filtered sinogram.
- algotom.rec.reconstruction.astra_reconstruction(sinogram, center, angles=None, ratio=1.0, method='FBP_CUDA', num_iter=1, filter_name='hann', pad=None, apply_log=True)[source]¶
Wrapper of reconstruction methods implemented in the astra toolbox package. https://www.astra-toolbox.com/docs/algs/index.html Users must install Astra Toolbox before using this function.
- Parameters
sinogram (array_like) – 2D array. Sinogram image.
center (float) – Center of rotation.
angles (array_like) – 1D array. List of angles (radian) corresponding to the sinogram.
ratio (float) – To apply a circle mask to the reconstructed image.
method (str) – Reconstruction algorithms. for CPU: ‘FBP’, ‘SIRT’, ‘SART’, ‘ART’, ‘CGLS’. for GPU: ‘FBP_CUDA’, ‘SIRT_CUDA’, ‘SART_CUDA’, ‘CGLS_CUDA’.
num_iter (int) – Number of iterations if using iteration methods.
filter_name (str) – Apply filter if using FBP method. Options: ‘hamming’, ‘hann’, ‘lanczos’, ‘kaiser’, ‘parzen’,…
pad (int) – Padding to reduce the side effect of FFT.
apply_log (bool) – Apply the logarithm function to the sinogram before reconstruction.
- Returns
array_like – Square array.
- algotom.rec.reconstruction.back_projection_cpu(sinogram, angles, xlist, center)¶
Implement the back-projection algorithm using CPU.
- sinogramarray_like
2D array. (Filtered) sinogram image.
- anglesarray_like
1D array. Angles (radian) corresponding to the sinogram.
- xlistarray_like
1D array. Distances of the integration lines to the image center.
- centerfloat
Center of rotation.
- Returns
recon (array_like) – Square array. Reconstructed image.
- algotom.rec.reconstruction.dfi_reconstruction(sinogram, center, angles=None, ratio=1.0, filter_name='hann', pad_rate=0.25, pad_mode='edge', apply_log=True)[source]¶
Apply the DFI (direct Fourier inversion) reconstruction method to a sinogram image (Ref. [1]). The method is a practical and direct implementation of the Fourier slice theorem (Ref. [2]).
- Parameters
sinogram (array_like) – 2D array. Sinogram image.
center (float) – Center of rotation.
angles (array_like) – 1D array. List of angles (in radian) corresponding to the sinogram.
ratio (float) – To apply a circle mask to the reconstructed image.
filter_name (*{None, “hann”, “bartlett”, “blackman”, “hamming”, “nuttall”,*) – “parzen”, “triang”} Apply a smoothing filter.
pad_rate (float) – To apply padding before the FFT. The padding width equals to (pad_rate * image_width).
pad_mode (str) – Padding method. Full list can be found at numpy.pad documentation.
apply_log (bool) – Apply the logarithm function to the sinogram before reconstruction.
- Returns
array_like – Square array. Reconstructed image.
References
- algotom.rec.reconstruction.fbp_reconstruction(sinogram, center, angles=None, ratio=1.0, ramp_win=None, filter_name='hann', pad=None, pad_mode='edge', apply_log=True, gpu=True)[source]¶
Apply the FBP (filtered back-projection) reconstruction method to a sinogram image.
- Parameters
sinogram (array_like) – 2D array. Sinogram image.
center (float) – Center of rotation.
angles (array_like, optional) – 1D array. List of angles (in radian) corresponding to the sinogram.
ratio (float, optional) – To apply a circle mask to the reconstructed image.
ramp_win (complex ndarray, optional) – Ramp window in the Fourier space. It will be generated if None is given.
filter_name (*{None, “hann”, “bartlett”, “blackman”, “hamming”, “nuttall”,*) – “parzen”, “triang”} Apply a smoothing filter.
pad (int, optional) – To apply padding before the FFT. The value is set to 10% of the image width if None is given.
pad_mode (str, optional) – Padding method. Full list can be found at numpy.pad documentation.
apply_log (bool, optional) – Apply the logarithm function to the sinogram before reconstruction.
gpu (bool, optional) – Use GPU for computing if True.
- Returns
array_like – Square array. Reconstructed image.
- algotom.rec.reconstruction.generate_mapping_coordinate(width_sino, height_sino, width_rec, height_rec)[source]¶
Calculate coordinates in the sinogram space from coordinates in the reconstruction space (in the Fourier domain). They are used for the DFI (direct Fourier inversion) reconstruction method.
- Parameters
width_sino (int) – Width of a sinogram image.
height_sino (int) – Height of a sinogram image.
width_rec (int) – Width of a reconstruction image.
height_rec (int) – Height of a reconstruction image.
- Returns
r_mat (array_like) – 2D array. Broadcast of the r-coordinates.
theta_mat (array_like) – 2D array. Broadcast of the theta-coordinates.
- algotom.rec.reconstruction.gridrec_reconstruction(sinogram, center, angles=None, ratio=1.0, filter_name='shepp', apply_log=True, pad=True, ncore=1)[source]¶
Wrapper of the gridrec method implemented in the tomopy package: https://tomopy.readthedocs.io/en/latest/api/tomopy.recon.algorithm.html Users must install Tomopy before using this function.
- Parameters
sinogram (array_like) – 2D array. Sinogram image.
center (float) – Center of rotation.
angles (array_like) – 1D array. List of angles (radian) corresponding to the sinogram.
ratio (float) – To apply a circle mask to the reconstructed image.
filter_name (str) – Apply a smoothing filter. Full list is at: https://github.com/tomopy/tomopy/blob/master/source/tomopy/recon/algorithm.py
apply_log (bool) – Apply the logarithm function to the sinogram before reconstruction.
pad (bool) – Apply edge padding to the nearest power of 2.
- Returns
array_like – Square array.
- algotom.rec.reconstruction.make_2d_ramp_window(height, width, filter_name=None)[source]¶
Make the 2d ramp window (in the Fourier space) by repeating the 1d ramp window with the option of adding a smoothing window.
- Parameters
height (int) – Height of the window.
width (int) – Width of the window.
filter_name (*{None, “hann”, “bartlett”, “blackman”, “hamming”, “nuttall”,*) – “parzen”, “triang”} Name of a smoothing window used.
- Returns
complex ndarray – 2D array.
- algotom.rec.reconstruction.make_smoothing_window(filter_name, width)[source]¶
Make a 1d smoothing window.
- Parameters
filter_name (*{“hann”, “bartlett”, “blackman”, “hamming”, “nuttall”,*) – “parzen”, “triang”} Window function used for filtering.
width (int) – Width of the window.
- Returns
array_like – 1D array.