hi Bastiaan,
in a way, yes, it was already supported, but you will have to do
some extra work to "repack"
the 8-byte voxel records generated by mcxsvmc.m into 2x
4-byte segments, which is the voxel format used internally by
mcx's GPU kernel.
I just committed two patches to avoid this manual step, so you
can directly use the volume created by mcxsvmc.m (cast to uint8)
https://github.com/fangq/mcx/commit/de9850c1bf32750f03de061ef4a86a3e0f64a80f
https://github.com/fangq/mcx/commit/4010d99f85084fdfc834f1c61e592d1065953d26
here are the two needed steps:
1. create the SVMC formatted volume (8-byte per voxel, see Fig. 2g of the svmc paper) using mcxsvmc.m, cast the volume to uint8(), and write it to a .bin file (use fopen/fwrite/fclose in matlab), then set the .bin file as the volume input file in the JSON input, under Domain.VolumeFile
2. when running mcx, you need to tell mcx you are using the svmc 8-byte volume format by attaching -K svmc or --mediabyte svmc, or replace svmc by 97, where identifier 97 is defined here
https://github.com/fangq/mcx/blob/master/src/mcx_const.h#L62
I just recompiled mcx nightly builds after these two patches, let
me know if this works for you.
Qianqian
Cheers,
Bastiaan--
You received this message because you are subscribed to the Google Groups "mcx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mcx-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/bafdfd32-f1db-4681-9ed0-cac21f4eeb6fn%40googlegroups.com.
hi Bastiaan,
I made additional commits and testing and now svmc is supported
in the command line.
I also added an example
https://github.com/fangq/mcx/tree/master/example/svmcsphshells
let me know if you are able to run this example.
Qianqian
Hi Qianqian,
I'm heaving some problems with the nightly build version that I've downloaded to use the split-voxel algorithm with json input files.1) No photons are detected, although a detector is included that detects photons when running a the voxel based algorithm2) when using a pencil beam, no photons are detected.
Below the matlab scripts that I use to generate the input files and run the simulation. I think I followed your instructions above correctly however the program is not behaving as I am expecting. If you have time, could you comment on this?
hi Bastiaan,
it looks like you used matlab to create the .json file and run mcx from the command line.
does this happen when you define the problem using mcxlab cfg data structure (instead of saving as json)? I am CCing my student Shijie, who implemented the svmc feature. From what I can tell, the detector processing in an SVMC volume was handled properly in our code.
if mcxlab does work, but .json does not, please send me your .json file so I can test (can not run your script because of local folders).
Qianqian
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/011e8982-050a-4029-9a98-f031e9cfb8dfn%40googlegroups.com.
Hi Qianqian,
With mcxlab I can run the examples and I can also my own simulations.
just to clarify - your simulation did return detected photons when you run it in mcxlab?
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/5b7dbd21-5f6c-49f3-8370-21728d43100dn%40googlegroups.com.
Hi Qianqian,
Do you also see similar problems with the split voxel nightly build version?
hi Bastiaan,
I spent a bit time yesterday looking into this issue, and I was able to reproduce both problems - a memory error, and then a cuda device busy message after an CUDA error.
the memory error appears in both mcxlab and command line, despite sometimes mcxlab did not crash. by adding -d 0, I traced the the issue to invalid lower/upper labels in the svmc data (max label # is 2, but the labels read is over 120).
I plan to do more debugging today to hopefully come up with a fix. stay tuned.
Qianqian
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/6af1e763-0800-473b-9bd4-29553e9b3962n%40googlegroups.com.
Hi Qianqian,
Any updates on the split voxel algorithm?
hi Bstiaan,
I am CCing my student Shijie - we spent a couple of hours on zoom
discussing this last weekend and had some confusing findings -
basically, running the script testSVMCbloodvesselMCXLAB.m in
matlab as well as using the mcx2json_bf.m exported .json file in
the command line results in no memory errors. However, running
another script testSVMCbloodvesselMCXLAB2.m on one of my machines
consistently raised a memory error in my user account, but not in
Shijie's account - we are not entirely sure why this was the case.
on the other side, we do see that the svmc method does not detect photons, shijie is currently working on debugging this issue.
I am attaching my related files.
can you let me know what are the results running these two
testSVMCbloodvessel scripts on your machine? do they have memory
errors or not?
Qianqian
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/1a362a9d-0966-4013-b70c-bb7babc72d43n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/PH0PR06MB71412766AC27EDDEEC505FAD9CEC9%40PH0PR06MB7141.namprd06.prod.outlook.com.
hi Shijie, can you take a look?
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/8b0be6c0-93d4-4e65-88d7-50d52bc96056n%40googlegroups.com.
Thanks a lot!
When will it be merged so I can download the nightly-build?
already done and should be in the nightly built packages.
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/2ec4fa9b-5e69-484a-b983-85b20e463e30n%40googlegroups.com.
hi Bastiaan,
I haven't tried it myself, but I assume the recent pybind-based pymcx module contributed by Matin should work with svmc, see
https://github.com/fangq/mcx/pull/149
the interface is nearly identical to mcxlab, you use
numpy.ndarray or array.array to define all 3D arrays. for svmc, I
assume it also accept 8-byte-per-voxel volumes
https://github.com/fangq/mcx/blob/master/src/pymcx.cpp#L123-L133
I haven't added documentation to this "official" python interface, but you can see the commands for compilation and running basic simulations in this tweet
CCing Matin in case you have feedback to this module.
Qianqian
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/0432eed2-76d9-4a3f-8f54-d808ad15023dn%40googlegroups.com.
sorry, forgot to attach the link to the tweet with screenshots
https://twitter.com/FangQ/status/1525903673095618560
https://pbs.twimg.com/media/FS0ZSMyXEAEMPdF?format=png&name=4096x4096

python -m pip install matlabengine
I was able to prove functionality with:
import matlab.engine
eng = matlab.engine.start_matlab()
tf = eng.isprime(37)
print(tf)
this returns true for me (as it should!)
I don't have matlab.engine on my machine, so I can't test this. But one possible issue I can see is that you are passing on a c-ordererd (row-major) 3D numpy array to matlab (which is FORTRAN- or column-major order) to call mcxsvmc.m, I think this can create problems.
please recreate your vol raw data in the 'F' order and see if that can fix the issue
https://numpy.org/doc/stable/reference/generated/numpy.asfortranarray.html
Qianqian
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/6a5eaf2a-61e4-4764-a019-1f459b669825n%40googlegroups.com.