7.3.2. algotom.rec.vertrec

Module of methods for directly reconstructing vertical slices without the need for full reconstruction and reslicing of tomography data.

  • Vertical back-projection methods for CPU and GPU that support single and multiple-slice reconstruction.

  • Direct vertical reconstruction of a single slice or multiple slices (at the same or different angles) using Filtered Back-Projection (FBP) or Back-Projection Filtering (BPF) methods.

  • Automatic determination of the center of rotation.

  • Tool to assist in manual determination of the center of rotation.

Functions:

vertical_back_projection_cpu

Perform vertical back-projection on CPU.

vertical_back_projection_cpu_chunk

Perform vertical back-projection on CPU for multiple slices.

vertical_back_projection_gpu(projections, ...)

Perform vertical back-projection on GPU.

vertical_back_projection_gpu_chunk(...[, ...])

Perform vertical back-projection on GPU for multiple slices.

vertical_reconstruction(projections, ...[, ...])

Reconstruct a vertical slice given a stack of projection-images (num_projection, height, width) with optional use of the ramp-filter.

vertical_reconstruction_multiple(...[, ...])

Reconstruct multiple vertical-slices given a stack of projection-images (num_projection, height, width) with optional use of the ramp-filter.

vertical_reconstruction_different_angles(...)

Reconstruct multiple vertical-slices at different slice-angles given a stack of projection-images (num_projection, height, width) with optional use of the ramp-filter.

find_center_vertical_slice(projections, ...)

Find the center-of-rotation (COR) by evaluating reconstruction metrics across estimated centers.

find_center_visual_vertical_slices(...[, ...])

For visually finding the center-of-rotation (COR) using reconstructed slices at different CORs.

algotom.rec.vertrec.vertical_back_projection_cpu(projections, angles, xlist, ylist, center, edge_pad=False)

Perform vertical back-projection on CPU.

Parameters
  • projections (array_like) – 3D array of projection data with shape (depth, height, width)

  • angles (array_like) – 1D array. Angles (radian) corresponding to projections.

  • xlist (array_like) – x-coordinates of points on the reconstructed line.

  • ylist (array_like) – y-coordinates of points on the reconstructed line.

  • center (float) – Center of rotation. (x-coordinate of the rotation axis)

  • edge_pad (bool) – Enable/disable edge padding.

Returns

recon (array_like) – 2D back-projected image, same size as projection (height, width).

algotom.rec.vertrec.vertical_back_projection_cpu_chunk(projections, angles, x_mat, y_mat, center, edge_pad=False)

Perform vertical back-projection on CPU for multiple slices.

Parameters
  • projections (array_like) – 3D array of projection data with shape (depth, height, width)

  • angles (array_like) – 1D array. Angles (radian) corresponding to projections.

  • x_mat (array_like) – 2D array (num_slice, width), each row contains x-coordinates for back-projection on each slice.

  • y_mat (array_like) – 2D array (num_slice, width), each row contains y-coordinates for back-projection on each slice.

  • center (float) – Center of rotation. (x-coordinate of the rotation axis)

  • edge_pad (bool) – Enable/disable edge padding.

Returns

recon (array_like) – 3D back-projected image with size (num_slice, height, width)

algotom.rec.vertrec.vertical_back_projection_gpu(projections, angles, xlist, ylist, center, edge_pad=False, block=(16, 16))[source]

Perform vertical back-projection on GPU.

Parameters
  • projections (array_like) – 3D array of projection data with shape (depth, height, width)

  • angles (array_like) – 1D array. Angles (radian) corresponding to projections.

  • xlist (array_like) – x-coordinates of points on the reconstructed line.

  • ylist (array_like) – y-coordinates of points on the reconstructed line.

  • center (float) – Center of rotation. (x-coordinate of the rotation axis)

  • edge_pad (bool) – Enable/disable edge padding.

  • block (tuple of two integer-values, optional) – Size of a GPU block. E.g. (8, 8), (16, 16), (32, 32), …

Returns

recon (array_like) – 2D back-projected image, same size as projection (height, width).

algotom.rec.vertrec.vertical_back_projection_gpu_chunk(projections, angles, x_mat, y_mat, center, edge_pad=False, block=(16, 16))[source]

