Units of MCX simulation

20 views
Skip to first unread message

Keyao Zhang

unread,
Aug 18, 2025, 1:03:57 PMAug 18
to mcx-users

Dear Dr. Fang,

I have noticed that in the latest version of MCX Studio, when selecting Energy density in the “output” column, the unit is shown as J/mm³, whereas in your earlier studies (Such as 2019, 2020) it was reported as J/cm³.

I would greatly appreciate your clarification on the following points:

  1. Has the output unit definition changed in recent versions of MCX Studio compared to earlier releases?

  2. Can this unit be interpreted as follows: when the voxel resolution is set to 1 mm × 1 mm × 1 mm, the reported value represents the photon energy deposited within each voxel (in Joules), normalized to a total input energy of 1 J ?

  3. When I use MCXLab with the configuration [cfg.outputtype = 'energy'], does this correspond to the Energy density mode in MCX Studio ,and the unit is set as J/mm³?

Thank you very much for your time and clarification!

Best regards,
keyao zhang

Qianqian Fang

unread,
Aug 18, 2025, 11:17:52 PMAug 18
to mcx-...@googlegroups.com, Keyao Zhang

hi Keyao,

see my replies below


On 8/18/25 04:32, Keyao Zhang wrote:

Dear Dr. Fang,

I have noticed that in the latest version of MCX Studio, when selecting Energy density in the “output” column, the unit is shown as J/mm³, whereas in your earlier studies (Such as 2019, 2020) it was reported as J/cm³.


I am not sure which 2019/2020 papers you referred to here. in some of the our past papers (related to photobiomodulation dosimetry), we convert the default mcx output (1/mm^3) to (1/cm^3) in order to match some of the results in previous publications made by other groups.


I would greatly appreciate your clarification on the following points:

  1. Has the output unit definition changed in recent versions of MCX Studio compared to earlier releases?


no. mcx uses mm as the default length unit since the very first release


  1. Can this unit be interpreted as follows: when the voxel resolution is set to 1 mm × 1 mm × 1 mm, the reported value represents the photon energy deposited within each voxel (in Joules), normalized to a total input energy of 1 J ?


the unit for the `energy` output type is a bit confusing.

it should have been Joule (J) - it means the total accumulated energy deposition in each voxel in Joule

only when the voxel size is 1mm^3 (default), the output coincidentally equals to the energy density - J/mm^3, but this is only valid in this default setting.

when you set the voxel size to a value different from 1mm^3, the energy output becomes dependent on the voxel volume, but still in Joule unit.

I might have mislabled the unit in mcx studio GUI's help info, I will fix that.


  1. When I use MCXLab with the configuration [cfg.outputtype = 'energy'], does this correspond to the Energy density mode in MCX Studio ,and the unit is set as J/mm³?


again, mcx always outputs accumulated energy in each voxel in either mcx studio/mcx binary, or mcxlab. 

energy-density is only coincidental when the voxel size is 1mm^3, and it is not valid when the voxel size differs from 1mm^3.


let me know if this answers your questions.


Qianqian


Thank you very much for your time and clarification!

Best regards,
keyao zhang

--
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/895c653e-b898-4b70-ab86-1715c1e490b1n%40googlegroups.com.

Keyao Zhang

unread,
Aug 20, 2025, 4:02:42 AMAug 20
to mcx-users

Dear Dr. Fang,

Thank you very much for your reply and clarification! This has been extremely helpful for me.

I still have some questions to ask regarding your answer:

1. " when you set the voxel size to a value different from 1mm^3, the energy output becomes dependent on the voxel volume, but still in Joule unit.  "
Can I understand it this way: If I set the voxel size to 0.5mm^3, then the total energy deposition in each voxel should be the MCX output value (assumed to be A (J/mm^3)) multiplied by the numerical part of the voxel size (0.5(mm^3)) = 0.5*A (J)?

2.Regarding the description of 'cfg.unitinmm', I only found such a statement in the 'output' section of the README: 'unitinmm: same as cfg.unitinmm, voxel edge-length in mm'.  
So I would like to consult you that when my model resolution is 0.5*0.5*0.5mm, should I directly set 'cfg.unitinmm = 0.5' in the configuration of MCXLAB? 
And then, when I want to calculate the total energy deposition of a certain voxel, do I still need to multiply the output of MCX by the volume of the voxel such as the question1? 
That is to say, no matter how we configure the voxel size in the config file (for example, cfg.unitinmm = 0.5;), the original output of MCX needs to be multiplied by the actual size of the voxel to obtain the actual deposition energy value within the voxel. Have I understood correctly?

  Thank you again for your kind support and for taking the time to help me! I look forward to your response ! 
  Best regards,
Keyao

Qianqian Fang

unread,
Aug 20, 2025, 11:05:05 AMAug 20
to mcx-...@googlegroups.com, Keyao Zhang

hi Keyao,

the best way to definitively understand mcx's output unit is to look into the source code - if you are willing to

there are two sections of the codes are related to the units of various output-types:


Section 1: during photon simulation (per-photon packet accumulation)

https://github.com/fangq/mcx/blob/v2025/src/mcx_core.cu#L2141-L2160


Section 2: final normalization

https://github.com/fangq/mcx/blob/v2025/src/mcx_core.cu#L3736-L3807


when the output type is set to energy (otEnergy), you see the accumulated quantity in each voxel is just the energy-loss of each packet (line#2143),

then, in the normalization (line#3762), the moralization factor (scale) is simply 1/N where N is the total launched photon initial weights (i.e. total simulated photon count in the case of non-patterned sources)


as you can see from this, your comment#1 below is not true - the output is already the integrated energy density within the volume of each voxel, assuming the total launched energy is 1 (i.e. unitary), no need to multiply the total volume again.


with the above code, you can see how other output types are accumulated and normalized.


So I would like to consult you that when my model resolution is 0.5*0.5*0.5mm, should I directly set 'cfg.unitinmm = 0.5' in the configuration of MCXLAB? 

yes, setting cfg.unitinmm=0.5 makes each voxel 0.5mm^3 in size


That is to say, no matter how we configure the voxel size in the config file (for example, cfg.unitinmm = 0.5;), the original output of MCX needs to be multiplied by the actual size of the voxel to obtain the actual deposition energy value within the voxel. Have I understood correctly?


no, the `energy` output is the total deposit energy in each voxel in joule. it is not energy density (just coincidentally equals to energy density when cfg.unitinmm=1 at the default value)


if you truly want to get "energy-density" instead of energy, you should change the normalization factor from

scale = 1/cfg->energytot

to

scale = 1/(cfg->energytot * Vvox)

where Vvox = cfg->unitinmm^3


Qianqian


On 8/20/25 04:02, Keyao Zhang wrote:

You don't often get email from keyao31...@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.
Reply all
Reply to author
Forward
0 new messages