Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
Python3 fixes for structure volume calculation
Browse files Browse the repository at this point in the history
When the CalculateVolume function in dvhdata.py was called, there was a
call to the itervalues() method, which is not used in Python 3. This was
changed to use the itervalues method in the six library.  Additionally,
the dictionary for each contour slice now has the key 'data' instead of
the previous 'contourData' key.
  • Loading branch information
StephenTerry committed Jan 29, 2018
1 parent 7de5e5c commit b448f65
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dicompyler/dvhdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# It's assumed that the reference (prescription) dose is in cGy.

import numpy as np
from six import itervalues

class DVH:
"""Processes the dose volume histogram from DICOM DVH data."""
Expand Down Expand Up @@ -51,7 +52,7 @@ def CalculateVolume(structure):

n = 0
# Iterate over each plane in the structure
for sPlane in sPlanes.itervalues():
for sPlane in itervalues(sPlanes):

# Calculate the area for each contour in the current plane
contours = []
Expand All @@ -61,7 +62,7 @@ def CalculateVolume(structure):
# Create arrays for the x,y coordinate pair for the triangulation
x = []
y = []
for point in contour['contourData']:
for point in contour['data']:
x.append(point[0])
y.append(point[1])

Expand All @@ -70,7 +71,7 @@ def CalculateVolume(structure):
for i in range(0, len(x)-1):
cArea = cArea + x[i]*y[i+1] - x[i+1]*y[i]
cArea = abs(cArea / 2)
contours.append({'area':cArea, 'data':contour['contourData']})
contours.append({'area':cArea, 'data':contour['data']})

# Determine which contour is the largest
if (cArea > largest):
Expand Down

0 comments on commit b448f65

Please sign in to comment.