Skip to content

Commit 3f636f9

Browse files
authored
Bugfix for proton sumplans
1 parent c6e37b5 commit 3f636f9

File tree

3 files changed

+48
-36
lines changed

3 files changed

+48
-36
lines changed

Evaluering4D.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
[assembly: ESAPIScript(IsWriteable = true)]
4141

4242

43-
[assembly: AssemblyVersion("3.0.0.10")] //This parameter must be changed when the script is changed. Hereafter the script must be approved in Eclipse.
43+
[assembly: AssemblyVersion("3.0.0.12")]
4444
[assembly: AssemblyFileVersion("1.0.0.0")]
4545
[assembly: AssemblyInformationalVersion("1.0")]
4646

Evaluering4D.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<OutputType>library</OutputType>
88
<AppDesignerFolder>Properties</AppDesignerFolder>
99
<RootNamespace>Evaluering4D</RootNamespace>
10-
<AssemblyName>Test_Evaluering4D_151123_a.esapi</AssemblyName>
10+
<AssemblyName>Evaluering4D_v3.esapi</AssemblyName>
1111
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
1212
<TargetFrameworkProfile>
1313
</TargetFrameworkProfile>

ExportableDVHs.cs

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,15 @@ internal void SaveAll()
8888
double[] minList = new double[numbOfStructs];
8989
double[] maxList = new double[numbOfStructs];
9090
double[] meanList = new double[numbOfStructs];
91-
double[] DxxList = new double[numbOfStructs];
92-
double[] DyyList = new double[numbOfStructs];
93-
double[] DzzList = new double[numbOfStructs];
91+
double[] D005List = new double[numbOfStructs];
92+
double[] D050List = new double[numbOfStructs];
93+
double[] D100List = new double[numbOfStructs];
94+
double[] D500List = new double[numbOfStructs];
9495

9596
// The header consists of the volume of the structure, the min, max and mean dose and D0.05cc, D0.5cc and D1cc DVH'points as they need a high resolution of the extracted DVH which is not provided.
96-
FillIminmaxmean(minList, maxList, meanList, DxxList,DyyList,DzzList, AllPlans[i], DvhResolution);
97+
FillIminmaxmean(minList, maxList, meanList, D005List,D050List,D100List, D500List, AllPlans[i], DvhResolution);
9798

98-
WriteDVHfile(Folder, filename, dvhList, idList, numbOfStructs, largestDVH, firstLine, volList, minList, maxList, meanList,DxxList, DyyList, DzzList, modalityLine); //MULTI
99+
WriteDVHfile(Folder, filename, dvhList, idList, numbOfStructs, largestDVH, firstLine, volList, minList, maxList, meanList,D005List, D050List, D100List, D500List, modalityLine); //MULTI
99100
}
100101

101102
//We are checking if the nominal plan has uncertainty scenarios. If yes we need to export them as well.
@@ -126,14 +127,14 @@ internal void SaveAll()
126127
double[] minList = new double[numbOfStructs];
127128
double[] maxList = new double[numbOfStructs];
128129
double[] meanList = new double[numbOfStructs];
129-
double[] DxxList = new double[numbOfStructs];
130-
double[] DyyList = new double[numbOfStructs];
131-
double[] DzzList = new double[numbOfStructs];
130+
double[] D005List = new double[numbOfStructs];
131+
double[] D050List = new double[numbOfStructs];
132+
double[] D100List = new double[numbOfStructs];
133+
double[] D500List = new double[numbOfStructs];
132134

135+
FillIminmaxmean(minList, maxList, meanList, D005List, D050List, D100List, D500List, AllPlans[0], uncert, DvhResolution); // Values for the uncertainty scenario
133136

