tomophantom.TomoP2D#

Modules for generating 2D synthetic phantoms and their analytical projection data. The dynamic phantoms (resulting in 3D arrays) can also be generated.

API Summary:

tomophantom.TomoP2D.Model(model_no: int, phantom_size: int, models_library_path: Path) <np.ndarray>[source]#

Generate 2D phantoms based on the model no. in the library file Library file for 2D phantoms.

Parameters:
  • model_no (int) – Model number from the Library file for 2D phantoms.

  • phantom_size (int) – A size of the generated phantom (squared).

  • models_library_path (Path) – A path to the library file.

Returns:

The generated 2D phantom (N x N).

Return type:

np.ndarray

tomophantom.TomoP2D.ModelSino(model_no: int, phantom_size: int, detector_size: int, angles: <np.ndarray>, models_library_path: ~pathlib._local.Path) <np.ndarray>[source]#

Generate 2D analytical sinogram for corresponding models in the Library file for 2D phantoms.

Parameters:
  • model_no (int) – Model number from the Library file for 2D phantoms.

  • phantom_size (int) – A size of the phantom (squared).

  • detector_size (int) – A size of the horizontal detector.

  • angles (np.ndarray) – Angles vector in degrees.

  • models_library_path (Path) – A path to the library file.

Returns:

The generated 2D analytical sinogram (angles_total x detector_size).

Return type:

np.ndarray

tomophantom.TomoP2D.ModelSinoTemporal(model_no: int, phantom_size: int, detector_size: int, angles: <np.ndarray>, models_library_path: ~pathlib._local.Path) <np.ndarray>[source]#

Generate 2D+time (temporal )analytical sinogram for corresponding models in the Library file for 2D phantoms.

Parameters:
  • model_no (int) – Temporal model number from the Library file for 2D phantoms.

  • phantom_size (int) – A size of the phantom (squared).

  • detector_size (int) – A size of the horizontal detector.

  • angles (np.ndarray) – Angles vector in degrees.

  • models_library_path (Path) – A path to the library file.

Returns:

The generated 2D+time analytical sinogram (time_frames x detector_size x angles_total).

Return type:

np.ndarray

tomophantom.TomoP2D.ModelTemporal(model_no: int, phantom_size: int, models_library_path: Path) <np.ndarray>[source]#

Generate 2D+time temporal phantoms based on the model no. in the Library file for 2D phantoms. Note that temporal phantom numbers begin at 100 onwards.

Parameters:
  • model_no (int) – Temporal model number from the Library file for 2D phantoms.

  • phantom_size (int) – A size of the generated phantom (squared).

  • models_library_path (Path) – A path to the library file.

Returns:

The generated 2D+time phantom (time_frames x N x N).

Return type:

np.ndarray

tomophantom.TomoP2D.Object(phantom_size: int, obj_params: list | dict) <np.ndarray>[source]#
Generates a 2D analytical phantom for the standalone

geometrical object that is parametrised in the “obj_params” dictionary, see Object API. Multiple objects can be stacked together by providing a list of dictionaries, where each dictionary associated with an object. See more in

Parameters:
  • phantom_size (int) – A size of the phantom (squared).

  • obj_params (a dict or a list of dict) – A dictionary or a list of dictionaries with the parameters for object(s), see Object API.

Returns:

The generated 2D analytical phantom.

Return type:

np.ndarray

tomophantom.TomoP2D.ObjectSino(phantom_size: int, detector_size: int, angles: <np.ndarray>, obj_params: list | dict) <np.ndarray>[source]#
Generate a 2D analytical sinogram for the standalone

geometrical object that is parametrised in the “obj_params” dictionary.

Parameters:
  • phantom_size (int) – A size of the phantom (squared).

  • detector_size (int) – A size of the horizontal detector.

  • angles (np.ndarray) – Angles vector in degrees.

  • obj_params (list of dicts or a dict) – A dictionary with parameters of an object, see Object API.

Returns:

The generated 2D analytical sinogram of an object.

Return type:

np.ndarray

tomophantom.TomoP2D.SinoNum(input: <np.ndarray>, detector_X: int, angles: <np.ndarray>) <np.ndarray>[source]#

Numerical calculation of 2D sinogram from the 2D input.

Parameters:
  • input (np.ndarray) – 2D object (e.g. a phantom).

  • detector_X (int) – The size of the detector X.

  • angles (np.ndarray) – Angles vector in degrees.

Raises:

ValueError – if input is 3D

Returns:

Numerical sinogram calculated from the object

Return type:

np.ndarray