forked from e0404/matRad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matRad_setOverlapPriorities.m
76 lines (63 loc) · 2.49 KB
/
matRad_setOverlapPriorities.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
function [cst,overlapPriorityCube] = matRad_setOverlapPriorities(cst,ctDim)
% function to handle overlap priorities during fluence optimizaiton and
% dose calculation. If you have overlapping volumes of interest you need to
% inform matrad to which volume(s) the intersection voxels belong
%
% call
% cst = matRad_considerOverlap(cst)
% [cst, overlapPriorityCube] = matRad_setOverlapPriorities(cst,cubeDim)
%
% input
% cst: cst file
% ctDim: dimension of the ct for overlap cube claculation (optional)
%
% output
% cst: updated cst file considering overlap priorities
% overlapPriorityCube cube visualizing the overlap priority (optional)
%
% References
% -
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 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.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
numOfCtScenarios = unique(cellfun(@(x)numel(x),cst(:,4)));
if numel(numOfCtScenarios) > 1
error('Inconsistent number of segmentations in cst struct.');
end
for i = 1:numOfCtScenarios
% consider VOI priorities
for j = 1:size(cst,1)
idx = cst{j,4}{i};
for k = 1:size(cst,1)
if cst{k,5}.Priority < cst{j,5}.Priority && ~(j==k) && ~isempty(cst{k,6})
% remove indices from VOI with higher priority from current VOI
% if an objective has been defined
idx = setdiff(idx,cst{k,4}{i});
end
end
cst{j,4}{i} = idx;
if isempty(cst{j,4}{i}) && ~isempty(cst{j,6})
error([cst{j,2} ': Objective(s) and/or constraints for inverse planning defined ' ...
'but structure overlapped by structure with higher overlap priority.' ...
'Objective(s) will not be considered during optimization']);
end
end
end
%Calculate the overlap cube if requested
if nargout == 2 && nargin == 2
overlapPriorityCube = zeros(ctDim);
for i = 1:size(cst,1)
overlapPriorityCube(cst{i,4}{1}) = cst{i,5}.Priority;
end
end
end