nabu.reconstruction.cone module

class nabu.reconstruction.cone.ConebeamReconstructor(sinos_shape, source_origin_dist, origin_detector_dist, angles=None, volume_shape=None, rot_center=None, relative_z_position=None, pixel_size=None, cuda_options=None)[source]

Bases: object

A reconstructor for cone-beam geometry using the astra toolbox.

Initialize a cone beam reconstructor. This reconstructor works on slabs of data, meaning that one partial volume is obtained from one stack of sinograms. To reconstruct a full volume, the reconstructor must be called on a series of sinograms stacks, with an updated “relative_z_position” each time.

Parameters:
  • sinos_shape (tuple) – Shape of the sinograms stack, in the form (n_sinos, n_angles, prj_width)

  • source_origin_dist (float) – Distance, in pixel units, between the beam source (cone apex) and the “origin”. The origin is defined as the center of the sample

  • origin_detector_dist (float) – Distance, in pixel units, between the center of the sample and the detector.

  • angles (array, optional) – Rotation angles in radians. If provided, its length should be equal to sinos_shape[1].

  • volume_shape (tuple of int, optional) – Shape of the output volume slab, in the form (n_z, n_y, n_x). If not provided, the output volume slab shape is (sinos_shape[0], sinos_shape[2], sinos_shape[2]).

  • rot_center (float, optional) – Rotation axis position. Default is (detector_width - 1)/2.0

  • relative_z_position (float, optional) – Position of the central slice of the slab, with respect to the full stack of slices. By default it is set to zero, meaning that the current slab is assumed in the middle of the stack

  • pixel_size (float or tuple, optional) –

    Size of the pixel. Possible options:
    • Nothing is provided (default): in this case, all lengths are normalized with respect to the pixel size, i.e ‘source_origin_dist’ and ‘origin_detector_dist’ should be expressed in pixels (and ‘pixel_size’ is set to 1).

    • A scalar number is provided: in this case it is the spacing between two pixels (in each dimension)

    • A tuple is provided: in this case it is the spacing between two pixels in both dimensions, vertically then horizontally, i.e (detector_spacing_y, detector_spacing_x)

Notes

This reconstructor is using the astra toolbox [1]. Therefore the implementation uses Astra’s reference frame, which is centered on the sample (source and detector move around the sample). For more information see Fig. 2 of paper [1].

To define the cone-beam geometry, two distances are needed:
  • Source-origin distance (hereby d1)

  • Origin-detector distance (hereby d2)

The magnification at distance d2 is m = 1+d2/d1, so given a detector pixel size p_s, the sample voxel size is p_s/m.

To make things simpler, this class internally uses a different (but equivalent) geometry:
  • d2 is set to zero, meaning that the detector is (virtually) moved to the center of the sample

  • The detector is “re-scaled” to have a pixel size equal to the voxel size (p_s/m)

Having the detector in the same plane as the sample center simplifies things when it comes to slab-wise reconstruction: defining a volume slab (in terms of z_min, z_max) is equivalent to define the detector bounds, like in parallel geometry.

References

[1] Aarle, Wim & Palenstijn, Willem & Cant, Jeroen & Janssens, Eline & Bleichrodt, Folkert & Dabravolski, Andrei & De Beenhouwer, Jan & Batenburg, Kees & Sijbers, Jan. (2016). Fast and flexible X-ray tomography using the ASTRA toolbox. Optics Express. 24. 25129-25147. 10.1364/OE.24.025129.

reconstruct(sinos, output=None, relative_z_position=None)[source]
sinos: numpy.ndarray or pycuda.gpuarray

Sinograms, with shape (n_sinograms, n_angles, width)

output: pycuda.gpuarray, optional

Output array. If not provided, a new numpy array is returned

relative_z_position: int, optional

Position of the central slice of the slab, with respect to the full stack of slices. By default it is set to zero, meaning that the current slab is assumed in the middle of the stack