Cone Beam Model#
The ConeBeamModel class implements a geometry and reconstruction model for cone beam computed tomography.
This class inherits all behaviors and attributes of the Tomography Model.
It also implements some cone-beam specific functions such as FDK (Feldkamp-Davis-Kress) reconstruction.
For cone-beam geometry, the default detector channel spacing is delta_det_channel is 1 ALU,
and the voxels are 3D cubes with spacing delta_voxel.
The default voxel spacing is set to delta_voxel = delta_det_channel / magnification where magnification = source_detector_dist / source_iso_dist.
This implies that as the magnification increases, the default voxel spacing decreases.
However, these parameters can be changed by the user using the TomographyModel.set_params() method.
See the API docs for the TomographyModel class for details on a wide range
of functions that can be implemented using the ConeBeamModel.
Constructor#
- class mbirjax.ConeBeamModel(sinogram_shape, angles, source_detector_dist, source_iso_dist, helical_z_shifts=None, use_curved_detector=False)[source]#
Bases:
TomographyModelA class designed for handling forward and backward projections in a cone beam geometry, extending the Tomography Model. This class offers specialized methods and parameters tailored for cone beam setups.
This class inherits all methods and properties from the Tomography Model and may override some to suit parallel beam geometrical requirements. See the documentation of the parent class for standard methods like setting parameters and performing projections and reconstructions.
Parameters not included in the constructor can be set using the set_params method of Tomography Model. Refer to Tomography Model documentation for a detailed list of possible parameters.
- Parameters:
sinogram_shape (tuple) – Shape of the sinogram as a tuple in the form (views, rows, channels), where ‘views’ is the number of different projection angles, ‘rows’ correspond to the number of detector rows, and ‘channels’ index columns of the detector that are assumed to be aligned with the rotation axis.
angles (numpy or jax array) – A 1D array of projection angles, in radians, specifying the angle of each projection relative to the origin.
source_detector_dist (float) – Distance between the X-ray source and the detector in units of ALU.
source_iso_dist (float) – Distance between the X-ray source and the center of rotation in units of ALU.
helical_z_shifts (numpy or jax array, optional) – Per-view axial shifts (ALU; same length as angles) for helical mode.
use_curved_detector (bool, optional) – Detector geometry type. Either False (default) or True implies each detector row has constant distance from source.
Note
Additional parameter:
recon_slice_offset (float, default=0) - This parameter controls the vertical offset of the reconstruction in ALU. If recon_slice_offset is positive, the region below iso is reconstructed.
See also
TomographyModelThe base class from which this class inherits.
Alternative Reconstruction#
- ConeBeamModel.fdk_recon(sinogram, filter_name='ramp', output_sharded=False)[source]#
Perform FDK reconstruction on the given sinogram.
Our implementation uses standard filtering of the sinogram, then uses the adjoint of the forward projector to perform the backprojection. This is different from many implementations, in which the backprojection is not exactly the adjoint of the forward projection. For a detailed theoretical derivation of this implementation, see the zip file linked at this page: https://mbirjax.readthedocs.io/en/latest/theory.html
Note
FDK assumes the view angles are EQUALLY SPACED over the full angular range (the
pi / num_viewsangular weight in the ramp filter), and does not apply short-scan (Parker-style) redundancy weighting; on nonuniformly-spaced, limited-angle, or short scans it is only approximate. For helical scans it is approximate regardless. FDK is best used as an initializer for the iterativerecon().- Parameters:
sinogram (numpy or jax array) – The input sinogram with shape (num_views, num_rows, num_channels).
filter_name (string, optional) – Name of the filter to be used. Defaults to “ramp”
output_sharded (bool, optional) – If False (default), return a numpy array. If True, return the slice-sharded device form (on an unsharded model the output is the same either way).
- Returns:
recon (numpy or jax array) – The reconstructed volume after FDK reconstruction – numpy by default, slice-sharded if
output_sharded=True.
- ConeBeamModel.split_sino_recon(sino, weights=None, half_overlap=5, init_recon=None, max_iterations=15, stop_threshold_change_pct=0.2, first_iteration=0, compute_prior_loss=False, logfile_path='~/.mbirjax/logs/recon.log', print_logs=True)[source]#
This function reduces memory usage for cone beam MBIR reconstruction by approximately a factor of 2 by splitting the detector rows into two overlapping halves, reconstructing each half separately, and stitching the reconstructions together.
The function can be called with the same arguments as TomographyModel.recon(), and it should return a reconstruction which is approximately equal to the reconstruction returned by TomographyModel.recon().
- Parameters:
sino (jnp.ndarray | np.ndarray) – Full sinogram of shape (num_views, num_rows, num_cols).
weights (jnp.ndarray | np.ndarray, optional) – Optional sinogram weights with the same shape as sino.
half_overlap (int) – Number of overlapping detector rows and recon slices per half. (total overlap = 2 * half_overlap)
init_recon (optional) – Same as in the recon method.
max_iterations (int, optional) – Same as in the recon method.
stop_threshold_change_pct (float, optional) – Same as in the recon method.
first_iteration (int, optional) – Same as in the TomographyModel.recon() method.
compute_prior_loss (bool, optional) – Same as in the TomographyModel.recon() method.
logfile_path (str, optional) – Same as in the TomographyModel.recon() method. The two halves’ logs are merged into this single file, each under a section header.
print_logs (bool, optional) – Same as in the TomographyModel.recon() method.
- Returns:
Tuple[np.ndarray, dict] – - Reconstructed volume (numpy array). - Dictionary of metadata containing recon and model parameters for each half.
- Raises:
ValueError – If inputs are missing or shapes are inconsistent, if half_overlap < 2, or if the geometry has nonzero helical z-shifts.
AssertionError – If array dimensions are invalid.
Example
>>> import jax.numpy as jnp >>> import mbirjax as mj >>> sino = jnp.ones((180, 64, 64)) # (views, rows, cols) >>> model = mj.ConeBeamModel(sinogram_shape=sino.shape, ... angles=jnp.linspace(0, jnp.pi, 180), ... source_detector_dist=1000.0, ... source_iso_dist=500.0) >>> recon, recon_info = model.split_sino_recon(sino, half_overlap=4) >>> recon.shape # Quilted reconstruction volume (64, 64, 64)