Python bindings for Monte Carlo eXtreme 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-2023) <q.fang at neu.edu>
- License: GNU Public License V3 or later
- Version: 0.0.5
- 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
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.
-
Zlib Compression Development Headers: On Linux, this is generally available via the built-in package manager. For example, on Debian-based distributions like Ubuntu it is available via
apt
under the namezlib1g-dev
. On macOS, brew provides it under the namezlib
. No packaged versions of Zlib are available for windows, therefore it must be downloaded manually and added to the CMake environment variables in your working Powershell session:curl.exe --retry 3 -kL https://cytranet.dl.sourceforge.net/project/gnuwin32/zlib/1.2.3/zlib-1.2.3-lib.zip --output zlib.zip Expand-Archive .\zlib.zip -DestinationPath zlib\ $env:CMAKE_INCLUDE_PATH=$PWD\zlib\include $env:CMAKE_LIBRARY_PATH=$PWD\zlib\lib
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
-
Run
pip wheel .
inside thepmcxcl
folder to locally build the Python wheel without installing it -
One can also run
python setup.py install
orpip install .
to build and directly install the compiled package
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.0.5-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f05c1f9e5f2e14874d44663bdf12a97d956fd3f0f303df8f3d664590be0c04dd |
|
MD5 | c4d6542548d57ce14812d4c7b008de00 |
|
BLAKE2b-256 | dcb9a83ddc1740f386a616c810783cd0db5d698f51e5bf1dd98fedc9d5065a4e |
Hashes for pmcxcl-0.0.5-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56d9c840ce30636bd0079d43975dc3129296f6a324bf0c2a4f3494464c9327a4 |
|
MD5 | 4208cea41ca3094689e92ace33ca8dcf |
|
BLAKE2b-256 | 3168a8df767e66283967c1c2866afb7582d2d3c191e3be04480b6792644bb5db |
Hashes for pmcxcl-0.0.5-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 025676f9f1249047aa900e1c44a382a5c60062c904f00de6c52f0bbef534d539 |
|
MD5 | 48ebe2b7f6b27e0746d461f62df415c4 |
|
BLAKE2b-256 | 46ed7ae2038e3cc242ebb5c351fb5c9bfe99bf4140952da3a69921f344a8963a |
Hashes for pmcxcl-0.0.5-pp39-pypy39_pp73-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ef9f7e30de39f39191f2c2c6a1d6ea5f8eb9c5ed04ac71baac7f265cd5ab2f6 |
|
MD5 | c2eb9d04f37a3a8b51438f784198951a |
|
BLAKE2b-256 | b5752966e8f4bea2e3f8e43c523763dc533d853141691b8557ad31a07d4b5fe9 |
Hashes for pmcxcl-0.0.5-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1a3d52210f2e696370ae645c7fc1ed693829240a03603ad17fe1e345a7e4a01 |
|
MD5 | ecb1ba2dd3180fa2bd994b4a7385e064 |
|
BLAKE2b-256 | d128ccd7705c103ee3732c7bca371d546147669ec0d94c2564524a451ccc0baa |
Hashes for pmcxcl-0.0.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aa8a210e51afcf64fb9e028627f15c230e723ba52a45d8b23f9ee34b84997be |
|
MD5 | 3fa7a4edc5f7a5e2329c103d010b7e4f |
|
BLAKE2b-256 | d3310979c626e10970a177279a71833cf7cb2d285335fc978c4a56918b7d4440 |
Hashes for pmcxcl-0.0.5-pp38-pypy38_pp73-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc58d12247f375727aeb1bc474f4a17cddc87ecb6a072cdaf182e3d7198440ff |
|
MD5 | 36b53c7ec1d57c3993336464384ee869 |
|
BLAKE2b-256 | b08252882bf313a9927742832f17a516039ad13d4d19107a6decb463401b90d3 |
Hashes for pmcxcl-0.0.5-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48656eab933049e960f65f05bb21e0fdbfc7a00f8e39213e69a76e24f7a165ec |
|
MD5 | c1543b88071da30367bf884309b4341e |
|
BLAKE2b-256 | 69a39654df5c578ba33f83553a2ddb0210dab75523c2ace14c85643425b4c4ae |
Hashes for pmcxcl-0.0.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c17e5e1d97457297194f4dd1c7d7af59258ab15558d905bbaf4f4b54144aa62 |
|
MD5 | 6944b0abe0a02da44e5ac1345374221e |
|
BLAKE2b-256 | 53a01b8828aacdab05491b3985d5defdc319eb84ec44ece501be381c3cbbd3b8 |
Hashes for pmcxcl-0.0.5-pp37-pypy37_pp73-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6121b2e9a8465b22f02124ef8ddc6368365772f20d7a0e8f0555ff6f8f0479c1 |
|
MD5 | fd8a0c145a442c271aec5abf7b139973 |
|
BLAKE2b-256 | 0fcc2bc660656e855da1081d42c3be2765979decaf1434f6752c4beaf7f34e33 |
Hashes for pmcxcl-0.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c9031aaca7a50fd2b364552f36e5ff74b5fc0025e388ae762e9eb0730485ba4 |
|
MD5 | 209ecd2bca7ae800e8670cbbba768967 |
|
BLAKE2b-256 | 4d85271b219d7441f434d33b6392d31ab4078aa202340f86b9935bec7be7be76 |
Hashes for pmcxcl-0.0.5-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64f676e4738dc0aada8f591e004feac83bc079e3e336967461df36338aeab4c0 |
|
MD5 | be91f9a42da257c96318eeb11ca4cc57 |
|
BLAKE2b-256 | 30b5aa0e0320562c2eb2d1b51d069f5e3e82096665b7fa75a7ec4f1ff52c5937 |
Hashes for pmcxcl-0.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d91f9ecb83b50331ae19b16e368ac0bc6f532b16fbf0005a953e5ad1c2ea0d04 |
|
MD5 | a02abf8676e038543c5bf73d7f4ca4d3 |
|
BLAKE2b-256 | 6a218c2f145960fe22ae3b9767a6cdd1b2ce26ddd2c31e8abfd42c277d5e4e2a |
Hashes for pmcxcl-0.0.5-cp311-cp311-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ed909e93d5572ed4fb48acff1d423abbe308928d6f9752d4cd0740455d881a5 |
|
MD5 | 382eafe4a4dab6575ed1a593c789e17f |
|
BLAKE2b-256 | 5243709dc82a62aed04af11f641bceafc34fdbcc69739d6a2b241822a5b159bc |
Hashes for pmcxcl-0.0.5-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7933a281e5ee1fdf81f4502746b8af1e22aafece9f5729b1200237570269db3d |
|
MD5 | 1971b130c8238d5821a2a88152a3a84a |
|
BLAKE2b-256 | 5441a1462f0ff5360bb4772a4626532559b61cd722dda98f222a1a3141bea5c9 |
Hashes for pmcxcl-0.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc6ac09fe375ba53589d8b8d1ac911bdf6481d7a4beef614ef06d98a69569226 |
|
MD5 | da7e841f86dc8c69fc2bed8ae43ca400 |
|
BLAKE2b-256 | 6047501eb26ac352a39c0a7808b3dd226957810ed2340d1d2c99fd1e680abd5e |
Hashes for pmcxcl-0.0.5-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41b861cd8027ac448b12a91ed2630aa346f1cc46ca95f147a4f75099b09ebfdb |
|
MD5 | b3128cbfab40d5e3b4d33ac3407b3d17 |
|
BLAKE2b-256 | 684fc1041e353c60681a991973c41631730985daa370634cd51e3fb23ec39ae5 |
Hashes for pmcxcl-0.0.5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cafccb118ba14d69e41c0fe2e3ba2b65efe980bb2fdea92c077d1efd793c82c6 |
|
MD5 | 715dc969cb2bed17e6c5c7b0e1d4c38d |
|
BLAKE2b-256 | caf3e601d1ccc225c3f0fafe05dec367e725cd35752b4f0bb3aeac663c51941f |
Hashes for pmcxcl-0.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afabc25b39ff8da323acfcb46150775ad3ad4d3eee1cb4a4e2461ee92dec7083 |
|
MD5 | 2782aa943ae93efc783fde48455a3275 |
|
BLAKE2b-256 | 5e37461e0d96c82119537ea61d01f92b2ab2302b714ff6e46b275b723aa6a6d4 |
Hashes for pmcxcl-0.0.5-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63f822fe0b888f6cbe1d9a6b22be57af829d23086c6d5cbdba54137765826d5a |
|
MD5 | 2ba28d81255c7598ab82cbb2666ed57b |
|
BLAKE2b-256 | eee90e5aedbc7dc2705436a7a0ebbdaa8f2b8557db2b1239e87053473165153d |
Hashes for pmcxcl-0.0.5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e5ac1331e44716db7617b7f47bdc8a440e0ba55cf02abb7d0dea47b40d68e5f |
|
MD5 | 953d4a453868239ef85fbda9d4da7e93 |
|
BLAKE2b-256 | d6e5263c76d9c2314d9316ec3ee6bafdd6dfed69d37c80af529a98e52fc92d1b |
Hashes for pmcxcl-0.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c6595e773f1b9018e9e87031eb998b2a88683886d3143b9c1d8d49ffb06a906 |
|
MD5 | 954d4772e6f6df30c9b68a1dbd3648c5 |
|
BLAKE2b-256 | 1e512432bf4bb5036cf07eb345088232af65412807d7cb4540540f303806924d |
Hashes for pmcxcl-0.0.5-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c856658429b85de103a5d0e73764a3ad498c66e6481575eb0bc974eb9bde58a7 |
|
MD5 | f62bce623cf8f8e1d2913ec1b6af2ce3 |
|
BLAKE2b-256 | 95952e2685984c712be63c6ebfef1fe93a8d1b7cfad863010a9afc91d4f701c0 |
Hashes for pmcxcl-0.0.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8042c683c1d6c54a1a52d7f265bbb9e089a8da43fb3769e19d7118daf85c8cea |
|
MD5 | 93d20ad6a51c2fd46565642b7f3f01d1 |
|
BLAKE2b-256 | e4288d2e612141ef02053d6634b2c6ce7ae01cc87e7f1f3312134b12aa92984a |
Hashes for pmcxcl-0.0.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2158fcf5c858cd814872acdc330ad78f0ade2b4b27cec862dd8d65f51143c6b |
|
MD5 | eb49ed99182b3564634cec531c0bf5d0 |
|
BLAKE2b-256 | fb352ca822056645d794069cda46a131ea5d918651ce04e74eae5e1d9d39c20b |
Hashes for pmcxcl-0.0.5-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6e23fb4d664196095cf799d38db1f29df49a82fd751faf7a64cccf6a21da39e |
|
MD5 | baf4d7e243e7922dbcd46fe8ebfdd029 |
|
BLAKE2b-256 | 7d21d8e3962ee23fca05c67feeab50e1be255978fe3b16235f59b85424b408e6 |
Hashes for pmcxcl-0.0.5-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75aececeaaa83a66b6f21a45bc1058e148d94b56639fcd370f67096406d589bb |
|
MD5 | 9381b413205017c82e588712a629ff75 |
|
BLAKE2b-256 | 5e80baaef8f25aa70dcc3dfa9470412fba3c1c41def1645ffde05c900ad7bd69 |
Hashes for pmcxcl-0.0.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be1597dc98370adcaeb0ab2514d44cb6ab677229a79e628e4a9c70de0158102e |
|
MD5 | 54513d21ea37fa6c6241f48fddd84926 |
|
BLAKE2b-256 | cc521821407d0f6bd1f53b5ed5851cd805ec1e4fb7ad5453c1ce64744356f5c6 |
Hashes for pmcxcl-0.0.5-cp36-cp36m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10ff6dbaeb212cc375c0146679c0693028e89f065a8ddd333c320bf25244b7d1 |
|
MD5 | bc74a79ef191770b17b71e650ed77939 |
|
BLAKE2b-256 | 30c26332ba8dab0834b79820d1a8761db2db68e9366481d6dda6db66305a7b33 |