def calculate_plane_histogram(plane, doseplane, dosegridpoints,
maxdose, dd, id, structure, hist):
"""Calculate the DVH for the given plane in the structure."""
contours = [[x[0:2] for x in c['data']] for c in plane]
# If there is no dose for the current plane, go to the next plane
if not len(doseplane):
return (np.arange(0, maxdose), 0)
# Create a zero valued bool grid
grid = np.zeros((dd['rows'], dd['columns']), dtype=np.uint8)
# Calculate the histogram for each contour in the plane
# and boolean xor to remove holes
for i, contour in enumerate(contours):
m = get_contour_mask(dd, id, dosegridpoints, contour)
grid = np.logical_xor(m.astype(np.uint8), grid).astype(np.bool)
hist, vol = calculate_contour_dvh(
grid, doseplane, maxdose, dd, id, structure)
return (hist, vol)
评论列表
文章目录