issue with detector radius in mcxlab?

51 views
Skip to first unread message

Joe Prosser

unread,
Aug 26, 2020, 12:35:49 PM8/26/20
to mcx-users
Hi Dr. Fang,

I seem to be having issues with detector radius. When I run the below in MCXLAB I get 5190 detected photon packets. If I change the detector radius detpos(1,4) from 1.2 to 1.1, I get zero. I realize there is a work-around to save the exit positions and filter them but the number of detected photons seems to drop off precipitously as the detector radius decreases from 1.2 to 1.1. For a source/detector distance of 20mm the radius threshold is around 0.5mm. Script below. Thanks for taking a look!

Joe
Joseph Prosser, PhD

%% set up the parameters and S/D locations
clear all;
cfg.srcpos = [24.5 40 0];
cfg.tend = 5e-9;
cfg.tstep = 2e-11;
cfg.nphoton = 1e7;
cfg.vol = ones(49,120,41);
cfg.srcdir = [0 0 1];
cfg.autopilot = 1;
cfg.detpos = [24.5000 50.0000 0 1.2];
cfg.prop = [0 0 1.0000 1.0000; 0.0264 2.8684 0.6200 1.5111];

[fluence,detphoton,vol,seed,trajectory]=mcxlab(cfg);

detphoton

Revision info
$Rev::f9ad72$2019.4 $Date::2019-09-06 18:50:12 -04$ by $Author::Qianqian Fang $
###############################################################################
- variant name: [Fermi] compiled by nvcc [7.5] with CUDA [7050]
- compiled with: RNG [xorshift128+] with Seed Length [4]


Fang, Qianqian

unread,
Aug 26, 2020, 1:56:33 PM8/26/20
to mcx-...@googlegroups.com, Joe Prosser
On 8/26/20 11:20 AM, Joe Prosser wrote:
Hi Dr. Fang,

I seem to be having issues with detector radius. When I run the below in MCXLAB I get 5190 detected photon packets. If I change the detector radius detpos(1,4) from 1.2 to 1.1, I get zero. I realize there is a work-around to save the exit positions and filter them but the number of detected photons seems to drop off precipitously as the detector radius decreases from 1.2 to 1.1. For a source/detector distance of 20mm the radius threshold is around 0.5mm. Script below. Thanks for taking a look!


hi Joe

if you assume the low-bottom-corner of the first voxel in the domain is [0,0,0], you need to explicitly set cfg.issrcfrom0=1 or -z 1 (by default, cfg.issrcfrom0 is set to 0)

otherwise, mcx by default assumes the lower-bottom-corner is [1,1,1] voxel-unit.

see this FAQ

http://mcx.space/wiki/index.cgi?Doc/FAQ#My_simulation_created_an_empty_history_file_why_is_that

I am attaching a side-view of the domain rendered by the command `mcxpreview(cfg)` (you have to download the latest version of mcxpreview to show the correct det radius), you can see that, because of this 1 voxel offset, the detector barely intersects with the domain bounding box, thus, failed to capture most of the photons. if you set the cfg.issrcfrom0=1, the detector is then centered exactly at the bounding box.

another thing I found is that you did not set cfg.tstart, and mcxlab may raise an error because of the uninitialized values. please add cfg.tstart=0 in the below script to avoid the error.

feel free to let me know if you have any further questions.

Qianqian


Joe
Joseph Prosser, PhD

%% set up the parameters and S/D locations
clear all;
cfg.srcpos = [24.5 40 0];
cfg.tend = 5e-9;
cfg.tstep = 2e-11;
cfg.nphoton = 1e7;
cfg.vol = ones(49,120,41);
cfg.srcdir = [0 0 1];
cfg.autopilot = 1;
cfg.detpos = [24.5000 50.0000 0 1.2];
cfg.prop = [0 0 1.0000 1.0000; 0.0264 2.8684 0.6200 1.5111];

[fluence,detphoton,vol,seed,trajectory]=mcxlab(cfg);

detphoton

Revision info
$Rev::f9ad72$2019.4 $Date::2019-09-06 18:50:12 -04$ by $Author::Qianqian Fang $
###############################################################################
- variant name: [Fermi] compiled by nvcc [7.5] with CUDA [7050]
- compiled with: RNG [xorshift128+] with Seed Length [4]


