Planar detector

118 views
Skip to first unread message

zhang haohui

unread,
Feb 23, 2024, 3:46:50 PM2/23/24
to mcx-users
Dear Prof. Fang,

1. I'd like to detect the partial length of diffusion-reflected photons. However, I've discovered that the spherical detector might miss some photons or capture photons within the tissue. Is there a better way to achieve it?

2. Another question I have is the "pattern3D" source: I am using it to simulate the fluorescent inside the body. At the end I attached my code.

My light source is one xy surface with thickness of one grid. In c fg.srcpattern, left half is 1 and the right half is 2. They all emit isotropically. In total 1e8 photons are released.

I think photons in the region with srcpattern =2 have energy of 2. So the total simulated energy is 1.5e8, which is the same as "total simulated energy: 149992746.00"

On the other hand, it said "absorbed: 68.43138%". So I think the total absorbed energy should be "1.5e8*68.43% = 1.026". So I compute total_absorb in the end and it is 1.1404. However, '1.1404/68.43%=5/3', which suggests the total released energy is 5/3, rather than 3/2. What is the reason of this difference?

Thank you very much!

Best wishes
Haohui

%% prepare cfg for MCX simulation
clear cfg
cfg.nphoton=1e8;
cfg.outputtype='fluence';
cfg.seed = 77542;
cfg.vol=ones(100,100,100);
cfg.prop = [0,0,0,1;0.2,0.64,0,1];
% light source
cfg.srctype = 'pattern3d';
cfg.srcpos=[0,0,50];
cfg.srcparam1=[100,100,1];
tmp = zeros(100,100);
tmp(1:50,:) = 1;
tmp(51:100,:) = 2;
cfg.srcpattern = tmp;
cfg.srcdir=[-1,0,0,nan];
cfg.issrcfrom0=1;
% time windows
cfg.tstart=0;
cfg.tend=1e-8;
cfg.tstep=1e-9;
% other simulation parameters
cfg.isspecular=1;
cfg.isreflect=1;
cfg.autopilot=1;
cfg.gpuid=1;
cfg.issaveref=1; % save diffuse reflectance
% Unit length
cfg.unitinmm = 0.1;
%% run MCX simulation
flux = mcxlab(cfg);
%% post-simulation data processing
CWfluence=sum(flux.data,4);
total_absorb = sum(0.2*CWfluence*0.001,'all') % 0.2 is the absorption coeff

Qianqian Fang

unread,
Feb 25, 2024, 5:52:01 PM2/25/24
to mcx-...@googlegroups.com, zhang haohui

hi Haohui,

I acknowledge that I have read your previous message, before this re-post, and had spent some time debugging mcx and trying to understand what was the reason, but I still don't have a clear answer for you, yet.

I also tested our built-in pattern3d source demo code, shown below

https://github.com/fangq/mcx/blob/v2023/mcxlab/examples/demo_mcxlab_srctype.m#L270-L311

the energy conservation can be verified - you can add

cfg.outputtype='energy';

to the original cfg definition, and then run

sum(flux.data(:))

you can see the output matches the percentage absorption. Even I multiply cfg.srcpattern by 2, the conservation is still satisfied.


however, in your case, if I add

cfg.outputtype='energy';
cfg.isnormalized=0;

and run your test, your total absorbed energy sum(flux.data(:))=1.7e8 is even bigger than the total launched energy (1.5e8), which does not make any sense.


I have a feeling that perhaps this is somehow related to your source shape - you used a 2D array to define a volumetric source, with the source area directly in contact with the bounding box (i.e. some photons are directly launched into the background, not even propagating).

but still, this seems to be a tricky case, and I still don't have an answer for you why.


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.
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/aeeeb9a2-905c-40fe-80d7-366438875dd5n%40googlegroups.com.

zhang haohui

unread,
Feb 25, 2024, 7:03:16 PM2/25/24
to mcx-users
Dear Prof. Fang,

Thanks for your discussion here. It is very helpful. I did some tests based on your thoughts
1. The reason I am using "pattern3D" is that when I use "pattern" for complex fluorescent source, it always had some memory problem.
2. I made the cfg.bc='mmmmmm' and extended the box to make sure the pattern is inside the bounding box. The total absorped power is about 2.50, while the released power is 1.5. I feel there is two ways to achieve my pattern. Left part emit 1/3 photons and right part emits 2/3 photons with same weight. Or both parts emit 1/2 photons but the weight of the right part is 2. Is it possible that both methods are applied so that the real released power becomes larger than desired? 
3. Continue 2. I changed the pattern tmp(1:50,:) = 1; tmp(51:100,:) = 2,3,4,5; The absorbed power is 5/2, 10/2, and 17/2, 26/2 which are (1+2^2)/2, (1+3^2)/2 , (1+4^2)/2 , (1+5^2)/2.

4. A side question besides previous questions. I'd like to detect the partial length of diffusion-reflected photons. However, I've discovered that the spherical detector might miss some photons or capture photons within the tissue. Is there a better way to achieve it?

I really appreciate your help on these issues!

Best wishes
Haohui
Reply all
Reply to author
Forward
0 new messages