-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathREADME.txt
1703 lines (1376 loc) · 84.5 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
= Monte Carlo eXtreme (MCX-CL) =
== OpenCL Edition ==
* '''Author:''' Qianqian Fang (q.fang at neu.edu)
* '''License:''' GNU General Public License version 3 (GPLv3)
* '''Version:''' 1.6 (Harmonic)
* '''Website:''' https://mcx.space
---------------------------------------------------------------------
<toc>
---------------------------------------------------------------------
== # What's New ==
MCX-CL v2025 is a maintenance release with multiple bug fixes and minor new features.
It is highly recommended to upgrade for all users.
Notable major bug fixes include
* a high priority bug fangq/mcx#222, introduced in 198cd34, was fixed. this bug affects all simulations \
since v2023. Particularly, when a photon has a long pathlength, with weight drops to numerical 0, \
its pathlength data is carried in the immediately launched new photon, causing skews in the \
detected photon pathlength distributions
* multi-GPU simulations was not working (serialized) in v2024.2, this has been fixed
* further updates to the handling of low absorption medium (fangq/mcx#164), previously affect not-so-low mua values
* fix incorrect angleinvcdf and invcdf buffer length, ported from fangq/mcx#233
* fix missing nscat output due to incorrect macro, fix #56
* add missing --maxjumpdebug flag, accept float, fix #54
* avoid double-base64-encoding when -Z 2 is used, fangq/mcx#219
* for all brain related simulations, we have updated the CSF mua value of 0.004/mm that was \
previously used in Custo et al. 2006 paper to 0.0004/mm, matching its upstream reference Strangman et al. 2003. \
However, we want to highlight that both literature may not provide the best mua value for CSF - as such low \
mua/mus CSF properties are mostly for CSF in the inner part of the brain, but not representiative to those in \
the subarachnoid space. A few literature have shown that CSF in the subarachnoid space may have a higher \
mus' value, in the range between 0.16/mm to 0.32/mm, as shown in Okada et al. 2003
* [Okada_2003] E. Okada and D. T. Delpy, “Near-infrared light propagation in an adult head model. I. Modeling of low-level scattering in the cerebrospinal fluid layer,” Applied Optics 42, 2906–2914 (2003)
* [Custo_2006] A. Custo, W. M. Wells III., A. H. Barnett, et al., “Effective scattering coefficient of the cerebral spinal fluid in adult head models for diffuse optical imaging,” Applied Optics 45, 4747 (2006)
* [Strangman_2003] G. Strangman, M. A. Franceschini, and D. A. Boas, “Factors affecting the accuracy of near-infrared spectroscopy concentration calculations for focal changes in oxygenation parameters,” NeuroImage 18, 865–879 (2003)
In addition, in this release, we also added the following key new features
* optimize thread configurations on Apple processors (M1/M2/M3/M4) and achieve 7x speed acceleration
* the new `-N/--net` command line flag allows one to browse and run growing number of community-contributed \
simulations hosted on https://neurojson.io (one can browse the list at https://neurojson.org/db/mcx)
* mcx can read stdin (standard input) using pipe, allow one to use advanced text processing utilities in the shell, \
such as `sed, perl, jq` to modify JSON inputs at runtime. For example `mcx -N cube60 | jq '.Forward.Dt=1e-10' | mcx -f`
* a new shortcut option `-Q` for `--bench` to conveniently browse and run built-in benchmarks
* mcxlabcl and pmcxcl cam set `cfg.flog=1` or 0 to disable printing of mcxcl banner
The detailed updates can be found in the below change log
* 2025-01-23 [2a9476b] [feat] support reading pipe from command line with -f -
* 2025-01-22 [febd932] [bug] fix incorrect per-voxel pathlength when mua->0, fangq/mcx#164
* 2025-01-21 [3640d79] [bug] fix windows -N error
* 2025-01-21 [44f63c0] [cmake] update cmake to add -N support
* 2025-01-20 [6de71b0] [neurojson] avoid needing c++11, fix ci
* 2025-01-20 [3cb78c4] [ci] fix mac warnings and errors
* 2025-01-20 [29b0f3b] [feat] add -N/--net to download simulations from NeuroJSON.io, add -Q
* 2024-11-13 [d79f6ed] [ci] remove mac local file
* 2024-11-13 [96b8dbc] [ci] speedup macos-13 and windows octave download
* 2024-11-13 [299b920] [ci] add install octave using dmg
* 2024-11-13 [f8bb370] [ci] add windows octave mex build back
* 2024-09-30 [0f642c3] [pmcxcl] bump pmcxcl version to 0.2.1 to include fix in fangq/mcx#233
* 2024-09-29 [42917da] [bug] fix incorrect angleinvcdf and invcdf length, fangq/mcx#233
* 2024-09-14 [f15814c] [ci] revert pybind11 version further for python3.6
* 2024-09-14 [d3baf8c] [ci] add ubuntu-24.04 and macos-14
* 2024-09-14 [e2fa087] [ci] remove DL_LDFLAGS
* 2024-09-14 [dd99f92] [ci] macos ci fails with -shared
* 2024-09-14 [7a3e4aa] [ci] test without macos-14
* 2024-09-13 [4b9e21b] [bug] fix the potential typo in Custo et al for CSF mua, fangq/mcx#232
* 2024-09-11 [c13dcf2] [ci] remove upx as github disabled upx for macos
* 2024-09-11 [2191885] [ci] allow make oct to link with OpenCL on macos
* 2024-09-03 [7c57318] [ci] fix action alert related to download-artifact https://github.com/NeuroJSON/zmat/security/dependabot/1
* 2024-08-20 [8f84acf] [ci] use gcc-12 on macos runner
* 2024-08-18 [d7defeb] [bug] fix lzma memory leakage, NeuroJSON/zmat#11, lloyd/easylzma#4
* 2024-07-19 [9c86f6b] [bug] fix multi-gpu serialization bug on nvidia GPUs the bug was introduced in https://github.com/fangq/mcxcl/commit/9b4d76f03d86c2c9f3f449e340925649d4514379
* 2024-06-12 [953c4e9] [ci] remove compiler warnings
* 2024-06-12 [57612d0] [test] make mcxcl pass all tests on Alder lake Intel iGPU
* 2024-06-12 [4609451] [bug] detector radius is not squared, fix #58
* 2024-06-11 [2b91626] [intel] pass all tests and remove all warnings on old i7-2635QM on mac
* 2024-06-11 [59d88a0] [test] sync test script between mcx and mcxcl after #57
* 2024-06-11 [88899f9] [bug] reset replay.tof when tof too big, improve replay test, fix #57
* 2024-06-09 [6e91fe3] [opencl] optimizing thread number on Apple silicon, gain 7x speedup
* 2024-06-09 [c2bbf7f] [ci] test on macos-13
* 2024-06-09 [7b558a4] [bug] fix colin27 failure on Apple silicon, fix #49
* 2024-06-08 [93c589c] [ci] trying to fix macos-12 build
* 2024-06-08 [9e84ecc] [bug] apply the same patch to ensure shared mem reset, fangq/mcx#222
* 2024-06-08 [1154916] [bug] fix missing nscat output due to incorrect macro, fix #56
* 2024-06-05 [8918150] [bug] add missing --maxjumpdebug flag, accept float, fix #54
* 2024-06-04 [4b00f6d] [bug] fix double fclose error, close #53
* 2024-04-25 [027cc55] [bug] avoid double-base64-encoding when -Z 2 is used, fangq/mcx#219
* 2024-03-29 [cbfa564] [ci] modify DL_LDFLAGS
* 2024-03-29 [ac879dc] [ci] revert LDFLAGS changes to compare difference on macos-12
* 2024-03-29 [d175187] [ci] print verbose mkoctfile log to debug macos-12
* 2024-03-29 [334c882] [package] copy LFLAGS to LDFLAGS, close #50
== # Introduction ==
Monte Carlo eXtreme (MCX) is a fast physically-accurate photon simulation
software for 3D heterogeneous complex media. By taking advantage of
the massively parallel threads and extremely low memory latency in a
modern graphics processing unit (GPU), this program is able to perform Monte
Carlo (MC) simulations at a blazing speed, typically hundreds to
a thousand times faster than a single-threaded CPU-based MC implementation.
MCX-CL is the OpenCL implementation of the MCX algorithm. Unlike MCX
which can only be executed on NVIDIA GPUs, MCX-CL is written in OpenCL,
the Open Computing Language, and can be executed on most modern CPUs
and GPUs available today, including Intel and AMD CPUs and GPUs. MCX-CL
is highly portable, highly scalable and is feature-rich just like MCX.
Due to the nature of the underlying MC algorithms, MCX and MCX-CL are
ray-tracing/ray-casting software under-the-hood. Compared to commonly
seen ray-tracing libraries used in computer graphics or gaming
engines, MCX-CL and MCX have many unique characteristics. The most
important difference is that MCX/MCX-CL are rigorously based on physical
laws. They are numerical solvers to the underlying radiative transfer equation
(RTE) and their solutions have been validated across many publications
using optical instruments and experimental measurements. In comparison,
most graphics-oriented ray-tracers have to make many approximations in
order to achieve fast rendering, enable to provide quantitatively accurate
light simulation results. Because of this, MCX/MCX-CL have been extensively
used by biophotonics research communities to obtain reference solutions and
guide the development of novel medical imaging systems or clinical
applications. Additionally, MCX/MCX-CL are volumetric ray-tracers; they
traverse photon-rays throughout complex 3-D domains and computes physically
meaningful quantities such as spatially resolved fluence, flux, diffuse
reflectance/transmittance, energy deposition, partial pathlengths,
among many others. In contrast, most graphics ray-tracing engines
only trace the RGB color of a ray and render it on a flat 2-D screen.
In other words, MCX/MCX-CL gives physically accurate 3-D light distributions
while graphics ray-tracers focus on 2-D rendering of a scene at the camera.
Nonetheless, they share many similarities, such as ray-marching computation,
GPU acceleration, scattering/absorption handling etc.
The details of MCX-CL can be found in the below paper
[Yu2018] Leiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang, \
"Scalable and massively parallel Monte Carlo photon transport simulations \
for heterogeneous computing platforms," J. Biomed. Optics, 23(1), 010504 (2018) .
A short summary of the main features includes:
* 3D heterogeneous media represented by voxelated array
* support over a dozen source forms, including wide-field and pattern illuminations
* boundary reflection support
* time-resolved photon transport simulations
* saving photon partial path lengths and trajectories
* optimized random number generators
* build-in flux/fluence normalization to output Green's functions
* user adjustable voxel resolution
* improved accuracy with atomic operations
* cross-platform graphical user interface
* native Matlab/Octave support for high usability
* flexible JSON interface for future extensions
* multi-GPU support
* advanced features: photon-replay, photon-sharing, and more
MCX-CL can be used on Windows, Linux and Mac OS. Multiple user
interfaces are provided, including
* '''Command line mode:''' mcxcl can be executed in the command line, best suited \
for batch data processing
* '''Graphical User Interface with MCXStudio:''' MCXStudio is a unified GUI program \
for MCX, MCX-CL and MMC. One can intuitively set all parameters, including \
GPU settings, MC settings and domain design, in the cross-platform interface
* '''Calling inside MATLAB/Octave:''' mcxlabcl is a mex function, one can call it \
inside MATLAB or GNU Octave to get all functionalities as the command line \
version.
* '''Calling inside Python:''' `pmcxcl` is a Python module wrapping the entire mcxcl \
simulation in an easy-to-use interface. One can install pmcxcl via `pip install pmcxcl`
If a user is familiar with MATLAB/Octave, it is highly recommended to
use MCXCL in MATLAB/Octave to ease data visualization. If one prefers a
GUI, please use MCXStudio to start. For users who are familiar with MCX/MCXCL
and need it for regular data processing, using the command line mode is
recommended.
---------------------------------------------------------------------------
== # Requirement and Installation ==
With the up-to-date driver installed for your computers, MCXCL can run on
almost all computers. The requirements for using this software include
* a modern CPU or GPU (Intel, NVIDIA, AMD, among others)
* pre-installed graphics driver - typically includes the OpenCL runtime (`libOpenCL.*` or `OpenCL.dll`)
For speed differences between different CPUs/GPUs made by different vendors, please
see your above paper [1] and our websites
* https://mcx.space/computebench/
* https://mcx.space/mcxcl
Generally speaking, AMD and NVIDIA high-end dedicated GPUs perform the best, about 20-60x
faster than a multi-core CPU; Intel's integrated GPU is about 3-4 times faster than
a multi-core CPU.
MCX-CL supports and has been fully tested with open-source OpenCL runtime
pocl (http://portablecl.org/) on the CPU. To install pocl, please run
sudo apt-get install pocl-opencl-icd
To install MCXCL, you simply download the binary executable corresponding to your
computer architecture and platform, extract the package
and run the executable under the <mcxcl root>/bin directory. For Linux
and MacOS users, please double check and make sure libOpenCL.so is installed under
the /usr/lib directory. If it is installed under a different directory, please
define environment variable LD_LIBRARY_PATH to include the path.
If `libOpenCL.so` or `OpenCL.dll` does not exist on your system or, please
make sure you have installed CUDA SDK (if you are using an nVidia card)
or AMD APP SDK (if you are using an AMD card).
The below installation steps can be browsed online at
https://mcx.space/wiki/index.cgi/wiki/index.cgi?Workshop/MCX18Preparation/MethodA
=== # Step 1. Verify your CPU/GPU support ==
MCX-CL supports a wide-range of processors, including Intel/AMD CPUs
and GPUs from NVIDIA/AMD/Intel. If your computer has been working previously,
in most cases, MCX-CL can simply run out-of-box. However, if you have trouble,
please follow the below detailed steps to verify and setup your OS to run
MCX-CL.
==== # Verify GPU/CPU support ===
To verify if you have installed the OpenCL or CUDA support, you may
* if you have a windows machine, download and install the \
[https://www.voidtools.com/ Everything Search] tool (a small and
fast file name search utility), and type '''"opencl.dll"''' in the search bar
** '''Expected result''': you must see <tt>OpenCL.dll</tt> (or \
<tt>nvopencl.dll</tt> if you have an NVIDIA GPU) installed in the \
<tt>Windows\System32</tt> directory.
* if you have an Mac, open a terminal, and type <tt>ls /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL</tt>
** '''Expected result''': you should not see an error.
* if you have a Linux laptop, open a terminal, and type <tt>locate libOpenCL.so</tt>,
** '''Expected result''': you should see one or multiple libOpenCL files
If the <tt>OpenCL.dll</tt> file is not found on your system, please
read the below sections. Otherwise, please go to Step 2: Install MATLAB.
==== # Computers without discrete GPUs ===
In many cases, your computer runs on an Intel CPU with integrated graphics. In
this case, please make sure you have installed the latest Intel graphics drivers.
If you are certain that you have installed the graphics drivers, or your
graphics works smoothly, please skip this step.
If you want to double check, for Windows machine, you can download the
"Intel Driver&Support Assistant" to check if you have installed the
graphics drivers
https://downloadcenter.intel.com/download/24345/Intel-Driver-Support-Assistant
for a Mac, you need to use your App store to update the driver, see the
below link for details
https://www.intel.com/content/www/us/en/support/articles/000022440/graphics-drivers.html
for a Linux (for example Ubuntu) laptop, the intel CPU OpenCL run-time
can be downloaded from
https://software.intel.com/en-us/articles/opencl-drivers#latest_CPU_runtime
if you want to use both Intel CPU and GPU on Linux, you need to install
the OpenCL™ 2.0 GPU/CPU driver package for Linux* (this involves compiling a new kernel)
https://software.intel.com/en-us/articles/opencl-drivers#latest_linux_driver
==== # Computers with discrete GPUs ===
If you have a computer with a discrete GPU, you need to make sure your
discrete GPU is configured with the appropriate GPU
driver installed. Again, if you have been using your laptop regularly and
the graphics has been smooth, likely your graphics driver has already been
installed.
If your GPU driver was not installed, and would like to install, or upgrade
from an older version, for an NVIDIA GPU, you may browse this link to
install the matching driver
http://www.nvidia.com/Download/index.aspx
if your GPU is an AMD GPU, please use the below link
https://support.amd.com/en-us/download
It is also possible to simultaneously access Intel CPU along with your
discrete GPU. In this case, you need to download the latest Intel OpenCL
Runtime for CPU only if you haven't installed it already.
https://software.intel.com/en-us/articles/opencl-drivers#latest_CPU_runtime
Note: if you have an NVIDIA GPU, there is no need to install CUDA in
order for you to run MCX-CL/MCXLABCL.
==== # Computers with hybrid GPUs ===
We noticed that running Ubuntu Linux 22.04 with a 6.5 kernel on a laptop with
a hybrid GPU with an Intel iGPU and an NVIDIA GPU, you must configure the
laptop to use the NVIDIA GPU as the primary GPU by choosing "NVIDIA (Performance Mode)"
in the PRIME Profiles section of **NVIDIA X Server Settings**. You can also run
sudo prime-select nvidia
to achieve the same goal. Otherwise, the simulation may hang your system
after running for a few seconds. A hybrid GPU laptop combing an NVIDIA GPU
with an AMD iGPU does not seem to have this issue if using Linux.
In addition, NVIDIA drirver (520 or newer) has a known glitch running on Linux kernel
6.x (such as those in Ubuntu 22.04). See
https://forums.developer.nvidia.com/t/dev-nvidia-uvm-io-error-on-ubuntu-22-04-520-to-535-driver-versions/262153
When the laptop is in the "performance" mode and wakes up from suspension, MCX/MCX-CL/MMC or any
CUDA program fails to run with an error
MCX ERROR(-999):unknown error in unit mcx_core.cu:2523
This is because the kernel module `nvida-uvm` fails to be reloaded after suspension.
If you had an open MATLAB session, you must close MATLAB first, and
run the below commands (if MATLAB is open, you will see `rmmod: ERROR: Module nvidia_uvm is in use`)
sudo rmmod /dev/nvidia-uvm
sudo modprobe nvidia-uvm
after the above command, MCX-CL should be able to run again.
=== # Step 2. Install MATLAB or GNU Octave =
One must install either a MATLAB or GNU Octave if one needs to use mcxlabcl.
If you use a Mac or Linux laptop, you need to create a link (if this link does
not exist) so that your system can find MATLAB. To do this you start a terminal,
and type
sudo ln -s /path/to/matlab /usr/local/bin
please replace <tt>/path/to/matlab</tt> to the actual <tt>matlab</tt> command
full path (for Mac, this is typically <tt>/Application/MATLAB_R20???.app/bin/matlab</tt>,
for Linux, it is typically <tt>/usr/local/MATLAB/R20???/bin/matlab</tt>, ???
is the year and release, such as 18a, 17b etc). You need to type your
password to create this link.
To verify your computer has MATLAB installed, please start a terminal on a
Mac or Linux, or type "cmd" and enter in Windows start menu, in the terminal,
type "<tt>matlab</tt>" and enter, you should see MATLAB starts.
=== # Step 3. Download MCXCL ==
One can download two separate MCXCL packages (standalone mcxcl binary, and mcxlabcl)
or download the integrated MCXStudio package (which contains mcx, mcxcl, mmc, mcxlab,
mcxlabcl and mmclab) where both packages, and many more, are included. The latest
stable released can be found on the MCX's website. However, if you want to use the
latest (but sometimes containing half-implemented features) software, you can access
the nightly-built packages from
https://mcx.space/nightly/
If one has downloaded the mcxcl binary package, after extraction, you may open
a terminal (on Windows, type cmd the Start menu), cd mcxcl folder and then cd
the bin subfolder. Please type "mcxcl" and enter, if the binary is compatible with
your OS, you should see the printed help info. The next step is to run
mcxcl -L
this will query your system and find any hardware that can run mcxcl. If your
hardware (CPU and GPU) have proper driver installed, the above command will typically
return 1 or more available computing hardware. Then you can move to the next step.
If you do not see any processor printed, that means your CPU or GPU does not have
OpenCL support (because it is too old or no driver installed). You will need to
go to their vendor's website and download the latest driver. For Intel CPUs older
than Ivy Bridge (4xxx), OpenCL and MCXCl are not well supported. Please consider
installing dedicated GPU or use a different computer.
In the case one has installed the MCXStudio package, you may follow the below
procedure to test for hardware compatibility.
Please click on the folder matching your operating system (for example, if you run
a 64bit Windows, you need to navigate into <tt>win64</tt> folder), and download
the file named <tt>"MCXStudio-MCX18-nightlybuild.zip"</tt>.
Open this file, and unzip it to a working folder (for Windows, for example, the
<tt>Documents</tt> or <tt>Downloads</tt> folder). The package needs about 100 MB disk space.
Once unzipped, you should be able to see a folder named '''"MCXStudio"''',
with a few executables and 3 subfolders underneath. See the folder structure below:
<pre>MCXStudio/
├── MATLAB/
│ ├── mcxlab/
│ ├── mcxlabcl/
│ └── mmclab/
├── MCXSuite/
│ ├── mcx/
│ ├── mcxcl/
│ └── mmc/
├── mcxstudio
├── mcxshow
└── mcxviewer
</pre>
Please make sure that your downloaded <tt>MCXStudio</tt> must match your operating system.
==== # Notes for Mac Users ===
'''For Mac users:''' Please unzip the package under your '''[https://www.cnet.com/how-to/how-to-find-your-macs-home-folder-and-add-it-to-finder/ home directory]''' directly (Shift+Command+H).
==== # Notes for Windows Users ===
When you start MCXStudio, you may see a dialog to ask you to modify the TdrDelay key
in the registry so that mcx can run more than 5 seconds. If you select Yes, some
of you may get an error saying you do not have permission.
To solve this problem, you need to quit MCXStudio, and then right-click on the
<tt>mcxstudio.exe</tt>, and select "Run as Administrator". Then, you should be
able to apply the registry change successfully.
Alternatively, one should open file browser, navigate into mcxcl/setup/win64 folder,
and right-click on the "apply_timeout_registry_fix.bat" file and select
"Run as Administrator".
'''You must reboot your computer for this change to be effective!'''
=== # Step 4. Start MCXStudio and query GPU information ==
Now, navigate to the MCXStudio folder (i.e. the top folder of the extracted
software structure). On Windows, right-click on the executable named <tt>"mcxstudio.exe"</tt>
and select "Run as Administrator" for the first time only; on the Linux,
double click on the <tt>mcxstudio</tt> executable; on the Mac, open a
terminal and type
cd ~/MCXStudio
open mcxstudio.app
First, click on the "New" button to the top-left (green plus icon),
select the 3rd option "<tt>NVIDIA/AMD/Intel CPUs/GPUs (MCX-CL)</tt>",
and type a session name '''"test"''' in the field below. Then click
OK. You should see a blue/yellow "test" icon added to the left panel.
Now, click on the '''"GPU"''' button on the toolbar (6th button from
the left side), an Output window will popup, and wait for a few seconds,
you should see an output like
<pre>"-- Run Command --"
"mcxcl" -L
"-- Printing GPU Information --"
Platform [0] Name NVIDIA CUDA
============ GPU device ID 0 [1 of 2]: Graphics Device ============
Device 1 of 2: Graphics Device
Compute units : 80 core(s)
Global memory : 12644188160 B
Local memory : 49152 B
Constant memory : 65536 B
Clock speed : 1455 MHz
Compute Capacity: 7.0
Stream Processor: 10240
Vendor name : NVIDIA
Auto-thread : 655360
...
Platform [1] Name Intel(R) OpenCL
============ CPU device ID 2 [1 of 1]: Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz ============
Device 3 of 1: Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Compute units : 8 core(s)
Global memory : 33404575744 B
Local memory : 32768 B
Constant memory : 131072 B
Clock speed : 4200 MHz
Vendor name : Intel
Auto-thread : 512
Auto-block : 64
"-- Task completed --"
</pre>
Your output may look different from above. If you do not see any output, or
it returns no GPU found, that means your OpenCL support was not installed
properly. Please go back to Steps 1-2 and reinstall the drivers.
If you have Intel CPU with Integrated GPU, you should be able to see a section with
<b>"Platform [?] Name Intel(R) OpenCL"</b> in the above output. You may see only
the CPU is listed, or both the CPU and the integrated GPU.
=== # Step 5. Run a trial simulation ==
If your above GPU query was successful, you should now see in the middle panel
of the MCXStudio window, under the Section entitled "GPU Settings", in a check-box
list under "Run MCX on", you should now see the available devices on your laptop.
To avoid running lengthy simulations, please change the <u>"Total photon number (-n)"</u>
field under the <u>"Basic Settings"</u> from <tt>1e6</tt> to <tt>1e5</tt>.
Now, you can then run a trial simulation, by first clicking on the "Validate"
button (blue check-mark icon), and then click on "Run" (the button to the
right of validate). This will launch an MCXCL simulation. The output window
will show again, and you can see the messages printed from the simulation,
similar to the output below
<pre>"-- Command: --"
mcxcl --session "preptest" --input "/drives/taote1/users/fangq/Download/MCXStudio/Output/mcxclsessions/preptest/preptest.json" --root "/drives/taote1/users/fangq/Download/MCXStudio/Output/mcxclsessions/preptest" --outputformat mc2 --gpu 10 --autopilot 1 --photon 10000000 --normalize 1 --save2pt 1 --reflect 1 --savedet 1 --unitinmm 1.00 --saveseed 0 --seed "1648335518" --compileropt "-D USE_ATOMIC" --array 0 --dumpmask 0 --repeat 1 --maxdetphoton 10000000
"-- Executing Simulation --"
==============================================================================
= Monte Carlo eXtreme (MCX) -- OpenCL =
= Copyright (c) 2010-2025 Qianqian Fang <q.fang at neu.edu> =
= https://mcx.space/ & https://neurojson.io =
= =
= Computational Optics&Translational Imaging (COTI) Lab - http://fanglab.org =
= Department of Bioengineering, Northeastern University, Boston, MA, USA =
==============================================================================
= The MCX Project is funded by the NIH/NIGMS under grant R01-GM114365 =
==============================================================================
= Open-source codes and reusable scientific data are essential for research, =
= MCX proudly developed human-readable JSON-based data formats for easy reuse=
= =
=Please visit our free scientific data sharing portal at https://neurojson.io=
= and consider sharing your public datasets in standardized JSON/JData format=
==============================================================================
$Rev::4fdc45 $ v2025 $Date::2018-03-29 00:35:53 -04$by $Author::Qianqian Fang$
==============================================================================
- variant name: [Detective MCXCL] compiled with OpenCL version [1]
- compiled with: [RNG] Logistic-Lattice [Seed Length] 5
initializing streams ... init complete : 0 ms
Building kernel with option: -cl-mad-enable -DMCX_USE_NATIVE -DMCX_SIMPLIFY_BRANCH -DMCX_VECTOR_INDEX -DMCX_SRC_PENCIL -D USE_ATOMIC -DUSE_ATOMIC -D MCX_SAVE_DETECTORS -D MCX_DO_REFLECTION
build program complete : 23 ms
- [device 0(1): Graphics Device] threadph=15 oddphotons=169600 np=10000000.0 nthread=655360 nblock=64 repetition=1
set kernel arguments complete : 23 ms
lauching mcx_main_loop for time window [0.0ns 5.0ns] ...
simulation run# 1 ...
kernel complete: 796 ms
retrieving flux ...
detected 0 photons, total: 0 transfer complete: 818 ms
normalizing raw data ... normalization factor alpha=20.000000
saving data to file ... 216000 1 saving data complete : 821 ms
simulated 10000000 photons (10000000) with 1 devices (repeat x1)
MCX simulation speed: 12953.37 photon/ms
total simulated energy: 10000000.00 absorbed: 27.22654%
(loss due to initial specular reflection is excluded in the total)
</pre>
If this simulation is completed successfully, you should be able to see the
"Simulation speed" and total simulated energy reported at the end. Please
verify your "absorbed" percentage value printed at the end (in bold above),
and make sure it is '''~27%'''. We found that some Intel OpenCL library
versions produced incorrect results.
If your laptop shows an error for the Intel GPU, please choose another
device from the "GPU Settings" section, and run the simulation again.
If your GPU/CPU gives the below error (found on HD4400 GPU and 4th gen Intel CPUs)
error: OpenCL extension 'cl_khr_fp64' is unsupported
MCXCL ERROR(11):Error: Failed to build program executable! in unit mcx_host.cpp:510
You may add
-J "-DUSE_LL5_RAND"
in the <tt>MCXStudio GUI</tt>\<tt>Advanced Settings</tt>\<tt>Additional Parameters</tt>
field. This should allow it to run, but please verify the absorption fraction
is ~27%. For 4th generation Intel CPU, we found that install the Intel CPU
OpenCL run-time can produce correct simulations. Please download it from here
https://software.intel.com/en-us/articles/opencl-drivers#latest_CPU_runtime
=== # Step 6. Test MATLAB for visualization ==
From v2019.3, MCXStudio provides builtin 3D volume visualization, this step is no longer needed.
=== # Step 7. Setting up MATLAB search path ==
The next step is to set up the search paths for MCXLAB/MMCLAB. You need to
start MATLAB, and in the Command window, please type
pathtool
this will popup a window. Click on the "Add with Subfolders ..." button
(the 2nd from the top), then browse the MCXStudio folder, then select
OK. Now you should see all needed MCX/MMC paths are added to MATLAB.
Before you quick this window, click on the "Save" button.
To verify if your MCXLAB/MMCLAB/MCXLABCL has been installed properly, please type
which mcxlab
which mmclab
which mcxlabcl
you should see their full paths printed.
To see if you can run MCXLAB-CL in your environment, please type
USE_MCXCL=1 ''%define this line in the base workspace, all subsequent mcxlab calls will use mcxcl''
info=mcxlab('gpuinfo')
clear USE_MCXCL
this should print a list of CPU/GPU devices using which you can run the MC simulations.
upload:matlab_gpu_verify.png
If you do not see any output, that means your CPU/GPU OpenCL driver was not installed
properly, you need to go back to Steps 1-2.
If you have an NVIDIA GPU, and have installed the proper GPU driver, you may run
info=mcxlab('gpuinfo') % notice the command is mcxlab instead of mcxlabcl
this should print a list of NVIDIA GPU from the MATLAB window.
---------------------------------------------------------------------------
== # Running Simulations ==
To run a simulation, the minimum input is a configuration (text) file,
and a volume (a binary file with each byte representing a medium
index). Typing the name of the executable without any parameters,
will print the help information and a list of supported parameters,
such as the following:
<pre>==============================================================================
= Monte Carlo eXtreme (MCX) -- OpenCL =
= Copyright (c) 2010-2025 Qianqian Fang <q.fang at neu.edu> =
= https://mcx.space/ & https://neurojson.io =
= =
= Computational Optics&Translational Imaging (COTI) Lab - http://fanglab.org =
= Department of Bioengineering, Northeastern University, Boston, MA, USA =
==============================================================================
= The MCX Project is funded by the NIH/NIGMS under grant R01-GM114365 =
==============================================================================
= Open-source codes and reusable scientific data are essential for research, =
= MCX proudly developed human-readable JSON-based data formats for easy reuse=
= =
=Please visit our free scientific data sharing portal at https://neurojson.io=
= and consider sharing your public datasets in standardized JSON/JData format=
==============================================================================
$Rev::4fdc45 $ v2025 $Date::2018-03-29 00:35:53 -04$by $Author::Qianqian Fang$
==============================================================================
usage: mcxcl <param1> <param2> ...
where possible parameters include (the first value in [*|*] is the default)
== Required option ==
-f config.json (--input) read an input file in the .json format,if config
string starts with '{',it is parsed as an inline
JSON input file; if -f is followed by nothing or
a single '-', it reads input from stdin via pipe
or
-Q/--bench [cube60, skinvessel,...] run a buint-in benchmark specified by name
run -Q without parameter to get a list
-N benchmark (--net) get benchmark from NeuroJSON.io, -N only to list
benchmark can be dataset URL,or dbname/benchname
requires 'curl', install from https://curl.se/
== MC options ==
-n [0|int] (--photon) total photon number (exponential form accepted)
-r [1|+/-int] (--repeat) if positive, repeat by r times,total= #photon*r
if negative, divide #photon into r subsets
-b [1|0] (--reflect) 1 to reflect photons at ext. boundary;0 to exit
-B '______' (--bc) per-face boundary condition (BC), 6 letters for
/case insensitive/ bounding box faces at -x,-y,-z,+x,+y,+z axes;
overwrite -b if given.
each letter can be one of the following:
'_': undefined, fallback to -b
'r': like -b 1, Fresnel reflection BC
'a': like -b 0, total absorption BC
'm': mirror or total reflection BC
'c': cyclic BC, enter from opposite face
if input contains additional 6 letters,
the 7th-12th letters can be:
'0': do not use this face to detect photon, or
'1': use this face for photon detection (-d 1)
the order of the faces for letters 7-12 is
the same as the first 6 letters
eg: --bc ______010 saves photons exiting at y=0
-u [1.|float] (--unitinmm) defines the length unit for the grid edge
-U [1|0] (--normalize) 1 to normalize flux to unitary; 0 save raw
-E [0|int|.jdat] (--seed) set random-number-generator seed, -1 to generate
if a jdat/mch file is followed, MCX "replays"
the detected photon; the replay mode can be used
to calculate the mua/mus Jacobian matrices
-z [0|1] (--srcfrom0) 1 volume origin is [0 0 0]; 0: origin at [1 1 1]
-Y [0|int] (--replaydet) replay only the detected photons from a given
detector (det ID starts from 1), used with -E
if 0, replay all detectors and sum all Jacobians
if -1, replay all detectors and save separately
-V [0|1] (--specular) 1 source located in the background,0 inside mesh
-e [0.|float] (--minenergy) minimum energy level to trigger Russian roulette
-g [1|int] (--gategroup) number of maximum time gates per run
== GPU options ==
-L (--listgpu) print GPU information only
-t [16384|int](--thread) total thread number
-T [64|int] (--blocksize) thread number per block
-A [1|int] (--autopilot) auto thread config:1 enable;0 disable
-G [0|int] (--gpu) specify which GPU to use, list GPU by -L; 0 auto
or
-G '1101' (--gpu) using multiple devices (1 enable, 0 disable)
-W '50,30,20' (--workload) workload for active devices; normalized by sum
-I (--printgpu) print GPU information and run program
-o [1|int] (--optlevel) optimization level 0-no opt;1-4 more optimized
-J '-DMACRO' (--compileropt) specify additional JIT compiler options
A few built-in preprocessors include
-DMCX_GPU_DEBUG - print step-by-step debug info
-k my_simu.cl (--kernel) user specified OpenCL kernel source file
== Input options ==
-P '{...}' (--shapes) a JSON string for additional shapes in the grid.
only the root object named 'Shapes' is parsed
and added to the existing domain defined via -f
or --bench
-j '{...}' (--json) a JSON string for modifying all input settings.
this input can be used to modify all existing
settings defined by -f or --bench
-K [1|int|str](--mediabyte) volume data format, use either a number or a str
voxel binary data layouts are shown in {...}, where [] for byte,[i:]
for 4-byte integer, [s:] for 2-byte short, [h:] for 2-byte half float,
[f:] for 4-byte float; on Little-Endian systems, least-sig. bit on left
1 or byte: 0-128 tissue labels
2 or short: 0-65535 (max to 4000) tissue labels
4 or integer: integer tissue labels
98 or mixlabel: label1+label2+label1_percentage
{[label1][label2][s:0-32767 label1 percentage]}
99 or labelplus: 32bit composite voxel format
{[h:mua/mus/g/n][s:(B15-16:0/1/2/3)(label)]}
100 or muamus_float: 2x 32bit floats for mua/mus
{[f:mua][f:mus]}; g/n from medium type 1
101 or mua_float: 1 float per voxel for mua
{[f:mua]}; mus/g/n from medium type 1
102 or muamus_half: 2x 16bit float for mua/mus
{[h:mua][h:mus]}; g/n from medium type 1
103 or asgn_byte: 4x byte gray-levels for mua/s/g/n
{[mua][mus][g][n]}; 0-255 mixing prop types 1&2
104 or muamus_short: 2x short gray-levels for mua/s
{[s:mua][s:mus]}; 0-65535 mixing prop types 1&2
when formats 99 or 102 is used, the mua/mus values in the input volume
binary data must be pre-scaled by voxel size (unitinmm) if it is not 1.
pre-scaling is not needed when using these 2 formats in mcxlab/pmcx
-a [0|1] (--array) 1 for C array (row-major); 0 for Matlab array
== Output options ==
-s sessionid (--session) a string to label all output file names
-O [X|XFEJPML](--outputtype) X - output flux, F - fluence, E - energy density
J - Jacobian (replay mode), P - scattering
event counts at each voxel (replay mode only)
M - momentum transfer; L - total pathlength
-d [1|0-3] (--savedet) 1 to save photon info at detectors; 0 not save
2 reserved, 3 terminate simulation when detected
photon buffer is filled
-w [DP|DSPMXVW](--savedetflag)a string controlling detected photon data fields
/case insensitive/ 1 D output detector ID (1)
2 S output partial scat. even counts (#media)
4 P output partial path-lengths (#media)
8 M output momentum transfer (#media)
16 X output exit position (3)
32 V output exit direction (3)
64 W output initial weight (1)
combine multiple items by using a string, or add selected numbers together
by default, mcx only saves detector ID and partial-path data
-x [0|1] (--saveexit) 1 to save photon exit positions and directions
setting -x to 1 also implies setting '-d' to 1
same as adding 'XV' to -w.
-X [0|1] (--saveref) 1 to save diffuse reflectance at the air-voxels
right outside of the domain; if non-zero voxels
appear at the boundary, pad 0s before using -X
-m [0|1] (--momentum) 1 to save photon momentum transfer,0 not to save.
same as adding 'M' to the -w flag
-q [0|1] (--saveseed) 1 to save photon RNG seed for replay; 0 not save
-M [0|1] (--dumpmask) 1 to dump detector volume masks; 0 do not save
-H [1000000] (--maxdetphoton) max number of detected photons
-S [1|0] (--save2pt) 1 to save the flux field; 0 do not save
-F [jnii|...](--outputformat) fluence data output format:
mc2 - MCX mc2 format (binary 32bit float)
jnii - JNIfTI format (https://neurojson.org)
bnii - Binary JNIfTI (https://neurojson.org)
nii - NIfTI format
hdr - Analyze 7.5 hdr/img format
tx3 - GL texture data for rendering (GL_RGBA32F)
the bnii/jnii formats support compression (-Z) and generate small files
load jnii (JSON) and bnii (UBJSON) files using below lightweight libs:
MATLAB/Octave: JNIfTI toolbox https://github.com/NeuroJSON/jnifti,
MATLAB/Octave: JSONLab toolbox https://github.com/NeuroJSON/jsonlab,
Python: PyJData: https://pypi.org/project/jdata
JavaScript: JSData: https://github.com/NeuroJSON/jsdata
-Z [zlib|...] (--zip) set compression method if -F jnii or --dumpjson
is used (when saving data to JSON/JNIfTI format)
0 zlib: zip format (moderate compression,fast)
1 gzip: gzip format (compatible with *.gz)
2 base64: base64 encoding with no compression
3 lzip: lzip format (high compression,very slow)
4 lzma: lzma format (high compression,very slow)
5 lz4: LZ4 format (low compression,extrem. fast)
6 lz4hc: LZ4HC format (moderate compression,fast)
--dumpjson [-,0,1,'file.json'] export all settings,including volume data using
JSON/JData (https://neurojson.org) format for
easy sharing; can be reused using -f
if followed by nothing or '-', mcx will print
the JSON to the console; write to a file if file
name is specified; by default, prints settings
after pre-processing; '--dumpjson 2' prints
raw inputs before pre-processing
== User IO options ==
-h (--help) print this message
-v (--version) print MCX revision number
-l (--log) print messages to a log file instead
-i (--interactive) interactive mode
== Debug options ==
-D [0|int] (--debug) print debug information (you can use an integer
or or a string by combining the following flags)
-D [''|RMPT] 1 R debug RNG
/case insensitive/ 2 M store photon trajectory info
4 P print progress bar
8 T save trajectory data only, disable flux/detp
combine multiple items by using a string, or add selected numbers together
== Additional options ==
--atomic [1|0] 1: use atomic operations; 0: do not use atomics
--voidtime [1|0] when src is outside, 1 enables timer inside void
--showkernel [1|0] 1:display the default or loaded (-k) MCXCL kernel
--root [''|string] full path to the folder storing the input files
--internalsrc [0|1] set to 1 to skip entry search to speedup launch
--gscatter [1e9|int] after a photon completes the specified number of
scattering events, mcx then ignores anisotropy g
and only performs isotropic scattering for speed
--maxvoidstep [1000|int] maximum distance (in voxel unit) of a photon that
can travel before entering the domain, if
launched outside (i.e. a widefield source)
--maxjumpdebug [10000000|int] when trajectory is requested (i.e. -D M),
use this parameter to set the maximum positions
stored (default: 1e7)
== Example ==
example: (list built-in benchmarks: -Q/--bench)
mcxcl -Q
or (list supported GPUs on the system: -L/--listgpu)
mcxcl -L
or (use multiple devices - 1st,2nd and 4th GPUs - together with equal load)
mcxcl -Q cube60b -n 1e7 -G 1101 -W 10,10,10
or (use inline domain definition)
mcxcl -f input.json -P '{"Shapes":[{"ZLayers":[[1,10,1],[11,30,2],[31,60,3]]}]}'
or (use inline json setting modifier)
mcxcl -f input.json -j '{"Optode":{"Source":{"Type":"isotropic"}}}'
or (dump simulation in a single json file)
mcxcl -Q cube60planar --dumpjson
or (use -N/--net to browse community-contributed mcxcl simulations at https://neurojson.io)
mcxcl -N
or (run user-shared mcxcl simulations, see full list at https://neurojson.org/db/mcx)
mcxcl -N aircube60
or (use -f - to read piped input file modified by shell text processing utilities)
mcxcl -Q cube60 --dumpjson | sed -e 's/pencil/cone/g' | mcxcl -f -
or (download/modify simulations from NeuroJSON.io and run with mcxcl -f)
curl -s -X GET https://neurojson.io:7777/mcx/aircube60 | jq '.Forward.Dt = 1e-9' | mcxcl -f
</pre>
To further illustrate the command line options, below one can find a sample command
mcxcl -A 0 -t 16384 -T 64 -n 1e7 -G 1 -f input.json -r 2 -s test -g 10 -d 1 -w dpx -b 1
the command above asks mcxcl to manually (`-A 0`) set GPU threads, and launch 16384
GPU threads (`-t`) with every 64 threads a block (`-T`); a total of 1e7 photons (`-n`)
are simulated by the first GPU (`-G 1`) and repeat twice (`-r`) - i.e. total 2e7 photons;
the media/source configuration will be read from a JSON file named `input.json`
(`-f`) and the output will be labeled with the session id “test” (`-s`); the
simulation will run 10 concurrent time gates (`-g`) if the GPU memory can not
simulate all desired time gates at once. Photons passing through the defined
detector positions are saved for later rescaling (`-d`); refractive index
mismatch is considered at media boundaries (`-b`).
Historically, MCXCL supports an extended version of the input file format (.inp)
used by tMCimg. However, we are phasing out the .inp support and strongly
encourage users to adopt JSON formatted (.json) input files. Many of the
advanced MCX options are only supported in the JSON input format.
<pre>
1000000 # total photon, use -n to overwrite in the command line
29012392 # RNG seed, negative to generate, use -E to overwrite
30.0 30.0 0.0 1 # source position (in grid unit), the last num (optional) sets --srcfrom0 (-z)
0 0 1 0 # initial directional vector, 4th number is the focal-length, 0 for collimated beam, nan for isotropic
0.e+00 1.e-09 1.e-10 # time-gates(s): start, end, step
semi60x60x60.bin # volume ('unsigned char' binary format, or specified by -K/--mediabyte)
1 60 1 60 # x voxel size in mm (isotropic only), dim, start/end indices
1 60 1 60 # y voxel size, must be same as x, dim, start/end indices
1 60 1 60 # y voxel size, must be same as x, dim, start/end indices
1 # num of media
1.010101 0.01 0.005 1.37 # scat. mus (1/mm), g, mua (1/mm), n
4 1.0 # detector number and default radius (in grid unit)
30.0 20.0 0.0 2.0 # detector 1 position (real numbers in grid unit) and individual radius (optional)
30.0 40.0 0.0 # ..., if individual radius is ignored, MCX will use the default radius
20.0 30.0 0.0 #
40.0 30.0 0.0 #
pencil # source type (optional)
0 0 0 0 # parameters (4 floats) for the selected source
0 0 0 0 # additional source parameters
</pre>
Note that the scattering coefficient mus=musp/(1-g).
The volume file (`semi60x60x60.bin` in the above example), can be read in two
ways by MCX: row-major[3] or column-major depending on the value of the user
parameter `-a`. If the volume file was saved using matlab or fortran, the
byte order is column-major, and you should use `-a 0` or leave it out of
the command line. If it was saved using the `fwrite()` in C, the order is
row-major, and you can either use `-a 1`.
You may replace the binary volume file by a JSON-formatted shape file. Please
refer to Section V for details.
The time gate parameter is specified by three numbers:
start time, end time and time step size (in seconds). In
the above example, the configuration specifies a total time
window of [0 1] ns, with a 0.1 ns resolution. That means the
total number of time gates is 10.
MCXCL provides an advanced option, -g, to run simulations when
the GPU memory is limited. It specifies how many time gates to simulate
concurrently. Users may want to limit that number to less than
the total number specified in the input file - and by default
it runs one gate at a time in a single simulation. But if there's
enough memory based on the memory requirement in Section II, you can
simulate all 10 time gates (from the above example) concurrently by using
"-g 10" in which case you have to make sure the video card has at least
60*60*60*10*5=10MB of free memory. If you do not include the -g,
MCX will assume you want to simulate just 1 time gate at a time..
If you specify a time-gate number greater than the total number in the
input file, (e.g, "-g 20") MCX will stop when the 10 time-gates are
completed. If you use the autopilot mode (-A), then the time-gates
are automatically estimated for you.
---------------------------------------------------------------------------
== # Using JSON-formatted input files ==
Starting from version 0.7.9, MCX accepts a JSON-formatted input file in
addition to the conventional tMCimg-like input format. JSON (JavaScript Object
Notation) is a portable, human-readable and “fat-free” text format to
represent complex and hierarchical data. Using the JSON format makes a input
file self-explanatory, extensible and easy-to-interface with other applications
(like MATLAB).
A sample JSON input file can be found under the examples/quicktest folder. The
same file, `qtest.json`, is also shown below:
<pre>
{
"Help": {
"[en]": {
"Domain::VolumeFile": "file full path to the volume description file, can be a binary or JSON file",
"Domain::Dim": "dimension of the data array stored in the volume file",
"Domain::OriginType": "similar to --srcfrom0, 1 if the origin is [0 0 0], 0 if it is [1.0,1.0,1.0]",
"Domain::LengthUnit": "define the voxel length in mm, similar to --unitinmm",
"Domain::Media": "the first medium is always assigned to voxels with a value of 0 or outside of
the volume, the second row is for medium type 1, and so on. mua and mus must
be in 1/mm unit",
"Session::Photons": "if -n is not specified in the command line, this defines the total photon number",
"Session::ID": "if -s is not specified in the command line, this defines the output file name stub",
"Forward::T0": "the start time of the simulation, in seconds",
"Forward::T1": "the end time of the simulation, in seconds",
"Forward::Dt": "the width of each time window, in seconds",
"Optode::Source::Pos": "the grid position of the source, can be non-integers, in grid unit",
"Optode::Detector::Pos": "the grid position of a detector, can be non-integers, in grid unit",
"Optode::Source::Dir": "the unitary directional vector of the photon at launch",
"Optode::Source::Type": "source types, must be one of the following:
pencil,isotropic,cone,gaussian,planar,pattern,fourier,arcsine,disk,fourierx,fourierx2d,
zgaussian,line,slit,pencilarray,pattern3d",
"Optode::Source::Param1": "source parameters, 4 floating-point numbers",
"Optode::Source::Param2": "additional source parameters, 4 floating-point numbers"
}
},
"Domain": {
"VolumeFile": "semi60x60x60.bin",
"Dim": [60,60,60],
"OriginType": 1,
"LengthUnit": 1,
"Media": [
{"mua": 0.00, "mus": 0.0, "g": 1.00, "n": 1.0},
{"mua": 0.005,"mus": 1.0, "g": 0.01, "n": 1.0}
]
},
"Session": {
"Photons": 1000000,
"RNGSeed": 29012392,
"ID": "qtest"
},
"Forward": {