Skip to content

Commit

Permalink
scale partial-path when getting det photon time and weight, close #83
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Nov 19, 2019
1 parent 8b9ef2d commit 1c07b16
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions utils/mcxdettime.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function dett=mcxdettime(detp,prop)
function dett=mcxdettime(detp,prop,unitinmm)
%
% dett=mcxdetweight(detp,prop)
% dett=mcxdettime(detp,prop,unitinmm)
%
% Recalculate the detected photon time using partial path data and
% optical properties (for perturbation Monte Carlo or detector readings)
Expand All @@ -11,6 +11,8 @@
% input:
% detp: the 2nd output from mcxlab. detp must be a struct
% prop: optical property list, as defined in the cfg.prop field of mcxlab's input
% unitinmm: voxel edge-length in mm, should use cfg.unitinmm used to generate detp;
% if ignored, assume to be 1 (mm)
%
% output:
% dett: re-caculated detected photon time based on the partial path data and optical property table
Expand All @@ -22,6 +24,10 @@

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

if(nargin<=3)
unitinmm=1;
end

medianum=size(prop,1);
if(medianum<=1)
error('empty property list');
Expand All @@ -30,7 +36,7 @@
if(isstruct(detp))
dett=zeros(size(detp.ppath,1),1);
for i=1:medianum-1
dett=dett+prop(i+1,4)*detp.ppath(:,i)*R_C0;
dett=dett+prop(i+1,4)*detp.ppath(:,i)*R_C0*unitinmm;
end
else
error('the first input must be a struct with a subfield named "ppath"');
Expand Down
12 changes: 9 additions & 3 deletions utils/mcxdetweight.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function detw=mcxdetweight(detp,prop)
function detw=mcxdetweight(detp,prop,unitinmm)
%
% detw=mcxdetweight(detp,prop)
% detw=mcxdetweight(detp,prop,unitinmm)
%
% Recalculate the detected photon weight using partial path data and
% optical properties (for perturbation Monte Carlo or detector readings)
Expand All @@ -10,6 +10,8 @@
% input:
% detp: the 2nd output from mcxlab. detp must a struct
% prop: optical property list, as defined in the cfg.prop field of mcxlab's input
% unitinmm: voxel edge-length in mm, should use cfg.unitinmm used to generate detp;
% if ignored, assume to be 1 (mm)
%
% output:
% detw: re-caculated detected photon weight based on the partial path data and optical property table
Expand All @@ -24,14 +26,18 @@
error('empty property list');
end

if(nargin<=3)
unitinmm=1;
end

if(isstruct(detp))
if(~isfield(detp,'w0'))
detw=ones(size(detp.ppath,1),1);
else
detw=detp.w0;
end
for i=1:medianum-1
detw=detw.*exp(-prop(i+1,1)*detp.ppath(:,i));
detw=detw.*exp(-prop(i+1,1)*detp.ppath(:,i)*unitinmm);
end
else
error('the first input must be a struct with a subfield named "ppath"');
Expand Down

0 comments on commit 1c07b16

Please sign in to comment.