toupy.tomo package

Submodules

toupy.tomo.iradon module

toupy.tomo.iradon.backprojector(sinogram, theta, **params)[source]

Wrapper to choose between Forward Radon transform using Silx and OpenCL or standard reconstruction.

Parameters
  • sinogram (ndarray) – A 2-dimensional array containing the sinogram

  • theta (ndarray) – A 1-dimensional array of thetas

  • params (dict) – Dictionary containing the parameters to be used in the reconstruction. See mod_iradonSilx() and mod_iradon() for the list of parameters

Returns

recons – A 2-dimensional array containing the reconstructed sliced by the choosen method

Return type

ndarray

toupy.tomo.iradon.compute_angle_weights(theta)[source]

Compute the corresponding weight for each angle according to the distance between its neighbors in case of non equally spaced angles

Parameters

theta (ndarray) – Angles in degrees

Returns

weights – The weights for each angle to be applied to the sinogram

Return type

ndarray

Note

The weights are computed assuming a angular distribution between 0 and 180 degrees. Forked from odtbrain.util.compute_angle_weights_1d (https://github.com/RI-imaging/ODTbrain/)

toupy.tomo.iradon.compute_filter(nbins, filter_type='ram-lak', derivatives=False, freqcutoff=1)[source]

Compute the filter for the FBP tomographic reconstruction

Parameters
  • nbins (int) – Size of the filter to be calculated

  • filter_type (str, optional) – Name of the filter to be applied. The options are: ram-lak, shepp-logan, cosine, hamming, hann. The default is ram-lak.

  • derivatives (bool, optional) – If True, it will use a Hilbert filter used for derivative projections. The default is True`.

  • freqcutoff (float, optional) – Normalized frequency cutoff of the filter. The default value is 1 which means no cutoff.

Returns

fourier_filter – A 2-Dimnesional array containing the filter to be used in the FBP reconstruction

Return type

ndarray

toupy.tomo.iradon.mod_iradon(radon_image, theta=None, output_size=None, filter_type='ram-lak', derivatives=False, interpolation='linear', circle=False, freqcutoff=1)[source]

Inverse radon transform.

Reconstruct an image from the radon transform, using the filtered back projection algorithm.

Parameters
  • radon_image (ndarray) – A 2-dimensional array containing radon transform (sinogram). Each column of the image corresponds to a projection along a different angle. The tomography rotation axis should lie at the pixel index radon_image.shape[0] // 2 along the 0th dimension of radon_image.

  • theta (ndarray, optional) – Reconstruction angles (in degrees). Default: m angles evenly spaced between 0 and 180 (if the shape of radon_image is (N, M)).

  • output_size (int) – Number of rows and columns in the reconstruction.

  • filter (str, optional) – Name of the filter to be applied in frequency domain filtering. The options are: ram-lak, shepp-logan, cosine, hamming, hann. The default is ram-lak. Assign None to use no filter.

  • derivatives (bool, optional) – If True, assumes that the radon_image contains the derivates of the projections. The default is True

  • interpolation (str, optional) – Interpolation method used in reconstruction. Methods available: linear, nearest, and cubic (cubic is slow). The default is linear

  • circle (bool, optional) – Assume the reconstructed image is zero outside the inscribed circle. Also changes the default output_size to match the behaviour of radon called with circle=True.

  • freqcutoff (int, optional) – Normalized frequency cutoff of the filter. The default value is 1 which means no cutoff.

Returns

reconstructed – A 2-dimensional array containing the reconstructed image. The rotation axis will be located in the pixel with indices (reconstructed.shape[0] // 2, reconstructed.shape[1] // 2).

Return type

ndarray

Notes

It applies the Fourier slice theorem to reconstruct an image by multiplying the frequency domain of the filter with the FFT of the projection data. This algorithm is called filtered back projection.

toupy.tomo.iradon.mod_iradonSilx(radon_image, theta=None, output_size=None, filter_type='ram-lak', derivatives=False, interpolation='linear', circle=False, freqcutoff=1, use_numpy=True)[source]

Inverse radon transform using Silx and OpenCL.

Reconstruct an image from the radon transform, using the filtered back projection algorithm.

Parameters
  • radon_image (ndarray) – A 2-dimensional array containing radon transform (sinogram). Each column of the image corresponds to a projection along a different angle. The tomography rotation axis should lie at the pixel index radon_image.shape[0] // 2 along the 0th dimension of radon_image.

  • theta (ndarray, optional) – Reconstruction angles (in degrees). Default: m angles evenly spaced between 0 and 180 (if the shape of radon_image is (N, M)).

  • output_size (int) – Number of rows and columns in the reconstruction.

  • filter (str, optional) – Name of the filter to be applied in frequency domain filtering. The options are: ram-lak, shepp-logan, cosine, hamming, hann. The default is ram-lak. Assign None to use no filter.

  • derivatives (bool, optional) – If True, assumes that the radon_image contains the derivates of the projections. The default is True

  • interpolation (str, optional) – Interpolation method used in reconstruction. Methods available: linear, nearest, and cubic (cubic is slow). The default is linear

  • circle (boolean, optional) – Assume the reconstructed image is zero outside the inscribed circle. Also changes the default output_size to match the behaviour of radon called with circle=True.

  • freqcutoff (int, optional) – Normalized frequency cutoff of the filter. The default value is 1 which means no cutoff.

Returns

reconstructed – A 2-dimensional array containing the reconstructed image. The rotation axis will be located in the pixel with indices (reconstructed.shape[0] // 2, reconstructed.shape[1] // 2).

Return type

ndarray

Notes

It applies the Fourier slice theorem to reconstruct an image by multiplying the frequency domain of the filter with the FFT of the projection data. This algorithm is called filtered back projection.

toupy.tomo.iradon.reconsSART(sinogram, theta, num_iter=2, FBPinitial_guess=True, relaxation_params=0.15, **params)[source]

Reconstruction with SART algorithm

Parameters
  • sinogram (ndarray) – A 2-dimensional array containing the sinogram

  • theta (ndarray) – A 1-dimensional array of thetas

  • num_iter (int, optional) – Number of iterations of the SART algorithm. The default is 2.

  • FBPinitial_guess (bool, optional) – If the results of FBP reconstruction should be used as initial guess. The default value is True

  • relaxation_params (float, optional) – Relaxation parameter of SART. The default value is 0.15.

Returns

recons – A 2-dimensional array containing the reconstructed sliced by SART

Return type

ndarray

toupy.tomo.radon module

toupy.tomo.radon.projector(recons, theta, **params)[source]

Wrapper to choose between Forward Radon transform using Silx and OpenCL or standard reconstruction.

Parameters
  • recons (ndarray) – A 2-dimensional array containing the tomographic slice

  • theta (ndarry) – A 1-dimensional array of thetas

  • params (dict) – Dictionary of parameters to be used

  • params["opencl"] (bool) – If True, it will perform the tomographic reconstruction using the opencl implementation of Silx.

Returns

sinogramcomp – A 2-dimensional array containing the reprojected sinogram

Return type

ndarray

toupy.tomo.radon.radonSilx(recons, theta)[source]

Forward Radon transform using Silx and OpenCL

Parameters
  • recons (ndarray) – A 2-dimensional array containing the tomographic slice

  • theta (ndarry) – A 1-dimensional array of thetas

Returns

sinogramcomp – A 2-dimensional array containing the reprojected sinogram

Return type

ndarray

toupy.tomo.tomorecons module

toupy.tomo.tomorecons.full_tomo_recons(input_stack, theta, **params)[source]

Full tomographic reconstruction

Parameters
  • input_stack (ndarray) – A 3-dimensional array containing the stack of projections. The order should be [projection_num, row, column]

  • theta (ndarray) – A 1-dimensional array of thetas

  • params (dict) – Dictionary containing additional parameters

  • params["algorithm"] (str) – Choice of algorithm. Two algorithm implemented: “FBP” and “SART”

  • params["slicenum"] (int) – Slice number

  • params["filtertype"] (str) – Filter to use for FBP

  • params["freqcutoff"] (float) – Frequency cutoff (between 0 and 1)

  • params["circle"] (bool) – Multiply the reconstructed slice by a circle to remove borders

  • params["derivatives"] (bool) – If the projections are derivatives. Only for FBP.

  • params["calc_derivatives"] (bool) – Calculate derivatives of the sinogram if not done yet.

  • params["opencl"] (bool) – Implement the tomographic reconstruction in opencl as implemented in Silx

  • params["autosave"] (bool) – Save the data at the end without asking

  • params["vmin_plot"] (float) – Minimum value for the gray level at each display

  • params["vmax_plot"] (float) – Maximum value for the gray level at each display

  • params["colormap"] (str) – Colormap

  • params["showrecons"] (bool) – If to show the reconstructed slices

Returns

Tomogram – A 3-dimensional array containing the full reconstructed tomogram

Return type

ndarray

toupy.tomo.tomorecons.tomo_recons(sinogram, theta, **params)[source]

Wrapper to select tomographic algorithm

sinogramndarray

A 2-dimensional array containing the sinogram

thetandarray

A 1-dimensional array of thetas

paramsdict

Dictionary containing additional parameters

params[“algorithm”]str

Choice of algorithm. Two algorithm implemented: “FBP” and “SART”

params[“slicenum”]int

Slice number

params[“filtertype”]str

Name of the filter to be applied in frequency domain filtering. The options are: ram-lak, shepp-logan, cosine, hamming, hann. Assign None to use no filter.

params[“freqcutoff”]float

Frequency cutoff (between 0 and 1)

params[“circle”]bool

Multiply the reconstructed slice by a circle to remove borders

params[“weight_angles”]bool

If True, weights each projection with a factor proportional to the angular distance between the neighboring projections.

\[\Delta \phi_0 \longmapsto \Delta \phi_j =\]

rac{phi_{j+1} - phi_{j-1}}{2}

params[“derivatives”]bool

If the projections are derivatives. Only for FBP.

params[“calc_derivatives”]bool

Calculate derivatives of the sinogram if not done yet.

params[“opencl”]bool

Implement the tomographic reconstruction in opencl as implemented in Silx

params[“autosave”]bool

Save the data at the end without asking

params[“vmin_plot”]float

Minimum value for the gray level at each display

params[“vmax_plot”]float

Maximum value for the gray level at each display

params[“colormap”]str

Colormap

params[“showrecons”]bool

If to show the reconstructed slices

reconsndarray

A 2-dimensional array containing the reconstructed slice