Giter Site home page Giter Site logo

xopto / pyxopto Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 8.0 30.12 MB

PyXOpto is a collection of python tools for performing Monte Carlo simulations of light propagation in turbid media.

License: GNU General Public License v3.0

Python 83.63% C 15.83% C++ 0.14% Shell 0.18% Dockerfile 0.22%
light-propagation voxelized-model monte-carlo transmittance fluence sampling-volume opencl python layered-model relfectance

pyxopto's Introduction

PyXOpto

PyXOpto is a collection of Python tools for performing Monte Carlo simulations of light propagation in turbid media using massively parallel processing on a wide range of OpenCL-enabled devices. The tools allow steady-state and time-resolved simulations of light propagation, deposition and fluence simulations, tracing and filtering of photon packet paths, computation of sampling volumes for a number of source-detector configurations, support arbitrary scattering phase functions and are easy to customize or extend.

Deposit simulations
Energy deposit simulations for a voxelized volume with a laterally moving Gaussian beam.

Sampling volume trajectories
Transmittance trajectories of photon packets on the way from the source to the laterally displaced detector optical fiber.

Sampling volume in transmittance configuration - source-detector separation
Sampling volume in transmittance configuration as a function of the lateral displacement between the source and detector optical fiber.

Sampling volume in reflectance configuration - source-detector separation
Sampling volume in reflectance configuration as a function of the distance between the source and detector optical fiber.

Sampling volume in reflectance configuration - incidence angle
Sampling volume in reflectance configuration as a function of the incidence angle of the source optical fiber.

Deposition
A sequence of voxelized simulations of energy deposition in a 2-layer skin model with an embedded blood vessel.

Time-resolved deposition
Time-resolved energy deposition simulation for a voxelized medium with an absorbing cylindrical inclusion that has a lower refractive index than the surrounding medium.

Documentation

Full documentation of PyXOpto is available here.

Installation

Detailed instructions are available here.

Python

PyXOpto requires a Python 3 installation. Most of the Linux OS distributions will come with a preinstalled Python 3. On Windows OS, the easiest way to install the Python 3 programming language is to use the WinPython or Anaconda distributions. There are numerous integrated development environments that work with Python, among these Visual Studio Code and PyCharm are two popular cross-platform options. The WinPython distributions can be downloaded with an embedded and preconfigured Visual Studio Code (e.g. Winpython64-3.9.4.0cod.exe).

PyXOpto

First, download or clone the PyXOpto source repository to a local directory. The source code can be installed as a Python package or used independently from the downloaded source.

As a Python package

PyXOpto can be installed as a package using the setup.py file. Run the following command from the root directory of PyXOpto (the one with the setup.py file).

python setup.py install

This will also install the dependencies that include several popular Python packages (SciPy, Matplotlib, NumPy, PyOpenCL, Shapely, Numba, and Jinja2).

Using from source

To use the PyXOpto package from source, you will have to manually install all the Python dependencies listed in the setup.py file (SciPy, Matplotlib, NumPy, PyOpenCL, Shapely, Numba, and Jinja2, ...). The easiest way to install the dependencies is to use the Python package installer pip. Note that the WinPython distribution will likely come with many if not all the dependencies already installed. Also note that on some Linux distributions, the Python 3 executable is named python3 and python is used for the deprecated Python 2. You will also have to manually include the root directory of the PyXOpto package into the Python search path. This can be conveniently accomplished through setting the PYTHONPATH environment variable. On Linux operating system use:

export PTYTHONPATH=path/to/pyxopto:$PYTHONPATH

On Windows operating systems use:

set PTYTHONPATH=path\to\pyxopto;%PYTHONPATH%

After installing the dependencies and setting the environment variable PYTHONPATH, you should be able to import PyXOpto.

Docker image

Docker images for NVIDIA CUDA 11 and Intel OpenCL with preinstalled PyXOpto and Jupyter Notebook environment are available from public repositories on the Docker Hub:

All the images include many of the popular Python libraries for scientific computing, data management and visualization (SciPy, NumPy, Matplotlib, Pandas, etc.).

