@@ -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