Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with photon id for trajectory output when number of photons exceeds number of threads #147

Closed
g-buist opened this issue Apr 25, 2022 · 1 comment
Assignees
Labels

Comments

@g-buist
Copy link

g-buist commented Apr 25, 2022

After running MCX simulations via commandline with the -F bnii and --debug M options to save trajectory info on photons there are errors in the file containing the trajectory info (traj.jdat). When the number of followed photons is larger than the number of threads used the number of photon id saved in the trajectory file is too low. Doing simulations with mus =0 and mua = 0 show the correct number of events (positional data), that is 2 per photon (one entry and one exit). However the number of photon id is still too low and shows more than 2 events for some photon id. In conclusion when the number of followed photons exceeds the number of threads data of multiple photons get added to a single photon id.

@fangq fangq closed this as completed in 1295024 May 19, 2022
@fangq
Copy link
Owner

fangq commented May 19, 2022

hi @g-buist, thanks for reporting this, I am able to reproduce the issue and the above commit should fix it

clear cfg
cfg.nphoton=1e6;
cfg.vol=uint8(ones(60,60,60));
cfg.prop=[0 0 1 1;0 0 1 1];
cfg.issrcfrom0=1;
cfg.srcpos=[30 30 1];
cfg.srcdir=[0 0 1];
cfg.issaveref=1;
cfg.gpuid=1;
cfg.autopilot=1;
cfg.tstart=0;
cfg.tend=5e-9;
cfg.tstep=5e-10;
cfg.nphoton=1e5;
[fluence,detpt,vol,seeds,traj]=mcxlab(cfg);
id=sort(double(traj.id));
[a,b]=histc(id,unique(id));
count = a(b); % count for each photon id - should be mostly 2
length(find(count==4))
max(count)

before fixing the issue, there are quite a few repeated photon trajectories with the same photon produced by different threads (i.e. count==4 for 2 positions per repeated track). After fixing, duplicated IDs are gone. The highest count is 3, due to multiple scattering (even along the same direction).

@fangq fangq self-assigned this May 19, 2022
@fangq fangq added the bug label May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants