コード例 #1
0
def create_algebra_roi(pm, examination, ss, roi):
    pm.CreateRoi(Name=roi.name, Color=roi.color, Type=roi.type)
    # Get ROI geometry:
    roi_geometry = SSF.rg(ss, roi.name)
    # Make sure that all ROI sources exists:
    missing = []
    sources = list(
        roi.sourcesA
    )  # (we need to make sure that we're working on a copy of this list)
    sources.extend(roi.sourcesB)
    for source_roi in sources:
        if not SSF.has_roi(ss, source_roi.name):
            missing.append(source_roi.name)
    if len(missing) == 0:
        roi_geometry.OfRoi.CreateAlgebraGeometry(
            Examination=examination,
            ExpressionA=roi.expressionA(),
            ExpressionB=roi.expressionB(),
            ResultOperation=roi.operator,
            ResultMarginSettings=roi.result_margin_settings())
        roi_geometry.OfRoi.SetAlgebraExpression(
            ExpressionA=roi.expressionA(),
            ExpressionB=roi.expressionB(),
            ResultOperation=roi.operator,
            ResultMarginSettings=roi.result_margin_settings())
        roi_geometry.OfRoi.UpdateDerivedGeometry(Examination=examination)
    else:
        GUIF.handle_missing_roi_for_derived_rois(roi.name, missing)
コード例 #2
0
def setup_clinical_goals(ss, es, site, prescription, target):
    for cg in site.target_clinical_goals:
        # Make sure corresponding ROI exists before trying to create clinical goal:
        if SSF.has_roi(ss, cg.name):
            if cg.name in [
                    ROIS.external.name, ROIS.igtv.name, ROIS.gtv.name
            ] and cg.criteria == 'AtMost' and cg.tolerance != 5000:
                cg.apply_to(es,
                            normalized_tolerance=round(
                                cg.tolerance * prescription.total_dose * 100,
                                0))
            elif cg.name in [
                    ROIS.ctv_sb.name, ROIS.ptv_sbc.name
            ] and target != ROIS.ctv_sb.name or cg.tolerance == 5000 or cg.type == homogeneity_index:
                cg.apply_to(es)
            elif cg.type == conformity_index:
                cg.apply_to(es,
                            normalized_value=round(
                                cg.value * prescription.total_dose * 100, 0))
            else:
                cg.apply_to(es,
                            normalized_tolerance=round(
                                cg.tolerance * prescription.total_dose * 100,
                                0))
        else:
            # Missing ROI:
            GUIF.handle_missing_roi_for_clinical_goal(cg.name)
    for cg in site.oar_clinical_goals:
        # Make sure corresponding ROI exists before trying to create clinical goal:
        if SSF.has_roi(ss, cg.name):
            if cg.type in [dose_at_volume, dose_at_abs_volume, average_dose]:
                cg.apply_to(
                    es,
                    normalized_tolerance=round(
                        cg.tolerance.equivalent(prescription.nr_fractions) *
                        100, 0))
            else:
                cg.apply_to(
                    es,
                    normalized_value=round(
                        cg.value.equivalent(prescription.nr_fractions) * 100,
                        0))
        else:
            # Missing ROI:
            GUIF.handle_missing_roi_for_clinical_goal(cg.name)
コード例 #3
0
def create_wall_roi(pm, examination, ss, roi):
    pm.CreateRoi(Name=roi.name, Color=roi.color, Type=roi.type)
    roi_geometry = SSF.rg(ss, roi.name)
    # Make sure that the source ROI exists:
    if SSF.has_roi(ss, roi.source.name):
        roi_geometry.OfRoi.SetWallExpression(SourceRoiName=roi.source.name,
                                             OutwardDistance=roi.outward_dist,
                                             InwardDistance=roi.inward_dist)
        roi_geometry.OfRoi.UpdateDerivedGeometry(Examination=examination,
                                                 Algorithm="Auto")
    else:
        GUIF.handle_missing_roi_for_derived_rois(roi.name, [roi.source.name])
コード例 #4
0
def create_expanded_roi(pm, examination, ss, roi):
    pm.CreateRoi(Name=roi.name, Color=roi.color, Type=roi.type)
    # Get ROI geometry:
    roi_geometry = SSF.rg(ss, roi.name)
    # Make sure that the source ROI exists:
    if SSF.has_roi(ss, roi.source.name):
        roi_geometry.OfRoi.CreateMarginGeometry(
            Examination=examination,
            SourceRoiName=roi.source.name,
            MarginSettings=roi.margin_settings)
        roi_geometry.OfRoi.SetMarginExpression(
            SourceRoiName=roi.source.name, MarginSettings=roi.margin_settings)
        roi_geometry.OfRoi.UpdateDerivedGeometry(Examination=examination)
    else:
        GUIF.handle_missing_roi_for_derived_rois(roi.name, [roi.source.name])
コード例 #5
0
  selected_oar_list[ROIS.submand_l] = True
  selected_oar_list[ROIS.submand_r] = True
if selected_oar_list.get(ROIS.ribs_l):
  selected_oar_list[ROIS.rib_y_l] = True
  selected_oar_list[ROIS.rib_x_l] = True  
