-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompPlan_main.m
128 lines (96 loc) · 5.03 KB
/
CompPlan_main.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
function Comp_Plan_main(BaseDirectoryLocation)
% Analyse a comp plan 'base directory'
% BaseDirectoryLocation is the directory in which the excel DVH files for the given
% plan are stored. If no base directory is input, a UI will be loaded to select one.
% For instructions on setting up a baseDirectory, please see the
% instruction on GitHub.
% add the source files:
addpath('compPlan_source')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% user defined variables:
Mode='singleDirectory'; %'singleDirectory' or 'batch'. Batch simply loops over all supplied directories.
plotDVHs=1; % set values below to 1 to plot DVHs or the parameter
plotparams=0; % set values below to 1 to plot parameters
xlnum=1; %position of data in excel, if you wish to add data to a previous file this
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
switch Mode
case 'singleDirectory'
if nargin==0
BaseDirectoryLocation=uigetdir('V:\Brendan\ED study\radiobiology base directory\IMRT\F3','select base directory');
end
fid=fopen(fullfile(BaseDirectoryLocation,'BaseDirectoryInfo.txt'));
BaseDirectoryInfo=textscan(fid,'%s %f');
maxnum_metrics=BaseDirectoryInfo{1,2}(1);
number_structures=BaseDirectoryInfo{1,2}(2);
maxnum_plans=BaseDirectoryInfo{1,2}(3);
%read in list of plans which are to have metrics calculated for them
plans=read_plans2(BaseDirectoryLocation,maxnum_plans);
%read in list of metrics to be calculated for each structure
structure_metrics=read_structure_metrics2(BaseDirectoryLocation,maxnum_metrics,number_structures);
% %for each plan, for each structure calculate the required metrics and
%output them in excel
for i=1:maxnum_plans
%for excel output
for l=1:number_structures
%separate one cell string array per structure- for ease of
%understanding
st_structure_metrics=cellstr(structure_metrics{l}{1});
DVHs=generate_DVHsboost (maxnum_metrics,BaseDirectoryLocation,plans{i},st_structure_metrics);
DVHcombined{i,l}=DVHs;
combmetric = calculate_structure_metrics8 (BaseDirectoryLocation,maxnum_metrics,st_structure_metrics,DVHs);
metric=combmetric.metric;
output_metrics_excel3(BaseDirectoryLocation,st_structure_metrics{1},i,maxnum_metrics,metric,xlnum,{plans{1,i}{1,1}{1,1}},st_structure_metrics);
if plotparams==1
output_metrics_excel3( BaseDirectoryLocation,[st_structure_metrics{1} 'params'],i,maxnum_metrics,combmetric.metricparams,xlnum,{plans{1,i}{1,1}{1,1}},st_structure_metrics);
end
end
end
if plotDVHs==1
DVH4( BaseDirectoryLocation, number_structures,maxnum_plans,DVHcombined,'cumulative')
close all
end
case 'batch'
warning('not coded yet')
if nargin==0
BaseDirectoryLocation=uigetdir('V:\Brendan\ED study\radiobiology base directory\IMRT\F3','select base directory');
end
fid=fopen(fullfile(BaseDirectoryLocation,'BaseDirectoryInfo.txt'));
BaseDirectoryInfo=textscan(fid,'%s %f');
maxnum_metrics=BaseDirectoryInfo{1,2}(1);
number_structures=BaseDirectoryInfo{1,2}(2);
maxnum_plans=BaseDirectoryInfo{1,2}(3);
%set values below to 1 if you want to plot the DVHs or the parameter
%values or set it to anything else if you don't want to ( much quicker)
plotDVHs=1;
plotparams=0;
%position of data in excel, if you wish to add data to a previous file this
%can be changed to start where the previous data finished
xlnum=1;
% %read in list of plans which are to have metrics calculated for them
plans=read_plans2(BaseDirectoryLocation,maxnum_plans);
% %read in list of metrics to be calculated for each structure
structure_metrics=read_structure_metrics2(BaseDirectoryLocation,maxnum_metrics,number_structures);
% %for each plan, for each structure calculate the required metrics and
%output them in excel
for i=1:maxnum_plans
%for excel output
for l=1:number_structures
%separate one cell string array per structure- for ease of
%understanding
st_structure_metrics=cellstr(structure_metrics{l}{1});
DVHs=generate_DVHsboost (maxnum_metrics,BaseDirectoryLocation,plans{i},st_structure_metrics);
DVHcombined{i,l}=DVHs;
combmetric = calculate_structure_metrics8 (BaseDirectoryLocation,maxnum_metrics,st_structure_metrics,DVHs);
metric=combmetric.metric;
output_metrics_excel3(BaseDirectoryLocation,st_structure_metrics{1},i,maxnum_metrics,metric,xlnum,{plans{1,i}{1,1}{1,1}},st_structure_metrics);
if plotparams==1
output_metrics_excel3( BaseDirectoryLocation,[st_structure_metrics{1} 'params'],i,maxnum_metrics,combmetric.metricparams,xlnum,{plans{1,i}{1,1}{1,1}},st_structure_metrics);
end
end
end
if plotDVHs==1
DVH4( BaseDirectoryLocation, number_structures,maxnum_plans,DVHcombined,'cumulative')
close all
end
end
fclose all