Imaging Models#
|
Base class for imaging models in real-space. |
|
Tomography forward model. |
|
Base class for coherent-diffraction imaging (CDI) models. |
|
Fourier-based Ptychography imaging model |
|
Bragg Ptychography imaging model |
|
Simple interface to create an instace of |
|
Simple interface to create an instace of |
|
Simple interface to create an instace of |
|
Simple interface to create an instace of |
A module that provides implementation(s) of imaging models (tomography, coherent diffraction imaging (CDI), etc.)
This module is incomplete, and will be updated gradually.
- class Imaging(configs)[source]#
Bases:
TimeIndependentModel
Base class for imaging models in real-space.
- class TomographyConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model_name='Radon-Tomography', screen_output_iter=1, file_output_iter=1, n_voxels=50, n_angles=10, theta=None, scale_matrix=True)[source]#
Bases:
TimeIndependentModelConfigs
Configurations for the Tomography model.
- Parameters:
verbose (bool) – a boolean flag to control verbosity of the object.
debug (bool) – a boolean flag that enables adding extra functionlity in a debug mode
output_dir (str | Path) – the base directory where the output files will be saved.
screen_output_iter (int) – iteration interval for screen output. Default is 1. Note that this should be a positive integer to enforce proper effect.
file_out_iter – iteration interval for file output. Default is 1. Note that this should be a positive integer to enforce proper effect.
model_name (str) – ‘Radon-Tomography’ this is just for verbosity and output.
n_voxels (int) – Number of pixels along each edge of the image. Default is 50.
n_angles (int) – Number of angles at which to probe the object used to create theta (if None found); as linearly spaced <n_angles> angles between 1, 360. This is overridden if theta is not None. Default is 10.
theta (ndarray | None) – If passed, array-like objects that contains angles (all must be between 0, 360). Overridess n_angles if passed. Default is None.
scale_matrix (bool) – default True; scale A, by maximum sum of rows!
- n_voxels: int#
- n_angles: int#
- theta: ndarray | None#
- scale_matrix: bool#
- __init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model_name='Radon-Tomography', screen_output_iter=1, file_output_iter=1, n_voxels=50, n_angles=10, theta=None, scale_matrix=True)#
- class Tomography(configs=None)[source]#
Bases:
Imaging
Tomography forward model.
- Parameters:
configs (TomographyConfigs | dict | None) – Object containing the configurations of the Tomography model.
Warning
This implementation is by no means efficient. In fact, it relies on a very inefficient implementation of radon transform. We will consider more efficient approaches if we resort to this much!
- validate_configurations(configs, raise_for_invalid=True)[source]#
Check the passed configuratios and make sure they are conformable with each other, and with current configurations once combined. This guarantees that any key-value pair passed in configs can be properly used
Note
Here only the locally-defined configurations in
TomographyConfigs
are validated. Finally, super classes validators are called.- Parameters:
configs (dict | TomographyConfigs) – full or partial (subset) configurations to be validated
raise_for_invalid (bool) – if True raise
TypeError
for invalid configrations type/key. Default True
- Returns:
flag indicating whether passed configurations dictionary is valid or not
- Raises:
AttributeError – if any (or a group) of the configurations does not exist in the model configurations
TomographyConfigs
.PyOEDConfigsValidationError – if the configurations are invalid and raise_for_invalid is set to True.
- Return type:
bool
- create_radon_forward_operator(n_voxels, n_angles, theta, scale_matrix, verbose=False)[source]#
Construct a radon-transoform matrix A for multiple projection angles. Each row of A, takes as an input an image (flattened out as a vector), and create a radon transform.
See
TomographyConfigs
for more details on the parameters.- Returns:
2D Numpy array representing the radon transform (Linear model for an image)
- parameter_vector(init_val=0)[source]#
Create an instance of model parameter vector. Here, the parameter is the model initial state, and thus
parameter_vector()
actually callsstate_vector()
- Parameters:
init_val (float) – (optional) value assigned to entries of the parameter vector upon initialization
- is_parameter_vector(parameter)[source]#
Test whether the passed parameter vector is valid or not Here, the parameter is the model initial state, and thus
is_parameter_vector()
actually callsis_state_vector()
- solve_forward(state, design=None, verbose=False)[source]#
- Apply/Solve the model (apply the radon transform to an image or a vectorized
version thereof)
- Parameters:
state – either 1d flattened image, or 2d array describing an image
design – observational design; typically a binary array of the same size as design, or an array of indexes to extract active observations from the result of applying the forward operator.
- Returns:
result of applying radon transorm to the passed state/image
- Raises:
AssertionError is raised if state or design don’t have the right shape/size
- class CDI(configs=None)[source]#
Bases:
TimeIndependentModel
Base class for coherent-diffraction imaging (CDI) models. The infrastructure, however, might be different because the domain is in complex space, rather than real space This might end up being similar to Imaging; we will see!
- class FourierPtychography(configs=None)[source]#
Bases:
CDI
Fourier-based Ptychography imaging model
- create_Tomography_model(n_voxels=50, n_angles=10, theta=None, scale_matrix=True)[source]#
Simple interface to create an instace of
Tomography
- create_FourierPtychography_model(*args, **kwargs)[source]#
Simple interface to create an instace of
FourierPtychography