def determine_choices(region_code, nr_fractions, fraction_dose, my_window, choices): # Default technique value, 'VMAT' technique = 'VMAT' # Default technique name, 'VMAT' or '3D-CRT' technique_name = 'VMAT' # Default optimization value opt = '' if region_code in RC.breast_tang_codes or region_code in RC.breast_partial_codes: # Chosen technique value, 'VMAT' or 'Conformal' technique = 'Conformal' # Chosen technique name, 'VMAT' or '3D-CRT' technique_name = '3D-CRT' # Chosen optimization value opt = 'oar' elif region_code in RC.breast_reg_codes: # Determine which technique choices which will appear in the form techniques = RB.RadioButton('Planoppsett ', 'Velg planoppsett: ', PC.techniques) # Collects the selected choices from the user choices = collect_choices(techniques, my_window, []) # Chosen technique value, 'VMAT' or 'Conformal' technique = choices[0] # Chosen technique name, 'VMAT' or '3D-CRT' if technique == 'Conformal': technique_name = '3D-CRT' else: technique_name = 'VMAT' # Optimization value opt = 'oar' else: if region_code in RC.palliative_codes and nr_fractions*fraction_dose < 55 and not PF.is_stereotactic(nr_fractions, fraction_dose) or region_code in RC.bladder_codes or region_code in RC.prostate_codes and nr_fractions*fraction_dose < 40 or region_code in RC.brain_whole_codes: opt = 'oar' results = [technique, technique_name, opt] return results
def determine_choices(region_code, prescription, my_window, choices): # Default technique value, 'VMAT' technique = 'VMAT' # Default technique name, 'VMAT' or '3D-CRT' technique_name = 'VMAT' # Default optimization value opt = '' if region_code in RC.breast_tang_codes or region_code in RC.breast_partial_codes: # Partial breast or whole breast: # Chosen technique value, 'VMAT' or 'Conformal' technique = 'Conformal' # Chosen technique name, 'VMAT' or '3D-CRT' technique_name = '3D-CRT' # Chosen optimization value opt = 'oar' elif region_code in RC.breast_reg_codes: # Regional breast: # Determine which technique choices which will appear in the form techniques = RB.RadioButton('Planoppsett ', 'Velg planoppsett: ', PC.techniques) # Collects the selected choices from the user choices = collect_choices(techniques, my_window, []) # Chosen technique value, 'VMAT' or 'Conformal' technique = choices[0] # Chosen technique name, 'VMAT' or '3D-CRT' if technique == 'Conformal': technique_name = '3D-CRT' else: technique_name = 'VMAT' # Optimization value opt = 'oar' elif region_code in RC.palliative_codes and not prescription.is_stereotactic( ): # Palliative (non-SBRT): opt = 'oar' elif region_code in RC.bladder_codes: # Bladder: opt = 'oar' elif region_code in RC.prostate_codes and prescription.total_dose < 40: # Palliative prostate: opt = 'oar' elif region_code in RC.brain_whole_codes: # Whole brain: opt = 'oar' elif region_code in RC.bone_stereotactic_codes: # Bone SBRT: opt = 'oar' results = [technique, technique_name, opt] return results
def handle_existing_rois(pm, ss): if SSF.has_roi_with_contours(ss): delete = RB.RadioButton('Eksisterende ROIs oppdaget', 'Velg:', DC.delete) my_window = Tk() choice_d = [] delete_choice = collect_delete_choice(delete, my_window, choice_d) for i in range(len(delete_choice)): if delete_choice[i] == 'yes': # All ROIs are to be deleted: PMF.delete_all_rois(pm) elif delete_choice[i] == 'some': # Only non-delineated ROIs are to be deleted: PMF.delete_rois_except_manually_contoured(pm, ss) my_window = Toplevel() else: my_window = Tk() return my_window
def collect_choices(options, my_window, choices): # Set up GUI windows frame = FRAME.RadioButtonFrame(my_window, options) frame.grid(row=0, column=0) my_window.mainloop() # Extract information from the users's selections in the GUI: if frame.ok: (selection, value) = frame.get_results() elif not frame.ok: print("Script execution cancelled by user...") sys.exit(0) else: messagebox.showinfo("Error.", "Unexpected error.") sys.exit(0) choices.append(value) if selection.children: new_window = Toplevel() next_options = RB.RadioButton(selection.next_category.capitalize(), 'Velg ' + selection.next_category + ':', selection.children) selection = collect_choices(next_options, new_window, choices) choices.append(value) return choices
roi = None for k in range(len(oar_list)): if roi_dict.get(oar_list[k]): roi = oar_list[k] break return roi # Setup GUI choices: parameter_property = [] for i in range(len(parameter_list)): parameter_property.append(P.Property(parameter_list[i], parameter_list[i])) # Create radio button object options = RB.RadioButton('Statistikk', 'Velg:', parameter_property) # Setup and run GUI: my_window = Toplevel() frame = FRAME.StatisticsFrame(my_window, options) frame.grid(row=0, column=0) my_window.mainloop() # Extract information from the users's selections in the GUI: if frame.ok: checkBoxes = frame.checkbuttons variables = frame.variables (start_date, stop_date, stereotactic, conv) = frame.get_results() elif not frame.ok: print("Script execution cancelled by user...") sys.exit(0)
ROIS.kidneys, ROIS.stomach, ROIS.liver, ROIS.small_bowel, ROIS.colon, ROIS.brachial, ROIS.bowel_space, ROIS.rectum, ROIS.z_rectum_p, ROIS.anal_canal, ROIS.bladder, ROIS.femoral_l, ROIS.femoral_r, ROIS.external, ROIS.body, ROIS.markers, ROIS.prosthesis_l, ROIS.prosthesis_r, ROIS.couch, ] oar_list.sort(key=get_my_key) # Setup GUI choices: oar_property = [] for i in range(len(oar_list)): oar_property.append(P.Property(oar_list[i].name, oar_list[i].name)) # Create radio button object options = RB.RadioButton('ROI','Velg:', oar_property) # Setup and run GUI: my_window = Tk() frame = FRAME.CheckButtonFrame(my_window, options) frame.grid(row = 0,column = 0) my_window.mainloop() # Extract information from the users's selections in the GUI: if frame.ok: checkBoxes = frame.checkbuttons variables = frame.variables elif not frame.ok: print ("Script execution cancelled by user...") sys.exit(0) else:
def __init__(self, patient_db, patient, case): self.patient_db = patient_db self.patient = patient self.case = case #messagebox.showinfo("Error.","hei") pm = case.PatientModel examination = get_current("Examination") ss = PMF.get_structure_set(pm, examination) # Check if the last CT has been set as primary, and display a warning if not. #success = TS_C.TSCase(case).last_examination_used_test() #if not success: # GUIF.handle_primary_is_not_most_recent_ct() # Check if any ROIs exist, and if they have a contour in the current Structure Set. # If there is, ask to delete rois. if SSF.has_roi_with_contours(ss): delete = RB.RadioButton('Eksisterende ROIs oppdaget', 'Velg:', DC.delete) my_window = Tk() choice_d = [] delete_choice = GUIF.collect_delete_choice(delete, my_window, choice_d) for i in range(len(delete_choice)): # If the delete all rois choice was selected, delete rois. if delete_choice[i] == 'yes': PMF.delete_all_rois(pm) elif delete_choice[i] == 'some': PMF.delete_rois_except_manually_contoured(pm, ss) my_window = Toplevel() else: my_window = Tk() # Create initial radiobutton object, then recursively iterate it to collect all user choices: regions = RB.RadioButton('Behandlingsregion', 'Velg behandlingsregion:', DC.regions) choices = GUIF.collect_choices(regions, my_window, []) # Create site: site = DS.DefSite(patient_db, pm, examination, ss, choices, targets=[], oars=[]) # Choice 1: Which region is going to be treated? region = choices[0] if region == 'brain': import def_brain as DEF_BRAIN DEF_BRAIN.DefBrain(pm, examination, ss, choices, site) elif region == 'lung': import def_lung as DEF_LUNG DEF_LUNG.DefLung(pm, examination, ss, choices, site) elif region == 'breast': import def_breast as DEF_BREAST DEF_BREAST.DefBreast(pm, examination, ss, choices, site) elif region == 'bladder': import def_bladder as DEF_BLADDER DEF_BLADDER.DefBladder(pm, examination, ss, choices, site) elif region == 'prostate': import def_prostate as DEF_PROSTATE DEF_PROSTATE.DefProstate(pm, examination, ss, choices, site) elif region == 'rectum': import def_rectum as DEF_RECTUM DEF_RECTUM.DefRectum(pm, examination, ss, choices, site) elif region == 'other': import def_palliative as DEF_PALLIATIVE DEF_PALLIATIVE.DefPalliative(pm, examination, ss, choices, site) # Changes OrganType to "Other" for all ROIs in the given patient model which are of type "Undefined" or "Marker". PMF.exclude_rois_from_export(pm) PMF.set_all_undefined_to_organ_type_other(pm)
i += 1 name = prefix + " " + str(i) available = True for p in plan.VerificationPlans: if p.BeamSet.DicomPlanLabel == name: available = False if available: break # Radiobutton choices for dose grid: c2mm = P.Property('Konvensjonell VMAT (2 mm)', '0.2', default=True) c1mm = P.Property('Stereotaksi (1 mm)', '0.1') choices = [c2mm, c1mm] # Create radio button object options = RB.RadioButton('VMAT QA', 'Velg dosematrise:', choices) # Setup and run GUI: my_window = Tk() frame = FRAME.RadioButtonFrame(my_window, options) frame.grid(row=0, column=0) my_window.mainloop() # Extract information from the users's selections in the GUI: if frame.ok: (selection, value) = frame.get_results() elif not frame.ok: print("Script execution cancelled by user...") sys.exit(0) else: messagebox.showinfo("Error.", "Unexpected error.")
def __init__(self, patient_db, patient, case): self.patient_db = patient_db self.patient = patient self.case = case # Load patient model, examination and structure set: pm = case.PatientModel examination = get_current("Examination") ss = PMF.get_structure_set(pm, examination) # Check if the last CT has been set as primary, and display a warning if not. # (This is activated in the plan script, but currently not here in the def script) #success = TS_C.TSCase(case).last_examination_used_test() #if not success: # GUIF.handle_primary_is_not_most_recent_ct() # Handle existing ROIs (if there are any): my_window = GUIF.handle_existing_rois(pm, ss) # Create initial radiobutton object, then recursively iterate it to collect all user choices: regions = RB.RadioButton('Behandlingsregion', 'Velg behandlingsregion:', DC.regions) choices = GUIF.collect_choices(regions, my_window, []) # Create site: site = DS.DefSite(patient_db, pm, examination, ss, choices, targets=[], oars=[]) # Choice 1: Which region is going to be treated? region = choices[0] # Execute the def script which corresponds to the user choice: if region == 'brain': import def_brain as DEF_BRAIN DEF_BRAIN.DefBrain(pm, examination, ss, choices, site) elif region == 'lung': import def_lung as DEF_LUNG DEF_LUNG.DefLung(pm, examination, ss, choices, site) elif region == 'breast': import def_breast as DEF_BREAST DEF_BREAST.DefBreast(pm, examination, ss, choices, site) elif region == 'bladder': import def_bladder as DEF_BLADDER DEF_BLADDER.DefBladder(pm, examination, ss, choices, site) elif region == 'prostate': import def_prostate as DEF_PROSTATE DEF_PROSTATE.DefProstate(pm, examination, ss, choices, site) elif region == 'rectum': import def_rectum as DEF_RECTUM DEF_RECTUM.DefRectum(pm, examination, ss, choices, site) elif region == 'other': import def_palliative as DEF_PALLIATIVE DEF_PALLIATIVE.DefPalliative(pm, examination, ss, choices, site) # Changes OrganType to "Other" for all ROIs in the given patient model which are of type "Undefined" or "Marker". PMF.exclude_rois_from_export(pm) PMF.set_all_undefined_to_organ_type_other(pm)
def palliative_beamset_form(ss, my_window): beam_set_options = RB.RadioButton('Multiple målvolum oppdaget', 'Velg ønsket oppsett for plan/beam set: ', PC.beam_set_choices(ss)) choices = collect_choices(beam_set_options, my_window, []) return choices