Skip to content

Commit 1c07b16

Browse files
committed
scale partial-path when getting det photon time and weight, close #83
1 parent 8b9ef2d commit 1c07b16

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

utils/mcxdettime.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
function dett=mcxdettime(detp,prop)
1+
function dett=mcxdettime(detp,prop,unitinmm)
22
%
3-
% dett=mcxdetweight(detp,prop)
3+
% dett=mcxdettime(detp,prop,unitinmm)
44
%
55
% Recalculate the detected photon time using partial path data and
66
% optical properties (for perturbation Monte Carlo or detector readings)
@@ -11,6 +11,8 @@
1111
% input:
1212
% detp: the 2nd output from mcxlab. detp must be a struct
1313
% prop: optical property list, as defined in the cfg.prop field of mcxlab's input
14+
% unitinmm: voxel edge-length in mm, should use cfg.unitinmm used to generate detp;
15+
% if ignored, assume to be 1 (mm)
1416
%
1517
% output:
1618
% dett: re-caculated detected photon time based on the partial path data and optical property table
@@ -22,6 +24,10 @@
2224

2325
R_C0 = 3.335640951981520e-12; % inverse of light speed in vacuum
2426

27+
if(nargin<=3)
28+
unitinmm=1;
29+
end
30+
2531
medianum=size(prop,1);
2632
if(medianum<=1)
2733
error('empty property list');
@@ -30,7 +36,7 @@
3036
if(isstruct(detp))
3137
dett=zeros(size(detp.ppath,1),1);
3238
for i=1:medianum-1
33-
dett=dett+prop(i+1,4)*detp.ppath(:,i)*R_C0;
39+
dett=dett+prop(i+1,4)*detp.ppath(:,i)*R_C0*unitinmm;
3440
end
3541
else
3642
error('the first input must be a struct with a subfield named "ppath"');

utils/mcxdetweight.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
function detw=mcxdetweight(detp,prop)
1+
function detw=mcxdetweight(detp,prop,unitinmm)
22
%
3-
% detw=mcxdetweight(detp,prop)
3+
% detw=mcxdetweight(detp,prop,unitinmm)
44
%
55
% Recalculate the detected photon weight using partial path data and
66
% optical properties (for perturbation Monte Carlo or detector readings)
@@ -10,6 +10,8 @@
1010
% input:
1111
% detp: the 2nd output from mcxlab. detp must a struct
1212
% prop: optical property list, as defined in the cfg.prop field of mcxlab's input
13+
% unitinmm: voxel edge-length in mm, should use cfg.unitinmm used to generate detp;
14+
% if ignored, assume to be 1 (mm)
1315
%
1416
% output:
1517
% detw: re-caculated detected photon weight based on the partial path data and optical property table
@@ -24,14 +26,18 @@
2426
error('empty property list');
2527
end
2628

29+
if(nargin<=3)
30+
unitinmm=1;
31+
end
32+
2733
if(isstruct(detp))
2834
if(~isfield(detp,'w0'))
2935
detw=ones(size(detp.ppath,1),1);
3036
else
3137
detw=detp.w0;
3238
end
3339
for i=1:medianum-1
34-
detw=detw.*exp(-prop(i+1,1)*detp.ppath(:,i));
40+
detw=detw.*exp(-prop(i+1,1)*detp.ppath(:,i)*unitinmm);
3541
end
3642
else
3743
error('the first input must be a struct with a subfield named "ppath"');

0 commit comments

Comments
 (0)