if selected_oar_list.get(ROIS.ribs_r):
  selected_oar_list[ROIS.rib_y_r] = True
  selected_oar_list[ROIS.rib_x_r] = True  
if selected_oar_list.get(ROIS.lungs):
  selected_oar_list[ROIS.lung_l] = True
  selected_oar_list[ROIS.lung_r] = True    
if selected_oar_list.get(ROIS.breast_l):
  selected_oar_list[ROIS.breast_l_draft] =True
if selected_oar_list.get(ROIS.breast_r):
  selected_oar_list[ROIS.breast_r_draft] =True
if selected_oar_list.get(ROIS.markers)and SSF.has_roi(ss, ROIS.rectum.name):
  del selected_oar_list[ROIS.markers]
  selected_oar_list[ROIS.marker1] = True
  selected_oar_list[ROIS.marker2] = True
  selected_oar_list[ROIS.marker3] = True
  selected_oar_list[ROIS.marker4] = True
if selected_oar_list.get(ROIS.couch):
  PMF.create_couch(patient_db, pm, ss, examination)
if selected_oar_list.get(ROIS.body):
  PMF.create_stereotactic_body_geometry(pm, examination, ss)
  PMF.create_stereotactic_external_geometry(pm, examination, ss)
if selected_oar_list.get(ROIS.external):
  PMF.create_external_geometry(pm, examination, ss)
if selected_oar_list.get(ROIS.anal_canal):
  PMF.create_bottom_part_x_cm(pm, examination, ss, ROIS.rectum, ROIS.anal_canal, 4)
if selected_oar_list.get(ROIS.dorso_rectum):
コード例 #6
0
def setup_clinical_goals(ss, es, site, total_dose, nr_fractions, target):
    for cg in site.target_clinical_goals:
        # Make sure corresponding ROI exists before trying to create clinical goal:
        if SSF.has_roi(ss, cg.name):
            if cg.name in [
                    ROIS.external.name, ROIS.igtv.name, ROIS.gtv.name
            ] and cg.criteria == 'AtMost' and cg.tolerance != 5000:
                c = es.AddClinicalGoal(RoiName=cg.name,
                                       GoalCriteria=cg.criteria,
                                       GoalType=cg.type,
                                       AcceptanceLevel=round(
                                           cg.tolerance * total_dose * 100, 0),
                                       ParameterValue=cg.value,
                                       Priority=cg.priority)
            elif cg.name in [
                    ROIS.ctv_sb.name, ROIS.ptv_sbc.name
            ] and target != ROIS.ctv_sb.name or cg.tolerance == 5000 or cg.type == homogeneity_index:
                c = es.AddClinicalGoal(RoiName=cg.name,
                                       GoalCriteria=cg.criteria,
                                       GoalType=cg.type,
                                       AcceptanceLevel=cg.tolerance,
                                       ParameterValue=cg.value,
                                       Priority=cg.priority)
            elif cg.type == conformity_index:
                c = es.AddClinicalGoal(RoiName=cg.name,
                                       GoalCriteria=cg.criteria,
                                       GoalType=cg.type,
                                       AcceptanceLevel=cg.tolerance,
                                       ParameterValue=round(
                                           cg.value * total_dose * 100, 0),
                                       Priority=cg.priority)
            else:
                c = es.AddClinicalGoal(RoiName=cg.name,
                                       GoalCriteria=cg.criteria,
                                       GoalType=cg.type,
                                       AcceptanceLevel=round(
                                           cg.tolerance * total_dose * 100, 0),
                                       ParameterValue=cg.value,
                                       Priority=cg.priority)

        else:
            # Missing ROI:
            GUIF.handle_missing_roi_for_clinical_goal(cg.name)

    for cg in site.oar_clinical_goals:
        # Make sure corresponding ROI exists before trying to create clinical goal:
        if SSF.has_roi(ss, cg.name):
            if cg.type != average_dose:
                if cg.type in [dose_at_volume, dose_at_abs_volume]:
                    c = es.AddClinicalGoal(
                        RoiName=cg.name,
                        GoalCriteria=cg.criteria,
                        GoalType=cg.type,
                        AcceptanceLevel=round(
                            cg.tolerance.equivalent(nr_fractions) * 100, 0),
                        ParameterValue=cg.value,
                        Priority=cg.priority)
                else:
                    c = es.AddClinicalGoal(
                        RoiName=cg.name,
                        GoalCriteria=cg.criteria,
                        GoalType=cg.type,
                        AcceptanceLevel=cg.tolerance,
                        ParameterValue=round(
                            cg.value.equivalent(nr_fractions) * 100, 0),
                        Priority=cg.priority)
            else:
                c = es.AddClinicalGoal(
                    RoiName=cg.name,
                    GoalCriteria=cg.criteria,
                    GoalType=cg.type,
                    AcceptanceLevel=round(
                        cg.tolerance.equivalent(nr_fractions) * 100, 0),
                    Priority=cg.priority)
        else:
            # Missing ROI:
            GUIF.handle_missing_roi_for_clinical_goal(cg.name)