Exemple #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()
Exemple #2
0
 def prescription_dose_test(self):
     t = TEST.Test(
         "Skal stemme overens med totaldose indikert av beam set label.",
         True, self.dose)
     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)
     if self.ts_beam_set.ts_label.label.valid:
         label_dose_acc = RSU.accumulated_label_dose(
             self.ts_beam_set.ts_plan.plan, self.ts_beam_set.beam_set,
             self.ts_beam_set.ts_label.label)
         t.expected = round(label_dose_acc, 2)
         if label_dose_acc != cum_pr_dose:
             return t.fail(cum_pr_dose)
         else:
             return t.succeed()
Exemple #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()
 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()