Perform vertical back-projection on GPU for multiple slices.

Parameters
  • projections (array_like) – 3D array of projection data with shape (depth, height, width)

  • angles (array_like) – 1D array. Angles (radian) corresponding to projections.

  • x_mat (array_like) – 2D array (num_slice, width), each row contains x-coordinates for back-projection on each slice.

  • y_mat (array_like) – 2D array (num_slice, width), each row contains y-coordinates for back-projection on each slice.

  • center (float) – Center of rotation. (x-coordinate of the rotation axis)

  • edge_pad (bool) – Enable/disable edge padding.

  • block (tuple of two integer-values, optional) – Size of a GPU block. E.g. (8, 8), (16, 16), (32, 32), …

Returns

recon (array_like) – 3D back-projected image with size (num_slice, height, width)

algotom.rec.vertrec.vertical_reconstruction(projections, slice_index, center, alpha=0.0, flat_field=None, dark_field=None, angles=None, crop=(0, 0, 0, 0), proj_start=0, proj_stop=-1, chunk_size=30, ramp_filter='after', filter_name='hann', pad=None, pad_mode='edge', apply_log=True, gpu=True, block=(16, 16), ncore=None, prefer='threads', show_progress=True, masking=False)[source]

Reconstruct a vertical slice given a stack of projection-images (num_projection, height, width) with optional use of the ramp-filter.

Parameters
  • projections (array_like) – 3D array of projection data with shape (depth, height, width). Can be a numpy array or HDF-dataset object.

  • slice_index (int) – Index of the slice for reconstruction. Referred to the cropped image.

  • center (float) – Center of rotation, x-coordinate of the rotation axis. Referred to the cropped image.

  • alpha (float, optional) – Angle of the slice in degree, between 0 and 180.

  • flat_field (array_like, optional) – 2D array for flat-field correction if not None.

  • dark_field (array_like, optional) – 2D array for dark-field correction if not None.

  • angles (array_like, optional) – 1D array. Angles corresponding to projections. The unit is radian to be consistent with other reconstruction methods.

  • crop (tuple of int, optional) – Edges to crop from the images (top, bottom, left, right).

  • proj_start (int, optional) – Start index for processing projections.

  • proj_stop (int, optional) – End index for processing projections.

  • chunk_size (int, optional) – Chunk size to manage memory usage.

  • ramp_filter ({“after”, “before”, None}) – When to apply the ramp filter or not apply.

  • filter_name ({None, “hann”, “bartlett”, “blackman”, “hamming”, “nuttall”, “parzen”, “triang”}) – Type of smoothing filter used with the ramp filter.

  • pad (int, optional) – Padding before FFT (defaults to 10% of width if None).

  • pad_mode (str, optional) – Padding method (see numpy.pad documentation).

  • apply_log (bool, optional) – Apply logarithm to projections before reconstruction.

  • gpu (bool, optional) – Use GPU for computing if True.

  • block (tuple of two integer-values, optional) – Size of a GPU block. E.g. (8, 8), (16, 16), (32, 32), …

  • ncore (int or None) – Number of CPU cores used (auto-selected if None).

  • prefer ({“threads”, “processes”}) – Preferred parallel backend.

  • show_progress (bool) – Display reconstruction progress.

  • masking (bool) – Mask non-reconstructable areas.

Returns

array_like – Reconstructed image, same size as projection (height, width).

algotom.rec.vertrec.vertical_reconstruction_multiple(projections, start_index, stop_index, center, alpha=0.0, step_index=1, flat_field=None, dark_field=None, angles=None, crop=(0, 0, 0, 0), proj_start=0, proj_stop=-1, chunk_size=30, ramp_filter='after', filter_name='hann', pad=None, pad_mode='edge', apply_log=True, gpu=True, block=(16, 16), ncore=None, prefer='threads', show_progress=True, masking=False)[source]

Reconstruct multiple vertical-slices given a stack of projection-images (num_projection, height, width) with optional use of the ramp-filter.

