Detected photons output is an empty set

4 views
Skip to first unread message

vijit...@gmail.com

unread,
Apr 1, 2026, 9:07:32 AM (3 days ago) Apr 1
to mcx-users

When I set cfg.issaveref = 1, the flux.dref saves the photons leaving the surface. The direction of the photon is missing.

I need the photon weight at the faces. I am not sure if I am missing any other input parameter.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MCXLAB - Monte Carlo eXtreme for MATLAB/Octave by Qianqina Fang
%
% In this example, we demonstrate light transport simulation in a digital
% mouse atlas - Digimouse
%
% This demo is similar to the MCX simulation used for Fig. 2 in
% [Fang2012], except this uses a voxelated model instead of a mesh.
%
%
% [Fang2012] Qianqian Fang and David R. Kaeli, "Accelerating mesh-based
% Monte Carlo method on modern CPU architectures ," Biomed. Opt. Express
% 3(12), 3223-3230 (2012)
%
% This file is part of Monte Carlo eXtreme (MCX) URL:https://mcx.space
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% only clear cfg to avoid accidentally clearing other useful data

clc;
clear all;
close all;

load digimouse.mat;

cfg.vol = digimouse;

cfg.prop = [1 0.0191 6.6 0.9 1.37
2 0.0136 8.6 0.9 1.37
3 0.0026 0.01 0.9 1.37
4 0.0186 11.1 0.9 1.37
5 0.0186 11.1 0.9 1.37
6 0.0186 11.1 0.9 1.37
7 0.0186 11.1 0.9 1.37
8 0.0186 11.1 0.9 1.37
9 0.0240 8.9 0.9 1.37
10 0.0026 0.01 0.9 1.37
11 0.0240 8.9 0.9 1.37
12 0.0240 8.9 0.9 1.37
13 0.0240 8.9 0.9 1.37
14 0.0240 8.9 0.9 1.37
15 0.0240 8.9 0.9 1.37
16 0.072 5.6 0.9 1.37
17 0.072 5.6 0.9 1.37
18 0.072 5.6 0.9 1.37
19 0.050 5.4 0.9 1.37
20 0.024 8.9 0.9 1.37
21 0.076 10.9 0.9 1.37];

cfg.prop(:, 1) = [];
cfg.prop(2:end + 1, :) = cfg.prop;
cfg.prop(1, :) = [0 0 1 1];

cfg.srctype = 'line';
cfg.srcpos = [95.0 100.0 104.0];
cfg.srcparam1 = [0.0 100.0 0.0];
cfg.srcdir = [0 0 -1];
% cfg.issrcfrom0 = 1;

cfg.tstart = 0;
cfg.tend = 5e-9;
cfg.tstep = 5e-9;
cfg.nphoton = 1e7;
cfg.autopilot = 1;
cfg.gpuid = 1;
cfg.unitinmm = 0.1 * 2;
cfg.debuglevel = 'P';
cfg.issaveref = 1;

cfg.bc = '______111111'; % capture photons existing from all faces except z=z_max
cfg.savedetflag = 'dpx';

[flux detpho]= mcxlab(cfg);
fcw = flux.data;

mcxplotvol(log10(double(flux.dref)));

Image

Qianqian Fang

unread,
Apr 1, 2026, 11:35:21 AM (3 days ago) Apr 1
to mcx-...@googlegroups.com, vijit...@gmail.com

I saw your question posted on github https://github.com/fangq/mcx/issues/257

please see my reply there.

it depends on what you want to output - if you want to output diffuse-reflectance (dref), issaveref=1 is sufficient. dref is an integration of all photons escaping from the tissue surface regardless of direction. it is fast to compute and memory efficient.

however, but if you want to get individual photon packet's detected weight and escaping direction, then you should create a detector with a radius large enough to cover the surface area where you are interested in (or the entire object). this will dump a lot of per-photon data. you will have to manually compute the weight and do the post-processing.


On 4/1/26 09:07, vijit...@gmail.com wrote:

You don't often get email from vijit...@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/2a05dfee-ca93-4a55-a756-779b2437f25fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages