Prescription¶
Define Prescription and methods for parsing prescription data
from python objects as well as JSON- or YAML-formatted files.
Parsing methods expect the following formats.
YAML:
- name : PTV
label : 1
is_target: Yes
dose : 35.
constraints:
- "D90 >= 32.3Gy"
- "D1 <= 1.1rx"
- name : OAR1
label : 2
is_target: No
dose :
constraints:
- "D95 <= 20Gy"
- "V30 Gy <= 20%"
Python list of dict (JSON approximately the same):
[{
"name" : "PTV",
"label" : 1,
"is_target" : True,
"dose" : 35.,
"constraints" : ["D1 <= 1.1rx", "D90 >= 32.3Gy"]
}, {
"name" : "OAR1",
"label" : 2,
"is_target" : False,
"dose" : None,
"constraints" : ["D95 <= 20Gy"]
}]
- JSON verus Python syntax differences:
true/falseinstead ofTrue/Falsenullinstead ofNone
-
class
prescription.Prescription(prescription_data=None)[source]¶ Class for specifying structures with dose targets and constraints.
-
add_structure_to_dictionaries(structure)[source]¶ Add a new structure to internal representation of prescription.
Parameters: structure ( Structure) – Structure added toPrescription.structure_dict. An corresponding, empty constraint list is added toPrescription.constraint_dict.Returns: None Raises: TypeError– Ifstructurenot aStructure.
-
constraints_by_label¶ Dictionary of constraints in prescription, by structure label.
-
dict¶ Dictionary of structures in prescription, by label.
-
digest(prescription_data)[source]¶ Populate
Prescription‘s structures and dose constraints.Specifically, for each entry in
prescription_data, construct aStructureto capture structure data (e.g., name, label), as well as a corresponding but separateConstraintListobject to capture any dose constraints specified for the structure.Add each such structure to
Prescription.structure_dict, and each such constraint list toPrescription.constraint_dict. Build or copy a “list of dictionaries” representation of the prescription data, assign toPrescription.rx_list.Parameters: prescription_data – Input to be parsed for structure and dose constraint data. Accepted formats include strspecifying a valid path to a suitably-formatted JSON or YAML file, or a suitably-formattedlistofdictobjects.Returns: None Raises: TypeError– If input not of typelistor astrspecfying a valid path to file that can be loaded with thejson.load()oryaml.safe_load()methods.
-
list¶ List of structures in prescription
-
report(anatomy)[source]¶ Reports whether
anatomyfulfills all prescribed constraints.Parameters: anatomy ( Antomy) – Container of structures to compare against prescribed constraints.Returns: Dictionary keyed by structure label, with data on each dose constraint associated with that structure in this Prescription. Reported data includes the constraint, whether it was satisfied, and the actual dose achieved at the percentile/threshold specified by the constraint.Return type: dictRaises: TypeError– Ifanatomynot anAnatomy.
-