Skip to content

nabu.reconstruction

source package nabu.reconstruction

Classes

  • Reconstructor Abstract base class for reconstructors.

  • MunchDeringer Initialize a "Munch Et Al" sinogram deringer. See References for more information.

  • SinoBuilder A class to build sinograms.

  • SinoNormalization A class for sinogram normalization utilities.

Functions

  • convert_halftomo Converts a sinogram into a sinogram with extended FOV with the "half tomography" setting.

source class Reconstructor(shape, indices_range, axis='z', vol_type='sinograms', slices_roi=None)

Abstract base class for reconstructors.

A Reconstructor is a helper to reconstruct slices in arbitrary directions (not only usual "horizontal slices") in parallel-beam tomography.

Initialize a reconstructor.

Current limitations

  • Limitation to the three main axes
  • One instance of Reconstructor can only reconstruct successive slices

Typical scenarios examples

  • "I want to reconstruct several slices along 'z'", where z is the vertical axis. In this case, we reconstruct "horizontal slices" in planes perpendicular to the rotation axis.
  • "I want to reconstruct slices along 'y'". Here y is an axis perpendicular to z, i.e we reconstruct "vertical slices".

Parameters

  • shape : tuple Shape of the stack of sinograms or projections.

  • indices_range : tuple Range of indices to reconstruct, in the form (start, end). As the standard Python behavior, the upper bound is not included. For example, to reconstruct 100 slices (numbered from 0 to 99), then you can provide (0, 100) or (0, None). Providing (0, 99) or (0, -1) will omit the last slice.

  • axis : str Axis along which the slices are reconstructed. This axis is orthogonal to the slices planes. This parameter can be either "x", "y", or "z". Default is "z" (reconstruct slices perpendicular to the rotation axis).

  • vol_type : str, optional Whether the parameter shape describes a volume of sinograms or projections. The two are the same except that axes 0 and 1 are swapped. Can be "sinograms" (default) or "projections".

  • slices_roi : tuple, optional Define a Region Of Interest to reconstruct a part of each slice. By default, the whole slice is reconstructed for each slice index. This parameter is in the form (start_u, end_u, start_v, end_v), where u and v are horizontal and vertical axes on the reconstructed slice respectively, regardless of its orientation. If one of the values is set to None, it will be replaced by the corresponding default value.

Examples

To reconstruct the first two horizontal slices, i.e along z: R = Reconstructor(vol_shape, [0, 1]) To reconstruct vertical slices 0-100 along the y axis: R = Reconstructor(vol_shape, (0, 100), axis="y")

A Reconstructor is tied to the set of slices to reconstruct (axis and orientation). Once defined, it cannot be changed ; i.e another class has to be instantiated to reconstruct slices in other axes/indices.

The volume geometry conventions are defined below::

                      __________
                     /         /|
                    /         / |
     z             /         /  |
     ^            /_________/   |
     |           |          |   |
     |    y      |          |   /
     |   /       |          |  /
     |  /        |          | /
     | /         |__________|/
     |/
     ---------- > x

The axis z parallel to the rotation axis. The usual parallel-beam tomography setting reconstructs slices along z, i.e in planes parallel to (x, y).

Methods

source method Reconstructor.reconstruct()

Raises

  • ValueError

source class MunchDeringer(sigma, sinos_shape, levels=None, wname='db15', padding=None, padding_mode='edge')

Initialize a "Munch Et Al" sinogram deringer. See References for more information.

Parameters

  • sigma : float Standard deviation of the damping parameter. The higher value of sigma, the more important the filtering effect on the rings.

  • levels : int, optional Number of wavelets decomposition levels. By default (None), the maximum number of decomposition levels is used.

  • wname : str, optional Default is "db15" (Daubechies, 15 vanishing moments)

  • sinos_shape : tuple, optional Shape of the sinogram (or sinograms stack).

  • padding : tuple of two int, optional Horizontal padding to use for reducing the aliasing artefacts

References

B. Munch, P. Trtik, F. Marone, M. Stampanoni, Stripe and ring artifact removal with combined wavelet-Fourier filtering, Optics Express 17(10):8567-8591, 2009.

