Skip to content

Commit 87c85e4

Browse files
committed
Bug fixes: Add filter dvh to clinical_criteria.py
1 parent bbc3a45 commit 87c85e4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

portpy/photon/clinical_criteria.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ def get_dvh_table(self, my_plan: Plan, constraint_list: list = None, opt_params:
284284
count = count + 1
285285
self.dvh_table = df
286286
self.get_max_tol(constraints_list=constraint_list)
287+
self.filter_dvh(my_plan=my_plan)
287288
return self.dvh_table
288289

289290

@@ -331,4 +332,17 @@ def get_max_tol(self, constraints_list: list = None):
331332
max_tol = self.dose_to_gy(limit_key, criterion['constraints'][limit_key])
332333
dvh_table.at[ind, 'max_tol'] = max_tol
333334

335+
return self.dvh_table
336+
337+
def filter_dvh(self, my_plan: Plan):
338+
dvh_table = deepcopy(self.dvh_table)
339+
drop_indices = []
340+
for ind in dvh_table.index:
341+
structure_name, dose_gy, vol_perc = dvh_table['structure_name'][ind], dvh_table['dose_gy'][ind], \
342+
dvh_table['volume_perc'][ind]
343+
vol_perc = vol_perc / my_plan.inf_matrix.get_fraction_of_vol_in_calc_box(structure_name)
344+
if vol_perc >= 100 or vol_perc <= 0: # remove unnecessary constraints or goals
345+
drop_indices.append(ind)
346+
dvh_table = dvh_table.drop(index=drop_indices).reset_index(drop=True)
347+
self.dvh_table = dvh_table
334348
return self.dvh_table

0 commit comments

Comments
 (0)