forked from e0404/matRad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matRad_calcPhotonDoseBixel.m
65 lines (60 loc) · 2.62 KB
/
matRad_calcPhotonDoseBixel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function dose = matRad_calcPhotonDoseBixel(SAD,m,betas,Interp_kernel1,...
Interp_kernel2,Interp_kernel3,radDepths,geoDists,...
isoLatDistsX,isoLatDistsZ)
% matRad photon dose calculation for an individual bixel
%
% call
% dose = matRad_calcPhotonDoseBixel(SAD,m,betas,Interp_kernel1,...
% Interp_kernel2,Interp_kernel3,radDepths,geoDists,...
% isoLatDistsX,isoLatDistsZ)
%
% input
% SAD: source to axis distance
% m: absorption in water (part of the dose calc base
% data)
% betas: beta parameters for the parameterization of the
% three depth dose components
% Interp_kernel1/2/3: kernels for dose calculation
% radDepths: radiological depths
% geoDists: geometrical distance from virtual photon source
% isoLatDistsX: lateral distance in X direction in BEV from central
% ray at iso center plane
% isoLatDistsZ: lateral distance in Z direction in BEV from central
% ray at iso center plane
%
% output
% dose: photon dose at specified locations as linear vector
%
% References
% [1] http://www.ncbi.nlm.nih.gov/pubmed/8497215
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2015 the matRad development team.
%
% This file is part of the matRad project. It is subject to the license
% terms in the LICENSE file found in the top-level directory of this
% distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
% of the matRad project, including this file, may be copied, modified,
% propagated, or distributed except according to the terms contained in the
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define function_Di
func_Di = @(beta,x) beta/(beta-m) * (exp(-m*x) - exp(-beta*x));
% Calulate lateral distances using grid interpolation.
lat1 = Interp_kernel1(isoLatDistsX,isoLatDistsZ);
lat2 = Interp_kernel2(isoLatDistsX,isoLatDistsZ);
lat3 = Interp_kernel3(isoLatDistsX,isoLatDistsZ);
% now add everything together (eq 19 w/o inv sq corr -> see below)
dose = lat1 .* func_Di(betas(1),radDepths) + ...
lat2 .* func_Di(betas(2),radDepths) + ...
lat3 .* func_Di(betas(3),radDepths);
% inverse square correction
dose = dose .* (SAD./geoDists(:)).^2;
% check if we have valid dose values and adjust numerical instabilities
% from fft convolution
dose(dose < 0 & dose > -1e-14) = 0;
if any(isnan(dose)) || any(dose<0)
error('Error in photon dose calculation.');
end