xopto / pyxopto

PyXOpto is a collection of python tools for performing Monte Carlo simulations of light propagation in turbid media.
GNU General Public License v3.0
35 stars 9 forks source link

Making a look up table using pyxopto #29

Open Randall531 opened 1 month ago

Randall531 commented 1 month ago

I’m working on creating a Look-Up Table for a Monte Carlo simulation to model light propagation in tissue. This has been done before using MATLAB, now I’m looking to transition to Python and considering using the pyxopto library for the simulation. Has anyone tried doing something similar before? Appreciate any insights or advice to direct me to my goal.

xopto commented 1 month ago

The dataset submodule can be used to render example Python scripts for various configurations and then customize the code: https://xopto.github.io/pyxopto/docs/html/source/dataset/description.html Utilities for sampling of scattering phase function parameters in native or gamma-delta space are available in xopto.pf.util submodule. Utilities for random sampling of parameters and creating statistical models are available in xopto.util.sampler submodule.

The general idea is to create a single Mc instance and then update the instance/model parameters before each call to the run method. For a simple 2D lookup table of a semi-infinite sample this would require updating of the absorption and scattering coefficients:

g = 0.8
for mu in mua_values:
    for musr in musr_values:
        mc_instance.layers[1].mua = mu
        mc_instance.layers[1].mus = musr/(1.0 - g)
        results = mc.run(10e6)
        # extract and save the desired data such as reflectance, transmittance, fluence, trace - see the examples