Hi,
I am currently trying to simulate a simplified skin model consisting of two tissue layers (epidermis and dermis).
My goal is to measure the reflected photons using a detector in order to estimate the "color" of the tissue.
For this purpose, I run 3 separate simulations for three wavelengths (R, G, B), and for each wavelength I simulate two different “"lood levels" by modifying the optical properties of the dermis.
However, I am running into two issues:
1. Photons do not seem to reach the second layer (dermis)
Although the geometry appears correct, the detector shows no photons in ppath entering the second layer.
I have verified the mesh and layer definitions, but I may still be missing something.
hi Jonas,
first, your code could not be copied and executed, because of unexpected line wraps. I had to make multiple edits in order to run some of it.
Going over your code, I found two problems, one is related to mmc, one is related to your cfg setting.
first, I noticed that mmc currently disables cfg.unitinmm if running on the GPU. Without the scaling of unitinmm, the epidermis layer is over 10 mm long and it is extremely rare for photon to pass to the 2nd layer.
more specifically, it disables cfg.unitinmm when using DMMC (dual-grid MMC, which output the fluence as a 3D array like mcx), which is the default on the GPU. I can't remember why this was disabled, likely because it could accidentally cause excessive memory allocation and cause crash.
for this issue, I created a new issue on github (https://github.com/fangq/mmc/issues/117) and was able to fix it with this patch
https://github.com/fangq/mmc/commit/2a58c43376d5c6700a56a33ace67ca852831b30f
secondly, I noticed a bigger problem is that you used a distributed/widefield source (srctype='disk') without applying mesh re-tessellation. It crashes matlab.
a disk source, like planar/pattern, launches photons from distributed locations. when a photon is launched at a different location, the index of the enclosing element is different. Handling such source is significantly more complex compared to a point source (pencil, isotropic, cone). We had to do an extra step, called mesh re-tessellation to modify the mesh in order to ensure the entire source area is enclosed inside a single tetrahedron. The details of this method is described in our paper
https://www.osapublishing.org/boe/abstract.cfm?uri=boe-7-1-171
see a similar discussion on this:
https://groups.google.com/g/mmc-users/c/__1qBrhYsAg/m/RXsZk6zBAQAJ
Qianqian
You don't often get email from jonas.k...@gmail.com. Learn why this is important
--
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 visit https://groups.google.com/d/msgid/mcx-users/c2a53a9c-7724-44ca-804e-e70b9e102de7n%40googlegroups.com.
2. Detector output structure [flux, det] = mmclab(cfg);
I am unsure how to interpret the fields inside det.data.
What exactly does det.data contain (detector_id, weight?, path lengths in the tissue?)?
just to answer your 2nd question:
yes, det.data is the concatenation of the other fields in the det struct, please see the format in this section of the help info
https://github.com/fangq/mmc/blob/v2025.10/mmclab/mmclab.m#L201-L213
however, you are not recommended to use det.data.
It is the raw output, and is sbsequently split into individual det subfields cast to the proper data types. you should use the split data struct.
You don't often get email from jonas.k...@gmail.com. Learn why this is important
hi Jonas,
have you tried the github action build at this link?
https://mcx.space/nightly/github/
on github, we have set up automated workflows to build and upload all mcx/mcxcl/mmc packages after every commit. if the build is successful, the binaries will appear in the above URL (the most recent build is successful: see log https://github.com/fangq/mmc/actions/runs/20120905394/job/57740644891).
if you want to build it on your own machine, you need to first install MinGW-w64 compiler as matlab suggested, and run mex -setup C and configure your matlab to use this compiler.
if there is a previously installed mingw gcc (via mingw64 or cygwin64), you can set an environment variable MW_MINGW64_LOC to point to its path
please see our github action script on how to setup dependencies and run compilation on github provided virtual machines (i.e. "runners")
https://github.com/fangq/mmc/blob/master/.github/workflows/build_all.yml
just search for all sections that is labeled for Windows, including
https://github.com/fangq/mmc/blob/master/.github/workflows/build_all.yml#L54-L80
https://github.com/fangq/mmc/blob/master/.github/workflows/build_all.yml#L118-L136
Qianqian
To view this discussion visit https://groups.google.com/d/msgid/mcx-users/5018ffab-29ee-4a47-9100-bc7d70b08ecdn%40googlegroups.com.