forked from e0404/matRad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matRad_visApertureInfo.m
134 lines (115 loc) · 4.9 KB
/
matRad_visApertureInfo.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
function matRad_visApertureInfo(apertureInfo,mode)
% matRad function to visualize aperture shapes stored as struct
%
% call
% matRad_visApertureInfo(apertureInfo,mode)
%
% input
% apertureInfo: aperture weight and shape info struct
% mode: switch to display leaf numbers ('leafNum') or physical
% coordinates of the leaves ('physical')
%
% output
% -
%
% 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.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin < 2 % set default mode to physical
mode = 'leafNum'; % options: 'physical','leafNum'
end
% global parameters
numOfBeams = size(apertureInfo.beam,2);
bixelWidth = apertureInfo.bixelWidth;
% custom colormap
color = [0.2:0.01:0.8; 0.2:0.01:0.8; 0.2:0.01:0.8]';
color = flipud(color);
color(:,3) = 0;
color(:,2) = 0;
% loop over all beams
for i=1:numOfBeams
% open new figure for every beam
figure('units','inches')
% get the MLC dimensions for this beam
minX = apertureInfo.beam(i).MLCWindow(1);
maxX = apertureInfo.beam(i).MLCWindow(2);
%get maximum weight
wMax = max([apertureInfo.beam(i).shape(:).weight]);
if strcmp(mode,'leafNum')
% get the active leaf Pairs
% the leaf indices have to be flipped in order to fit to the order of
% the leaf positions (1st row of leafPos is lowest row in physical
% coordinates
activeLeafInd = flipud(find(apertureInfo.beam(i).isActiveLeafPair));
end
subplotColumns = ceil(apertureInfo.beam(i).numOfShapes/2);
subplotLines = ceil(apertureInfo.beam(i).numOfShapes/subplotColumns);
%adjust figure position
set(gcf,'pos',[0 0 1.8*subplotColumns 3*subplotLines])
% loop over all shapes of the beam
for j = 1:apertureInfo.beam(i).numOfShapes
% creating subplots
subplot(subplotLines,subplotColumns,j)
title(['Beam: ' num2str(i) ' Shape: ' num2str(j) ' w=' ...
num2str(apertureInfo.beam(i).shape(j).weight,2)],...
'Fontsize',8)
colorInd = max(ceil((apertureInfo.beam(i).shape(j).weight/wMax)*61+eps),1);
set(gca,'Color',color(colorInd,:));
hold on
if strcmp(mode,'physical')
% loop over all active leaf pairs
for k = 1:apertureInfo.beam(i).numOfActiveLeafPairs
fill([minX apertureInfo.beam(i).shape(j).leftLeafPos(k) ...
apertureInfo.beam(i).shape(j).leftLeafPos(k) minX],...
[apertureInfo.beam(i).leafPairPos(k)- bixelWidth/2 ...
apertureInfo.beam(i).leafPairPos(k)- bixelWidth/2 ...
apertureInfo.beam(i).leafPairPos(k)+ bixelWidth/2 ...
apertureInfo.beam(i).leafPairPos(k)+ bixelWidth/2],'b')
fill([apertureInfo.beam(i).shape(j).rightLeafPos(k) ...
maxX maxX ...
apertureInfo.beam(i).shape(j).rightLeafPos(k)],...
[apertureInfo.beam(i).leafPairPos(k)- bixelWidth/2 ...
apertureInfo.beam(i).leafPairPos(k)- bixelWidth/2 ...
apertureInfo.beam(i).leafPairPos(k)+ bixelWidth/2 ...
apertureInfo.beam(i).leafPairPos(k)+ bixelWidth/2],'b')
end
elseif strcmp(mode,'leafNum')
% loop over all active leaf pairs
for k = 1:apertureInfo.beam(i).numOfActiveLeafPairs
fill([minX apertureInfo.beam(i).shape(j).leftLeafPos(k) ...
apertureInfo.beam(i).shape(j).leftLeafPos(k) minX],...
[activeLeafInd(k) - 1/2 ...
activeLeafInd(k) - 1/2 ...
activeLeafInd(k) + 1/2 ...
activeLeafInd(k) + 1/2],'b')
fill([apertureInfo.beam(i).shape(j).rightLeafPos(k) ...
maxX maxX ...
apertureInfo.beam(i).shape(j).rightLeafPos(k)],...
[activeLeafInd(k) - 1/2 ...
activeLeafInd(k) - 1/2 ...
activeLeafInd(k) + 1/2 ...
activeLeafInd(k) + 1/2],'b')
end
end
axis tight
xlabel('horiz. pos. [mm]')
if strcmp(mode,'physical')
ylabel('vert. pos. [mm]')
elseif strcmp(mode,'leafNum')
ylabel('leaf pair #')
end
end
end
end