def setModules(self, modules):
    self.ui.moduleList.clear()
    self._moduleItems = {}

    for module in modules:
      item = qt.QListWidgetItem(module.key)
      item.setFlags(item.flags() | qt.Qt.ItemIsUserCheckable)
      item.setCheckState(qt.Qt.Checked)
      self.ui.moduleList.addItem(item)
      self._moduleItems[item] = module

    if len(modules) > 1:
      self.ui.label.text = (
        "The following modules can be loaded. "
        "Would you like to load them now?")

    elif len(modules) == 1:
      self.ui.label.text = (
        "The following module can be loaded. "
        "Would you like to load it now?")

    else:
      raise ValueError("At least one module must be provided")

    self.validate()
Exemple #2
0
  def _onAddMeasurementButtonClicked(self):
    # TODO: findings assessment
    # TODO: add segmentation and enable editor
    listWidgetItem = qt.QListWidgetItem(self._measurementsListWidget)
    self._measurementsListWidget.addItem(listWidgetItem)
    findingsItemWidget = ProstateMeasurementItemWidget()
    listWidgetItem.setSizeHint(findingsItemWidget.sizeHint)
    self._findingsListWidget.setItemWidget(listWidgetItem, findingsItemWidget)

    self._findingsListWidget.selectionModel().clear()
    model = self._findingsListWidget.model()
    self._findingsListWidget.selectionModel().setCurrentIndex(model.index(model.rowCount()-1, 0),
                                                              qt.QItemSelectionModel.Select)

    self.updateButtons()
 def _fillAnnotationTable(self):
     self._annotationListWidget.clear()
     for volume in self._volumeNodes:
         volumeSeriesTypes = VolumeSeriesTypeSceneObserver(
         ).volumeSeriesTypes
         if volume in volumeSeriesTypes:
             seriesType = volumeSeriesTypes[volume]
             listWidgetItem = qt.QListWidgetItem(self._annotationListWidget)
             self._annotationListWidget.addItem(listWidgetItem)
             annotationItemWidget = AnnotationItemWidget(
                 self._finding, seriesType)
             listWidgetItem.setSizeHint(annotationItemWidget.sizeHint)
             self._annotationListWidget.setItemWidget(
                 listWidgetItem, annotationItemWidget)
         else:
             logging.info(
                 "Could not find matching series type for volume %s" %
                 volume.GetName())
 def calculateTargetsDistance(self):
     self.targetDistanceWidget.clear()
     if self.targetTablePlugin.currentTargets is not None:
         numberOfTargets = self.targetTablePlugin.currentTargets.GetNumberOfFiducials(
         )
         for targetIndex_A in range(numberOfTargets):
             for targetIndex_B in range(targetIndex_A + 1, numberOfTargets):
                 tAName = self.targetTablePlugin.currentTargets.GetNthFiducialLabel(
                     targetIndex_A)
                 tBName = self.targetTablePlugin.currentTargets.GetNthFiducialLabel(
                     targetIndex_B)
                 posA = 3 * [0.0]
                 posB = 3 * [0.0]
                 self.targetTablePlugin.currentTargets.GetNthFiducialPosition(
                     targetIndex_A, posA)
                 self.targetTablePlugin.currentTargets.GetNthFiducialPosition(
                     targetIndex_B, posB)
                 dist = numpy.linalg.norm(
                     numpy.array(posA) - numpy.array(posB)) / 10.0
                 itemString = str(tAName) + " -> " + str(
                     tBName) + ": " + '%3.1f' % dist + " cm"
                 tmpWidgetItem = qt.QListWidgetItem(itemString)
                 self.targetDistanceWidget.addItem(tmpWidgetItem)
     pass
