@@ -60,7 +60,10 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
60
60
clinical_criteria = my_plan .clinical_criteria
61
61
# df = pd.DataFrame.from_dict(clinical_criteria.clinical_criteria_dict['criteria'])
62
62
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 ()
64
67
if dose_volume_V_ind :
65
68
volumn_cols = [col for col in df .columns if 'volume' in col ]
66
69
if volumn_cols :
@@ -99,7 +102,10 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
99
102
if 'goal' in col :
100
103
df = Evaluation .add_dvh_to_frame (my_plan , df , 'Goal' , col , 'Gy' )
101
104
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 ()
103
109
if dose_volume_D_ind :
104
110
vol_cols = [col for col in df .columns if 'parameters.volume' in col ]
105
111
if vol_cols :
@@ -114,8 +120,11 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
114
120
# df = df.drop(
115
121
# ['parameters.dose_gy', 'constraints.limit_dose_gy', 'constraints.limit_volume_perc',
116
122
# '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'] = ''
119
128
df = df [['constraint' , 'structure_name' , 'Limit' , 'Goal' ]]
120
129
121
130
dose_1d_list = []
@@ -191,6 +200,9 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
191
200
elif 'Gy' in str (df .Limit [ind ]) or 'Gy' in str (df .Goal [ind ]):
192
201
df .at [ind , sol_names [p ]] = np .round (dose , 2 )
193
202
df .round (2 )
203
+ for sol_name in sol_names :
204
+ if sol_name not in df :
205
+ df [sol_name ] = ''
194
206
df = df [df [sol_names ].notna ().all (axis = 1 )] # remove rows for which plan value is Nan
195
207
df = df .fillna ('' )
196
208
# df.dropna(axis=0, inplace=True) # remove structures which are not present
0 commit comments