TomographyModel#
The TomographyModel
provides the basic interface for all specific geometries for tomographic projection
and reconstruction.
Constructor#
- class mbirjax.TomographyModel(sinogram_shape, **kwargs)[source]
Bases:
object
Represents a general model for tomographic reconstruction using MBIRJAX. This class encapsulates the parameters and methods for the forward and back projection processes required in tomographic imaging.
Note that this class is a template for specific subclasses. TomographyModel by itself does not implement projectors or recon. Use self.print_params() to print the parameters of the model after initialization.
- Parameters:
sinogram_shape (tuple) – The shape of the sinogram array expected (num_views, num_det_rows, num_det_channels).
**kwargs (dict) – Arbitrary keyword arguments for setting model parameters dynamically.
Sets up the reconstruction size and parameters.
Recon and Projection#
- TomographyModel.recon(sinogram, weights=1.0, num_iterations=13, init_recon=None)[source]
Perform MBIR reconstruction using the Multi-Granular Vector Coordinate Descent algorithm. This function takes care of generating its own partitions and partition sequence.
- Parameters:
sinogram (jax array) – 3D sinogram data with shape (num_views, num_det_rows, num_det_channels).
weights (scalar or jax array) – scalar or 3D positive weights with same shape as error_sinogram.
num_iterations (int) – number of iterations of the VCD algorithm to perform.
init_recon (jax array) – optional reconstruction to be used for initialization.
- Returns:
[recon, fm_rmse] – reconstruction and array of loss for each iteration.
- TomographyModel.forward_project(recon)[source]
Perform a full forward projection at all voxels in the field-of-view.
- Parameters:
recon (jnp array) – The 3D reconstruction array.
- Returns:
jnp array – The resulting 3D sinogram after projection.
- TomographyModel.back_project(sinogram)[source]
Perform a full back projection at all voxels in the field-of-view.
- Parameters:
sinogram (jnp array) – 3D jax array containing sinogram.
- Returns:
jnp array – The resulting 3D sinogram after projection.
Parameter Handling#
- TomographyModel.set_params(no_warning=False, no_compile=False, **kwargs)[source]
Updates parameters using keyword arguments. After setting parameters, it checks if key geometry-related parameters have changed and, if so, recompiles the projectors.
- Parameters:
no_warning (bool, optional, default=False) – This is used internally to allow for some initial parameter setting.
no_compile (bool, optional, default=False) – Prevent (re)compiling the projectors. Used for initialization.
**kwargs – Arbitrary keyword arguments where keys are parameter names and values are the new parameter values.
- Raises:
NameError – If any key provided in kwargs is not a recognized parameter.
- TomographyModel.get_params(parameter_names)[source]
Get the values of the listed parameter names. Raises an exception if a parameter name is not defined in parameters.
- Parameters:
parameter_names – String or list of strings
- Returns:
Single value or list of values
Data Generation#
- static TomographyModel.gen_weights(sinogram, weight_type)[source]
Compute the weights used in MBIR reconstruction.
- Parameters:
sinogram (jax array) – 3D jax array containing sinogram with shape (num_views, num_det_rows, num_det_channels).
weight_type (string) – Type of noise model used for data - weight_type = ‘unweighted’ => return numpy.ones(sinogram.shape). - weight_type = ‘transmission’ => return numpy.exp(-sinogram). - weight_type = ‘transmission_root’ => return numpy.exp(-sinogram/2). - weight_type = ‘emission’ => return 1/(numpy.absolute(sinogram) + 0.1).
- Returns:
(jax array) – Weights used in mbircone reconstruction, with the same array shape as
sinogram
.- Raises:
Exception – Raised if
weight_type
is not one of the above options.
- TomographyModel.gen_3d_sl_phantom()[source]
Generates a 3D Shepp-Logan phantom.
- Returns:
ndarray – A 3D numpy array of shape specified by TomographyModel class parameters.