forked from e0404/APMtoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobFunc.m
More file actions
34 lines (23 loc) · 723 Bytes
/
obFunc.m
File metadata and controls
34 lines (23 loc) · 723 Bytes
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
function [objFunc,gradient] = obFunc(dij,Voxel,w)
if ~isfield(dij,'mAlphaDose')
d = dij.physicalDose * w;
else
d = (dij.mAlphaDose * w) + (dij.mSqrtBetaDose * w).^2;
end
deviation = (d - Voxel.presDose');
deviation(Voxel.ixNT' == 1 & deviation < 0) = 0;
% calculate objective function value
objFunc = (Voxel.penalty' .* deviation)' * deviation;
% calculate gradient
delta = 2 * (Voxel.penalty'.*deviation);
if nargout > 1
if ~isfield(dij,'mAlphaDose')
gradient = dij.physicalDose' * delta;
else
vBias = (delta' * dij.mAlphaDose)';
quadTerm = dij.mSqrtBetaDose * w;
mPsi = (2*(delta.*quadTerm)'* dij.mSqrtBetaDose)';
gradient = vBias + mPsi ;
end
end
end