Skip to content

Commit 56aaf17

Browse files
committed
Fix warnings in structures and visualization.py. Fix bug in clinical_criteria.py dvh constraints. Remove typing from dependency
1 parent 238659c commit 56aaf17

File tree

8 files changed

+17
-13
lines changed

8 files changed

+17
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ docs/_build/
5454
/ai_data/
5555
/checkpoints/
5656
/results/
57+
/metadata/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
</h2>
1212

13-
![Version](https://img.shields.io/static/v1?label=latest&message=v1.0.5&color=darkgreen)
13+
![Version](https://img.shields.io/static/v1?label=latest&message=v1.0.6&color=darkgreen)
1414
[![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)
1515
[![Monthly Downloads](https://static.pepy.tech/badge/portpy/month)](https://pepy.tech/project/portpy)
1616

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.5"
1+
__version__ = "1.0.6"
22

33
from portpy import photon

portpy/photon/clinical_criteria.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ def convert_dvh_to_dose_gy_vol_perc(my_plan, old_criteria):
188188
criteria = deepcopy(old_criteria)
189189
struct_name = criteria['parameters']['structure_name']
190190
if criteria['type'] == 'dose_volume_D':
191-
constraint_keys = criteria['constraints'].keys()
191+
constraint_keys = list(criteria['constraints'].keys())
192192
for key in constraint_keys:
193193
if 'perc' in key:
194194
value = criteria['constraints'][key]
195195
new_key = key.replace('perc', 'gy')
196196
criteria['constraints'][new_key] = criteria['constraints'].pop(key)
197197
criteria['constraints'][new_key] = value / 100 * my_plan.get_prescription()
198-
param_keys = criteria['parameters'].keys()
198+
param_keys = list(criteria['parameters'].keys())
199199
for key in param_keys:
200200
if 'volume_cc' in key:
201201
value = criteria['parameters'][key]
@@ -204,15 +204,15 @@ def convert_dvh_to_dose_gy_vol_perc(my_plan, old_criteria):
204204
criteria['parameters'][new_key] = value / my_plan.structures.get_volume_cc(
205205
struct_name.upper()) * 100
206206
if criteria['type'] == 'dose_volume_V':
207-
constraint_keys = criteria['constraints'].keys()
207+
constraint_keys = list(criteria['constraints'].keys())
208208
for key in constraint_keys:
209209
if 'volume_cc' in key:
210210
value = criteria['constraints'][key]
211211
new_key = key.replace('cc', 'perc')
212212
criteria['constraints'][new_key] = criteria['constraints'].pop(key)
213213
criteria['constraints'][new_key] = value / my_plan.structures.get_volume_cc(
214214
struct_name.upper()) * 100
215-
param_keys = criteria['parameters'].keys()
215+
param_keys = list(criteria['parameters'].keys())
216216
for key in param_keys:
217217
if 'dose_perc' in key:
218218
value = criteria['parameters'][key]

portpy/photon/structures.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,10 @@ def create_structure(self, new_struct_name: str, mask_3d: np.ndarray) -> None:
333333
frac_of_mask_in_calc_box = mask_3d & dose_mask
334334
counts = np.count_nonzero(frac_of_mask_in_calc_box)
335335
volume_cc_in_calc_box = counts * np.prod(self._ct_voxel_resolution_xyz_mm) / 1000
336-
self.structures_dict['fraction_of_vol_in_calc_box'].append(volume_cc_in_calc_box/volume_cc)
336+
if volume_cc == 0:
337+
self.structures_dict['fraction_of_vol_in_calc_box'].append(0)
338+
else:
339+
self.structures_dict['fraction_of_vol_in_calc_box'].append(volume_cc_in_calc_box/volume_cc) # avoid divide by zero error
337340
else:
338341
self.structures_dict[key].append(None)
339342

portpy/photon/visualization.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ def plot_dvh(my_plan: Plan, sol: dict = None, dose_1d: np.ndarray = None, struct
123123
elif dose_scale == 'Relative(%)':
124124
x = x / pres * 100
125125
max_dose = np.maximum(max_dose, x[-1])
126-
ax.set_xlabel('Dose ($\%$)', fontsize=fontsize)
126+
ax.set_xlabel(r'Dose ($\%$)', fontsize=fontsize)
127127

128128
if volume_scale == 'Absolute(cc)':
129129
y = y * my_plan.structures.get_volume_cc(all_orgs[i]) / 100
130130
max_vol = np.maximum(max_vol, y[1] * 100)
131131
ax.set_ylabel('Volume (cc)', fontsize=fontsize)
132132
elif volume_scale == 'Relative(%)':
133133
max_vol = np.maximum(max_vol, y[0] * 100)
134-
ax.set_ylabel('Fractional Volume ($\%$)', fontsize=fontsize)
134+
ax.set_ylabel(r'Fractional Volume ($\%$)', fontsize=fontsize)
135135
ax.plot(x, 100 * y, linestyle=style, linewidth=width, color=colors[count], label=struct_names[i])
136136
count = count + 1
137137
# legend.append(struct_names[i])
@@ -275,6 +275,7 @@ def plot_robust_dvh(my_plan: Plan, sol: dict = None, dose_1d_list: list = None,
275275
print('Skipping Structure {} as it is not within calculation box.'.format(all_orgs[i]))
276276
continue
277277
dose_sort_list = []
278+
y = []
278279
for dose_1d in dose_1d_list:
279280
x, y = Evaluation.get_dvh(sol, struct=all_orgs[i], dose_1d=dose_1d)
280281
dose_sort_list.append(x)
@@ -289,15 +290,15 @@ def plot_robust_dvh(my_plan: Plan, sol: dict = None, dose_1d_list: list = None,
289290
elif dose_scale == 'Relative(%)':
290291
max_dose = np.maximum(max_dose, d_max_mat[-1])
291292
max_dose = max_dose / pres * 100
292-
ax.set_xlabel('Dose ($\%$)', fontsize=fontsize)
293+
ax.set_xlabel(r'Dose ($\%$)', fontsize=fontsize)
293294

294295
if volume_scale == 'Absolute(cc)':
295296
y = y * my_plan.structures.get_volume_cc(all_orgs[i]) / 100
296297
max_vol = np.maximum(max_vol, y[1] * 100)
297298
ax.set_ylabel('Volume (cc)', fontsize=fontsize)
298299
elif volume_scale == 'Relative(%)':
299300
max_vol = np.maximum(max_vol, y[0] * 100)
300-
ax.set_ylabel('Fractional Volume ($\%$)', fontsize=fontsize)
301+
ax.set_ylabel(r'Fractional Volume ($\%$)', fontsize=fontsize)
301302
# ax.plot(x, 100 * y, linestyle=style, linewidth=width, color=colors[count])
302303

303304
# ax.plot(d_min_mat, 100 * y, linestyle='dotted', linewidth=width*0.5, color=colors[count])

requirements.txt

-34 Bytes
Binary file not shown.

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def _get_portpy_photon_version():
6464
"Shapely>=1.8.4",
6565
"SimpleITK>=2.0.2",
6666
"tabulate>=0.9.0",
67-
"typing>=3.7.4.3",
6867
"jinja2>=3.0.1",
6968
"typing-extensions>=3.10.0.0",
7069
"scikit-image>=0.17.2",
@@ -79,7 +78,7 @@ def _get_portpy_photon_version():
7978
extras_require={
8079
'mosek': ["Mosek>=9.3.14"],
8180
'pydicom': ["pydicom>=2.2.0"],
82-
'full': ["Mosek>=9.3.14", "pydicom>=2.2.0"],
81+
'full': ["Mosek>=9.3.14", "pydicom>=2.2.0", "websocket-client>=1.8.0", "visdom>=0.2.4", "dominate>=2.6.0", "torch>=2.2.0", "torchfile==0.1.0", "torchvision==0.9.1"],
8382
'ai': ["websocket-client>=1.8.0", "visdom>=0.2.4", "dominate>=2.6.0", "torch>=2.2.0", "torchfile==0.1.0", "torchvision==0.9.1"]
8483
}
8584

0 commit comments

Comments
 (0)