134-
FillIminmaxmean(minList, maxList, meanList, DxxList, DyyList,DzzList, AllPlans[0], uncert, DvhResolution); // Values for the uncertainty scenario
135-
136-
WriteDVHfile(Folder, filename, dvhList, idList, numbOfStructs, largestDVH, firstLine, volList, minList, maxList, meanList,DxxList,DyyList,DzzList, modalityLine);
137+
WriteDVHfile(Folder, filename, dvhList, idList, numbOfStructs, largestDVH, firstLine, volList, minList, maxList, meanList, D005List, D050List, D100List, D500List, modalityLine);
137138
}
138139
}
139140
}
@@ -144,12 +145,13 @@ internal void SaveAll()
144145
/// <param name="minList">List of min dose for each structure</param>
145146
/// <param name="maxList">List of max dose for each structure</param>
146147
/// <param name="meanList">List of mean dose for each structure</param>
147-
/// <param name="DxxList"> List of D0.05cc values in Gy </param>
148-
/// <param name="DyyList">List of D0.5cc values in Gy</param>
149-
/// <param name="DzzList">List of D1.0cc values in Gy</param>
148+
/// <param name="D005List"> List of D0.05cc values in Gy </param>
149+
/// <param name="D050List">List of D0.5cc values in Gy</param>
150+
/// <param name="D100List">List of D1.0cc values in Gy</param>
151+
/// <param name="D500List">List of D5.0cc values in Gy</param>
150152
/// <param name="planSetup">The single plan to extract from</param>
151153
/// <param name="dvhresolution">The dvh resolution</param>
152-
private void FillIminmaxmean(double[] minList, double[] maxList, double[] meanList, double[] DxxList, double[] DyyList,double[] DzzList, PlanSetup planSetup, double dvhresolution)
154+
private void FillIminmaxmean(double[] minList, double[] maxList, double[] meanList, double[] D005List, double[] D050List, double[] D100List, double[] D500List, PlanSetup planSetup, double dvhresolution)
153155
{
154156
int countStruct = 0;
155157
for (int j = 0; j < planSetup.StructureSet.Structures.Count(); j++)
@@ -166,9 +168,10 @@ private void FillIminmaxmean(double[] minList, double[] maxList, double[] meanLi
166168

167169
//We need a high resolution for the volume datapoints
168170
DVHData dvhdata2 = planSetup.GetDVHCumulativeData(planSetup.StructureSet.Structures.ElementAt(j), DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.0001);
169-
DxxList[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 0.05, planSetup.TotalDose.Dose);
170-
DyyList[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 0.5, planSetup.TotalDose.Dose);
171-
DzzList[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 1.0, planSetup.TotalDose.Dose);
171+
D005List[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 0.05, planSetup.TotalDose.Dose);
172+
D050List[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 0.5, planSetup.TotalDose.Dose);
173+
D100List[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 1.0, planSetup.TotalDose.Dose);
174+
D500List[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 5.0, planSetup.TotalDose.Dose);
172175

173176
countStruct++;
174177
}
@@ -180,12 +183,13 @@ private void FillIminmaxmean(double[] minList, double[] maxList, double[] meanLi
180183
/// <param name="minList">List of min dose for each structure</param>
181184
/// <param name="maxList">List of max dose for each structure</param>
182185
/// <param name="meanList">List of mean dose for each structure</param>
183-
/// <param name="DxxList"> List of D0.05cc values in Gy </param>
184-
/// <param name="DyyList">List of D0.5cc values in Gy</param>
185-
/// <param name="DzzList">List of D1.0cc values in Gy</param>
186+
/// <param name="D005List"> List of D0.05cc values in Gy </param>
187+
/// <param name="D050List">List of D0.5cc values in Gy</param>
188+
/// <param name="D100List">List of D1.0cc values in Gy</param>
189+
/// <param name="D500List">List of D5.0cc values in Gy</param>
186190
/// <param name="planSetup">The plan to extract from</param>
187191
/// <param name="dvhresolution">The dvh resolution</param>
188-
private void FillIminmaxmean(double[] minList, double[] maxList, double[] meanList, double[] DxxList, double[] DyyList, double[] DzzList, PlanSetup planSetup, PlanUncertainty uncert, double dvhresolution)
192+
private void FillIminmaxmean(double[] minList, double[] maxList, double[] meanList, double[] D005List, double[] D050List, double[] D100List, double[] D500List, PlanSetup planSetup, PlanUncertainty uncert, double dvhresolution)
189193
{
190194
int countStruct = 0;
191195
for (int j = 0; j < planSetup.StructureSet.Structures.Count(); j++)
@@ -202,9 +206,11 @@ private void FillIminmaxmean(double[] minList, double[] maxList, double[] meanLi
202206

203207
//We need a high resolution for the volume datapoints
204208
DVHData dvhdata2 = uncert.GetDVHCumulativeData(planSetup.StructureSet.Structures.ElementAt(j), DoseValuePresentation.Absolute, VolumePresentation.AbsoluteCm3, 0.0001);
205-
DxxList[countStruct] = CalculateDXXcc(dvhdata2.CurveData,0.05,planSetup.TotalDose.Dose);
206-
DyyList[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 0.5, planSetup.TotalDose.Dose);
207-
DzzList[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 1.0, planSetup.TotalDose.Dose);
209+
D005List[countStruct] = CalculateDXXcc(dvhdata2.CurveData,0.05,planSetup.TotalDose.Dose);
210+
D050List[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 0.5, planSetup.TotalDose.Dose);
211+
D100List[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 1.0, planSetup.TotalDose.Dose);
212+
D500List[countStruct] = CalculateDXXcc(dvhdata2.CurveData, 5.0, planSetup.TotalDose.Dose);
213+
208214
countStruct++;
209215
}
210216
}
@@ -244,11 +250,12 @@ private void FillIVols(double[] volList, PlanSetup planSetup)
244250
/// <param name="minList">All minimum doses</param>
245251
/// <param name="maxList">All maximum doses</param>
246252
/// <param name="meanList">All mean doses</param>
247-
/// <param name="DxxList"> All D0.05cc values in Gy </param>
248-
/// <param name="DyyList">All D0.5cc values in Gy</param>
249-
/// <param name="DzzList">All D1.0cc values in Gy</param>
253+
/// <param name="D005List"> All D0.05cc values in Gy </param>
254+
/// <param name="D050List">All D0.5cc values in Gy</param>
255+
/// <param name="D100List">All D1.0cc values in Gy</param>
256+
///<param name="D500List">All D5.0cc values in Gy</param>
250257
/// <param name="modalityLine">Line descriping modality, resolution of dose and fractionation</param>
251-
private void WriteDVHfile(string v, string filename, double[,] dvhList, string[] idList, int numbOfStructs, int largestDVH, string firstLine, double[] volList, double[] minList, double[] maxList, double[] meanList, double[] DxxList, double[] DyyList, double[] DzzList,string modalityLine)
258+
private void WriteDVHfile(string v, string filename, double[,] dvhList, string[] idList, int numbOfStructs, int largestDVH, string firstLine, double[] volList, double[] minList, double[] maxList, double[] meanList, double[] D005List, double[] D050List, double[] D100List, double[] D500List, string modalityLine)
252259
{
253260
string lines = firstLine + Environment.NewLine;
254261

@@ -293,21 +300,28 @@ private void WriteDVHfile(string v, string filename, double[,] dvhList, string[]
293300
temp = "D0.05cc [Gy] \t";
294301
for (int p = 0; p < numbOfStructs; p++)
295302
{
296-
temp += Math.Round(DxxList[p], 3, MidpointRounding.AwayFromZero).ToString("0.000") + "\t";
303+
temp += Math.Round(D005List[p], 3, MidpointRounding.AwayFromZero).ToString("0.000") + "\t";
297304
}
298305
lines += temp + Environment.NewLine;
299306

300307
temp = "D0.5cc [Gy] \t";
301308
for (int p = 0; p < numbOfStructs; p++)
302309
{
303-
temp += Math.Round(DyyList[p], 3, MidpointRounding.AwayFromZero).ToString("0.000") + "\t";
310+
temp += Math.Round(D050List[p], 3, MidpointRounding.AwayFromZero).ToString("0.000") + "\t";
304311
}
305312
lines += temp + Environment.NewLine;
306313

307314
temp = "D1cc [Gy] \t";
308315
for (int p = 0; p < numbOfStructs; p++)
309316
{
310-
temp += Math.Round(DzzList[p], 3, MidpointRounding.AwayFromZero).ToString("0.000") + "\t";
317+
temp += Math.Round(D100List[p], 3, MidpointRounding.AwayFromZero).ToString("0.000") + "\t";
318+
}
319+
lines += temp + Environment.NewLine;
320+
321+
temp = "D5cc [Gy] \t";
322+
for (int p = 0; p < numbOfStructs; p++)
323+
{
324+
temp += Math.Round(D500List[p], 3, MidpointRounding.AwayFromZero).ToString("0.000") + "\t";
311325
}
312326
lines += temp + Environment.NewLine;
313327

@@ -346,7 +360,6 @@ private void FillValues(double[,] dvhList, PlanSetup planSetup, int largestDVH,
346360
//Here we start by 1 as the first column is the dose
347361
//We will find all struyctures to fill in.
348362
int countStruct = 1;
349-
//double resolutiondvh = 0.1;
350363
for (int j = 0; j < planSetup.StructureSet.Structures.Count(); j++)
351364
{
352365
if (planSetup.StructureSet.Structures.ElementAt(j) == null || planSetup.StructureSet.Structures.ElementAt(j).IsEmpty || planSetup.StructureSet.Structures.ElementAt(j).DicomType.ToLower() == "support")
@@ -385,7 +398,6 @@ private void FillValues(double[,] dvhList, PlanSetup planSetup, int largestDVH,
385398
//Here we start by 1 as the first column is the dose
386399
//We will find all struyctures to fill in.
387400
int countStruct = 1;
388-
//double resolutiondvh = 0.1;
389401
for (int j = 0; j < planSetup.StructureSet.Structures.Count(); j++)
390402
{
391403
if (planSetup.StructureSet.Structures.ElementAt(j) == null || planSetup.StructureSet.Structures.ElementAt(j).IsEmpty || planSetup.StructureSet.Structures.ElementAt(j).DicomType.ToLower() == "support")

0 commit comments

Comments
 (0)