Python bindings for Monte Carlo eXtreme (OpenCL) photon transport simulator
Project description
PMCX-CL - Python bindings for Monte Carlo eXtreme (OpenCL) photon transport simulator
- Copyright: (C) Matin Raayai Ardakani (2022-2023) <raayaiardakani.m at northeastern.edu> and Qianqian Fang (2019-2024) <q.fang at neu.edu>
- License: GNU Public License V3 or later
- Version: 0.1.6
- URL: https://pypi.org/project/pmcxcl/
- Github: https://github.com/fangq/mcxcl
This module provides a Python binding for Monte Carlo eXtreme for OpenCL (MCXCL). For other binaries, including the standalone executable and the MATLAB bindings, see our website.
Monte Carlo eXtreme (MCX) is a fast photon transport simulation software for 3D heterogeneous turbid media. By taking advantage of the massively parallel threads and extremely low memory latency in a modern graphics processing unit (GPU), MCX is capable of performing Monte Carlo (MC) photon simulations at a blazing speed, typically hundreds to a thousand times faster than a single-threaded CPU-based MC implementation.
How to Install
- PIP:
pip install pmcxcl
, see https://pypi.org/project/pmcxcl/
Runtime Dependencies
- CPU or GPU: An OpenCL-capable CPU or GPU; most modern CPUs or GPUs support OpenCL - an industrial-standard heterogeneous computing library and specification (https://www.khronos.org/opencl/)
- OpenCL CPU or GPU runtime/driver: Both NVIDIA and AMD GPU graphics drivers should contain
out-of-box OpenCL runtimes or drivers; for Intel GPUs, one should install additional OpenCL runtime
support from https://github.com/intel/compute-runtime or install the
intel-opencl-icd
package if the OS provides (such as Ubuntu 22.04); one can also install an open-source OpenCL runtime POCL, using package manager such assudo apt-get install pocl-opencl-icd
. However, POCL's support is largely limited to CPUs. You do not need to install CUDA SDK to use pmcxcl. - Python: Python 3.6 and newer is required. Python 2 is not supported.
- numpy: Used to pass/receive volumetric information to/from pmcxcl. To install, use either conda or pip
package managers:
pip install numpy
orconda install numpy
- (optional) jdata: Only needed to read/write JNIfTI output files. To install, use pip:
pip install jdata
on all operating systems; For Debian-based Linux distributions, you can also install to the system interpreter using apt-get:sudo apt-get install python3-jdata
. See https://pypi.org/project/jdata/ for more details. - (optional) bjdata: Only needed to read/write BJData/UBJSON files. To install, run
pip install bjdata
on all operating systems; For Debian-based Linux distributions, you can also install to the system interpreter using apt-get:sudo apt-get install python3-bjdata
. See https://pypi.org/project/bjdata/ for more details. - (optional) matplotlib: For plotting the results. To install, run either
pip install matplotlib
orconda install matplotlib
Build Instructions
Build Dependencies
-
Operating System: pmcxcl and mcxcl can be compiled on most OSes, including Windows, Linux and MacOS.
-
OpenCL library: compiling mcxcl or pmcxcl requires to link with
libOpenCL.so
on Linux, orlibOpenCL.dylib
on MacOS orOpenCL.dll
on Windows. These libraries should have been installed by either graphics driver or OpenCL runtimes. -
Python Interpreter: Python 3.6 or above. The
pip
Python package manager and thewheel
package (available viapip
) are not required but recommended. -
C/C++ Compiler: pmcxcl can be compiled using a wide variety of C compilers, including
- GNU GCC for Linux, MacOS (intalled via MacPorts or brew), and Windows (installed via msys2, mingw64 or cygwin64)
- Microsoft Visual Studio C/C++ Compiler for Windows.
- Apple Clang for macOS, available via Xcode.
Refer to each OS's online documentations for more in-depth information on how to install these compilers. MacOS provides built-in OpenCL library support.
-
OpenMP: The installed C/C++ Compiler should have support for OpenMP. GCC and Microsoft Visual Studio compiler support OpenMP out of the box. Apple Clang, however, requires manual installation of OpenMP libraries for Apple Clang. The easiest way to do this is via the Brew package manager, preferably after selecting the correct Xcode version:
brew install libomp brew link --force libomp
-
CMake: CMake version 3.15 and later is required. Refer to the CMake website for more information on how to download. CMake is also widely available on package managers across all operating systems.
Build Steps
-
Ensure that
cmake
,python
and the C/C++ compiler are all located over yourPATH
. This can be queried viaecho $env:PATH
on Windows orecho $PATH
on Linux. If not, locate them and add their folder to thePATH
. -
Clone the repository and switch to the
pmcxcl/
folder:git clone --recursive https://github.com/fangq/mcx.git cd mcx/pmcxcl
-
One can run
python3 setup.py install
orpython3 -m pip install .
to both locally build and install the module -
If one only wants to locally build the module, one should run
python3 -m pip wheel .
-
If the binary module is successfully built locally, you should see a binary wheel file
pmcxcl-X.X.X-cpXX-cpXX-*.whl
stored inside themcxcl/pmcxcl
folder. You can install this wheel package usingpython3 -m pip install --force-reinstall pmcxcl-*.whl
to force installing this locally compiledpmcxcl
module and overwrite any previously installed versions.
How to use
The PMCXCL module is easy to use. You can use the pmcxcl.gpuinfo()
function to first verify
if you have NVIDIA/CUDA compatible GPUs installed; if there are NVIDIA GPUs detected,
you can then call the run()
function to launch a photon simulation.
A simulation can be defined conveniently in two approaches - a one-liner and a two-liner:
- For the one-liner, one simply pass on each MCX simulation setting as positional argument. The supported setting names are compatible to nearly all the input fields for the MATLAB version of MCX/MCXCL - MCXLAB)
import pmcxcl
import numpy as np
import matplotlib.pyplot as plt
res = pmcxcl.run(nphoton=1000000, vol=np.ones([60, 60, 60], dtype='uint8'), tstart=0, tend=5e-9,
tstep=5e-9, srcpos=[30,30,0], srcdir=[0,0,1], prop=np.array([[0, 0, 1, 1], [0.005, 1, 0.01, 1.37]]))
res['flux'].shape
plt.imshow(np.log10(res['flux'][30,:, :]))
plt.show()
- Alternatively, one can also define a Python dict object containing each setting
as a key, and pass on the dict object to
pmcxcl.run()
import pmcxcl
import numpy as np
cfg = {'nphoton': 1000000, 'vol':np.ones([60,60,60],dtype='uint8'), 'tstart':0, 'tend':5e-9, 'tstep':5e-9,
'srcpos': [30,30,0], 'srcdir':[0,0,1], 'prop':[[0,0,1,1],[0.005,1,0.01,1.37]]}
res = pmcxcl.run(cfg)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pmcxcl-0.1.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9dd2192940bdb25c8fcc88ce31771bb03178ebe552bb26dd8b0648ce782e886 |
|
MD5 | b04f29bb99f06cb024d0dea79b9c34a5 |
|
BLAKE2b-256 | 988d3dd53e7f36eb576496e1ebe19d6c95b03c94954a5a5d7645b77162583512 |
Hashes for pmcxcl-0.1.6-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44d5d3f741cfcefbd9b55c58ed7ed13e92b562bffa716fe83703acac34e2cef4 |
|
MD5 | 5ed9d41c12367dd0ec09eb7e85d9c6d5 |
|
BLAKE2b-256 | faba0ec01116db488f7817b0afea4e354692cfc04a0df9be15ebbb93e1c8c274 |
Hashes for pmcxcl-0.1.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3c6501ca92c43ee2259c764b22b55ee4c8f2242a4644ee3cd9e0e12dd997bc5 |
|
MD5 | ee31dc36720c6fdc91c99ce54aabaddc |
|
BLAKE2b-256 | 7533505231893bbd1d8120fc6d2df3aaf1cbb36b469681225ff94c31237eba49 |
Hashes for pmcxcl-0.1.6-pp39-pypy39_pp73-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d04f927a32cf442540b1f6b4e1d6e49bd794f0de152a99a7c2b2588dceaafc82 |
|
MD5 | 101d1a898cef0f3b0945db28d0da0088 |
|
BLAKE2b-256 | ba38adaf39c33ea6d241862894e8d2a6c4a257568694bacb8d59b4a64685f757 |
Hashes for pmcxcl-0.1.6-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf306eff435600a73d08d697fc72eb573297ee9232e226280f9011b8c2b5205d |
|
MD5 | 0792086950bbd7c39109fc1bff080027 |
|
BLAKE2b-256 | 640e42a2c17e55d6e01e08aaf0eb9c9b1723f77fbe6052755ede958757984020 |
Hashes for pmcxcl-0.1.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a12b7db4a538f923e9586ae0eb59e1ea8869556ed460f9440a73cc14e832f87 |
|
MD5 | d9b37523fa5b2a22d764bef5d85c5712 |
|
BLAKE2b-256 | 5dcfaaac3edeaf943196c37151aa75701133b11095a8b4d2ee56b69371025cd4 |
Hashes for pmcxcl-0.1.6-pp38-pypy38_pp73-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 497a629abc1a186ec21095b1b9d4ecd9b9db9e3f57778440e68e24bb77f321b2 |
|
MD5 | bf2de5a012d98759182658fca6e4f644 |
|
BLAKE2b-256 | 086cbd92c8234299e309a38a4481ff566effce744baec6768b8d01463d556049 |
Hashes for pmcxcl-0.1.6-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0ae1338418b213baa63b676bf8ebbd6c557e652a8068ca8344287f1e9aec8ce |
|
MD5 | c88a8d3429e20625eeb99bd8c3ca6cef |
|
BLAKE2b-256 | 452c01603360d39ee57b167ff3fbe4bbf31384bd8f8efbb30f163485df53b129 |
Hashes for pmcxcl-0.1.6-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1ffe48ed37ca0d1b3e18adf1ab60f21bb7e6c8c86edf90c6a56191196c63faf |
|
MD5 | 738771a0a05a518a157f53758e62cf95 |
|
BLAKE2b-256 | 624d83df3874558854469ce27a3f6eefd3ea8e3fcb7e7f26b42e643143c131b1 |
Hashes for pmcxcl-0.1.6-pp37-pypy37_pp73-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1d95538e2ddceea1a16534fcee6d2eda14d11af72aec32df5d09d3c7cec99e5 |
|
MD5 | c904b7a8d2ae0792966093bdb852dde8 |
|
BLAKE2b-256 | 44d3b1014c8856ca9e98694ca6254b382898371b341908a12f0d7c41235761e5 |
Hashes for pmcxcl-0.1.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2001466be3aa6e6a8d2fa1260b4843e71f695486f97402fdcfe5c4706ed9ad6 |
|
MD5 | c5772f313f6a1f13d1efbc39e36855f1 |
|
BLAKE2b-256 | fd18a62792bebf77956d5c61f04842df255390afa933e76e211143415b2e2139 |
Hashes for pmcxcl-0.1.6-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83bfa9cb67b1f8d6416b431ec5b68b59fff1d3111b192b7a57c14b20da66cb2e |
|
MD5 | 43bbd63cbfa84853fe97d766c4a407c7 |
|
BLAKE2b-256 | b0585ea77b295c4d54f66814e77c6510be56f73fd9fc3229f3a38dcae43a10c9 |
Hashes for pmcxcl-0.1.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a2fc9283a36f3e65b24191784eaa912d3ada6bf1ed8f501462d7115a64e7fa3 |
|
MD5 | 6c251be23d6d810c3b3191187a6db723 |
|
BLAKE2b-256 | 25ee37d21c0b424177fec9a01cd37f72bd7128ed195816afb8aece6ff3bf9253 |
Hashes for pmcxcl-0.1.6-cp311-cp311-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 601c18777278a0c49335da353a035a6b85d04225ecf67402646b3ef84e189476 |
|
MD5 | d36f7f4891ec81c59050ccd3b8958db6 |
|
BLAKE2b-256 | 4e7ea64c2b771c79b73e270c30da4e6ff0f7b20bf50fd7226ed7c9dbaa218ba9 |
Hashes for pmcxcl-0.1.6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c6fbface5b6bb381d4a58dafc31dae092e6caa09ec91edcab40ce3cf5d4a784 |
|
MD5 | 1b1f3842605aef97db13f67fac85abc8 |
|
BLAKE2b-256 | 33a9e86e14e46614a7600e35e6f5a2259341841e927919f2121f3d14b6a3e79b |
Hashes for pmcxcl-0.1.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27ec39845b718e9b125b3e79f29ba259d2e4e06c3e137c990629b5f9cfffcec7 |
|
MD5 | a404f05b12d8a160b17d7839bbb68152 |
|
BLAKE2b-256 | 49329d07c502da508546c89cc5fd8c02139fb06cb3ca130f5850f32a660bc186 |
Hashes for pmcxcl-0.1.6-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cf1e001720b5e5318b6b6ccb8161112f2f115f393760ab4580999bc14643467 |
|
MD5 | 7e6d03ad681f489b418bc321c588d209 |
|
BLAKE2b-256 | 245325770b608037535a5fc374598cbbb8590d40d443cd583c1611d99b1e90d6 |
Hashes for pmcxcl-0.1.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74cfb7c1e589abf86be1f1ff4e95d97bf2d7e8a684b26951e2f98057088b1580 |
|
MD5 | a7e91d353858bfbc9e1d5e29002398db |
|
BLAKE2b-256 | 576390d5d94c5613896ea8082f32f059626b77ba5bedb07528fa52f9ff2c828f |
Hashes for pmcxcl-0.1.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91b3c5a717a5b4cab73616a81d7edb9a4dcb580b62ed9fb71e037ff7b78e85c8 |
|
MD5 | 31ef74bd3c16ae064c43e175736f01c3 |
|
BLAKE2b-256 | 21483214b4598f34459acc96ded3eba4f9f7fe96c3bfc4578f61669fda56bd8f |
Hashes for pmcxcl-0.1.6-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e059ef5e449d708f62e34c6adc8a4a605102006c8b9298aa5cefb9c77ee5c598 |
|
MD5 | 4d55873998bd10ed09e41cedf3176e1d |
|
BLAKE2b-256 | ea308e0e7cd50425bf189f23e091ab29361812c9a4cd6cd6f3a770ee229fc03f |
Hashes for pmcxcl-0.1.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2660a7e5f027110b124899f21647b0988b330b55a857667c4d4b3ea6cefb1c0d |
|
MD5 | b167df3e2559f7e2d76fbdf462fb0d17 |
|
BLAKE2b-256 | a9e0b6eb14d3d2681d4ebab3276ff54d4ea2615511cad6fe91e450c5c3627bcb |
Hashes for pmcxcl-0.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d52977626eaa82e7734ba858c27433e88bc7aa9c52d44b4c2270f1a86d07842d |
|
MD5 | ac4e23cc941f1ca10ef27b5091930a04 |
|
BLAKE2b-256 | f47dba62b00fcc6024225775094e64a6115e0d1f4367147d78234a46352ffc0c |
Hashes for pmcxcl-0.1.6-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65084a921f6a680b2a387d35ac007bd863c6e82a5d77bfda50662a219a2e6c1c |
|
MD5 | b3735f5dece462cf9f2a3a550a78cc32 |
|
BLAKE2b-256 | 4d662a46607082d9f561cefaf28af9883bc910585ea214bfa20ff81da90e112a |
Hashes for pmcxcl-0.1.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f88f9bcc7af99d739e74ad82335b995d4a248045d1e35d8d2f72b118e2749a7a |
|
MD5 | f0ebfbe950631a020e4bfc352955e5cc |
|
BLAKE2b-256 | e277250fb073e8b975cea42c6371570c46c64ce666ca2567f01f236ecd85f552 |
Hashes for pmcxcl-0.1.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 417faa5b780be4772d85e925880aa154e03d4377e75365945fed652267be4540 |
|
MD5 | 1428cc93b03e04b71633a3dac4a6998c |
|
BLAKE2b-256 | cf29637cef6c0fbc754b91b1c9fbc0513b1591296b385dd4c23552d4e9334d2b |
Hashes for pmcxcl-0.1.6-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43245a2daa7386c1ce1ae7db7d433bd18613e0456947331d613defeb279db54d |
|
MD5 | d04ef80eb7f33b629500418b23f09a04 |
|
BLAKE2b-256 | fdadfb093338473daaa239dc26dfc6dc2f964cc438065f3398bd4805c1b7f467 |
Hashes for pmcxcl-0.1.6-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3ed043c4d34865a47c75e2ce594169299e164f6dddf9de24745517549540d37 |
|
MD5 | 3360bfc7d5287c2c5ef52425cc25264f |
|
BLAKE2b-256 | a4b2433383ec1c4dbae7ef71aa99b5732ea007acabb64817a400bc61f5629609 |
Hashes for pmcxcl-0.1.6-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89864b76a8df14cbd96b05fbb2e972d673c58005844a4d36b6db0cba1c7ef409 |
|
MD5 | b758eb3b1511b0780b92df84e765b288 |
|
BLAKE2b-256 | 53f34ca2ce47d5cca5782ea92ea6ca15364563fb5d921779d8182e4ce49cdd31 |
Hashes for pmcxcl-0.1.6-cp36-cp36m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a121eba8f3679cdadcff1d166df89a8894998788cb9621e4d72ee4a415435f4 |
|
MD5 | 1580f9eed1ec22efba68b63ff100b1cb |
|
BLAKE2b-256 | 16bb1a6316c476428c4fa9f940bef93f88ed1542d1b92896c1d81a75a1e37d9f |