Summary of the latest PyXOpto Docker images.

Image Tag PyXOpto OS CUDA CUDNN
xopto/pyxopto-intel-jupyter v0.2.2 0.2.2 Ubuntu 20.04 - -
xopto/pyxopto-nvidia-jupyter v0.2.2 0.2.2 Ubuntu 20.04 11.03 8
xopto/pyxopto-nvidia-jupyter-dl v0.2.2 0.2.2 Ubuntu 20.04 11.03 8

The xopto/pyxopto-nvidia-jupyter, and xopto/pyxopto-nvidia-jupyter-dl Docker images can be run by executing the following command:

sudo docker run --rm --runtime nvidia -p 8888:8888 -it xopto/pyxopto-nvidia-jupyter:v0.2.2

or

sudo docker run --rm --runtime nvidia -p 8888:8888 -it xopto/pyxopto-nvidia-jupyter-dl:v0.2.2

The Intel OpenCL images xopto/pyxopto-intel-jupyter can be run as:

sudo docker run --rm --device /dev/dri:/dev/dri -u 0 -p 8888:8888 -it xopto/pyxopto-intel-jupyter:v0.2.2

This will produce output in the terminal that should be similar to:

[I 2021-11-18 22:53:55.782 LabApp] JupyterLab extension loaded from /usr/local/lib/python3.8/dist-packages/jupyterlab
[I 2021-11-18 22:53:55.782 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 22:53:55.788 NotebookApp] Serving notebooks from local directory: /home/jovyan
[I 22:53:55.788 NotebookApp] Jupyter Notebook 6.4.6 is running at:
[I 22:53:55.788 NotebookApp] http://5a29ef955782:8888/?token=7e1168ae3711761bad536257a28745a02020c1fc9db6fe7a
[I 22:53:55.788 NotebookApp] or http://127.0.0.1:8888/?token=7e1168ae3711761bad536257a28745a02020c1fc9db6fe7a
[I 22:53:55.788 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

The Jupyter Notebook can be accessed in the host browser through the displayed link, which is in this example http://127.0.0.1:8888/?token=7e1168ae3711761bad536257a28745a02020c1fc9db6fe7a.

Persisting data

PyXopto and user data can be persisted by mounting a Docker Volume or a local directory to /home/jovyan/work. In the following example the /home/someuser/data directory of the host machine will be used to persist the container data. All the Python scripts, Jupyter Notebooks and other user files inside the container should be placed into the /home/jovyan/work directory.

sudo docker run --rm --runtime nvidia -p 8888:8888  -v /home/someuser/data:/home/jovyan/work -it xopto/pyxopto-nvidia-jupyter:v0.2.2

Building the Docker images from source

The PyXOpto Docker images can be build from source by running the docker/build_intel_jupyter.sh, docker/build_nvidia_jupyter.sh or docker/build_nvidia_jupyter-dl.sh scripts. This step might require super user rights.

sudo bash ./build_intel_jupyter.sh
sudo bash ./build_nvidia_jupyter.sh
sudo bash ./build_nvidia_jupyter-dl.sh

Note that the build scripts must be run from the docker directory of the PyXOpto source tree. The built images will be tagged with the version of the PyXOpto source distribution.

Basic Monte Carlo simulations of a layered medium

This basic example is available in the examples/mcml/basic_example.py file.

The functionality of layered Monte Carlo (MC) is accessible through the xopto.mcml.mc module. First, create an empty file, e.g. basic_example.py and import the xopto.mcml.mc module.

from xopto.mcml import mc

The layer stack

The layers of the medium can be defined through the mclayer submodule. The layers are stacked along the positive direction of the z coordinate axis.

The topmost and bottommost layers of the stack are used to describe the medium that surrounds the sample at the top and at the bottom surfaces, respectively. Therefore, at least three layers must be always defined, namely the two layers of the surrounding medium and one sample layer!

The bottom surface of the topmost layer (the surrounding medium) is located at coordinate z=0. The positive direction of the z axis points in the direction of the sample layer stack.

The thicknesses of the topmost and bottommost layers will be automatically set to infinity regardless of the specified layer thickness.

Note that all the layers in the stack must use the same scattering phase function model. A variety of scattering phase function models is available through the mcpf submodule.

An example of a basic turbid sample of thickness d=10.0 mm, with an absorption coefficient mua=1.0 1/cm, scattering coefficient mus=50.0 1/cm, a Henyey-Greenstein scattering phase function (mc.mcph.Hg) with an anisotropy g=0.8 and refractive index 1.33 is as follows.

layers = mc.mclayer.Layers(
    [
        mc.mclayer.Layer(n=1.00, d=np.inf,  mua=1.0e2, mus=50.0e2, pf=mc.mcpf.Hg(0.0)),
        mc.mclayer.Layer(n=1.33, d=10.0e-3, mua=1.0e2, mus=50.0e2, pf=mc.mcpf.Hg(0.8)),
        mc.mclayer.Layer(n=1.00, d=np.inf,  mua=1.0e2, mus=50.0e2, pf=mc.mcpf.Hg(0.0))
    ]
)

Note that the absorption coefficient mua, scattering coefficient mus and the scattering phase function pf of the topmost and bottommost layers are not used in the MC simulations, since the photon packets are not propagated through the surrounding medium. However, the refractive index n of the two outermost layers is used to properly refract/reflect the photon packet at the layer boundaries when launched by the source or when escaping the sample. The value of the layer thickness d should be given in m and the values of the scattering mus and absorption mua coefficient in 1/m.

The photon packet source

Different sources of photon packets are available through the mcsource submodule. The following example creates a basic line source (infinitely thin) at the top sample surface (x, y, z)=(0, 0, 0) with a perpendicular incidence (0, 0, 1).

source = mc.mcsource.Line()

The detectors

The photon packets can be collected by a surface detector after exiting the top or bottom sample surface. Different types of surface detectors are available through the mcdetector submodule. Note that the top and bottom sample surface can use different configurations and/or types of detectors.

detectors = mc.mcdetector.Detectors(
    top = mc.mcdetector.Radial(
        mc.mcdetector.Axis(0.0, 10.0e-3, 1000, cosmin=np.deg2rad(20))
    ),
    bottom = mc.mcdetector.Radial(
        mc.mcdetector.Axis(0.0, 10.0e-3, 100)
    )
)

In the above example, we create two radial detectors one at the top and one at the bottom sample surface. The spacing between the concentric accumulators of the radial detector at the top sample surface is set to 10 μm, while the spacing of the concentric accumulators at the bottom sample surface is set to 100 μm. Both detectors are accumulating photon packets from 0.0 mm to 10.0 mm. The detector at the top sample surface only collects photon packets that exit the sample within 20° of the surface normal, while the detector at the bottom sample surface collects all the photon packets that exit the sample.

The OpenCL device

The OpenCL device that will run the MC simulations can be selected through the xopto.cl.clinfo module. In the following example we pick the first available GPU device.

gpu = clinfo.gpu()

The Monte Carlo simulator

Next, we create a Monte Carlo simulator instance from the defined layers, photon packet source and detectors.

mc_obj = mc.Mc(layers, source, detectors, cl_devices=gpu)

Optionally, we can limit the maximum simulation radius that is measured from the position of the photon packet source. In this example, we limit the simulation radius to 25 mm.

mc_obj.rmax = 25.0e-3

Finally, we can run the simulator instance with a given number of photon packets (10,000,000 in this example) and collect the results. The simulator returns three objects/results, namely the trace, fluence and detectors. Since in this basic example we only use the surface detectors, the remaining two results (fluence and trace) will be set to None.

trace_res, fluence_res, detectors_res = mc_obj.run(10e6)

Note that the photon packets that exit the sample within the acceptance cone but at a distance/radius that exceeds the maximum radius of the detector will be accumulated in the last concentric ring.

Visualizing the results

We can plot the simulation results using the mtplotlib.pyplot module. For a better visualization of the reflectance/transmittance a logarithmic scale is used in the y axis of the plots.

fig, (ax1, ax2) = pp.subplots(2, 1)

ax1.semilogy(detectors_res.top.r*1e3, detectors_res.top.reflectance)
ax1.set_xlabel('Distance from source (mm)')
ax1.set_ylabel('Reflectance')

ax2.semilogy(detectors_res.bottom.r*1e3, detectors_res.bottom.reflectance)
ax2.set_xlabel('Distance from source (mm)')
ax2.set_ylabel('Reflectance')

pp.show()

Reflectance and transmittance collected by the surface detectors.

The complete example

basic.py

You can run this example from the root directory of the PyXopto package as:

python examples/mcml/basic.py

MC Dataset

Precomputed datasets of reflectance, transmittance, energy deposition and sampling volume for a number of different source, detector and sample configurations are available through a separate repository MC Dataset.

Citing PyXOpto

We, the authors of PyXOpto, expect that the package is used in accordance with the GPL3+ license and that any work using the PyXOpto package also cites the project and at least one of the following references:

  • M. Bürmen, F. Pernuš, and P. Naglič, MCDataset: a public reference dataset of Monte Carlo simulated quantities for multilayered and voxelated tissues computed by massively parallel PyXOpto Python package, J. Biomed. Opt., 27 (8), 083012 (2022), https://doi.org/10.1117/1.JBO.27.8.083012.

  • P. Naglič, F. Pernuš, B. Likar, and M. Bürmen, Limitations of the commonly used simplified laterally uniform optical fiber probe-tissue interface in Monte Carlo simulations of diffuse reflectance, Biomed. Opt. Expres, 6 (10), 3973-3988 (2015), https://doi.org/10.1364/BOE.6.003973.

  • P. Naglič, F. Pernuš, B. Likar, and M. Bürmen, Lookup table-based sampling of the phase function for Monte Carlo simulations of light propagation in turbid media, Biomed. Opt. Expres, 8 (3), 1895-1910 (2017), https://doi.org/10.1364/BOE.8.001895.

For alternative licensing options of PyXOpto please contact us at [email protected].

pyxopto's People

Contributors

xopto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyxopto's Issues

Fixing the seed of random number generator in MC simulation

Hi,

I am running a MC simulation to estimate the reflectance and transmittance from a 3D slab with low number of photons (100K). I would like to know how I can fix the seed value of the random number generator in MC object to simulate exactly the same reflectance and transmittance whenever I perform the MC simulation.

Thanks.

Multiple Light Source Implementation into MC Object

Hi,

I would like to perform a Monte Carlo simulation with multiple light sources at the same time. My goal is to simulate the impact of ambient lighting on the optical signal. In literature, the ambient light is usually modeled as a percentage of specular reflectance added to the diffuse reflectance. However, I would like to have a more effective and objective way of simulating ambient light in the Monte Carlo simulation. Could you please give me some ideas and hints on how I can add multiple light sources to my MC object?

Thanks.

Material Folder is not copied.

Hi,
I installed pyxopto on macOS apple silicon.
I tried to run the basic scripts but it gave error showing that it could not find materials folder in the path.
I then manually copied the materials folder to the installed directory and it works fine.

Issue regarding Opencl and Overflow

Hello, recently I modeled a 7 layer human skin Monte Carlo simulation. But, after running this first time, it ran perfectly with photons 10e4. But after some time, I am facing several issues. Sometimes, this "---------------------------------------------------------------------------
LogicError Traceback (most recent call last)
Cell In[19], line 39
35 mc_obj.layers[7].mus = mus7(w)
38 # detector = mc_obj.run(nphotons, verbose=True)[-1]
---> 39 trace, fluence_res, detector = mc_obj.run(100e3)
40 reflectance_spectrum[i] = detector.top.reflectance[0] * np.pi * sp_r**2
42 wav[i] = w

File c:\Users\user\anaconda3\envs\mcs2\Lib\site-packages\pyxopto-0.2.2-py3.11.egg\xopto\mcml\mc.py:953, in Mc.run(self, nphotons, out, wgsize, maxthreads, copyseeds, exportsrc, verbose)
919 t1 = time.perf_counter()
921 # call the kernel
922 self._cl_exec.McKernel(
923 cl_queue, globalWG, localWG,
924
925 np.dtype(self._types.np_cnt).type(nphotons),
926 cl_buffers['num_processed_packets'],
927
928 cl_buffers['num_kernels'],
929
930 np.dtype(self._types.np_float).type(self._rmax),
931
932 cl_buffers['rng_seeds_x'],
933 cl_buffers['rng_seeds_a'],
934
935 np.uint32(len(self._layers)),
936 cl_buffers['layers'],
937
938 cl_buffers['source'],
939
940 cl_buffers['surface_layouts'],
941
942 cl_buffers['trace'],
943
944 cl_buffers['fluence'],
945
946 cl_buffers['detectors'],
947
948 self.cl_r_float_lut(False),
949
950 self.cl_rw_int_buffer(),
951 self.cl_rw_float_buffer(),
952 self.cl_rw_accumulator_buffer(),
--> 953 ).wait()
955 t2 = time.perf_counter()
957 # get the number of concurrent kernels that were used to process the job

LogicError: clWaitForEvents failed:" also sometimes this "OverflowError: Python int too large to convert to C long". I think it's handling floating point values and that's why it's happening. After I reduced the photon packets to 10e3, the code is running successfully. But when I increase the number of photon packets, these type of issues are occurring.

I think the solution is here: https://xopto.github.io/pyxopto/docs/html/source/mcml/simulator_data_types.html
But, unfortunately I am not getting it. Could you please give me an example about it's implementation? Thanks!

Clarifying visualization, and some other things

Hello, I am also facing some problems.
These are my configurations:
detectors = mc.mcdetector.Detectors(
top = mc.mcdetector.Radial(
mc.mcdetector.Axis(0.0, 10.0e-3, 1000),
cosmin=np.cos(np.deg2rad(20.0))
))

fluence = mc.mcfluence.Fluence(
xaxis=mc.mcfluence.Axis(-5.0e-3, 5.0e-3, 100),
yaxis=mc.mcfluence.Axis(-5.0e-3, 5.0e-3, 100),
zaxis=mc.mcfluence.Axis(0.0, 10.0e-3, 100))

trace = mc.mctrace.Trace(
maxlen=1000, options=mc.mctrace.Trace.TRACE_ALL,
filter=mc.mctrace.Filter(
z=(-1e-9, 1e-9),
pz=(-1, -np.cos(np.arcsin(0.22/1.45))),
r=(0, 100e-6, (220e-6, 0))
)
)

I am having some troubles as am really new with PyXopto. Thanks!

MCVOX light sources and mcgeometry

Hi,

I am performing MC simulations with the mcvox module. Unfortunately, there is no LambertianRectangular light source defined for the mcvox module. Could you please let me know how I can extend the mcml LambertianRectangular for the mcvox module? I would like to be able to place it inside my voxelied geometry without initialization at z=0 point. This is because I am using IsotropicVoxel light source at z points close to 0 (but >0) and the photons are just reflecting from the boundaries and exiting the geometry at z=0. So I dont have any effective photon propagation in my simulation.

Additionally, it seems that there are some bugs related to the mcgeometry-voxel class. Apparently, fetch_cl_options(mc) does not take "mc" as an argument. I replaced "mc" with "self" and it resolved the issue.
PyXopto-MCGeometry

How to set multiple detectors or visualize the internal voxel boundaries

Currently the detectors are available at top and bottom but I don't see an example to specify the z axis location of the detectors. For an example, if I added an air layer above the skin, then the detector.top will give the reflectance in the air, if I still want to place it on the skin, what shall I do? Or is there a way to convert the fluence at the surface layer directly to the reflections? Thank you.

Issues with Rectangular Light Source (mcml.mcsource.*Rectangular)

Hi,

I am trying to perform a simple Monte Carlo simulation with rectangular light source and detector. I built the MC object as follows:
`from xopto.mcml import mc
from xopto.cl import clinfo

cl_device = clinfo.gpu()
layers = mc.mclayer.Layers([mc.mclayer.Layer(d=0.0, n=1.0, mua=0.0, mus=0.0, pf=mc.mcpf.Hg(1)), # Surrounding medium
mc.mclayer.Layer(d=2.0e-3, n=1.34, mua=0.2e+3, mus=(3/(1-0.9))*1e+3, pf=mc.mcpf.Hg(0.9)), # tissue
mc.mclayer.Layer(d=0.0, n=1.0, mua=0.0, mus=0.0, pf=mc.mcpf.Hg(1))]) # Surrounding medium
filter = mc.mctrace.Trace(maxlen=250, options=mc.mctrace.Trace.TRACE_ALL, plon=True)
fluence = mc.mcfluence.Fluence(xaxis=mc.mcfluence.Axis(-5e-3, 5e-3, 500),
yaxis=mc.mcfluence.Axis(-5e-3, 5e-3, 500),
zaxis=mc.mcfluence.Axis(0, 2e-3, int(2.0e-3/2e-5)))
detector = mc.mcdetector.Detectors(top=mc.mcdetector.Cartesian(xaxis=mc.mcdetector.Axis(-4.5e-3, -4e-3, 1),
yaxis=mc.mcdetector.Axis(-3.5e-3, -3e-3, 1),
direction=(0.0, 0.0, 1.0)))
light_source = mc.mcsource.LambertianRectangular(position=(-0.5e-3,-0.2e-3, 0), width=0.3e-3, height=0.3e-3, n=1.5, na=0.9)
mc_obj = mc.Mc(layers=layers, trace=filter, fluence=fluence, source=light_source, detectors=detector, cl_devices=cl_device)

output = mc_obj.run(nphotons=100000, verbose=True)`

When I try to run the simulation, I receive the following error:
Pyxopto-RectangularLight-Error

I traced the error and realized there was a typo! Instead of "Structure", "Stucture" was used. I fixed the typo in the code and tried to re-perform the simulation. I received another error as follows:
Pyxopto-RectangularLight-Error2

When I traced the source of error again, I came to this part of the LambertianRectangular class definition code:
`class LambertianRectangular(UniformRectangular):
@staticmethod
def cl_type(mc: mcobject.McObject) -> cltypes.Structure:
T = mc.types
class ClLambertianRectangular(cltypes.Structure):
'''
Structure that is passed to the Monte carlo simulator kernel.

        Fields
        ------
        position: mc_point3f_t
            Source position (center of the source),
        size: mc_point2f_t
            Source size along the x and y axis.
        n: mc_fp_t
            Refractive index of the source.
        cos_critical: mc_fp_t
            Cosine of the total internal reflection angle for the
            source -> sample boundary transition.
        na: mc_fp_t
            Numerical aperture of the source in air. 
        layer_index: mc_int_t
            Layer index in which the source is located.
        '''
        _fields_ = [
            ('position', T.mc_point3f_t),
            ('size', T.mc_point2f_t),
            ('n', T.mc_float),
            ('cos_critical', T.mc_float),
            ('na', T.mc_fp_t),
            ('layer_index', T.mc_int),
        ]
    return  ClLambertianRectangular

@staticmethod
def cl_declaration(mc: mcobject.McObject) -> str:
    '''
    Structure that defines the source in the Monte Carlo simulator.
    '''
    return '\n'.join((
        'struct MC_STRUCT_ATTRIBUTES McSource{',
        '	mc_point3f_t position;',
        '	mc_point2f_t size;',
        '	mc_fp_t n;',
        '	mc_fp_t cos_critical;',
        '	mc_fp_t na;',
        '	mc_int_t layer_index;',
        '};'
    ))`

When I compared it with the Fiber class code, I realized in the cl_type function, the input types are different. The same can be observed if you compare the input types declared in the cl_type function with those in the cl_declaration function -> "join" segment. So I tried to adjust the input types of cl_type function according to those specified in the cl_declaration function. I performed the simulation and received the following error.
Pyxopto-RectangularLight-Error3

I would say similar thing must happen for other classes of rectangular sources; however, I didn't check all of them except the UniformRectangular class. I would appreciate it if you could please let me know how I can fix this issue.

Obtaining pathlengths from RadialPl

Hello, referring to the previous solution that you gave, I am going to use RadialPl for obtaining pathlength. But, could you please add some details about that? I found nothing there specifically in the documentation. I think, some calculations need to be done for obtaining that. Please answer these:

  1. Please give me a sample code for RadialPl having position at (0, 0).
  2. After that also the code for obtaining the pathlengths.
  3. I am currently thinking, pathlengths should be in this, "detector.top.normalized". Is that so? If not, then please tell me the process.

Thanks!

3D mesh import capabilities for generating voxelized geometry

Hi,

I would like to ask you whether there is a possibility to import a 3d geometry or any point-cloud file for creating a voxelized mesh for optical simulation. Although in all the mcvox examples, the voxelized geometry was specified in the script, I believe it must be feasible to import a 3D file and specify it as the voxelized geometry. I just wanted to ask you for a clear example of how to import such 3D model and assign its material properties accordingly.

Thank you very much.

Incresing photon packets does not work when using the fiber source

When I use a fiber source in the simulator, it can not get more accurate results with Incresing the photon packets.The same problem also occurr in the example examples/mcml/reflectance_optical_probes.py.
I'm not sure whether there are some bugs I don't know and any help would be appreciated.

weights not adding to 1 for MieMixture

Hi,

I am currently running a simulation using MieMixture for my phase function. I created weights that should in theory add to one, but due to machine precision, they don't always do. My current fix to the issue is to add an np.round around the weight sum to trick it into accepting that the weights are off by a machine epsilon.

Best,
Daniel

How to simulate the larger size tissues?

Hopefully this is not a stupid question: I tried to multiply the blood diameter sizes of the skin-blood model by 10 times and adjusted the depth of it correspondingly. I set the nphoton to the maximum allowed value but still get zero fluence/deposited energy at the center of blood vessel. Any good recommendations for the larger model simulations? Your help would be greatly appreciated!

Mutiple voxels as illumination sources

Dear pyxopto Team,
I am tying to model fluorescence of voltage sensitive dyes in cardiac tissue as wave of excitation propagates. So, I need to define multiple voxels as illumination sources. I read that it is possible to define singe voxel as source https://xopto.github.io/pyxopto/docs/html/apidoc/xopto.mcvox.mcsource.voxel.html. I've done good bit of digging docs and code examples without any luck.
Is it possible to define multiple voxels as source?

Best,
Kestutis

How to add multiple light sources?

Do you support multiple light sources for the Voxelized Monte Carlo simulations?
I have tried source = {mc.mcsource.IsotropicPoint((-0.2e-3,0.0, 0.0)),mc.mcsource.IsotropicPoint((0.2e-3,0.0, 0.0))}
but it gives error when deploying deposit = mc_obj.run(nphotons, verbose=True)[1].
Any good suggestions to perform multiple light sources? Thank you!

absorption spectrum axis label units may be incorrect

Using Interpolator.plot to plot an absorption spectrum seems to be putting incorrect units on the $y$-axis.

See the figure under section 2.2 here:
https://omlc.org/news/jan98/skinoptics.html

And compare to the plot generated by this code:

from xopto.materials.absorption import oxyhem, deoxyhem
import numpy as np

wls = np.arange(350,1200,1) * 1e-9

mua_oxy = oxyhem.OxyHem()
mua_deoxy = deoxyhem.DeOxyHem()

mua_oxy.plot(wls,show=False)
mua_deoxy.plot(wls,show=False)
plt.gca().get_lines()[0].set_color('red')
plt.gca().get_lines()[1].set_color('blue')
plt.legend(['HbO2', 'HbO'])
plt.show()

image

They would agree if the $y$-axis units were $\text{m}^{-1}$ rather than $\text{cm}^{-1}$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.