Parameters
  • projections (array_like) – 3D array of projection data with shape (depth, height, width). Can be a numpy array or HDF-dataset object.

  • start_index (int) – Start index of reconstructing slice. Referred to the cropped image.

  • stop_index (int) – End index of reconstructing slice. Referred to the cropped image.

  • center (float) – Center of rotation, x-coordinate of the rotation axis. Referred to the cropped image.

  • alpha (float, optional) – Angle of the slices in degree, between 0 and 180.

  • step_index (int) – Gap between reconstructing slices. Referred to the cropped image.

  • flat_field (array_like, optional) – 2D array for flat-field correction if not None.

  • dark_field (array_like, optional) – 2D array for dark-field correction if not None.

  • angles (array_like, optional) – 1D array. Angles corresponding to projections. The unit is radian to be consistent with other reconstruction methods.

  • crop (tuple of int, optional) – Edges to crop from the images (top, bottom, left, right).

  • proj_start (int, optional) – Start index for processing projections.

  • proj_stop (int, optional) – End index for processing projections.

  • chunk_size (int, optional) – Chunk size to manage memory usage.

  • ramp_filter ({“after”, “before”, None}) – When to apply the ramp filter or not apply.

  • filter_name ({None, “hann”, “bartlett”, “blackman”, “hamming”, “nuttall”, “parzen”, “triang”}) – Type of smoothing filter used with the ramp filter.

  • pad (int, optional) – Padding before FFT (defaults to 10% of width if None).

  • pad_mode (str, optional) – Padding method (see numpy.pad documentation).

  • apply_log (bool, optional) – Apply logarithm to projections before reconstruction.

  • gpu (bool, optional) – Use GPU for computing if True.

  • block (tuple of two integer-values, optional) – Size of a GPU block. E.g. (8, 8), (16, 16), (32, 32), …

  • ncore (int or None) – Number of CPU cores used (auto-selected if None).

  • prefer ({“threads”, “processes”}) – Preferred parallel backend.

  • show_progress (bool) – Display reconstruction progress.

  • masking (bool) – Mask non-reconstructable areas.

Returns

array_like – 3D array. Multiple-reconstructed image.

algotom.rec.vertrec.vertical_reconstruction_different_angles(projections, slice_indices, alphas, center, flat_field=None, dark_field=None, angles=None, crop=(0, 0, 0, 0), proj_start=0, proj_stop=-1, chunk_size=30, ramp_filter='after', filter_name='hann', pad=None, pad_mode='edge', apply_log=True, gpu=True, block=(16, 16), ncore=None, prefer='threads', show_progress=True, masking=False)[source]

Reconstruct multiple vertical-slices at different slice-angles given a stack of projection-images (num_projection, height, width) with optional use of the ramp-filter.

Parameters
  • projections (array_like) – 3D array of projection data with shape (depth, height, width). Can be a numpy array or HDF-dataset object.

  • slice_indices (list of int) – List of reconstructing slice indices. Referred to the cropped image.

  • alphas (list of float) – List of angles (degrees, between 0 and 180) corresponding to the slice indices.

  • center (float) – Center of rotation, x-coordinate of the rotation axis. Referred to the cropped image.

  • flat_field (array_like, optional) – 2D array for flat-field correction if not None.

  • dark_field (array_like, optional) – 2D array for dark-field correction if not None.

  • angles (array_like, optional) – 1D array. Angles corresponding to projections. The unit is radian to be consistent with other reconstruction methods.

  • crop (tuple of int, optional) – Edges to crop from the images (top, bottom, left, right).

  • proj_start (int, optional) – Start index for processing projections.

  • proj_stop (int, optional) – End index for processing projections.

  • chunk_size (int, optional) – Chunk size to manage memory usage.

  • ramp_filter ({“after”, “before”, None}) – When to apply the ramp filter or not apply.

  • filter_name ({None, “hann”, “bartlett”, “blackman”, “hamming”, “nuttall”, “parzen”, “triang”}) – Type of smoothing filter used with the ramp filter.

  • pad (int, optional) – Padding before FFT (defaults to 10% of width if None).

  • pad_mode (str, optional) – Padding method (see numpy.pad documentation).

  • apply_log (bool, optional) – Apply logarithm to projections before reconstruction.

  • gpu (bool, optional) – Use GPU for computing if True.

  • block (tuple of two integer-values, optional) – Size of a GPU block. E.g. (8, 8), (16, 16), (32, 32), …

  • ncore (int or None) – Number of CPU cores used (auto-selected if None).

  • prefer ({“threads”, “processes”}) – Preferred parallel backend.

  • show_progress (bool) – Display reconstruction progress.

  • masking (bool) – Mask non-reconstructable areas.

