dvhcalc.get_interpolated_dose raises IndexError if no dose for z
cutright opened this issue · 1 comments
cutright commented
When there is no dose plane, GetDoseGrid
returns an empty array. So an IndexError
is raised in dvhcalc.get_interpolated_dose
when there is no dose plane:
dicompyler-core/dicompylercore/dvhcalc.py
Lines 490 to 492 in de6a0ed
There is a check for an empty dose plane, but it occurs after get_interpolated_dose
is called.
dicompyler-core/dicompylercore/dvhcalc.py
Lines 206 to 213 in de6a0ed
cutright commented
I changed lines 490+ to the following:
d = dose.GetDoseGrid(z)
if not d.size:
return d
extent_dose = d[extents[1]:extents[3],
extents[0]:extents[2]] if len(extents) else d
But then calculate_contour_dvh
ultimately fails here:
dicompyler-core/dicompylercore/dvhcalc.py
Lines 231 to 233 in de6a0ed
ERROR: Unhandled exception: Traceback (most recent call last):
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\dvha\main.py", line 1808, in Run
run_old(*args, **kwargs)
File "C:\Users\dcutright\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\dvha\models\import_dicom.py", line 2178, in import_target
StudyImporter(*parameters)
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\dvha\models\import_dicom.py", line 1758, in __init__
self.run()
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\dvha\models\import_dicom.py", line 1850, in run
dvh_row = parsed_data.get_dvh_row(roi_key)
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\dvha\db\dicom_parser.py", line 701, in get_dvh_row
dvh_new = dvhcalc.get_dvh(**kwargs)
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\venv-production\lib\site-packages\dicompylercore\dvhcalc.py", line 90, in get_dvh
callback)
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\venv-production\lib\site-packages\dicompylercore\dvhcalc.py", line 233, in _calculate_dvh
dd, id, structure, hist)
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\venv-production\lib\site-packages\dicompylercore\dvhcalc.py", line 270, in calculate_plane_histogram
structure)
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\venv-production\lib\site-packages\dicompylercore\dvhcalc.py", line 299, in calculate_contour_dvh
mask = ma.array(doseplane * dd['dosegridscaling'] * 100, mask=~mask)
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\venv-production\lib\site-packages\numpy\ma\core.py", line 6562, in array
ndmin=ndmin, shrink=shrink, order=order)
File "C:\Users\dcutright\PycharmProjects\DVH-Analytics\venv-production\lib\site-packages\numpy\ma\core.py", line 2909, in __new__
raise MaskError(msg % (nd, nm))
numpy.ma.core.MaskError: Mask and data not compatible: data size is 23443, mask size is 1500352.