Exemple #5
0
    def setup(self):

        ScriptedLoadableModuleWidget.setup(self)

        self.logic = SegmentationExtractionModuleLogic()

        # ------ 1. CREACION LAYOUT Y BOTONES ------

        self.layoutManager = slicer.app.layoutManager()
        self.layoutManager.setLayout(0)

        #
        # CARGAR IMAGEN
        #

        # Creacion layout
        collapsibleButtonLoad = ctk.ctkCollapsibleButton()
        collapsibleButtonLoad.text = "Load Files"
        self.layout.addWidget(collapsibleButtonLoad)
        formLayout_load = qt.QFormLayout(collapsibleButtonLoad)

        # Definir botones para cargar DICOM y crop volume

        # DICOM
        self.inputDICOM_label = qt.QLabel('DICOM Location: ')
        self.loadDICOM_button = qt.QPushButton('Search DICOM')
        self.loadDICOM_button.accessibleDescription = 'DICOM'
        self.loadDICOM_button.toolTip = "Search DICOM"
        self.loadDICOM_button.enabled = True
        formLayout_load.addRow(self.inputDICOM_label, self.loadDICOM_button)

        # Crop Volume
        self.inputCropVolume_label = qt.QLabel('Crop Volume location: ')
        self.loadCropVolume_button = qt.QPushButton('Search Crop Volume ')
        self.loadCropVolume_button.accessibleDescription = 'Volume'
        self.loadCropVolume_button.toolTip = "Search Crop Volume"
        formLayout_load.addRow(self.inputCropVolume_label,
                               self.loadCropVolume_button)

        # # Cuadro de texto para introducir el directorio de la imagen a cargar
        # self.inputImage_label = qt.QLabel('Imagen original: ')
        # self.inputImage_textInput = qt.QLineEdit()
        # self.inputImage_textInput.text = 'C:/Slicer/Pyramid/Pyramid/Data/inputImage.png'
        # formLayout_load.addRow(self.inputImage_label, self.inputImage_textInput) # incluimos el cuadro de texto al layout

        # Boton para cargar imagen
        self.loadImagesButton = qt.QPushButton("Load Files")
        self.loadImagesButton.toolTip = "Load files"
        self.loadImagesButton.enabled = True
        formLayout_load.addRow(
            self.loadImagesButton)  # incluimos el boton al layout

        # SEGMENTATIONS TO EXPORT

        collapsibleButtonSegmentation = ctk.ctkCollapsibleButton()
        collapsibleButtonSegmentation.text = "Segmentations to Export"
        self.layout.addWidget(collapsibleButtonSegmentation)
        formLayout_segmentation = qt.QFormLayout(
            collapsibleButtonSegmentation)  # Layout dentro de la seccion

        #
        # create table
        #

        # Original Contour Names table

        # self.segmentationsTable = qt.QTableWidget(5, 1)
        # self.segmentationsTable.setHorizontalHeaderLabels([" "])
        # self.segmentationsTable.setVerticalHeaderLabels(" ")
        # newItem = qt.QTableWidgetItem(3)
        # self.segmentationsTable.setItem(1,1, newItem)
        # formLayout_segmentation.addRow(self.segmentationsTable)

        # call function to get names of contours
        # define lists
        self.contour_names = ['Ojo', 'medula', 'tronco', 'paciente']
        self.original_contour_list = qt.QListWidget()
        # Initiate empty list of exported contours at first (None selected)
        self.exported_contours_list = qt.QListWidget()

        # Initiate empty list of exported contours at first (None selected)
        for contour in self.contour_names:
            contour_item = qt.QListWidgetItem(contour)
            self.original_contour_list.addItem(contour_item)

        # define button layout
        vertical_layout_buttons = qt.QVBoxLayout()

        # define forwards button
        self.move_segments_forwards_button = qt.QPushButton(">")
        self.move_segments_forwards_button.toolTip = "Copy segmentations"
        self.move_segments_forwards_button.enabled = True
        vertical_layout_buttons.addWidget(self.move_segments_forwards_button)
        vertical_layout_buttons.addStretch()
        #define backwards button. Set enable = False at the beginning
        self.move_segments_backwards_button = qt.QPushButton("<")
        self.move_segments_backwards_button.toolTip = "Eliminate segmentation from exported list"
        self.move_segments_backwards_button.enabled = True
        vertical_layout_buttons.addWidget(self.move_segments_backwards_button)
        vertical_layout_buttons.addStretch()

        # export button
        self.export_button = qt.QPushButton('Export Labelmaps')
        self.export_button.enabled = True

        #define titles
        # title_right = qt.QLabel('Original segmentation')
        # title_right.setAlignment(qt.Qt.AlignRight)
        # title_left = qt.QLabel('Segmentations to export')
        # title_left.setAlignment(qt.Qt.AlignLeft)

        # set layout
        horizontal_layout = qt.QHBoxLayout()
        horizontal_layout.addWidget(self.original_contour_list)
        horizontal_layout.addLayout(vertical_layout_buttons)
        horizontal_layout.addWidget(self.exported_contours_list)

        #formLayout_segmentation.addRow(title_right, title_left)
        formLayout_segmentation.addRow(horizontal_layout)
        formLayout_segmentation.addRow(self.export_button)

        #
        # GUARDAR IMAGEN
        #

        # Creacion Layout
        collapsibleButtonSave = ctk.ctkCollapsibleButton()
        collapsibleButtonSave.text = "Save Labelmaps"
        self.layout.addWidget(collapsibleButtonSave)
        formLayout_save = qt.QFormLayout(
            collapsibleButtonSave)  # Layout dentro de la seccion

        # Cuadro de texto para indicar el directorio de la imagen de salida (procesada)
        self.outputImage_label = qt.QLabel('Select folder to save: ')
        self.folder_to_save = qt.QPushButton(
            'Explore')  #'C:/Slicer/Pyramid/Pyramid/Data/outputImage.png'
        formLayout_save.addRow(
            self.outputImage_label,
            self.folder_to_save)  # incluimos el cuadro de texto al layout

        # Boton para guardar imagen
        self.saveImageButton = qt.QPushButton("Save labelmaps")
        self.saveImageButton.toolTip = "Save labelmaps"
        self.saveImageButton.enabled = True
        formLayout_save.addRow(
            self.saveImageButton)  # incluimos el boton al layout

        # Incluimos un espacio en vertical
        self.layout.addStretch(1)

        # ------ 2. CONEXION BOTONES CON FUNCIONES ------

        # Conectar cada boton a una funcion
        self.loadDICOM_button.connect('clicked(bool)',
                                      self.config_dialog_dicom)
        self.loadCropVolume_button.connect('clicked(bool)',
                                           self.config_dialog_cropped_volume)
        self.loadImagesButton.connect('clicked(bool)', self.onLoadImageButton)
        self.move_segments_forwards_button.connect('clicked(bool)',
                                                   self.move_segments_forwards)
        self.move_segments_backwards_button.connect(
            'clicked(bool)', self.move_segments_backwards)