Methods

  • remove_rings Main function to performs rings artefacts removal on sinogram(s). CAUTION: this function defaults to in-place processing, meaning that the sinogram(s) you pass will be overwritten.

source method MunchDeringer.remove_rings(sinos, output=None)

Main function to performs rings artefacts removal on sinogram(s). CAUTION: this function defaults to in-place processing, meaning that the sinogram(s) you pass will be overwritten.

Parameters

  • sinos : numpy.ndarray Sinogram or stack of sinograms.

  • output : numpy.ndarray, optional Output array. If set to None (default), the output overwrites the input.

source class SinoBuilder(sinos_shape=None, radios_shape=None, rot_center=None, halftomo=False, angles=None, interpolate=False)

A class to build sinograms.

Initialize a SinoBuilder instance.

Parameters

  • sinos_shape : tuple of int Shape of the stack of sinograms, in the form (n_z, n_angles, n_x). If not provided, it is derived from radios_shape.

  • radios_shape : tuple of int Shape of the chunk of radios, in the form (n_angles, n_z, n_x). If not provided, it is derived from sinos_shape.

  • rot_center : int or array Rotation axis position. A scalar indicates the same rotation axis position for all the projections.

  • halftomo : bool Whether "half tomography" is enabled. Default is False.

  • interpolate : bool, optional Only used if halftomo=True. Whether to re-grid the second part of sinograms to match projection k with projection k + n_a/2. This forces each pair of projection (k, k + n_a/2) to be separated by exactly 180 degrees.

  • angles : array, optional Rotation angles (in radians). Used and required only when halftomo and interpolate are True.

Attributes

  • output_shape Get the output sinograms shape.

Methods

source method SinoBuilder.set_rot_center(rot_center)

Set the rotation axis position for the current radios/sinos stack.

rot_center: int or array Rotation axis position. A scalar indicates the same rotation axis position for all the projections.

Raises

  • ValueError

source property SinoBuilder.output_shape

Get the output sinograms shape.

source method SinoBuilder.get_sino(radios, i, output=None)

The the sinogram at a given index.

Parameters

  • radios : array 3D array with shape (n_z, n_angles, n_x)

  • i : int Sinogram index

Returns

  • sino : array Two dimensional array with shape (n_angles2, n_x2) where the dimensions are determined by the current settings.

source method SinoBuilder.convert_sino(sino, output=None)

source method SinoBuilder.get_sinos(radios, output=None)

source method SinoBuilder.radios_to_sinos(radios, output=None, copy=False)

DEPRECATED. Use get_sinos() or get_sino() instead.

source convert_halftomo(sino, extended_width, transition_width=None)

Converts a sinogram into a sinogram with extended FOV with the "half tomography" setting.

source class SinoNormalization(kind='chebyshev', sinos_shape=None, radios_shape=None, normalization_array=None)

A class for sinogram normalization utilities.

Initialize a SinoNormalization class.

Parameters

  • kind : str, optional Normalization type. They can be the following: - chebyshev: Each sinogram line is estimated by a Chebyshev polynomial of degree 2. This estimation is then subtracted from the sinogram. - subtraction: Each sinogram is subtracted with a user-provided array. The array can be 1D (angle-independent) and 2D (angle-dependent) - division: same as previously, but with a division operation. Default is "chebyshev"

  • sinos_shape : tuple, optional Shape of the sinogram or sinogram stack. Either this parameter or 'radios_shape' has to be provided.

  • radios_shape : tuple, optional Shape of the projections or projections stack. Either this parameter or 'sinos_shape' has to be provided.

  • normalization_array : numpy.ndarray, optional Normalization array when kind='subtraction' or kind='division'.

Methods

  • normalize Normalize a sinogram or stack of sinogram. The process is done in-place, meaning that the sinogram content is overwritten.

source method SinoNormalization.normalize(sino)

Normalize a sinogram or stack of sinogram. The process is done in-place, meaning that the sinogram content is overwritten.