コード例 #1
0
 def init_patient_A_initial_roi_list(self):
     """
     Initialize the layout for patient A's roi list
     """
     self.patient_A_initial_rois_list_widget = QListWidget(self)
     self.patient_A_initial_rois_list_widget.itemDoubleClicked.connect(
         self.patient_A_initial_roi_double_clicked)
     for idx in self.fixed_image_initial_rois:
         roi_label = QListWidgetItem(
             self.fixed_image_initial_rois[idx]['name'])
         roi_label.setForeground(Qt.darkGreen)
         roi_label.setData(Qt.UserRole, self.fixed_image_initial_rois[idx])
         self.patient_A_initial_rois_list_widget.addItem(roi_label)
     self.transfer_roi_window_grid_layout.addWidget(
         self.patient_A_initial_rois_list_widget, 1, 0)
コード例 #2
0
 def patient_B_to_A_rois_double_clicked(self, item):
     """
     This function is triggered when a roi in "B to A" list is
     double-clicked.
     """
     roi_to_remove = item.data(Qt.UserRole)
     to_delete_value = roi_to_remove['name']
     self.moving_to_fixed_rois.pop(to_delete_value)
     self.patient_B_rois_to_A_list_widget.clear()
     for key, value in self.moving_to_fixed_rois.items():
         roi_label = QListWidgetItem(value)
         roi_label.setForeground(Qt.red)
         roi_label.setData(Qt.UserRole, {'name': key})
         self.patient_B_rois_to_A_list_widget.addItem(roi_label)
     if self.transfer_list_is_empty():
         self.save_button.setDisabled(True)
コード例 #3
0
    def patient_B_initial_roi_double_clicked(self, item):
        """
        This function is triggered when a roi in patient B's roi list is
        double-clicked.
        """
        roi_to_add = item.data(Qt.UserRole)
        transferred_roi_name = roi_to_add['name']

        # If the clicked roi is already transferred, return
        if transferred_roi_name in self.moving_to_fixed_rois.keys():
            QMessageBox.about(self, "Transfer Failed",
                              "Chosen ROI has already been transferred!")
            return

        # Create a set to store all current roi names in target patient
        # including both initial rois name and added roi names so far
        patient_A_current_roi_name_list = set()

        for item in self.moving_to_fixed_rois.values():
            patient_A_current_roi_name_list.add(item)

        for idx in self.fixed_image_initial_rois:
            patient_A_current_roi_name_list.add(
                self.fixed_image_initial_rois[idx]['name'])

        # Check if clicked roi name has duplicate in
        # target patient's roi names list
        if transferred_roi_name in patient_A_current_roi_name_list:
            # if add suffix is ticked, iteratively try adding suffix
            # from _A to _Z, stop when no duplicate found
            if self.add_suffix:
                transferred_roi_name = generate_non_duplicated_name(
                    transferred_roi_name, patient_A_current_roi_name_list)
            else:
                QMessageBox.about(
                    self, "Transfer Failed", "Duplicated ROI name. "
                    "Please consider adding suffix.")
                return

        # Add clicked roi to transferred list
        self.moving_to_fixed_rois[roi_to_add['name']] = transferred_roi_name
        roi_label = QListWidgetItem(transferred_roi_name)
        roi_label.setForeground(Qt.red)
        roi_label.setData(Qt.UserRole, roi_to_add)
        self.patient_B_rois_to_A_list_widget.addItem(roi_label)
        self.save_button.setDisabled(False)