Пример #1
0
 def prescription_real_dose_test(self):
     t = TEST.Test(
         "Skal stemme overens (innenfor 0.5%) med aktuell dose for nomeringsvolum (eller punkt)",
         True, self.dose)
     if self.ts_beam_set.beam_set.Modality == 'Photons':
         cum_pr_dose = RSU.prescription_dose(self.ts_beam_set.beam_set)
         diff_pr_dose = RSU.differential_prescription_dose(
             self.ts_beam_set.ts_plan.plan, self.ts_beam_set.beam_set)
         low_dose = round(diff_pr_dose * 0.995, 2)
         high_dose = round(diff_pr_dose * 1.005, 2)
         t.expected = "<" + str(low_dose) + " - " + str(high_dose) + ">"
         # If the prescription type is "SITE", we are not able to verify the prescription (at least currently):
         try:
             struct = self.prescription.PrimaryDosePrescription.OnStructure
         except:
             struct = None
         if struct:
             # What type of prescription has been used?
             if self.prescription.PrimaryDosePrescription.PrescriptionType == 'DoseAtPoint':
                 norm_poi = RSU.ss_poi_geometry(self.ts_beam_set.beam_set,
                                                struct)
                 p = {
                     'x': norm_poi.Point.x,
                     'y': norm_poi.Point.y,
                     'z': norm_poi.Point.z
                 }
                 real_poi_dose = RSU.gy(
                     self.ts_beam_set.beam_set.FractionDose.
                     InterpolateDoseInPoint(Point=p)
                 ) * self.ts_beam_set.beam_set.FractionationPattern.NumberOfFractions
                 if real_poi_dose < low_dose or real_poi_dose > high_dose:
                     return t.fail(round(real_poi_dose, 2))
                 else:
                     return t.succeed()
             if self.prescription.PrimaryDosePrescription.PrescriptionType == 'MedianDose':
                 real_dose_d50 = RSU.gy(
                     self.ts_beam_set.beam_set.FractionDose.
                     GetDoseAtRelativeVolumes(RoiName=struct.Name,
                                              RelativeVolumes=[0.50])[0]
                 ) * self.ts_beam_set.beam_set.FractionationPattern.NumberOfFractions
                 if real_dose_d50 < low_dose or real_dose_d50 > high_dose:
                     return t.fail(round(real_dose_d50, 2))
                 else:
                     return t.succeed()
             elif self.prescription.PrimaryDosePrescription.PrescriptionType == 'DoseAtVolume':
                 real_dose_d99 = RSU.gy(
                     self.ts_beam_set.beam_set.FractionDose.
                     GetDoseAtRelativeVolumes(RoiName=struct.Name,
                                              RelativeVolumes=[0.99])[0]
                 ) * self.ts_beam_set.beam_set.FractionationPattern.NumberOfFractions
                 if real_dose_d99 < low_dose or real_dose_d99 > high_dose:
                     return t.fail(round(real_dose_d99, 2))
                 else:
                     return t.succeed()
 def clinical_max_test(self):
     t = TEST.Test(
         "Skal i utgangspunktet være mindre enn 105% av normeringsdosen",
         True, self.maks)
     ts = TEST.Test(
         "Skal i utgangspunktet være mindre enn 150% av normeringsdosen",
         True, self.maks)
     diff_pr_dose = RSU.differential_prescription_dose(
         self.ts_beam_set.ts_plan.plan, self.ts_beam_set.beam_set)
     ss = self.ts_beam_set.ts_structure_set().structure_set
     if SSF.has_named_roi_with_contours(ss, ROIS.external.name):
         #external = RSU.ss_roi_geometry(self.ts_beam_set.beam_set, self.ts_beam_set.ts_plan.ts_case.case.PatientModel.RegionsOfInterest[ROIS.external.name])
         external = ss.OutlineRoiGeometry
         volume = external.GetRoiVolume()
         # Determine the fraction corresponding to a 2cc volume:
         fraction = 2 / volume
         #clinical_max_dose = RSU.gy(self.ts_beam_set.beam_set.FractionDose.GetDoseAtRelativeVolumes(RoiName = external.OfRoi.Name, RelativeVolumes = [fraction])[0]) * self.ts_beam_set.beam_set.FractionationPattern.NumberOfFractions
         if self.ts_beam_set.ts_label.label.technique:
             if not self.ts_beam_set.ts_label.label.technique.upper(
             ) == 'S':
                 clinical_max_dose = RSU.gy(
                     self.ts_beam_set.beam_set.FractionDose.
                     GetDoseAtRelativeVolumes(RoiName=external.OfRoi.Name,
                                              RelativeVolumes=[fraction])[0]
                 ) * self.ts_beam_set.beam_set.FractionationPattern.NumberOfFractions
                 if clinical_max_dose > diff_pr_dose * 1.05:
                     t.expected = "<" + str(round(diff_pr_dose * 1.05, 2))
                     return t.fail(round(clinical_max_dose, 2))
                 else:
                     return t.succeed()
             elif self.ts_beam_set.ts_label.label.technique.upper() == 'S':
                 clinical_max_dose = RSU.gy(
                     self.ts_beam_set.beam_set.FractionDose.
                     GetDoseAtRelativeVolumes(RoiName=external.OfRoi.Name,
                                              RelativeVolumes=[0])[0]
                 ) * self.ts_beam_set.beam_set.FractionationPattern.NumberOfFractions
                 if clinical_max_dose > diff_pr_dose * 1.50:
                     ts.expected = "<" + str(round(diff_pr_dose * 1.50, 2))
                     ts.fail(round(clinical_max_dose, 2))
                 else:
                     ts.succeed()
