MCX Transmittance and detector query

40 views
Skip to first unread message

Samin Enam

unread,
Oct 30, 2025, 10:11:46 AMOct 30
to mcx-users
Dear Dr. Fang,
I am looking to map the transmittance over thickness for my model. I wanted to know, what would be the most responsible way to get transmittance? Do I use detectors? Or do I use the fluence map? And if I do end up using fluence map, do I add a zero-labeled layer and use that layer to map my fluence? Please let me know if my question was clear enough or if you need further details. 
But to sum it up, how would you calculate transmittance from the source through a tissue/biological layer most effectively and accurately in MCX?

Qianqian Fang

unread,
Oct 30, 2025, 12:08:31 PMOct 30
to mcx-...@googlegroups.com, Samin Enam

hi Samin,

to calculate transmittance, you need to compute the total energy passing through the boundary opposing to the side where the source is placed.

for example, if you place a source at z=0 of a slab domain, you should pad a layer of zeros on the z=max_z and set cfg.issaveref=1 and cfg.outputtype='energy'. after the simulation, sum the flux.dref values in the z=max_z layer. it should be a value less than 1 (as it is normalized - so that total launched energy is 1), which you can use to estimate the transmittance.

if you want to be sure, you can also pad a layer of zeros at z=0 (in addition to the changes above) and sum flux.dref at z=0 layer. This should give you the total diffuse reflectance. Summing the transmitance and reflectance should give you something close to 1.

if it is significantly less than 1, that means a good portion of the photons exits from the other 4 sides (x=0/y=0/x=max_x/y=max_y), then can increase your x/y dimension to minimize these energy leakages.

you can also set the 4 side boundaries to have a mirror or cyclic boundary condition, so that photons only exit from z=0 or z=max_z. see this example

https://github.com/fangq/mcx/blob/master/mcxlab/examples/demo_infinite_slab_cyclic_bc.m

Qianqian

On 10/29/25 18:41, Samin Enam wrote:

You don't often get email from samin...@gmail.com. Learn why this is important

Dear Dr. Fang,
I am looking to map the transmittance over thickness for my model. I wanted to know, what would be the most responsible way to get transmittance? Do I use detectors? Or do I use the fluence map? And if I do end up using fluence map, do I add a zero-labeled layer and use that layer to map my fluence? Please let me know if my question was clear enough or if you need further details. 
But to sum it up, how would you calculate transmittance from the source through a tissue/biological layer most effectively and accurately in MCX?
--
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/de328a68-b8e9-4624-92f9-99ba4d1289b4n%40googlegroups.com.

Samin Enam

unread,
Nov 20, 2025, 12:18:44 PM (13 days ago) Nov 20
to mcx-users
Dear Dr. Fang,
This is how I am trying to mimic an energy meter placed at the bottom of CSF (in experiments). Please let me know if I am missing something.
w = mcxdetweight(det,cfg.prop,cfg.unitinmm);
idx = (det.detid == 1);
wsum = sum(w(idx));
transmittance = wsum/cfg.nphoton;

This is my simulation setup
cfg.vol = uint8(vol);
cfg.nphoton=1e9;
cfg.maxdetphoton = 5e9;
cfg.outputtype='energy';
% 1070 nm
cfg.prop = [0 0 1 1;                                                 % Air
    0.017 16.72476403 0.9 1.37;                          % Scalp
    0.0163636 16.46070248 0.9 1.37;         % Skull
    3.696785714 20.20408163 0.9 1.37; % Blood
    0.014718019 0.00003 0.9 1.33;                 % CSF
    0 0 1 1];                                                               % Air

% light source
cfg.srctype = 'disk';
cfg.srcpos = [150 100 10];
cfg.srcparam1 = [45 0 0];
cfg.srcparam2 = [30 0 0];
cfg.srcdir = [0,0,1];
cfg.angleinvcdf = asin(0:0.01:1) / pi; %test lambertian/cosine distribution based on git
cfg.issrcfrom0 = 1;
cfg.isreflect = 1;
% time windows
cfg.tstart=0;
cfg.tend=1e-8;
cfg.tstep=1e-9;
% other simulation parameters
cfg.isspecular=1; %calculate specular reflection if source is outside
cfg.isreflect=1; %consider refractive index mismatch, 0-matched index
% cfg.autopilot=1;
cfg.gpuid = 2;
cfg.issaveref = 1; % summation of the weights of all escaped photons to the background, regardless of their direction
cfg.issaveexit = 1; %save the position (x,y,z) and (vx,vy,vz) for a detected photon
cfg.unitinmm = 0.09;
cfg.vol(:,:,Nz) = 0;
cfg.bc='cccccr';
% Detector
cfg.detpos=[150 100 250 40];
cfg.savedetflag = 'dpx';

Best,
Samin

Qianqian Fang

unread,
Nov 20, 2025, 6:05:09 PM (13 days ago) Nov 20
to mcx-...@googlegroups.com, Samin Enam

hi Samin,

your cfg.bc setting looks a bit strange - 'cccccr' - why you want to make the z=0 to be cyclic? if you want to make the domain x/y infinite slab, cc_cc_ should be enough, I don't really know what kind physical signifiance if you set z=0 as cyclic while collecting exit photons from z=z_max.

also, you don't need to use detpos to capture detected photons, you just set cfg.bc='cc_cc_000001', this will capture all photons coming out of z=z_max plane.

a more memory efficient to get the total transmittance is to use diffuse transmittance, by setting cfg.issaveref=1 and pad a layer of zerors at z=z_max voxels.

Qianqian

Samin Enam

unread,
Nov 21, 2025, 4:13:19 PM (12 days ago) Nov 21
to mcx-users
Thank you very much Dr. Fang. My main goal here is to have the transmittance restricted to the detector/ energy detected at the detector. Basically, I want to have sizing restrictions and do not want to get the total transmittance coming out of the last layer. The main reason would be that I am trying to mimic an energy meter. So my physical model would be restricted to the area covered by the energy meter (which is the size of the detector).
I am not able to explain correctly. But I understand your point. Hence, I was asking if I can put the weight to my detected photons
w = mcxdetweight(det,cfg.prop,cfg.unitinmm);
idx = (det.detid == 1);
wsum = sum(w(idx));
transmittance = wsum/cfg.nphoton;

Best,
Samin

Qianqian Fang

unread,
Nov 28, 2025, 11:30:45 AM (5 days ago) Nov 28
to mcx-...@googlegroups.com, Samin Enam

the way you computed the weights and transmittance looks fine to me.

Reply all
Reply to author
Forward
0 new messages