forked from e0404/matRad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matRad_calcCubes.m
90 lines (73 loc) · 3.28 KB
/
matRad_calcCubes.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
function resultGUI = matRad_calcCubes(w,dij,cst,scenNum)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% matRad computation of all cubes for the resultGUI struct which is used
% as result container and for visualization in matRad's GUI
%
% call
% resultGUI = matRad_calcCubes(w,dij,cst)
%
% input
% w: bixel weight vector
% dij: dose influence matrix
% cst: matRad cst struct
% scenNum: optional: number of scenario to calculated (default 1)
%
% output
% resultGUI: matRad result struct
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 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.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin < 4
scenNum = 1;
end
resultGUI.w = w;
% calc dose and reshape from 1D vector to 2D array
resultGUI.physicalDose = reshape(full(dij.physicalDose{scenNum}*resultGUI.w),dij.dimensions);
% consider RBE for protons
if isfield(dij,'RBE')
fprintf(['matRad: applying a constant RBE of ' num2str(dij.RBE) ' \n']);
resultGUI.RBExDose = resultGUI.physicalDose * dij.RBE;
end
% consider VOI priorities
[cst,resultGUI.overlapCube] = matRad_setOverlapPriorities(cst,dij.dimensions);
if isfield(dij,'mLETDose')
LETDoseCube = dij.mLETDose{scenNum} * resultGUI.w;
resultGUI.LET = zeros(dij.dimensions);
ix = resultGUI.physicalDose>0;
resultGUI.LET(ix) = LETDoseCube(ix)./resultGUI.physicalDose(ix);
end
% consider biological optimization for carbon ions
if isfield(dij,'mAlphaDose') && isfield(dij,'mSqrtBetaDose')
a_x = zeros(size(resultGUI.physicalDose));
b_x = zeros(size(resultGUI.physicalDose));
for i = 1:size(cst,1)
% Only take OAR or target VOI.
if isequal(cst{i,3},'OAR') || isequal(cst{i,3},'TARGET')
a_x(cst{i,4}{scenNum}) = cst{i,5}.alphaX;
b_x(cst{i,4}{scenNum}) = cst{i,5}.betaX;
end
end
ix = b_x~=0;
resultGUI.effect = full(dij.mAlphaDose{scenNum}*resultGUI.w+(dij.mSqrtBetaDose{scenNum}*resultGUI.w).^2);
resultGUI.effect = reshape(resultGUI.effect,dij.dimensions);
resultGUI.RBExDose = zeros(size(resultGUI.effect));
resultGUI.RBExDose(ix) = ((sqrt(a_x(ix).^2 + 4 .* b_x(ix) .* resultGUI.effect(ix)) - a_x(ix))./(2.*b_x(ix)));
resultGUI.RBE = resultGUI.RBExDose./resultGUI.physicalDose;
resultGUI.alpha = zeros(size(resultGUI.effect));
resultGUI.beta = zeros(size(resultGUI.effect));
AlphaDoseCube = full(dij.mAlphaDose{scenNum} * resultGUI.w);
resultGUI.alpha(ix) = AlphaDoseCube(ix)./resultGUI.physicalDose(ix);
SqrtBetaDoseCube = full(dij.mSqrtBetaDose{scenNum} * resultGUI.w);
resultGUI.beta(ix) = (SqrtBetaDoseCube(ix)./resultGUI.physicalDose(ix)).^2;
end