Пример #3
0
 def clinical_max_test(self):
     ss = self.ts_beam_set.ts_structure_set().structure_set
     if SSF.has_named_roi_with_contours(ss, ROIS.external.name):
         # Get the external ROI and its volume:
         external = ss.OutlineRoiGeometry
         volume = external.GetRoiVolume()
         # Determine which max dose level and volume fraction is to be used:
         if self.is_stereotactic():
             # Use point dose (0 cc):
             fraction = 0
             # For stereotactic treatments, max allowed dose is dependent on site:
             if self.ts_beam_set.ts_label.label.region in RC.brain_codes:
                 # Brain SRT:
                 max_factor = 1.7
             else:
                 # Other SBRT:
                 max_factor = 1.5
         else:
             # Use the fraction which gives a 2 cc volume:
             fraction = 2 / volume
             # For conventional treatment max allowed dose is 105 %:
             max_factor = 1.05
         # The differential dose of this prescription:
         diff_pr_dose = RSU.differential_prescription_dose(
             self.ts_beam_set.ts_plan.plan, self.ts_beam_set.beam_set)
         # Create the test:
         expected = "<" + str(round(diff_pr_dose * max_factor, 2))
         t = TEST.Test(
             "Skal i utgangspunktet være mindre enn {} % av normeringsdosen"
             .format(round(max_factor * 100)), expected, self.max)
         # Get the clinical max dose:
         clinical_max_dose = RSU.gy(
             self.ts_beam_set.beam_set.FractionDose.
             GetDoseAtRelativeVolumes(RoiName=external.OfRoi.Name,
                                      RelativeVolumes=[fraction])[0]
         ) * self.ts_beam_set.beam_set.FractionationPattern.NumberOfFractions
         # Is it outside the set limit?
         if clinical_max_dose > diff_pr_dose * max_factor:
             return t.fail(round(clinical_max_dose, 2))
         else:
             return t.succeed()
Пример #4
0
 def target_volume_normalisation_for_sib_test(self):
     if self.ts_label.label.region in RC.prostate_codes + RC.breast_codes + RC.rectum_codes:
         ss = self.ts_structure_set().structure_set
         roi_dict = SSF.create_roi_dict(ss)
         potential_target_volumes = [
             ROIS.ctv_47.name, ROIS.ctv_56.name, ROIS.ctv_70_sib.name,
             ROIS.ctv_57.name
         ]
         objective_target_volumes = {}
         # Create a dictionary of all CTVs defined as an objective.
         po = RSU.plan_optimization(self.ts_plan.plan, self.beam_set)
         if po:
             for objective in po.Objective.ConstituentFunctions:
                 if objective.ForRegionOfInterest.Type == 'Ctv':
                     objective_target_volumes[
                         objective.ForRegionOfInterest.Name] = True
         # Check in the list of potential SIB volumes if any exist in the structure set, define as target
         for i in range(len(potential_target_volumes)):
             if roi_dict.get(potential_target_volumes[i]):
                 target = potential_target_volumes[i]
                 t = TEST.Test(
                     "Skal stemme overens (innenfor 0.5%) med aktuell dose for normeringsvolumet "
                     + target + ".", True, self.norm_dose)
                 # Check if the target was used as objective
                 if objective_target_volumes.get(target):
                     # Use the two last characters in the target-string to find the wanted median dose of that target volume
                     if int(target[-2:]) > 30:
                         prescription_dose = int(target[-2:])
                         low_dose = round(prescription_dose * 0.995, 2)
                         high_dose = round(prescription_dose * 1.005, 2)
                         real_dose_d50 = RSU.gy(
                             self.beam_set.FractionDose.
                             GetDoseAtRelativeVolumes(
                                 RoiName=target, RelativeVolumes=[0.50])[0]
                         ) * self.beam_set.FractionationPattern.NumberOfFractions
                         t.expected = ">" + str(
                             low_dose) + " og " + "<" + str(high_dose)
                         if real_dose_d50 < low_dose or real_dose_d50 > high_dose:
                             t.fail(round(real_dose_d50, 2))
                         else:
                             t.succeed()