Returns

array_like – 3D array. Multiple-reconstructed image.

algotom.rec.vertrec.find_center_vertical_slice(projections, slice_index, start, stop, step=1.0, metric='entropy', alpha=0.0, angles=None, chunk_size=30, ramp_filter='after', sigma=3, apply_log=True, gpu=True, block=(16, 16), ncore=None, prefer='threads', show_progress=True, masking=True, return_metric=False, invert_metric=False, metric_function=None, **kwargs)[source]

Find the center-of-rotation (COR) by evaluating reconstruction metrics across estimated centers. Minimum metric is corresponding to the optimal center.

Parameters
  • projections (array_like) – 3D array of projection data with shape (depth, height, width).

  • slice_index (int) – Index of the slice for reconstruction.

  • start (float) – Starting point for searching the center.

  • stop (float) – Ending point for searching the center.

  • step (float, optional) – Searching step.

  • metric ({“entropy”, “sharpness”, “autocorrelation”}) – Which metric to use.

  • alpha (float, optional) – Angle of the slice in degree, between 0 and 180.

  • angles (array_like, optional) – 1D array. Angles corresponding to projections. The unit is radian to be consistent with other reconstruction methods.

  • chunk_size (int, optional) – Chunk size to manage memory usage.

  • ramp_filter ({“after”, “before”}) – When to apply the ramp filter.

  • sigma (int) – Denoising the projections using Gaussian filter before reconstruction.

  • apply_log (bool, optional) – Apply logarithm to projections before reconstruction.

  • gpu (bool, optional) – Use GPU for computing if True.

  • block (tuple of two integer-values, optional) – Size of a GPU block. E.g. (8, 8), (16, 16), (32, 32), …

  • ncore (int or None) – Number of CPU cores used (auto-selected if None).

  • prefer ({“threads”, “processes”}) – Preferred parallel backend.

  • show_progress (bool) – Display the computing progress.

  • masking (bool) – Mask non-reconstructable areas.

  • return_metric (bool) – Return list of centers and their metrics if True.

  • invert_metric (bool) – Invert the metric scale.

  • metric_function (obj) – Custom function to calculate metric, accepts keyword arguments (kwargs).

Returns

float or ndarray – Optimal center or tuple of two lists; centers and their metrics if return_metric=True.

algotom.rec.vertrec.find_center_visual_vertical_slices(projections, output_folder, slice_index, start, stop, step=1.0, alpha=0.0, angles=None, chunk_size=30, ramp_filter='after', apply_log=True, gpu=True, block=(16, 16), ncore=None, prefer='processes', display=True, masking=True)[source]

For visually finding the center-of-rotation (COR) using reconstructed slices at different CORs.

Parameters
  • projections (array_like) – 3D array of projection data with shape (depth, height, width).

  • output_folder (str) – Base folder for saving reconstructed slices.

  • slice_index (int) – Index of the slice for reconstruction.

  • start (float) – Starting point for searching the center.

  • stop (float) – Ending point for searching the center.

  • step (float, optional) – Searching step.

  • alpha (float, optional) – Angle of the slice in degree, between 0 and 180.

  • angles (array_like, optional) – 1D array. Angles corresponding to projections. The unit is radian to be consistent with other reconstruction methods.

  • chunk_size (int, optional) – Chunk size to manage memory usage.

  • ramp_filter ({“after”, “before”}) – When to apply the ramp filter.

  • apply_log (bool, optional) – Apply logarithm to projections before reconstruction.

  • gpu (bool, optional) – Use GPU for computing if True.

  • block (tuple of two integer-values, optional) – Size of a GPU block. E.g. (8, 8), (16, 16), (32, 32), …

  • ncore (int or None) – Number of CPU cores used (auto-selected if None).

  • prefer ({“threads”, “processes”}) – Preferred parallel backend.

  • display (bool) – Print the output if True.

  • masking (bool) – Mask non-reconstructable areas.

Returns

output_base (str) – Folder path to tif images.