xopto.dataset.render.mcml_comparison module

CONFIG = {'double_precision': False, 'fluence_k': 8388607, 'num_packets': 100000000.0, 'rmax': 1.0, 'sample': {'1-layer-100mm': {'dir': '1-layer-100mm', 'g': (0.1, 0.5, 0.9), 'layers': [{'d': 'np.inf', 'n': 1.0, 'mua': 0.0, 'mus': 0.0, 'g': 0.0}, {'d': 0.1, 'n': 1.337, 'mua': 0.0, 'mus': 0.0, 'g': 0.0}, {'d': 'np.inf', 'n': 1.0, 'mua': 0.0, 'mus': 0.0, 'g': 0.0}], 'mua': 'np.linspace(0.0, 5.0e2, 3)', 'musr': 'np.linspace(5.0e2, 35.0e2, 3)'}, '1-layer-1mm': {'dir': '1-layer-1mm', 'g': (0.1, 0.5, 0.9), 'layers': [{'d': 'np.inf', 'n': 1.0, 'mua': 0.0, 'mus': 0.0, 'g': 0.0}, {'d': 0.001, 'n': 1.337, 'mua': 0.0, 'mus': 0.0, 'g': 0.0}, {'d': 'np.inf', 'n': 1.0, 'mua': 0.0, 'mus': 0.0, 'g': 0.0}], 'mua': 'np.linspace(0.0, 5.0e2, 3)', 'musr': 'np.linspace(5.0e2, 35.0e2, 3)'}, '2-layer-100um-1mm': {'dir': '2-layer-100um-1mm', 'g': (0.1, 0.5, 0.9), 'layers': [{'d': 'np.inf', 'n': 1.0, 'mua': 0.0, 'mus': 0.0, 'g': 0.0}, {'d': 0.0001, 'n': 1.462, 'mua': 0.0, 'mus': 0.0, 'g': 0.0}, {'d': 0.001, 'n': 1.337, 'mua': 50.0, 'mus': 10000.000000000002, 'g': 0.8}, {'d': 'np.inf', 'n': 1.0, 'mua': 0.0, 'mus': 0.0, 'g': 0.0}], 'mua': 'np.linspace(0.0, 5.0e2, 3)', 'musr': 'np.linspace(5.0e2, 35.0e2, 3)'}}}

MCML comparison dataset configuration.

FILENAME_FORMAT(mua, musr)
PF_DIR_FORMAT(g)
load(sample: str, g: float, mua: float, musr: float, mcvox: bool = False, dataset_dir: Optional[str] = None)dict[source]

Load data for the given sample configuration and layer parameters.

Parameters
  • sample (str) – One of the sample configurations defined in CONFIG.

  • g (float) – Scattering phase function anisotropy.

  • mua (float) – Absorption coefficient (1/m).

  • musr (float) – Reduced scattering coefficient (1/m).

  • mcvox (bool) – Indicates if the dataset produced by the voxelized MC should be loaded.

  • dataset_dir (str) – Root dataset directory (one that contains “data” directory). If None or empty, the current working directory is used as the dataset directory.

Returns

data – Sample data.

Return type

dict

path(sample: str, g: float, mua: float, musr: float, mcvox: bool = False)str[source]

Returns path to a dataset file relative to the root directory of the dataset.

Parameters
  • sample (str) – One of the sample configurations defined in CONFIG.

  • g (float) – Scattering phase function anisotropy.

  • mua (float) – Absorption coefficient (1/m).

  • musr (float) – Reduced scattering coefficient (1/m).

  • mcvox (bool) – Indicates if the dataset produced by the voxelized MC should be loaded.

Returns

pats – Path to the dataset file relative to the toot directory of the dataset.

Return type

str

render_mcml_comparison(target_dir: Optional[str] = None, config: Optional[dict] = None, method: Optional[str] = None, cache: bool = False, cl_device: Optional[str] = None, cl_index: int = 0, cl_build_options: Optional[List[str]] = None, test: bool = False, verbose: bool = False)[source]

Render templates with the given configuration.

Parameters
  • target_dir (str) – Root directory for the dataset. The scripts will be rendered into “run” subdirectory and the dataset data will be saved into the data subdirectory. If None, the parent directory of this file will serve as the root directory.

  • config (dict) – Configuration / context to use when rendering the run scripts. If None, the default configuration will be used.

  • method (str) – Monte Carlo stepping method. One of “ar” “aw” or “mbl”.

  • cache (bool) – Enables fluence accumulator cache.

  • cl_device (str) – Default OpenCL device name or None. The value can be also set through the CL_DEVICE environment variable.

  • cl_index (int) – OpenCL device index (if multiple OpenCL devices of the same kind are installed). The value can be also set through the CL_INDEX environment variable.

  • cl_build_options (List[str]) – A list of OpenCL build options. See ClBuildOption for more details.

  • test (bool) – Do a test run. The run scripts will be rendered but not saved. This option will automatically enable the verbose mode.

  • verbose (bool) – Enables verbose reporting.

visualize(sample: str, g: float, mua: float, musr: float, mcvox: bool = False, dataset_dir: Optional[str] = None)dict[source]

Load data for the given sample configuration and layer parameters and plot the results.

Parameters
  • sample (str) – One of the sample configurations defined in SAMPLE_CONTEXT.

  • g (float) – Scattering phase function anisotropy.

  • mua (float) – Absorption coefficient (1/m).

  • musr (float) – Reduced scattering coefficient (1/m).

  • mcvox (bool) – Indicates if the dataset produced by the voxelized MC should be loaded.

  • dataset_dir (str) – Root dataset directory (one that contains “data” directory). The current working directory is used if None.

Returns

data – Sample data.

Return type

dict