Skip to content

Commit c28dd6a

Browse files
committed
Fix bug in evaluation.py to display clinical criteria
1 parent 283cea0 commit c28dd6a

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<img src="./images/PortPy_logo.png" width="40%" height="40%">
44
</p>
55

6-
![Version](https://img.shields.io/static/v1?label=latest&message=v1.0.4.4&color=darkgreen)
6+
![Version](https://img.shields.io/static/v1?label=latest&message=v1.0.4.5&color=darkgreen)
77
[![Total Downloads](https://static.pepy.tech/personalized-badge/portpy?period=total&units=international_system&left_color=grey&right_color=blue&left_text=total%20downloads)](https://pepy.tech/project/portpy?&left_text=totalusers)
88
[![Monthly Downloads](https://static.pepy.tech/badge/portpy/month)](https://pepy.tech/project/portpy)
99
# What is PortPy?

portpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "1.0.4.4"
1+
__version__ = "1.0.4.5"
22

33
from portpy import photon

portpy/photon/evaluation.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
6060
clinical_criteria = my_plan.clinical_criteria
6161
# df = pd.DataFrame.from_dict(clinical_criteria.clinical_criteria_dict['criteria'])
6262
df = pd.json_normalize(clinical_criteria.clinical_criteria_dict['criteria'])
63-
dose_volume_V_ind = df.index[df['type'] == 'dose_volume_V'].tolist()
63+
if df.empty:
64+
dose_volume_V_ind = []
65+
else:
66+
dose_volume_V_ind = df.index[df['type'] == 'dose_volume_V'].tolist()
6467
if dose_volume_V_ind:
6568
volumn_cols = [col for col in df.columns if 'volume' in col]
6669
if volumn_cols:
@@ -99,7 +102,10 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
99102
if 'goal' in col:
100103
df = Evaluation.add_dvh_to_frame(my_plan, df, 'Goal', col, 'Gy')
101104

102-
dose_volume_D_ind = df.index[df['type'] == 'dose_volume_D'].tolist()
105+
if df.empty:
106+
dose_volume_D_ind = []
107+
else:
108+
dose_volume_D_ind = df.index[df['type'] == 'dose_volume_D'].tolist()
103109
if dose_volume_D_ind:
104110
vol_cols = [col for col in df.columns if 'parameters.volume' in col]
105111
if vol_cols:
@@ -114,8 +120,11 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
114120
# df = df.drop(
115121
# ['parameters.dose_gy', 'constraints.limit_dose_gy', 'constraints.limit_volume_perc',
116122
# 'constraints.goal_dose_gy', 'constraints.goal_volume_perc','parameters.structure_def'], axis=1, errors='ignore')
117-
if 'Goal' not in df:
118-
df['Goal'] = ''
123+
for label in ['constraint', 'structure_name', 'Limit', 'Goal']:
124+
if label not in df:
125+
df[label] = ''
126+
# if 'Goal' not in df:
127+
# df['Goal'] = ''
119128
df = df[['constraint', 'structure_name', 'Limit', 'Goal']]
120129

121130
dose_1d_list = []
@@ -191,6 +200,9 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
191200
elif 'Gy' in str(df.Limit[ind]) or 'Gy' in str(df.Goal[ind]):
192201
df.at[ind, sol_names[p]] = np.round(dose, 2)
193202
df.round(2)
203+
for sol_name in sol_names:
204+
if sol_name not in df:
205+
df[sol_name] = ''
194206
df = df[df[sol_names].notna().all(axis=1)] # remove rows for which plan value is Nan
195207
df = df.fillna('')
196208
# df.dropna(axis=0, inplace=True) # remove structures which are not present

0 commit comments

Comments
 (0)