-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmetrics_examples.py
More file actions
51 lines (46 loc) · 1.69 KB
/
Copy pathmetrics_examples.py
File metadata and controls
51 lines (46 loc) · 1.69 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import matplotlib.pyplot as plt
import os
from complexity.PyComplexityMetric import (
PyComplexityMetric,
MeanAreaMetricEstimator,
AreaMetricEstimator,
ApertureIrregularityMetric,
)
from complexity.misc import ModulationIndexScore
from complexity.dicomrt import RTPlan
if __name__ == "__main__":
# Path to DICOM RTPLAN file - IMRT/VMAT
# pfile = "RP.dcm"
path_to_rtplan_file = "RP.dcm"
# Getting planning data from DICOM file.
plan_info = RTPlan(filename=path_to_rtplan_file)
plan_dict = plan_info.get_plan()
metrics_list = [
#ModulationIndexScore,
PyComplexityMetric,
MeanAreaMetricEstimator,
AreaMetricEstimator,
ApertureIrregularityMetric,
]
units = ["CI [mm^-1]", "mm^2", "mm^2", "dimensionless"]
# plotting results
for unit, cc in zip(units, metrics_list):
cc_obj = cc()
# compute per plan
plan_metric = cc_obj.CalculateForPlan(None, plan_dict)
print(f"{cc.__name__} Plan Metric - {plan_metric} {unit}")
for k, beam in plan_dict["beams"].items():
# skip setup fields
if beam["TreatmentDeliveryType"] == "TREATMENT" and beam["MU"] > 0:
fig = plt.figure(figsize=(6, 6))
# create a subplot
ax = fig.add_subplot(111)
cpx_beam_cp = cc_obj.CalculateForBeamPerAperture(
None, plan_dict, beam
)
ax.plot(cpx_beam_cp)
ax.set_xlabel("Control Point")
ax.set_ylabel(f"${unit}$")
txt = f"Output - Beam name: {beam['BeamName']} - {cc.__name__}"
ax.set_title(txt)
plt.show()