Esempio n. 1
0
    def get_combined_fuzz_score(self, a, b, mode='geom_mean'):
        a, b = clean_name(a), clean_name(b)

        simple = float(fuzz.ratio(a, b) * self.weight['simple'])
        partial = float(fuzz.partial_ratio(a, b) * self.weight['partial'])

        return self.combine_scores(simple, partial, mode=mode)
Esempio n. 2
0
 def update_enable(self, *evt):
     invalid_choices = list(self.roi_map.physicians) + ['']
     new = clean_name(self.text_ctrl_physician.GetValue(), physician=True)
     self.button_ok.Enable(new not in invalid_choices)
     disable = self.text_ctrl_physician.GetValue(
     ) == '' or self.combo_box_copy_from.GetValue().lower() == 'none'
     self.checkbox_variations.Enable(not disable)
Esempio n. 3
0
 def new_name(self):
     new = clean_name(
         self.text_ctrl.GetValue())  # clean name will result in lower-case
     if self.lower_case:
         return new
     else:
         return new.upper()
Esempio n. 4
0
 def get_uncategorized_variations(physician, ignored_variations=False):
     if echo_sql_db():
         with DVH_SQL() as cnx:
             physician = clean_name(physician).upper()
             condition = "physician_roi = '%s'" % [
                 'uncategorized', 'ignored'
             ][ignored_variations]
             cursor_rtn = cnx.query('dvhs', 'roi_name, study_instance_uid',
                                    condition)
             new_variations = {}
             for row in cursor_rtn:
                 variation = str(row[0])
                 study_instance_uid = str(row[1])
                 physician_db = cnx.get_unique_values(
                     'Plans', 'physician',
                     "study_instance_uid = '%s'" % study_instance_uid)
                 if physician_db and physician_db[0] == physician:
                     if variation not in list(new_variations):
                         new_variations[variation] = {
                             'roi_name': variation,
                             'study_instance_uid': [study_instance_uid]
                         }
                     else:
                         new_variations[variation][
                             'study_instance_uid'].append(
                                 study_instance_uid)
             return new_variations
Esempio n. 5
0
 def run(self):
     res = self.ShowModal()
     if res == wx.ID_OK:
         map_file_name = "physician_%s.roi" % clean_name(self.physician,
                                                         physician=True)
         self.map_file_path = self.generator(map_file_name,
                                             body_sites=self.checked_values)
     self.Destroy()
Esempio n. 6
0
    def update_physician_rois(self, old_physician_rois=None):
        choices = self.roi_map.get_physician_rois(self.physician)
        new = choices[0]
        if old_physician_rois:
            new = list(set(choices) - set(old_physician_rois))
            if new:
                new = clean_name(new[0])

        self.update_combo_box_choices(self.combo_box_physician_roi, choices, new)
Esempio n. 7
0
    def update_enable(self, evt):
        if not self.institutional_mode:
            invalid_choices = set(
                self.roi_map.get_physician_rois(self.physician) +
                self.roi_map.get_all_variations_of_physician(self.physician))
        else:
            invalid_choices = self.roi_map.institutional_rois

        new = clean_name(self.text_ctrl_physician_roi.GetValue())
        self.button_ok.Enable(new not in invalid_choices)
Esempio n. 8
0
    def update_physicians(self, old_physicians=None):

        choices = self.roi_map.get_physicians()
        new = choices[0]
        if old_physicians:
            new = list(set(choices) - set(old_physicians))
            if new:
                new = clean_name(new[0]).upper()

        self.update_combo_box_choices(self.combo_box_physician, choices, new)
        self.update_physician_roi_label()
        self.update_physician_enable()
