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