cbi_toolbox.splineradon

Module contents

The splineradon package implements radon and inverse radon transforms using b-spline interpolation formulas described in [1] using multithreading and GPU acceleration.

Conventions:

arrays follow the ZXY convention, with

  • Z : depth axis (axial, focus axis)

  • X : horizontal axis (lateral)

  • Y : vertical axis (lateral, rotation axis when relevant)

sinograms follow the TPY convention, with

  • T : angles (theta)

  • P : captor axis

  • Y : rotation axis

[1] S. Horbelt, M. Liebling, M. Unser, “Discretization of the Radon Transform and of Its Inverse by Spline Convolutions”, IEEE Transactions on Medical Imaging, vol 21, no 4, pp. 363-376, April 2002.

cbi_toolbox.splineradon.iradon(sinogram, theta=None, angledeg=True, filter_type='RAM-LAK', b_spline_deg=(2, 3), sampling_steps=(1, 1), center=None, captors_center=None, circle=False, nt=200, use_cuda=False)[source]

Perform a filtered back projection on the sinogram.

Parameters:
  • sinogram (numpy.ndarray [TPY]) – The input sinogram.

  • theta (array_like, optional) – The sinogram angles, by default None. If None, uses numpy.arange(180).

  • angledeg (bool, optional) – Give angles in degrees instead of radians, by default True.

  • filter_type (str, optional) – The type of filter used for FBP, by default ‘RAM-LAK’. Can be one of [‘None’, ‘Ram-Lak’, ‘Shepp-Logan’, ‘Cosine’].

  • b_spline_deg (tuple, optional) – (ni, ns) the degrees of the image and sinogram bspline bases, by default (2, 3).

  • sampling_steps (tuple, optional) – Pixel sampling steps on the image and the sinogram, by default (1, 1).

  • center (tuple, optional) – (z, x) the center of rotation of the image, by default None (centered).

  • captors_center (float, optional) – The position of the center of rotation in the sinogram, by default None.

  • circle (bool, optional) – If the object is contained in the inner circle/cylinder (will produce a sinogram with same width as the image), by default False.

  • nt (int, optional) – Number of points stored in the spline kernel, by default 200.

  • use_cuda (bool, optional) – Use CUDA GPU acceleration, by default False.

Returns:

The reconstructed image.

Return type:

numpy.ndarray [ZXY]

cbi_toolbox.splineradon.iradon_inner(sinogram_filtered, theta=None, angledeg=True, b_spline_deg=(2, 3), sampling_steps=(1, 1), center=None, captors_center=None, nt=200, use_cuda=False)[source]

Raw inverse radon transform, requires pre and post-processing for sinogram filtering and change to bspline basis. Can be run in parallel by splitting the sinogram and theta.

Parameters:
  • sinogram_filtered (numpy.ndarray [TPY]) – The pre-processed sinogram.

  • theta (array_like, optional) – The sinogram angles, by default None. If None, uses numpy.arange(180).

  • angledeg (bool, optional) – Give angles in degrees instead of radians, by default True.

  • b_spline_deg (tuple, optional) – (ni, ns) the degrees of the image and sinogram bspline bases, by default (2, 3).

  • sampling_steps (tuple, optional) – Pixel sampling steps on the image and the sinogram, by default (1, 1).

  • center (tuple, optional) – (z, x) the center of rotation of the image, by default None (centered).

  • captors_center (float, optional) – The position of the center of rotation in the sinogram, by default None.

  • nt (int, optional) – Number of points stored in the spline kernel, by default 200.

  • use_cuda (bool, optional) – Use CUDA GPU acceleration, by default False.

Returns:

The image in bspline basis.

Return type:

numpy.ndarray

cbi_toolbox.splineradon.iradon_post(image, theta, ni=2)[source]

Post-processing for the inverse Radon transform. Projects the image back from a bspline basis and normalizes it.

Parameters:
  • image (numpy.ndarray) – The image in bspline basis.

  • theta (array_like) – The projection angles of the sinogram.

  • ni (tuple, optional) – The degree of the image bspline basis, by default 2.

Returns:

The reconstructed image.

Return type:

numpy.ndarray

cbi_toolbox.splineradon.iradon_pre(sinogram, ns=3, filter_type='RAM-LAK', circle=False)[source]

Pre-processing for the inverse radon transform. Filters the sinogram and projects it onto a bspline basis.

