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-2023) <q.fang at neu.edu>
- License: GNU Public License V3 or later
- Version: 0.0.12
- 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.0.12-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac57186add1eab7ce095d3c1077cde9af88150ea20a990bcb1b4b1fed57c7a9a |
|
MD5 | d3fb85125b1cf1d502ef2ef65d7c7f01 |
|
BLAKE2b-256 | d94ee107a5832aa7bef53a6637352350d400f7e973f83f10a345dff786a71c72 |
Hashes for pmcxcl-0.0.12-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0c9a2cb022f18354e85672297e09b072e48ae7bbc9670d2e96e5d12cec7c177 |
|
MD5 | d3d0e4c40b75c59e91bb7b3d4df68964 |
|
BLAKE2b-256 | 6c085011dc3b761598dfcde2c8d9f4a6251e08849210ccbdfe6d7c008db56f39 |
Hashes for pmcxcl-0.0.12-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a759e02e41f337f0a3076b9343f760c1244de6d49ca3ae1c4174d3b2303e46a5 |
|
MD5 | 90e9718afce69562dac5f927004b1b77 |
|
BLAKE2b-256 | 1521e4a1c151edc3f9acdc167014267c9ce810577b29875d5f2eaca6a498e36c |
Hashes for pmcxcl-0.0.12-pp39-pypy39_pp73-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c17fa478ced66199f672d58a266879d560c08b885490dd936bafc23099101b1 |
|
MD5 | 4a4e4ac9f3ccf59d8d59319538e9ad20 |
|
BLAKE2b-256 | 7c4ed48b42ae79df6092178bcb5c7c699657057b7ae8bae767b6f34643e949f0 |
Hashes for pmcxcl-0.0.12-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b450edd5044712dc7091e39e358a88365961b82a76ddcc2cf690bd80365fbd9 |
|
MD5 | 5c34461042aee66f0a7749b007d573a1 |
|
BLAKE2b-256 | 2b2e8f90189f0722759eb3d4f413cb7a3b6da2f9ed845545c4d0f36271d5ee75 |
Hashes for pmcxcl-0.0.12-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 050667d1b118c97f1601a64e738355209bc51e8617be024c3079ccd028ff9308 |
|
MD5 | 1019ee8eb755a29f90ddc19e673eb4dd |
|
BLAKE2b-256 | 632f4c75c52c867e7f5c2acc36131f106e77c17faf8c990824b4963a4b26afea |
Hashes for pmcxcl-0.0.12-pp38-pypy38_pp73-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6972ec79bbae4e31006606996be7f2f45c6856f858c9d010460db57a5dff16f8 |
|
MD5 | d54b34ec7931afcc4ba376f079efab50 |
|
BLAKE2b-256 | b64bb6b9420a010112f70813e3747b9ece3017ad40c46c9156245365ae949a99 |
Hashes for pmcxcl-0.0.12-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5717a0f9b71142ab969128c12bfa9b372fccb691f0d6455c51a554a9bd615626 |
|
MD5 | 2dd9527833943d37ac6c8ec36dd9d295 |
|
BLAKE2b-256 | 25dac4ae10d439786fd6ba4d2f3e315099abc4dd4dbcc7c452365345cf24dcd3 |
Hashes for pmcxcl-0.0.12-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3063a14451c043953208436eda3b341edfd4d411ff30d1516426868ff0baee8 |
|
MD5 | bab912527c68117d0b29f9a31286f06b |
|
BLAKE2b-256 | 00c2815e5fe4642e8524162a8a2938a6c9cb0e9a0bbccaf498db4c08f09d2167 |
Hashes for pmcxcl-0.0.12-pp37-pypy37_pp73-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cea142cd1bc3e6bb6d15d25bed30c6eb9b9f0996832100539765fc5298bc5d8a |
|
MD5 | d3d1da7d1f804285eb74ba0deb236287 |
|
BLAKE2b-256 | 1d4d8da57bd37603eda985712a5c630c7c1b3a0d2e66c2e13a70a553c672bb3c |
Hashes for pmcxcl-0.0.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 219ff3aeb0e9b36c0cb2c6c33779f77ed2f7e4185911a9940d641429b161871d |
|
MD5 | 4ea7f56beb6495a8b360c37aa44fab6c |
|
BLAKE2b-256 | ed0a14ec5998089a331d711d70db237d03dbc0a459eb82578835b4011b6ea4ea |
Hashes for pmcxcl-0.0.12-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3984f5b9c875d89dfe5d46f27465732d6b9d413dc5f89171994f1a025e98437 |
|
MD5 | 6c4f7fb6835bf34e0af4c7a4502ac8eb |
|
BLAKE2b-256 | c4df38532e340d8f0607f9c1b19544fcc4359ccaeca2c72e3a31df37258d07f8 |
Hashes for pmcxcl-0.0.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89532b41d521b50df9141be70e8855eb69a1330a8eb1625590883bf5bee56a71 |
|
MD5 | 029f128b112f5415210224e58257916d |
|
BLAKE2b-256 | fc889b43d6a07109f3c9dd3f1987d3c818e805d1966d8b526d0264e0a7080400 |
Hashes for pmcxcl-0.0.12-cp311-cp311-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5df55605e946492aed6ed307332e7b62aa2ffe445e612c7dae652a1e9c9e0951 |
|
MD5 | 7b77ffa1eae24759d308a4edabe282ab |
|
BLAKE2b-256 | 5a6e7b5d887eaf6506c707a50fd40e9e5ef7f92ec815b20ad98c46f905bd58f9 |
Hashes for pmcxcl-0.0.12-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cf0ac7af6e389b69b8f5e3453c53e5713d8c734a60b036005f3b5cc9f0da842 |
|
MD5 | 6301158446986d24aa70216ebd47e7bc |
|
BLAKE2b-256 | 7332893b1826f291a21acc17e356e8ab1426cfd28515ca00bd6fd821b559716c |
Hashes for pmcxcl-0.0.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb025cc8074756e4ecbbe55ecc8511d672a46f97417b0a3adcf00b0e53c92083 |
|
MD5 | a2a8d84e276a9c0d68b41e2038fb8b00 |
|
BLAKE2b-256 | 211b8e596daf0a53c7f3e4b40bc227c0007dbc2a153aa33cd525321312fe4bc4 |
Hashes for pmcxcl-0.0.12-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 485e2e63d72bfc31ee3c314a816cfc2ec7450c9d85e91e68955c7727c8f4f320 |
|
MD5 | dc0c87954c4f7c9fda31271346d88a37 |
|
BLAKE2b-256 | d44b3ba2f6c82c31a6b39a00bba543126dc9ae2b8b81dc8ea75254777fb20dd7 |
Hashes for pmcxcl-0.0.12-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 606511def9eed601851fff5b4ec1770d2d0c0722ff2a151bd360bed3034c55f1 |
|
MD5 | 0152160951dc3b1a3a426cac527ff00c |
|
BLAKE2b-256 | 628bdfa3370ea27cb3615ed4f44e3183f114940cd45c71bb84565d30e74fcb0d |
Hashes for pmcxcl-0.0.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 833dd98f6906586e30114cc48e8b095c750ee87c6c52f163ff145861853cfbad |
|
MD5 | a3ad51e64a2edbe594c3d2cf13128f4f |
|
BLAKE2b-256 | 8b9cf0e9d93b67dff4054ad789485e5e0d4baefe0d147eeac213603514bd1f2b |
Hashes for pmcxcl-0.0.12-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62fdcfea46d18f52c4663ec228077f05682aad91e2a50830ea8ac2525c35a98a |
|
MD5 | d4b61533818a131983b400785875b95b |
|
BLAKE2b-256 | f61dc309f2cffc0fc2cb0c088cb2826b49c24a41bc962afb7fbe8c0c326da48a |
Hashes for pmcxcl-0.0.12-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd26873a73a2ecbb4ce5ff6c889270164538b3f843f8cdde4807805af45d9024 |
|
MD5 | dd08fc8a7d69679d07da18d184cc7114 |
|
BLAKE2b-256 | ef3a185df8c7c6ae21aac99052f9019eaccce7ea2a32c1e889aee7f71204ffe6 |
Hashes for pmcxcl-0.0.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 463c6aa32562f80098d242068fbbc7b3e27985ee7dff736b97cf0c1ecd958a2e |
|
MD5 | 9094438978b4414d7d286e1a80963579 |
|
BLAKE2b-256 | 7da76999b926dc8ff8a655b3b959e624964f341ce67e4444505166f41ac31df6 |
Hashes for pmcxcl-0.0.12-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 805e1c3db55ba0a9e786641661cbbbcd13bd99cf8e6e3fe439944c3f32156498 |
|
MD5 | 03ec48bd6f9e250bb413b23faf8eaf9a |
|
BLAKE2b-256 | e6e49a89432ab4be796b88b2ad088a0fa42c5e53b4c89087de4d8f0675f6b293 |
Hashes for pmcxcl-0.0.12-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 959ead665764916f466e8ca22b080e61f9c874deb6d638b97f39cb39cbeaddcc |
|
MD5 | e530130730beca6ac82f2fe595a39215 |
|
BLAKE2b-256 | 218f6147ab687c89bf38f06d991f9250f28167ff802e21797f26e95429b815a4 |
Hashes for pmcxcl-0.0.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c162c7b21d77220d2675188029e392aeec964fb8ab1d526d1076fdc9a82724a0 |
|
MD5 | ec4c329f5021e7c84f5273e8ece353d8 |
|
BLAKE2b-256 | 84b918fd5001516f0748a56c97b1d016553f9b5ab33d3545456fa6ae5df12211 |
Hashes for pmcxcl-0.0.12-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfd0c409eec734a1ffefa598677584aaa4458734e8b9d629ba7fbe2257ceffc7 |
|
MD5 | 5ef2463f7fc1846fd7c62184acbaacf2 |
|
BLAKE2b-256 | 4b6f4cd9f3f155702e0e31739cb5f879d9c20375b335d61138c43a873ac7a76d |
Hashes for pmcxcl-0.0.12-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3610533edb6cd73e6eea65a37a0bbb6df16267dfa744f506f421859ccee0dd35 |
|
MD5 | 1863da96446cacbdbddb679269915e73 |
|
BLAKE2b-256 | 48eec1d46be49ca78d61cd1cf728091de64f5ee65e5bbeb5962093dfa267482c |
Hashes for pmcxcl-0.0.12-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0da9240394ee5effa7bce955007462d1a3aae2eda483d27c7d65118129583fde |
|
MD5 | 8641482f6928e2f22faa481270254a4c |
|
BLAKE2b-256 | 0ff03c046f0e6119bf9c6329cb088d763c255882f45ee422a33ec95cdffe5200 |
Hashes for pmcxcl-0.0.12-cp36-cp36m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bed6867dc4dd04ffc8067d3592974ee46991e75b99c06ca6fff6f7e069d91c7 |
|
MD5 | 271fceb72fb30a9e224f367916373a22 |
|
BLAKE2b-256 | 6530b1c5f921c05595fd86b1dc163670459a2a230dca31f63b0069d5af268169 |