Reflectance Calculation in PMCX

135 views
Skip to first unread message

Shiru Wang

unread,
Feb 13, 2025, 3:53:24 PMFeb 13
to mcx-users
Hi Dr.Fang,

I hope this email finds you well. First, I wanted to express my appreciation for PMCX - it's proving to be a valuable tool for our work.

I'm encountering some challenges while using PMCX to simulate and calculate time-resolved surface reflectance (backscattered photons) of a geometry using a planar source. After reviewing the intensity curve over time in my simulation results, I have concerns about potential issues in my approach. I would greatly appreciate your guidance on two specific questions:
1. Where the source should be located? Should the source start at the air layer above the defined volume or should it start at the top of the volume?
2. Could you clarify how to determine the photon termination point? Specifically, I'm uncertain whether to look for a label value of 0 or optical property [0 0 1 1].

It would be great if there's a demo that we could look into. Hope to get your reply and thanks for the help!

Best,
Shiru

Qianqian Fang

unread,
Feb 13, 2025, 4:35:26 PMFeb 13
to mcx-...@googlegroups.com, Shiru Wang

hi Shiru,

see my replies below


On 2/13/25 15:53, Shiru Wang wrote:
Hi Dr.Fang,

I hope this email finds you well. First, I wanted to express my appreciation for PMCX - it's proving to be a valuable tool for our work.

I'm encountering some challenges while using PMCX to simulate and calculate time-resolved surface reflectance (backscattered photons) of a geometry using a planar source. After reviewing the intensity curve over time in my simulation results, I have concerns about potential issues in my approach. I would greatly appreciate your guidance on two specific questions:
1. Where the source should be located? Should the source start at the air layer above the defined volume or should it start at the top of the volume?


either way is ok - when a photon is launched outside of the volume (we call it a wide-field source), mcx performs an initial propagation to advance it to the first non-zero voxel, then start propagating it based on the optical properties. The space outside of the volume, as well as 0-valued voxels are defined as cfg.prop(1,:), which is by default mua=0/mus=0/g=1/n=1, simulating air.

If your source is collimated, pulling it back along the launch direction won't change the final solution, although it adds a slight overhead due to the initial ray-tracing.

I do want to add two details

1. cfg.voidtime flag controls whether the photon's travel time includes the time traveling before entering the first non-zero voxel, by default (cfg.voidtime=1), the timer starts when a photon is launched; if set to 0, the timer starts when it enters the first non-zero voxel

https://github.com/fangq/mcx/blob/v2024.2/mcxlab/mcxlab.m#L270


2. cfg.isspecular flag controls whether a photon's initial weight is reduced when entering from air to the first non-zero voxel, by default (cfg.isspecular=0) does not reduce the initial weight (i.e. w0=1 when entering the volume), if set to 0, it reduces based on 1-specular-reflection = transmission using the angle/optical properties of the interface of the voxel.


2. Could you clarify how to determine the photon termination point? Specifically, I'm uncertain whether to look for a label value of 0 or optical property [0 0 1 1].


a photon is terminated by one of the 4 conditions

1. moving from a non-zero voxel to a zero-voxel

2. transmitting through the exterior bounding box of the volume, and

3. total travel time exceeds cfg.tend

4. if cfg.minenergy is defined, a photon is terminated if it does not survive the Russian roulette after its weight drops below cfg.minenergy


for your question, it uses the label instead of optical properties to terminate. this is why when you simulate a cavity, you should set the voxels in the cavity to a non-zero label with air properties instead of setting it to 0.

let me know if this is clear


Qianqian



It would be great if there's a demo that we could look into. Hope to get your reply and thanks for the help!

Best,
Shiru
--
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/15e8f0d9-3ea3-4325-90c5-e696d164c4b6n%40googlegroups.com.
Message has been deleted

Qianqian Fang

unread,
Feb 19, 2025, 10:30:13 AMFeb 19
to mcx-...@googlegroups.com, Shiru Wang

hi Shiru,

the diffuse reflectance output is accumulated by tracking photon packets that escape from the desired surface, there is no need to manually track those.

unless you need to estimate something that is exiting-angle-dependent, then you should save the photon's exiting direction using the cfg.bc flag, and do this calculation manually. otherwise, diffuse reflectance (accumulating escape weights regardless of exiting direction) is sufficient for most purposes.


by the way, diffuse reflectance can only be saved in the 0-valued voxels immediately outside of the object boundary (non-zero valued voxels), so you must pad a layer of zeros outside of the surface where you want to save it. see example code

https://github.com/fangq/mcx/blob/v2025/mcxlab/mcxlab.m#L401-L402

reading your code, I don't fully understand why you set vol[:,:,0]=3, and read the output from Data[:,:,1]

Qianqian

On 2/17/25 13:47, Shiru Wang wrote:
Hi Dr.Fang,

Thank you for your detailed guidance on the previous discussion. I've been implementing the photon simulation using pmcx following your instructions, and I have another question regarding the surface reflectance calculation.

Currently, I'm estimating the surface reflectance by collecting photon data from the top layer of my geometry. I'm not sure if this could be considered as a reasonable estimation. I wanted to ask your opinion on this approach and whether there might be a more accurate method, such as specifically tracking upward-traveling photons. Attached is my code for the simulation. 

Hope to get your reply. Thanks so much for your time and consideration!

Best,

Shiru

saiei yu

unread,
Mar 6, 2025, 8:25:15 PMMar 6
to mcx-users
你好,我看到了您在咨询求漫反射的问题,我现在也遇到了求漫反射不对的情况,请问你是如何求漫反射率的,是累积flux2.data 的数值吗,除此外我找不到求的方法,如果能得到你的回复那真是太棒了,祝您一切顺利。

Qianqian Fang

unread,
Mar 9, 2025, 6:02:19 PMMar 9
to mcx-...@googlegroups.com

Dear Saiwei,

mcx-users has nearly 400 subscribers from all over the world. While I perfectly fine reading your questions in Chinese, out of the respect to all other subscribed users, please ONLY post questions in English, so everyone understands what you asked about.

If you feel that you can not express your question clearly in English, please feel free to use Google Translate, or email me individually.

Qianqian

--
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.

saiei yu

unread,
Mar 9, 2025, 9:10:15 PMMar 9
to mcx-users

Dear Professor Fang,

First of all, I sincerely apologize. This is my first time posting here, and I am not yet familiar with all the rules. I accidentally posted a letter in Chinese, which may have caused you some inconvenience. I am truly sorry for that.

Additionally, I really appreciate your patience in responding to my question. I will carefully read your reply and follow your guidance to resolve the issue.

Thank you once again.

Best regards,

saiwei

Qianqian Fang

unread,
Mar 10, 2025, 12:03:15 AMMar 10
to mcx-...@googlegroups.com

no worries, I hope my response to your question earlier was helpful - feel free to follow up if you have any additional questions.

Reply all
Reply to author
Forward
0 new messages