Parameters:
  • sinogram (numpy.ndarray) – The raw sinogram.

  • ns (tuple, optional) – Degree of the sinogram bspline basis, by default 3.

  • filter_type (str, optional) – The type of filter used for FBP, by default ‘RAM-LAK’. Can be one of [‘None’, ‘Ram-Lak’, ‘Shepp-Logan’, ‘Cosine’].

  • circle (bool, optional) – If the object is contained in the inner circle/cylinder (will produce a sinogram with same width as the image), by default False.

Returns:

The filtered and projected sinogram.

Return type:

numpy.ndarray

cbi_toolbox.splineradon.is_cuda_available(verbose=False)[source]

Check if CUDA can be used for computations.

Parameters:

verbose (bool, optional) – Print verbose errors, by default False.

Returns:

Whether CUDA is available.

Return type:

bool

cbi_toolbox.splineradon.radon(image, theta=None, angledeg=True, n=None, b_spline_deg=(2, 3), sampling_steps=(1, 1), center=None, captors_center=None, circle=False, nt=200, use_cuda=False)[source]

Perform a radon transform on the image.

Parameters:
  • image (numpy.ndarray [ZXY] or [ZX]) – The input image.

  • theta (array_like, optional) – The sinogram angles, by default None. If None, uses numpy.arange(180).

  • angledeg (bool, optional) – Give angles in degrees instead of radians, by default True.

  • n (int, optional) – The number of captors (overrides sampling_steps[1]), by default None.

  • b_spline_deg (tuple, optional) – (ni, ns) the degrees of the image and sinogram bspline bases, by default (2, 3).

  • sampling_steps (tuple, optional) – Pixel sampling steps on the image and the sinogram, by default (1, 1).

  • center (tuple, optional) – (z, x) the center of rotation of the image, by default None (centered).

  • captors_center (float, optional) – The position of the center of rotation in the sinogram, by default None.

  • circle (bool, optional) – If the object is contained in the inner circle/cylinder (will produce a sinogram with same width as the image), by default False.

  • nt (int, optional) – Number of points stored in the spline kernel, by default 200.

  • use_cuda (bool, optional) – Use CUDA GPU acceleration, by default False.

Returns:

The computed sinogram.

Return type:

numpy.ndarray [TPY]

cbi_toolbox.splineradon.radon_inner(spline_image, theta=None, angledeg=True, n=None, b_spline_deg=(2, 3), sampling_steps=(1, 1), center=None, captors_center=None, circle=False, nt=200, use_cuda=False)[source]

Raw radon transform, requires pre and post-processing (projections onto bspline bases). This can be run in parallel by splitting theta.

Parameters:
  • spline_image (numpy.ndarray) – The input image in a bspline basis.

  • theta (array_like, optional) – The sinogram angles, by default None. If None, uses numpy.arange(180).

  • angledeg (bool, optional) – Give angles in degrees instead of radians, by default True.

  • n (int, optional) – The number of captors (overrides sampling_steps[1]), by default None.

  • b_spline_deg (tuple, optional) – (ni, ns) the degrees of the image and sinogram bspline bases, by default (2, 3).

  • sampling_steps (tuple, optional) – Pixel sampling steps on the image and the sinogram, by default (1, 1).

  • center (tuple, optional) – (z, x) the center of rotation of the image, by default None (centered).

  • captors_center (float, optional) – The position of the center of rotation in the sinogram, by default None.

  • circle (bool, optional) – If the object is contained in the inner circle/cylinder (will produce a sinogram with same width as the image), by default False.

  • nt (int, optional) – Number of points stored in the spline kernel, by default 200.

  • use_cuda (bool, optional) – Use CUDA GPU acceleration, by default False.

Returns:

The computed sinogram in a bspline basis.

Return type:

numpy.ndarray [TPY]

cbi_toolbox.splineradon.radon_post(sinogram, ns=3)[source]

Post-processing for the radon transform. Projects the sinogram back from a bspline basis.

Parameters:
  • sinogram (numpy.ndarray) – The sinogram in bspline basis.

  • ns (tuple, optional) – The degree of the sinogram bspline basis, by default 3

Returns:

The sinogram.

Return type:

numpy.ndarray

cbi_toolbox.splineradon.radon_pre(image, ni=2)[source]

Pre-processing step for radon transform. Projects the image onto a bspline basis.

Parameters:
  • image (numpy.ndarray [ZXY] or [ZX]) – The raw input image.

  • ni (tuple, optional) – The degree of the image bspline basis, by default 2.

Returns:

The projected image.

Return type:

np.ndarray