Esempio n. 9
0
    def __init__(self, tree_ctrl_roi, tree_item, plan_uid, parsed_dicom_data,
                 dicom_importer):
        """
        :param tree_ctrl_roi: the roi tree from the DICOM importer view
        :param tree_item: the tree_ctrl_roi item to be edited
        :param plan_uid: the study instance uid of the plan of interest
        :type plan_uid: str
        :param parsed_dicom_data: parsed dicom data object for plan of interest
        :type parsed_dicom_data: DICOM_Parser
        :param dicom_importer: Needed to edit tree
        :type dicom_importer: DicomTreeBuilder
        """
        wx.Dialog.__init__(self,
                           None,
                           title='Edit %s' %
                           tree_ctrl_roi.GetItemText(tree_item))

        self.tree_ctrl_roi = tree_ctrl_roi
        self.tree_item = tree_item
        self.roi = tree_ctrl_roi.GetItemText(tree_item)

        self.plan_uid = plan_uid

        self.parsed_dicom_data = parsed_dicom_data
        self.dicom_importer = dicom_importer

        invalid_options = [''] + parsed_dicom_data.roi_names
        self.invalid_options = [clean_name(name) for name in invalid_options]

        self.text_input_label = 'Change ROI name to:'

        self.text_ctrl = wx.TextCtrl(self, wx.ID_ANY, "")
        self.button_ok = wx.Button(self, wx.ID_OK, 'OK')
        self.button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")

        self.__set_properties()
        self.__do_bind()
        self.__do_layout()

        self.run()
Esempio n. 10
0
    def __init__(self, tree_ctrl_roi, tree_item, mrn, study_instance_uid,
                 parsed_dicom_data):
        """
        :param tree_ctrl_roi: the roi tree from the DICOM importer view
        :param tree_item: the tree_ctrl_roi item to be edited
        :param mrn: the patient's mrn for the plan of interest
        :type mrn: str
        :param study_instance_uid: the study instance uid of the plan of interest (should be plan_uid now?)
        :type study_instance_uid: str
        :param parsed_dicom_data: parsed dicom data object for plan of interest
        :type parsed_dicom_data: DICOM_Parser
        """
        wx.Dialog.__init__(self,
                           None,
                           title='Edit %s' %
                           tree_ctrl_roi.GetItemText(tree_item))

        self.tree_ctrl_roi = tree_ctrl_roi
        self.tree_item = tree_item
        self.roi = tree_ctrl_roi.GetItemText(tree_item)
        self.initial_mrn = mrn
        self.initial_study_instance_uid = study_instance_uid

        self.parsed_dicom_data = parsed_dicom_data

        invalid_options = [''] + parsed_dicom_data.roi_names
        self.invalid_options = [clean_name(name) for name in invalid_options]

        self.text_input_label = 'Change ROI name to:'

        self.text_ctrl = wx.TextCtrl(self, wx.ID_ANY, "")
        self.button_ok = wx.Button(self, wx.ID_OK, 'OK')
        self.button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")

        self.__set_properties()
        self.__do_bind()
        self.__do_layout()

        self.run()
Esempio n. 11
0
    def __init__(self,
                 title,
                 text_input_label,
                 invalid_options,
                 is_physician=False):
        """
        :param title: title of the dialog window
        :type title: str
        :param text_input_label: label to be displayed above text_ctrl
        :type text_input_label: str
        :param invalid_options: if text_ctrl is in invalid options, OK button will be disabled
        :type invalid_options: list
        :param is_physician: if editing a physician, clean_name() needs to know
        :type is_physician: bool
        """
        wx.Dialog.__init__(self, None, title=title)

        self.invalid_options = [
            clean_name(option, physician=is_physician)
            for option in invalid_options
        ]
        self.is_physician = is_physician

        self.text_input_label = text_input_label

        self.text_ctrl = wx.TextCtrl(self, wx.ID_ANY, "")
        self.button_ok = wx.Button(self, wx.ID_OK, 'OK')
        self.button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")

        self.__set_properties()
        self.__do_bind()
        self.__do_layout()

        self.res = None

        self.run()
Esempio n. 12
0
 def text_ticker(self, evt):
     value = clean_name(self.new_name, physician=self.is_physician)
     [self.button_ok.Disable,
      self.button_ok.Enable][value not in self.invalid_options]()
Esempio n. 13
0
 def new_name(self):
     return clean_name(self.text_ctrl.GetValue())
Esempio n. 14
0
 def update_enable(self, evt):
     invalid_choices = set(self.roi_map.get_physicians())
     new = clean_name(self.text_ctrl_physician.GetValue()).upper()
     self.button_ok.Enable(new not in invalid_choices)