--
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/69b905e7-407a-4d5e-92f2-7f98cb544609n%40googlegroups.com.
det_offset.png

Joe Prosser

unread,
Aug 26, 2020, 4:48:33 PM8/26/20
to mcx-users
The issue also happens when issrcfrom0=1, only at the detector radius of 0.5 instead of ~1.0 (see below). Sorry for the confusion I had removed that line, trying to minimize the cfg but didn't realize I caused the loss of photons in a different way.

Changed cfg.detpos(1,4) to 0.5
added cfg.tstart=0
added cfg.issrcfrom0 = 1

Same issue. Interestingly the XY exit positions of detected photons when the radius is 0.51 actually forms a 0.51 radius circle. If the circle was only tangentially intersecting the volume, I would expect the radius of XY exit positions to be smaller in that case. 
 
When cfg.detpos(1,4) is set to 0.51:
figure; scatter(detphoton.p(:,1),detphoton.p(:,2),'.')

Fang, Qianqian

unread,
Aug 27, 2020, 12:50:41 AM8/27/20
to mcx-...@googlegroups.com, Joe Prosser
On 8/26/20 4:48 PM, Joe Prosser wrote:
The issue also happens when issrcfrom0=1, only at the detector radius of 0.5 instead of ~1.0 (see below). Sorry for the confusion I had removed that line, trying to minimize the cfg but didn't realize I caused the loss of photons in a different way.

Changed cfg.detpos(1,4) to 0.5
added cfg.tstart=0
added cfg.issrcfrom0 = 1

Same issue. Interestingly the XY exit positions of detected photons when the radius is 0.51 actually forms a 0.51 radius circle. If the circle was only tangentially intersecting the volume, I would expect the radius of XY exit positions to be smaller in that case. 
 
When cfg.detpos(1,4) is set to 0.51:
figure; scatter(detphoton.p(:,1),detphoton.p(:,2),'.')


thanks Joe, 0 detected photon when det radius<=0.5 appears to be a legitimate bug of mcx. I was able to reproduce it in either v2019.4 or the latest github version.

I have created a bug report on github, and also committed a fix, see

https://github.com/fangq/mcx/issues/101

basically, mcx prepossesses the volume to label all boundary voxels near a detector, whose surface area forms a full cover of the circle centered at the detector, really like what this picture shows

http://mcx.space/wiki/upload/detmask_coordinates.png

it turns out the masking algorithm is flawed and rounds down the detector radius. by adding an extra 0.5f, this issue is now fixed (see screenshot). I just manually ran the nightly build scripts. wait a few min to check this link and get the updated mcxlab packages

http://mcx.space/nightly/

let me know if that is fixed for you as well.

Qianqian



On Wednesday, August 26, 2020 at 12:35:49 PM UTC-4 Joe Prosser wrote:
Hi Dr. Fang,

I seem to be having issues with detector radius. When I run the below in MCXLAB I get 5190 detected photon packets. If I change the detector radius detpos(1,4) from 1.2 to 1.1, I get zero. I realize there is a work-around to save the exit positions and filter them but the number of detected photons seems to drop off precipitously as the detector radius decreases from 1.2 to 1.1. For a source/detector distance of 20mm the radius threshold is around 0.5mm. Script below. Thanks for taking a look!

Joe
Joseph Prosser, PhD

%% set up the parameters and S/D locations
clear all;
cfg.srcpos = [24.5 40 0];
cfg.tend = 5e-9;
cfg.tstep = 2e-11;
cfg.nphoton = 1e7;
cfg.vol = ones(49,120,41);
cfg.srcdir = [0 0 1];
cfg.autopilot = 1;
cfg.detpos = [24.5000 50.0000 0 1.2];
cfg.prop = [0 0 1.0000 1.0000; 0.0264 2.8684 0.6200 1.5111];

[fluence,detphoton,vol,seed,trajectory]=mcxlab(cfg);

detphoton

Revision info
$Rev::f9ad72$2019.4 $Date::2019-09-06 18:50:12 -04$ by $Author::Qianqian Fang $
###############################################################################
- variant name: [Fermi] compiled by nvcc [7.5] with CUDA [7050]
- compiled with: RNG [xorshift128+] with Seed Length [4]


--
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.
detpos.png
Reply all
Reply to author
Forward
0 new messages