Skip to content

Commit

Permalink
Fix bug in evaluation.py to display clinical criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
gourav3017 committed Oct 30, 2024
1 parent 283cea0 commit c28dd6a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<img src="./images/PortPy_logo.png" width="40%" height="40%">
</p>

![Version](https://img.shields.io/static/v1?label=latest&message=v1.0.4.4&color=darkgreen)
![Version](https://img.shields.io/static/v1?label=latest&message=v1.0.4.5&color=darkgreen)
[![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)
[![Monthly Downloads](https://static.pepy.tech/badge/portpy/month)](https://pepy.tech/project/portpy)
# What is PortPy?
Expand Down
2 changes: 1 addition & 1 deletion portpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "1.0.4.4"
__version__ = "1.0.4.5"

from portpy import photon
20 changes: 16 additions & 4 deletions portpy/photon/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
clinical_criteria = my_plan.clinical_criteria
# df = pd.DataFrame.from_dict(clinical_criteria.clinical_criteria_dict['criteria'])
df = pd.json_normalize(clinical_criteria.clinical_criteria_dict['criteria'])
dose_volume_V_ind = df.index[df['type'] == 'dose_volume_V'].tolist()
if df.empty:
dose_volume_V_ind = []
else:
dose_volume_V_ind = df.index[df['type'] == 'dose_volume_V'].tolist()
if dose_volume_V_ind:
volumn_cols = [col for col in df.columns if 'volume' in col]
if volumn_cols:
Expand Down Expand Up @@ -99,7 +102,10 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
if 'goal' in col:
df = Evaluation.add_dvh_to_frame(my_plan, df, 'Goal', col, 'Gy')

dose_volume_D_ind = df.index[df['type'] == 'dose_volume_D'].tolist()
if df.empty:
dose_volume_D_ind = []
else:
dose_volume_D_ind = df.index[df['type'] == 'dose_volume_D'].tolist()
if dose_volume_D_ind:
vol_cols = [col for col in df.columns if 'parameters.volume' in col]
if vol_cols:
Expand All @@ -114,8 +120,11 @@ def display_clinical_criteria(my_plan: Plan, sol: Union[dict, List[dict]] = None
# df = df.drop(
# ['parameters.dose_gy', 'constraints.limit_dose_gy', 'constraints.limit_volume_perc',
# 'constraints.goal_dose_gy', 'constraints.goal_volume_perc','parameters.structure_def'], axis=1, errors='ignore')
if 'Goal' not in df:
df['Goal'] = ''
for label in ['constraint', 'structure_name', 'Limit', 'Goal']:
if label not in df:
df[label] = ''
# if 'Goal' not in df:
# df['Goal'] = ''
df = df[['constraint', 'structure_name', 'Limit', 'Goal']]

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

0 comments on commit c28dd6a

Please sign in to comment.