-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathload_dose_from_dicom.py
33 lines (27 loc) · 1.27 KB
/
load_dose_from_dicom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
==============
Reading dose information from an RTDose Dicom file
==============
Extracts the dose matrix from an RTDose Dicom.
"""
import numpy as np
import rtdsm
from rtdsm import examples
Filename = examples.RDfile()
###############################################################################
# RT Dose Dicom files can be read into numpy arrays using the method get_doseinfo()
dosegrid, xs, ys, zs = rtdsm.get_doseinfo(Filename)
###############################################################################
# The variable dosegrid is the RTDose matrix created during the radiotherapy
# treatment planning process. The variables xs, ys, and zs are arrays that
# specify where the centers of the voxels in dosegrid are located in the patient
# coordinate system. They are necessary to identify the dose to an arbitrary
# point P on an ROI surface object.
#
# IMPORTANT: The dicom standard encodes the dosegrid such that M[i,j,k] is
# formatted as M[z,y,x]. This is the reverse order of how contour point data
# is stored [x,y,z]
# We can determine the location of the center of the voxel dosegrid[40,81,80] as follows
loc = [ xs[80], ys[50], zs[40] ]
print('Dose of voxel at [40,50,80] in the grid:',dosegrid[40,50,80],
'Gy\nLocation in the patient coordinate system:',loc,'mm')