monospectral
- class FieldOfViewCropping(global_settings, settings_key=None)[source]
Bases:
ProcessingComponentBase
Initialises the ProcessingComponent object.
- Parameters:
component_settings_key – The key where the component settings are stored in
- run(device: DigitalDeviceTwinBase)[source]
Executes the respective simulation module
- Parameters:
digital_device_twin – The digital twin that can be used by the digital device_twin.
- class IterativeqPAI(global_settings, component_settings_key: str)[source]
Bases:
ProcessingComponentBase
Applies iterative qPAI Algorithm [1] on simulated initial pressure map and saves the reconstruction result in the hdf5 output file. If a 2-d map of initial_pressure is passed the algorithm saves the reconstructed absorption coefficients as a 2-d map, else a 3-d absorption reconstruction is saved. The reconstruction result is saved as an image processing entry “iterative_qpai_result” in the hdf5 output file. If intended (e.g. for testing) a list of intermediate iteration updates (only 2-d middle slices) can be saved as a npy file. To run the reconstruction the scattering coefficients must be known a priori. Parameters: Tags.DOWNSCALE_FACTOR (default: 0.73) Tags.ITERATIVE_RECONSTRUCTION_CONSTANT_REGULARIZATION (default: False) Tags.ITERATIVE_RECONSTRUCTION_MAX_ITERATION_NUMBER (default: 10) Tags.ITERATIVE_RECONSTRUCTION_REGULARIZATION_SIGMA (default: 0.01) Tags.ITERATIVE_RECONSTRUCTION_SAVE_INTERMEDIATE_RESULTS (default: False) Tags.ITERATIVE_RECONSTRUCTION_STOPPING_LEVEL (default: 0.03) global_settings (required) component_settings_key (required)
[1] B. T. Cox et al. 2006, “Two-dimensional quantitative photoacoustic image reconstruction of absorption distributions in scattering media by use of a simple iterative method”, https://doi.org/10.1364/ao.45.001866
Initialises the ProcessingComponent object.
- Parameters:
component_settings_key – The key where the component settings are stored in
- convergence_stopping_criterion(errors: list, iteration: int) bool [source]
Serves as a stopping criterion for the iterative algorithm. If False the iterative algorithm continues.
- Parameters:
errors – List of log (base 10) sum of squared errors.
iteration – Iteration number.
- Returns:
if iteration method should be stopped.
- Raises:
AssertionError: if Tags.ITERATIVE_RECONSTRUCTION_STOPPING_LEVEL tag is zero
- extract_initial_data_from_hdf5() Tuple[ndarray, ndarray, ndarray] [source]
Extract necessary information - initial pressure and scattering coefficients - from settings dictionaries. The setting dictionaries is extracted from a hdf5 file.
- Returns:
Initial pressure and a priori known scattering coefficients.
- forward_model_fluence(absorption: ndarray, scattering: ndarray, anisotropy: ndarray, pa_device) ndarray [source]
Simulates photon propagation in 3-d volume and returns simulated fluence map in units of J/cm^2.
- Parameters:
absorption – Volume of absorption coefficients in 1/cm for Monte Carlo Simulation.
scattering – Volume of scattering coefficients in 1/cm for Monte Carlo Simulation.
anisotropy – Volume of anisotropy data for Monte Carlo Simulation.
pa_device – The simulation device.
- Returns:
Fluence map.
- Raises:
AssertionError: if Tags.OPTICAL_MODEL tag was not or incorrectly defined in settings.
- iterative_absorption_reconstruction(pa_device) Tuple[ndarray, list] [source]
Performs quantitative photoacoustic image reconstruction of absorption distribution by use of an iterative method. The distribution of scattering coefficients must be known a priori.
- Returns:
Reconstructed absorption coefficients in 1/cm.
- Raises:
TypeError: if input data are not passed as a certain type ValueError: if input data cannot be used for reconstruction due to shape or value FileNotFoundError: if paths stored in settings cannot be accessed AssertionError: is Tags.MAX_NUMBER_ITERATIVE_RECONSTRUCTION tag is zero
- log_sum_squared_error(image_data: ~numpy.ndarray, absorption: ~numpy.ndarray, fluence: ~numpy.ndarray, sigma: [<class 'numpy.ndarray'>, <class 'int'>, <class 'float'>]) float [source]
Computes log (base 10) of the sum of squared error between image and reconstructed pressure map in middle slice.
- Parameters:
image_data – Measured image data used for reconstruction.
absorption – Reconstructed map of absorption coefficients in 1/cm.
fluence – Simulated fluence map in J/cm^2.
sigma – Regularization parameter to avoid instability if the fluence is low.
- Returns:
sse error.
- preprocessing_for_iterative_qpai(intial_pressure: ndarray, scattering: ndarray, anisotropy: ndarray) Tuple[ndarray, ndarray, ndarray, bool] [source]
Preprocesses image data and scattering distribution for iterative algorithm using mcx. The preprocessing step includes: 1. Stacking the input data from 2-d to 3-d if necessary, since the mcx adapter can only perform
a Monte Carlo Simulation of fluence given 3-d volumes of absorption, scattering, and anisotropy
Resampling the input data to mitigate the inverse crime
- Parameters:
intial_pressure – Raw input image of initial pressure.
scattering – Map of scattering coefficients known a priori.
- Returns:
Resampled and (if necessary) stacked volume of noisy initial pressure, scattering and bool indicating if image had to be stacked to 3-d.
- regularization_sigma(input_image: ndarray, stacked_to_volume) [<class 'numpy.ndarray'>, <class 'int'>, <class 'float'>] [source]
Computes spatial (same shape as input image) or constant regularization parameter sigma.
- Parameters:
input_image – Noisy input image.
stacked_to_volume – If True input data was 2 dimensional and a constant sigma should be used.
- Returns:
Regularization parameter.
- Raises:
ValueError: if estimated noise is zero, so SNR cannot be computed.
- resampling_for_iterative_qpai(initial_pressure: ndarray, scattering: ndarray, anisotropy: ndarray) Tuple[ndarray, ndarray, ndarray] [source]
Downscales the input image and scattering map by a given scale (downscale factor) to avoid inverse crime.
- Parameters:
initial_pressure – Raw input image of initial pressure.
scattering – Map of scattering coefficients.
anisotropy – Map of anisotropies.
- Returns:
Downscaled image and scattering map.
- run(pa_device)[source]
Executes the respective simulation module
- Parameters:
digital_device_twin – The digital twin that can be used by the digital device_twin.
- stacking_to_3d(input_data: ndarray) ndarray [source]
Stacks the input map in sequence along axis=1 to build 3-d volume.
- Parameters:
input_data – 2-d image data.
- Returns:
Volume of stacked input image.
- standard_optical_properties(image_data: ndarray) dict [source]
Returns a optical properties dictionary containing scattering coefficients and anisotropy.
- Parameters:
image_data – Measured image data.
- Returns:
Optical properties (scattering and anisotropy).
- update_absorption_estimate(image_data: ~numpy.ndarray, fluence: ~numpy.ndarray, sigma: [<class 'numpy.ndarray'>, <class 'int'>, <class 'float'>]) ndarray [source]
Reconstructs map of absorption coefficients in 1/cm given measured data and simulated fluence.
- Parameters:
image_data – Measured image data (initial pressure) used for reconstruction.
fluence – Simulated fluence map in J/cm^2.
sigma – Regularization factor to avoid instability if the fluence is low.
- Returns:
Reconstructed absorption.