Esempio n. 1
0
    def setup(self):

        # Collapsible button
        self.centrarCollapsibleButton = ctk.ctkCollapsibleButton()
        self.centrarCollapsibleButton.text = u"Centrar imagen y guardar transformación"
        self.layout.addWidget(self.centrarCollapsibleButton)

        # Layout within the collapsible button
        self.centrarLayout = qt.QFormLayout(self.centrarCollapsibleButton)

        #selector de imgen a centrar
        self.imagenSelector = slicer.qMRMLNodeComboBox()
        self.imagenSelector.objectName = 'imagenSelector'
        self.imagenSelector.toolTip = 'Seleccione la imagen que desea centrar'
        self.imagenSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.imagenSelector.noneEnabled = True
        self.imagenSelector.addEnabled = False  # Se quita la posibilidad al usuario de crear un nuevo nodo con este widget
        self.imagenSelector.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        ##        self.imagenSelector.connect('currentNodeChanged(bool)', self.enableOrDisableCentrarButton)
        self.imagenSelector.setMRMLScene(slicer.mrmlScene)
        self.centrarLayout.addRow("Volumen a centrar:", self.imagenSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.imagenSelector, 'setMRMLScene(vtkMRMLScene*)')

        #Boton centrar
        self.centrarButton = qt.QPushButton("Centrar")
        self.centrarButton.toolTip = u"Centre la imagen y guarde la transoformación de sentrado y su transformada inversa"
        self.centrarLayout.addWidget(self.centrarButton)
        self.centrarButton.connect('clicked(bool)', self.onCentrar)
        self.centrarButton.enabled = True
        self.layout.addStretch(1)

        # Collapsible button
        self.registrarCollapsibleButton = ctk.ctkCollapsibleButton()
        self.registrarCollapsibleButton.text = u"Registrar imágenes"
        self.layout.addWidget(self.registrarCollapsibleButton)

        # Layout within the collapsible button
        self.registrarLayout = qt.QFormLayout(self.registrarCollapsibleButton)

        #selector de transformacion
        self.transformSelector = slicer.qMRMLNodeComboBox()
        self.transformSelector.objectName = 'transformSelector'
        self.transformSelector.toolTip = u'El método requiere que sólo centre la resonancia con este modulo'
        self.transformSelector.nodeTypes = ['vtkMRMLLinearTransformNode']
        self.transformSelector.noneEnabled = True
        self.transformSelector.addEnabled = True  # Se quita la posibilidad al usuario de crear un nuevo nodo con este widget
        self.transformSelector.removeEnabled = True  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        ##        self.transformSelector.connect('currentNodeChanged(bool)', self.enableOrDisableRegistrarButton)
        self.transformSelector.setMRMLScene(slicer.mrmlScene)
        self.registrarLayout.addRow("Transformacion de entrada:",
                                    self.transformSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.transformSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        #selector de imgen fija
        self.imagenFijaSelector = slicer.qMRMLNodeComboBox()
        self.imagenFijaSelector.objectName = 'imagenFijaSelector'
        self.imagenFijaSelector.toolTip = 'Seleccione la imagen fija'
        self.imagenFijaSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.imagenFijaSelector.noneEnabled = True
        self.imagenFijaSelector.addEnabled = False  # Se quita la posibilidad al usuario de crear un nuevo nodo con este widget
        self.imagenFijaSelector.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        ##        self.imagenFijaSelector.connect('currentNodeChanged(bool)', self.enableOrDisableRegistrarButton)
        self.imagenFijaSelector.setMRMLScene(slicer.mrmlScene)
        self.registrarLayout.addRow("Imagen Fija:", self.imagenFijaSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.imagenFijaSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        #selector de imgen movil
        self.imagenMovilSelector = slicer.qMRMLNodeComboBox()
        self.imagenMovilSelector.objectName = 'imagenMovilSelector'
        self.imagenMovilSelector.toolTip = u'Seleccione la imagen móvil'
        self.imagenMovilSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.imagenMovilSelector.noneEnabled = True
        self.imagenMovilSelector.addEnabled = False  # Se quita la posibilidad al usuario de crear un nuevo nodo con este widget
        self.imagenMovilSelector.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        ##        self.imagenMovilSelector.connect('currentNodeChanged(bool)', self.enableOrDisableRegistrarButton)
        self.imagenMovilSelector.setMRMLScene(slicer.mrmlScene)
        self.registrarLayout.addRow(u"Imagen Móvil:", self.imagenMovilSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.imagenMovilSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        #selector de imgen Salida
        self.imagenSalidaSelector = slicer.qMRMLNodeComboBox()
        self.imagenSalidaSelector.objectName = 'imagenMovilSelector'
        self.imagenSalidaSelector.toolTip = u'Seleccione la imagen Salida'
        self.imagenSalidaSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.imagenSalidaSelector.noneEnabled = True
        self.imagenSalidaSelector.addEnabled = True  # Se quita la posibilidad al usuario de crear un nuevo nodo con este widget
        self.imagenSalidaSelector.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        ##        self.imagenMovilSelector.connect('currentNodeChanged(bool)', self.enableOrDisableRegistrarButton)
        self.imagenSalidaSelector.setMRMLScene(slicer.mrmlScene)
        self.registrarLayout.addRow(u"Imagen Salida:",
                                    self.imagenSalidaSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.imagenSalidaSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        #Boton ajustar
        self.ajustarButton = qt.QPushButton(u"Pre-ajustar imágenes")
        self.ajustarButton.toolTip = u"ajustar imágenes para facilitar el registro"
        self.registrarLayout.addWidget(self.ajustarButton)
        self.ajustarButton.connect('clicked(bool)', self.onAjustar)
        self.ajustarButton.enabled = True
        self.layout.addStretch(1)

        #Boton registrar
        self.registrarButton = qt.QPushButton(u"Registrar imágenes")
        self.registrarButton.toolTip = u"Centre una imagen y guarde la transformación de centrado y su inversa"
        self.registrarLayout.addWidget(self.registrarButton)
        self.registrarButton.connect('clicked(bool)', self.onRegistrar)
        self.registrarButton.enabled = True
        self.layout.addStretch(1)

        # Collapsible button
        #self.ajustarCollapsibleButton = ctk.ctkCollapsibleButton()
        #self.ajustarCollapsibleButton.text = u"Preajustar imágenes"
        #self.layout.addWidget(self.ajustarCollapsibleButton)

        self.ajustarDialog = qt.QDialog()
        #self.ajustarDialog.rejected.connect(self.onCancelarPreajuste)
        #self.ajustarDialog.accepted.connect(self.onAplicarPreajuste)

        # Layout within the collapsible button
        self.ajustarLayout = qt.QFormLayout(self.ajustarDialog)

        #sliders para de desplazamiento la posicion de la imagen movil
        self.transformTraslationSliders = slicer.qMRMLTransformSliders()
        self.transformTraslationSliders.toolTip = u"Desplace para trasladar la imagen móvil"
        self.transformTraslationSliders.Title = u'Traslación'
        self.transformTraslationSliders.TypeOfTransform = self.transformTraslationSliders.TRANSLATION
        self.ajustarLayout.addRow(self.transformTraslationSliders)

        #sliders para de desplazamiento la posicion de la imagen movil
        self.transformRotationSliders = slicer.qMRMLTransformSliders()
        self.transformRotationSliders.toolTip = u"Desplace para rotar la imagen móvil"
        self.transformRotationSliders.TypeOfTransform = self.transformRotationSliders.ROTATION
        self.transformRotationSliders.Title = u'Rotación'
        self.transformRotationSliders.LRLabel = 'Sagital'
        self.transformRotationSliders.PALabel = 'Coronal'
        self.transformRotationSliders.ISLabel = 'Axial'
        self.transformRotationSliders.minMaxVisible = False
        self.ajustarLayout.addRow(self.transformRotationSliders)

        self.cancelarButton = qt.QPushButton(u"Cancelar")
        self.cancelarButton.toolTip = u"Devuelve la imagen movil al estado inicial del preajuste"
        self.ajustarLayout.addWidget(self.cancelarButton)
        self.cancelarButton.connect('clicked(bool)', self.onCancelarPreajuste)
        self.cancelarButton.enabled = True

        self.capplyButton = qt.QPushButton(u"Aplicar")
        self.capplyButton.toolTip = u"Aplica el preajuste"
        self.ajustarLayout.addWidget(self.capplyButton)
        self.capplyButton.connect('clicked(bool)', self.onAplicarPreajuste)
        self.capplyButton.enabled = True
    def setup(self):
        # Instantiate and connect widgets ...

        if not NUMPY_AVAILABLE:
            label = qt.QLabel(
                'The module is not available due to missing Numpy package.')
            self.layout.addWidget(label)
            label = qt.QLabel(
                'You can seek help by contacting 3D Slicer user list: [email protected]'
            )
            self.layout.addWidget(label)

            # Add vertical spacer
            self.layout.addStretch(1)
            return

        # Collapsible button
        dummyCollapsibleButton = ctk.ctkCollapsibleButton()
        dummyCollapsibleButton.text = "Basic settings"
        self.layout.addWidget(dummyCollapsibleButton)
        dummyFormLayout = qt.QFormLayout(dummyCollapsibleButton)

        # add input directory selector
        label = qt.QLabel('Input directory:')
        self.__fDialog = ctk.ctkDirectoryButton()
        self.__fDialog.caption = 'Input directory'
        dummyFormLayout.addRow(label, self.__fDialog)

        label = qt.QLabel('Output node:')
        self.__mvSelector = slicer.qMRMLNodeComboBox()
        self.__mvSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.__mvSelector.setMRMLScene(slicer.mrmlScene)
        self.__mvSelector.connect('mrmlSceneChanged(vtkMRMLScene*)',
                                  self.onMRMLSceneChanged)
        self.__mvSelector.addEnabled = 1
        dummyFormLayout.addRow(label, self.__mvSelector)

        # Collapsible button
        dummyCollapsibleButton = ctk.ctkCollapsibleButton()
        dummyCollapsibleButton.text = "Advanced settings"
        dummyCollapsibleButton.collapsed = 1
        self.layout.addWidget(dummyCollapsibleButton)
        dummyFormLayout = qt.QFormLayout(dummyCollapsibleButton)
        self.__advancedFrame = dummyCollapsibleButton

        label = qt.QLabel('Frame identifying DICOM tag (if known):')
        self.__dicomTag = qt.QLineEdit()
        self.__dicomTag.text = 'NA'
        dummyFormLayout.addRow(label, self.__dicomTag)

        label = qt.QLabel('Frame identifying units:')
        self.__veLabel = qt.QLineEdit()
        self.__veLabel.text = 'na'
        dummyFormLayout.addRow(label, self.__veLabel)

        label = qt.QLabel('Initial value:')
        self.__veInitial = qt.QDoubleSpinBox()
        self.__veInitial.value = 0
        dummyFormLayout.addRow(label, self.__veInitial)

        label = qt.QLabel('Step:')
        self.__veStep = qt.QDoubleSpinBox()
        self.__veStep.value = 1
        dummyFormLayout.addRow(label, self.__veStep)

        label = qt.QLabel('EchoTime:')
        self.__te = qt.QDoubleSpinBox()
        self.__te.value = 1
        dummyFormLayout.addRow(label, self.__te)

        label = qt.QLabel('RepetitionTime:')
        self.__tr = qt.QDoubleSpinBox()
        self.__tr.value = 1
        dummyFormLayout.addRow(label, self.__tr)

        label = qt.QLabel('FlipAngle:')
        self.__fa = qt.QDoubleSpinBox()
        self.__fa.value = 1
        dummyFormLayout.addRow(label, self.__fa)

        importButton = qt.QPushButton("Import")
        importButton.toolTip = "Import the contents of the directory as a MultiVolume"
        self.layout.addWidget(importButton)
        importButton.connect('clicked(bool)', self.onImportButtonClicked)

        self.__status = qt.QLabel('Status: Idle')
        self.layout.addWidget(self.__status)

        # Add vertical spacer
        self.layout.addStretch(1)
Esempio n. 3
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

    #
    # Parameters Area
    #
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Parameters"
    self.layout.addWidget(parametersCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

    self.inputDirSelector = ctk.ctkPathLineEdit()
    self.inputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.inputDirSelector.settingKey = 'DICOMPatcherInputDir'
    parametersFormLayout.addRow("Input DICOM directory:", self.inputDirSelector)

    self.outputDirSelector = ctk.ctkPathLineEdit()
    self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.outputDirSelector.settingKey = 'DICOMPatcherOutputDir'
    parametersFormLayout.addRow("Output DICOM directory:", self.outputDirSelector)

    self.normalizeFileNamesCheckBox = qt.QCheckBox()
    self.normalizeFileNamesCheckBox.checked = True
    self.normalizeFileNamesCheckBox.setToolTip("Replace file and folder names with automatically generated names."
      " Fixes errors caused by file path containins special characters or being too long.")
    parametersFormLayout.addRow("Normalize file names", self.normalizeFileNamesCheckBox)

    self.forceSamePatientNameIdInEachDirectoryCheckBox = qt.QCheckBox()
    self.forceSamePatientNameIdInEachDirectoryCheckBox.checked = False
    self.forceSamePatientNameIdInEachDirectoryCheckBox.setToolTip("Generate patient name and ID from the first file in a directory"
      " and force all other files in the same directory to have the same patient name and ID."
      " Enable this option if a separate patient directory is created for each patched file.")
    parametersFormLayout.addRow("Force same patient name and ID in each directory", self.forceSamePatientNameIdInEachDirectoryCheckBox)

    self.generateMissingIdsCheckBox = qt.QCheckBox()
    self.generateMissingIdsCheckBox.checked = True
    self.generateMissingIdsCheckBox.setToolTip("Generate missing patient, study, series IDs. It is assumed that"
      " all files in a directory belong to the same series. Fixes error caused by too aggressive anonymization"
      " or incorrect DICOM image converters.")
    parametersFormLayout.addRow("Generate missing patient/study/series IDs", self.generateMissingIdsCheckBox)

    self.generateImagePositionFromSliceThicknessCheckBox = qt.QCheckBox()
    self.generateImagePositionFromSliceThicknessCheckBox.checked = True
    self.generateImagePositionFromSliceThicknessCheckBox.setToolTip("Generate 'image position sequence' for"
      " multi-frame files that only have 'SliceThickness' field. Fixes error in Dolphin 3D CBCT scanners.")
    parametersFormLayout.addRow("Generate slice position for multi-frame volumes", self.generateImagePositionFromSliceThicknessCheckBox)

    self.anonymizeDicomCheckBox = qt.QCheckBox()
    self.anonymizeDicomCheckBox.checked = False
    self.anonymizeDicomCheckBox.setToolTip("If checked, then some patient identifiable information will be removed"
      " from the patched DICOM files. There are many fields that can identify a patient, this function does not remove all of them.")
    parametersFormLayout.addRow("Partially anonymize", self.anonymizeDicomCheckBox)

    #
    # Patch Button
    #
    self.patchButton = qt.QPushButton("Patch")
    self.patchButton.toolTip = "Fix DICOM files in input directory and write them to output directory"
    parametersFormLayout.addRow(self.patchButton)

    #
    # Import Button
    #
    self.importButton = qt.QPushButton("Import to DICOM database")
    self.importButton.toolTip = "Import DICOM files in output directory into the application's DICOM database"
    parametersFormLayout.addRow(self.importButton)

    # connections
    self.patchButton.connect('clicked(bool)', self.onPatchButton)
    self.importButton.connect('clicked(bool)', self.onImportButton)

    self.statusLabel = qt.QPlainTextEdit()
    self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
    parametersFormLayout.addRow(self.statusLabel)

    # Add vertical spacer
    self.layout.addStretch(1)

    self.logic = DICOMPatcherLogic()
    self.logic.logCallback = self.addLog
    def setup(self):
        #
        # Configuration
        #
        self.configCollapsibleButton = ctk.ctkCollapsibleButton()
        self.configCollapsibleButton.text = "Configuration"
        self.layout.addWidget(self.configCollapsibleButton)

        # Layout within the configuration collapsible button
        self.configFormLayout = qt.QFormLayout(self.configCollapsibleButton)

        import platform
        self.elastixPath = ctk.ctkPathLineEdit()
        self.elastixPath.filters = ctk.ctkPathLineEdit.Dirs
        self.configFormLayout.addRow("Elastix Executable Path:",
                                     self.elastixPath)

        if platform.system() == 'Linux':
            self.elastixPath.setCurrentPath(
                '/home/mrusu/Programs/elastix-4.9.0-linux/bin/')
        if platform.system() == 'Windows':
            self.elastixPath.setCurrentPath("C:/Programs/elastix-4.9.0-win64/")

        self.slicerElastixPath = ctk.ctkPathLineEdit()
        self.slicerElastixPath.filters = ctk.ctkPathLineEdit.Dirs
        self.configFormLayout.addRow("Slicer Elastix Path:",
                                     self.slicerElastixPath)

        if platform.system() == 'Linux':
            self.slicerElastixPath.setCurrentPath(
                '/home/mrusu/Programs/SlicerElastix/Elastix')
        if platform.system() == 'Windows':
            self.slicerElastixPath.setCurrentPath(
                "C:/Programs/SlicerElastix/Elastix/")

        #
        # Input
        #
        self.inputCollapsibleButton = ctk.ctkCollapsibleButton()
        self.inputCollapsibleButton.text = "Input"
        self.layout.addWidget(self.inputCollapsibleButton)

        # Layout within the input collapsible button
        self.inputFormLayout = qt.QFormLayout(self.inputCollapsibleButton)

        #
        # rgb volume selector
        #
        self.inputVolumeSelector = slicer.qMRMLNodeComboBox()
        self.inputVolumeSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
        self.inputVolumeSelector.selectNodeUponCreation = True
        self.inputVolumeSelector.addEnabled = False
        self.inputVolumeSelector.removeEnabled = False
        self.inputVolumeSelector.noneEnabled = False
        self.inputVolumeSelector.showHidden = False
        self.inputVolumeSelector.showChildNodeTypes = False
        self.inputVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.inputFormLayout.addRow("Fixed volume: ", self.inputVolumeSelector)

        ###
        """
        self.fixedVolumeMaskSelector = slicer.qMRMLNodeComboBox()
        self.fixedVolumeMaskSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.fixedVolumeMaskSelector.addEnabled = False
        self.fixedVolumeMaskSelector.removeEnabled = False
        self.fixedVolumeMaskSelector.noneEnabled = True
        self.fixedVolumeMaskSelector.showHidden = False
        self.fixedVolumeMaskSelector.showChildNodeTypes = False
        self.fixedVolumeMaskSelector.setMRMLScene( slicer.mrmlScene )
        self.inputFormLayout.addRow("Fixed volume mask: ", self.fixedVolumeMaskSelector)
        
        self.movingVolumeSelector = slicer.qMRMLNodeComboBox()
        self.movingVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.movingVolumeSelector.selectNodeUponCreation = True
        self.movingVolumeSelector.addEnabled = False
        self.movingVolumeSelector.removeEnabled = False
        self.movingVolumeSelector.noneEnabled = False
        self.movingVolumeSelector.showHidden = False
        self.movingVolumeSelector.showChildNodeTypes = False
        self.movingVolumeSelector.setMRMLScene( slicer.mrmlScene )
        self.inputFormLayout.addRow("Moving volume: ", self.movingVolumeSelector)


        #
        # moving volume mask selector
        #
        self.movingVolumeMaskSelector = slicer.qMRMLNodeComboBox()
        self.movingVolumeMaskSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.movingVolumeMaskSelector.selectNodeUponCreation = True
        self.movingVolumeMaskSelector.addEnabled = False
        self.movingVolumeMaskSelector.removeEnabled = False
        self.movingVolumeMaskSelector.noneEnabled = True
        self.movingVolumeMaskSelector.showHidden = False
        self.movingVolumeMaskSelector.showChildNodeTypes = False
        self.movingVolumeMaskSelector.setMRMLScene( slicer.mrmlScene )
        self.movingVolumeMaskSelector.setToolTip("Moving volume mask")
        self.inputFormLayout.addRow("Moving volume mask: ", self.movingVolumeMaskSelector)
        """

        #
        #Output
        #
        self.outputCollapsibleButton = ctk.ctkCollapsibleButton()
        self.outputCollapsibleButton.text = "Output"
        self.layout.addWidget(self.outputCollapsibleButton)

        # Layout within the output collapsible button
        self.outputFormLayout = qt.QFormLayout(self.outputCollapsibleButton)

        #
        # output volume selector
        #
        self.outputVolumeSelector = slicer.qMRMLNodeComboBox()
        self.outputVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.outputVolumeSelector.selectNodeUponCreation = True
        self.outputVolumeSelector.addEnabled = True
        self.outputVolumeSelector.renameEnabled = True
        self.outputVolumeSelector.removeEnabled = True
        self.outputVolumeSelector.noneEnabled = True
        self.outputVolumeSelector.showHidden = False
        self.outputVolumeSelector.showChildNodeTypes = False
        self.outputVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.outputFormLayout.addRow("Output volume: ",
                                     self.outputVolumeSelector)
        """
        #
        # output transform selector
        #
        self.outputTransformSelector = slicer.qMRMLNodeComboBox()
        self.outputTransformSelector.nodeTypes = ["vtkMRMLTransformNode"]
        self.outputTransformSelector.selectNodeUponCreation = True
        self.outputTransformSelector.addEnabled = True
        self.outputTransformSelector.renameEnabled = True
        self.outputTransformSelector.removeEnabled = True
        self.outputTransformSelector.noneEnabled = True
        self.outputTransformSelector.showHidden = False
        self.outputTransformSelector.showChildNodeTypes = False
        self.outputTransformSelector.setMRMLScene( slicer.mrmlScene )
        self.outputFormLayout.addRow("Output transform: ", self.outputTransformSelector)

        """
        # Add vertical spacer
        self.layout.addStretch(1)

        #
        # Status and Progress
        #
        statusLabel = qt.QLabel("Status: ")
        self.currentStatusLabel = qt.QLabel("Idle")
        hlayout = qt.QHBoxLayout()
        hlayout.addStretch(1)
        hlayout.addWidget(statusLabel)
        hlayout.addWidget(self.currentStatusLabel)
        self.layout.addLayout(hlayout)

        self.progress = qt.QProgressBar()
        self.progress.setRange(0, 1000)
        self.progress.setValue(0)
        self.layout.addWidget(self.progress)
        self.progress.hide()

        #Cancel
        self.cancelButton = qt.QPushButton("Cancel")
        self.cancelButton.toolTip = "Abort the algorithm."
        self.cancelButton.enabled = False

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the Radiology-Pathology Fusion."
        self.applyButton.enabled = True

        # Test button
        self.testButton = qt.QPushButton("Test")
        self.testButton.toolTip = "Text elastix."
        self.testButton.enabled = True

        hlayout = qt.QHBoxLayout()

        hlayout.addWidget(self.testButton)
        hlayout.addStretch(1)
        hlayout.addWidget(self.cancelButton)
        hlayout.addWidget(self.applyButton)
        self.layout.addLayout(hlayout)

        self.cancelButton.connect('clicked(bool)', self.onCancel)
        self.applyButton.connect('clicked(bool)', self.onApply)
        self.testButton.connect('clicked(bool)', self.onTest)
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = ExtensionStatsLogic()
        self.logic.setStatusCallback(self.setStatusText)

        self.queryInProgress = False

        # Instantiate and connect widgets ...

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        extensionNameBox = qt.QHBoxLayout()

        self.extensionNameEdit = qt.QLineEdit()
        self.extensionNameEdit.setText('')
        extensionNameBox.addWidget(self.extensionNameEdit)

        self.extensionNameAllButton = qt.QPushButton()
        self.extensionNameAllButton.text = "all"
        self.extensionNameAllButton.toolTip = "Get statistics for all extensions"
        extensionNameBox.addWidget(self.extensionNameAllButton)
        self.populateExtensionNameEdit()

        parametersFormLayout.addRow("Extension name: ", extensionNameBox)

        self.applyButton = qt.QPushButton("Get download statistics")
        self.applyButton.toolTip = "Get download statistics"
        parametersFormLayout.addRow(self.applyButton)

        self.statusText = qt.QLabel()
        parametersFormLayout.addRow("Status:", self.statusText)

        # Stats table
        self.statsTableWidget = slicer.qMRMLTableView()
        self.statsTableWidget.setMRMLScene(slicer.mrmlScene)
        parametersFormLayout.addRow("Statistics:", self.statsTableWidget)
        policy = qt.QSizePolicy()
        policy.setVerticalStretch(1)
        policy.setHorizontalPolicy(qt.QSizePolicy.Expanding)
        policy.setVerticalPolicy(qt.QSizePolicy.Expanding)
        self.statsTableWidget.setSizePolicy(policy)

        self.statsTableNode = slicer.vtkMRMLTableNode()
        self.statsTableNode.SetName('ExtensionStats')
        self.statsTableNode.SetUseColumnNameAsColumnHeader(True)
        self.statsTableNode.SetUseFirstColumnAsRowHeader(True)
        slicer.mrmlScene.AddNode(self.statsTableNode)
        self.statsTableWidget.setMRMLTableNode(self.statsTableNode)

        # Copy to clipboard button
        self.copyToClipboardButton = qt.QPushButton("Copy table to clipboard")
        parametersFormLayout.addRow('', self.copyToClipboardButton)

        # connections
        self.extensionNameAllButton.connect('clicked()',
                                            self.populateExtensionNameEdit)
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.copyToClipboardButton.connect('clicked()',
                                           self.copyTableToClipboard)
Esempio n. 6
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # fixed image selector
        #
        self.fixedImageSelector = slicer.qMRMLNodeComboBox()
        self.fixedImageSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.fixedImageSelector.selectNodeUponCreation = True
        self.fixedImageSelector.addEnabled = False
        self.fixedImageSelector.removeEnabled = False
        self.fixedImageSelector.noneEnabled = True
        self.fixedImageSelector.showHidden = False
        self.fixedImageSelector.showChildNodeTypes = False
        self.fixedImageSelector.setMRMLScene(slicer.mrmlScene)
        self.fixedImageSelector.setToolTip("Fixed image (optional)")
        parametersFormLayout.addRow("Fixed Image: ", self.fixedImageSelector)

        #
        # fixed image label selector
        #
        self.fixedImageLabelSelector = slicer.qMRMLNodeComboBox()
        self.fixedImageLabelSelector.nodeTypes = ((
            "vtkMRMLLabelMapVolumeNode"), "")
        self.fixedImageLabelSelector.selectNodeUponCreation = True
        self.fixedImageLabelSelector.addEnabled = False
        self.fixedImageLabelSelector.removeEnabled = False
        self.fixedImageLabelSelector.noneEnabled = False
        self.fixedImageLabelSelector.showHidden = False
        self.fixedImageLabelSelector.showChildNodeTypes = False
        self.fixedImageLabelSelector.setMRMLScene(slicer.mrmlScene)
        self.fixedImageLabelSelector.setToolTip(
            "Segmentation of the fixed image")
        parametersFormLayout.addRow("Segmentation of the fixed Image: ",
                                    self.fixedImageLabelSelector)

        #
        # moving image selector
        #
        self.movingImageSelector = slicer.qMRMLNodeComboBox()
        self.movingImageSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.movingImageSelector.selectNodeUponCreation = True
        self.movingImageSelector.addEnabled = False
        self.movingImageSelector.removeEnabled = False
        self.movingImageSelector.noneEnabled = True
        self.movingImageSelector.showHidden = False
        self.movingImageSelector.showChildNodeTypes = False
        self.movingImageSelector.setMRMLScene(slicer.mrmlScene)
        self.movingImageSelector.setToolTip("Moving image (optional)")
        parametersFormLayout.addRow("Moving Image: ", self.movingImageSelector)

        #
        # moving image label selector
        #
        self.movingImageLabelSelector = slicer.qMRMLNodeComboBox()
        self.movingImageLabelSelector.nodeTypes = ((
            "vtkMRMLLabelMapVolumeNode"), "")
        self.movingImageLabelSelector.selectNodeUponCreation = True
        self.movingImageLabelSelector.addEnabled = False
        self.movingImageLabelSelector.removeEnabled = False
        self.movingImageLabelSelector.noneEnabled = False
        self.movingImageLabelSelector.showHidden = False
        self.movingImageLabelSelector.showChildNodeTypes = False
        self.movingImageLabelSelector.setMRMLScene(slicer.mrmlScene)
        self.movingImageLabelSelector.setToolTip(
            "Segmentation of the moving image")
        parametersFormLayout.addRow("Segmentation of the moving Image: ",
                                    self.movingImageLabelSelector)

        #
        # Affine output transform selector
        #
        self.affineTransformSelector = slicer.qMRMLNodeComboBox()
        self.affineTransformSelector.nodeTypes = (("vtkMRMLTransformNode"), "")
        self.affineTransformSelector.selectNodeUponCreation = True
        self.affineTransformSelector.addEnabled = True
        self.affineTransformSelector.removeEnabled = False
        self.affineTransformSelector.noneEnabled = False
        self.affineTransformSelector.showHidden = False
        self.affineTransformSelector.showChildNodeTypes = False
        self.affineTransformSelector.baseName = 'Affine Transform'
        self.affineTransformSelector.setMRMLScene(slicer.mrmlScene)
        self.affineTransformSelector.setToolTip(
            "Registration affine transform")
        parametersFormLayout.addRow("Registration affine transform: ",
                                    self.affineTransformSelector)

        #
        # B-spline output transform selector
        #
        self.bsplineTransformSelector = slicer.qMRMLNodeComboBox()
        self.bsplineTransformSelector.nodeTypes = (("vtkMRMLTransformNode"),
                                                   "")
        self.bsplineTransformSelector.selectNodeUponCreation = True
        self.bsplineTransformSelector.addEnabled = True
        self.bsplineTransformSelector.removeEnabled = False
        self.bsplineTransformSelector.noneEnabled = False
        self.bsplineTransformSelector.showHidden = False
        self.bsplineTransformSelector.showChildNodeTypes = False
        self.bsplineTransformSelector.baseName = 'Deformable Transform'
        self.bsplineTransformSelector.setMRMLScene(slicer.mrmlScene)
        self.bsplineTransformSelector.setToolTip(
            "Registration b-spline transform")
        parametersFormLayout.addRow("Registration B-spline Transform: ",
                                    self.bsplineTransformSelector)

        #
        # registered volume selector
        #
        '''
    self.outputImageSelector = slicer.qMRMLNodeComboBox()
    self.outputImageSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    # self.outputImageSelector.nodeTypes = ( ("vtkMRMLLabelMapVolumeNode"), "" )
    self.outputImageSelector.selectNodeUponCreation = True
    self.outputImageSelector.addEnabled = True
    self.outputImageSelector.removeEnabled = True
    self.outputImageSelector.noneEnabled = True
    self.outputImageSelector.showHidden = False
    self.outputImageSelector.showChildNodeTypes = False
    self.outputImageSelector.baseName = 'Registered Volume'
    self.outputImageSelector.setMRMLScene( slicer.mrmlScene )
    self.outputImageSelector.setToolTip( "Registered volume (will be generated only if the moving image was provided)" )
    parametersFormLayout.addRow("Registered Volume: ", self.outputImageSelector)
    '''

        #
        # To be added later: advanced parameters
        #  registration modes (rigid/affine/bspline), save rigid/affine transforms,
        #  crop box margin, number of samples, ...
        #
        # Add parameter node to facilitate registration from other modules and
        # command line
        #

        self.registrationModeGroup = qt.QButtonGroup()
        self.noRegistrationRadio = qt.QRadioButton('Before registration')
        self.linearRegistrationRadio = qt.QRadioButton(
            'After linear registration')
        self.deformableRegistrationRadio = qt.QRadioButton(
            'After deformable registration')
        self.noRegistrationRadio.setChecked(1)
        self.registrationModeGroup.addButton(self.noRegistrationRadio, 1)
        self.registrationModeGroup.addButton(self.linearRegistrationRadio, 2)
        self.registrationModeGroup.addButton(self.deformableRegistrationRadio,
                                             3)
        parametersFormLayout.addRow(qt.QLabel("Visualization"))
        parametersFormLayout.addRow("", self.noRegistrationRadio)
        parametersFormLayout.addRow("", self.linearRegistrationRadio)
        parametersFormLayout.addRow("", self.deformableRegistrationRadio)

        self.registrationModeGroup.connect('buttonClicked(int)',
                                           self.onVisualizationModeClicked)

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = True
        parametersFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)

        # Add vertical spacer
        self.layout.addStretch(1)

        # Refresh Apply button state
        #self.onSelect()

        self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
        '''
Esempio n. 7
0
  def setup(self):
    print(" ")
    print("=======================================================")   
    print("   Automatic Cochlea Image Registration                ")
    print("=======================================================")    

    # to avoid conflict between slicer and elastix ITKs
    #os.environ['ITK_AUTOLOAD_PATH'] = ' '
       
    ScriptedLoadableModuleWidget.setup(self)
      
    # to access logic class functions and setup global variables
  
    # Set default VisSIm location in the user home 
    #TODO: add option user-defined path when installed first time 
    self.logic = CochleaRegLogic()
    self.logic.setGlobalVariables()
    #=================================================================
    #                     Create the GUI interface
    #=================================================================   
    # Create collapsible Button for registration, transformix and invert transform
    self.mainCollapsibleBtn = ctk.ctkCollapsibleButton()
    self.mainCollapsibleBtn.setStyleSheet("ctkCollapsibleButton { background-color: DarkSeaGreen  }")
    self.mainCollapsibleBtn.text = "ACIR: Automatic Cochlea Image Registration"
    self.layout.addWidget(self.mainCollapsibleBtn)
    self.mainFormLayout = qt.QFormLayout(self.mainCollapsibleBtn)

    # Create fixed Volume Selector
    self.fixedSelectorCoBx                        = slicer.qMRMLNodeComboBox()
    self.fixedSelectorCoBx.nodeTypes              = ["vtkMRMLScalarVolumeNode"]
    self.fixedSelectorCoBx.selectNodeUponCreation = True
    self.fixedSelectorCoBx.addEnabled             = False
    self.fixedSelectorCoBx.removeEnabled          = False
    self.fixedSelectorCoBx.noneEnabled            = False
    self.fixedSelectorCoBx.showHidden             = False
    self.fixedSelectorCoBx.showChildNodeTypes     = False
    self.fixedSelectorCoBx.setMRMLScene( slicer.mrmlScene )
    self.fixedSelectorCoBx.setToolTip("Pick the fixed volume")
    self.mainFormLayout.addRow("Fixed Volume: ", self.fixedSelectorCoBx)

    # Create moving Volume Selector
    self.movingSelectorCoBx                        = slicer.qMRMLNodeComboBox()
    self.movingSelectorCoBx.nodeTypes              = ["vtkMRMLScalarVolumeNode"]
    self.movingSelectorCoBx.selectNodeUponCreation = True
    self.movingSelectorCoBx.addEnabled             = False
    self.movingSelectorCoBx.removeEnabled          = False
    self.movingSelectorCoBx.noneEnabled            = False
    self.movingSelectorCoBx.showHidden             = False
    self.movingSelectorCoBx.showChildNodeTypes     = False
    self.movingSelectorCoBx.setMRMLScene( slicer.mrmlScene )
    self.movingSelectorCoBx.setToolTip("Pick the moving volume")
    self.mainFormLayout.addRow("Moving Volume: ", self.movingSelectorCoBx)       

    # Create a time label
    self.timeLbl = qt.QLabel("                 Time: 00:00")
    self.timeLbl.setFixedWidth(500)   
    self.tmLbl = self.timeLbl
    
    # Create a textbox for cochlea location
    # TODO activate input IJK values as well
    self.fixedPointEdt = qt.QLineEdit()
    self.fixedPointEdt.setFixedHeight(40)
    Pt = self.logic.fixedPoint
    self.fixedPointEdt.setText(str(Pt))

    # Create a textbox for cochlea location
    # TODO activate input IJK values as well
    self.movingPointEdt = qt.QLineEdit()
    self.movingPointEdt.setFixedHeight(40)
    Pt = self.logic.movingPoint
    self.movingPointEdt.setText(str(Pt))

    # Create a cochlea locator button
    self.fixedFiducialBtn = qt.QPushButton("Pick cochlea location in fixed image    ")
    self.fixedFiducialBtn.setFixedHeight(40)
    self.fixedFiducialBtn.setToolTip("Pick the fixed fiducial point that will be the center of the cropped image")
    self.fixedFiducialBtn.connect('clicked(bool)', lambda: self.onInputFiducialBtnClick("fixed"))
    self.mainFormLayout.addRow( self.fixedFiducialBtn, self.fixedPointEdt)    

    # Create a cochlea locator button
    self.movingFiducialBtn = qt.QPushButton("Pick cochlea location in moving image    ")
    self.movingFiducialBtn.setFixedHeight(40)
    self.movingFiducialBtn.setToolTip("Pick the moving fiducial point that will be the center of the cropped image")
    self.movingFiducialBtn.connect('clicked(bool)', lambda: self.onInputFiducialBtnClick("moving"))
    self.mainFormLayout.addRow( self.movingFiducialBtn, self.movingPointEdt)    
        
    # Add check box for disabling colors in the result of the registration
    self.colorsChkBox = qt.QCheckBox()
    self.colorsChkBox.text = "Disable colors"
    self.colorsChkBox.checked = False
    self.colorsChkBox.stateChanged.connect(self.OnColorsChkBoxChange)
    self.mainFormLayout.addRow(self.colorsChkBox)

    # Create a button to run registration
    self.applyBtn = qt.QPushButton("Run")
    self.applyBtn.setFixedHeight(50)
    self.applyBtn.setFixedWidth (250)
    self.applyBtn.setStyleSheet("QPushButton{ background-color: DarkSeaGreen  }")
    self.applyBtn.toolTip = ('How to use:' ' Load at least two images into Slicer. Pick cochlea locations using the buttons and the Slicer Fiducial tool ')
    self.applyBtn.connect('clicked(bool)', self.onApplyBtnClick)
    self.mainFormLayout.addRow(self.applyBtn, self.timeLbl)
    self.runBtn = self.applyBtn
    
    self.layout.addStretch(1) # Collapsible button is held in place when collapsing/expanding.
    def setup(self):
        # Instantiate and connect widgets ...

        #
        # Filters Area
        #
        filtersCollapsibleButton = ctk.ctkCollapsibleButton()
        filtersCollapsibleButton.text = "Filters"
        self.layout.addWidget(filtersCollapsibleButton)
        # Layout within the dummy collapsible button
        filtersFormLayout = qt.QFormLayout(filtersCollapsibleButton)

        # filter search
        self.searchBox = ctk.ctkSearchBox()
        filtersFormLayout.addRow("Search:", self.searchBox)
        self.searchBox.connect("textChanged(QString)", self.onSearch)

        # filter selector
        self.filterSelector = qt.QComboBox()
        filtersFormLayout.addRow("Filter:", self.filterSelector)

        # add all the filters listed in the json files
        for idx, j in enumerate(self.jsonFilters):
            name = j["name"]
            self.filterSelector.addItem(name, idx)

        # connections
        self.filterSelector.connect('currentIndexChanged(int)',
                                    self.onFilterSelect)

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        self.filterParameters = FilterParameters(parametersCollapsibleButton)

        # Add vertical spacer
        self.layout.addStretch(1)

        #
        # Status and Progress
        #
        statusLabel = qt.QLabel("Status: ")
        self.currentStatusLabel = qt.QLabel("Idle")
        hlayout = qt.QHBoxLayout()
        hlayout.addStretch(1)
        hlayout.addWidget(statusLabel)
        hlayout.addWidget(self.currentStatusLabel)
        self.layout.addLayout(hlayout)

        self.filterStartTime = None

        self.progress = qt.QProgressBar()
        self.progress.setRange(0, 1000)
        self.progress.setValue(0)
        self.layout.addWidget(self.progress)
        self.progress.hide()

        #
        # Cancel/Apply Row
        #
        self.restoreDefaultsButton = qt.QPushButton("Restore Defaults")
        self.restoreDefaultsButton.toolTip = "Restore the default parameters."
        self.restoreDefaultsButton.enabled = True

        self.cancelButton = qt.QPushButton("Cancel")
        self.cancelButton.toolTip = "Abort the algorithm."
        self.cancelButton.enabled = False

        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = True

        hlayout = qt.QHBoxLayout()

        hlayout.addWidget(self.restoreDefaultsButton)
        hlayout.addStretch(1)
        hlayout.addWidget(self.cancelButton)
        hlayout.addWidget(self.applyButton)
        self.layout.addLayout(hlayout)

        # connections
        self.restoreDefaultsButton.connect('clicked(bool)',
                                           self.onRestoreDefaultsButton)
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.cancelButton.connect('clicked(bool)', self.onCancelButton)

        # Initlial Selection
        self.filterSelector.currentIndexChanged(
            self.filterSelector.currentIndex)
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)
    self.dirPaths = RegistrationHierarchyHelp()
    #self.predefinedList = ["","FC","SingleFC","MDACC"]
    self.predefinedList = ["","Example","4DCT"]
    # Instantiate and connect widgets ...

    ##
    ## Reload and Test area
    ##
    #reloadCollapsibleButton = ctk.ctkCollapsibleButton()
    #reloadCollapsibleButton.text = "Reload && Test"
    #self.layout.addWidget(reloadCollapsibleButton)
    #reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

    ## reload button
    ## (use this during development, but remove it when delivering
    ##  your module to users)
    #self.reloadButton = qt.QPushButton("Reload")
    #self.reloadButton.toolTip = "Reload this module."
    #self.reloadButton.name = "CreateRegistrationHierarchy Reload"
    #reloadFormLayout.addWidget(self.reloadButton)
    #self.reloadButton.connect('clicked()', self.onReload)

    ## reload and test button
    ## (use this during development, but remove it when delivering
    ##  your module to users)
    #self.reloadAndTestButton = qt.QPushButton("Reload and Test")
    #self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
    #reloadFormLayout.addWidget(self.reloadAndTestButton)
    #self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

    #
    # Parameters Area
    #
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Parameters"
    self.layout.addWidget(parametersCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)
    
    # Voi list
    self.predefPatBox = qt.QComboBox()
    self.predefPatBox.enabled = True
    parametersFormLayout.addRow("Templates: ", self.predefPatBox)
    for element in self.predefinedList:
       self.predefPatBox.addItem(element)

    #
    # Patient Name
    #
    self.patientName = qt.QLineEdit()     
    self.patientName.setToolTip( "Input patient name" )
    self.patientName.text = ''
    parametersFormLayout.addRow("Patient Name:", self.patientName)

    # Directories
    self.CTDIR = qt.QLineEdit()     
    self.CTDIR.setToolTip( "Input the path to CT Directory" )
    self.CTDIR.text = ''
    parametersFormLayout.addRow("CT Directory:", self.CTDIR)
    
    self.contourDIR = qt.QLineEdit()     
    self.contourDIR.setToolTip( "Input the path to Contour Directory" )
    self.contourDIR.text = ''
    self.contourDIR.visible = False
    parametersFormLayout.addRow("Contour Directory:", self.contourDIR)
    
    self.contourID = qt.QLineEdit()     
    self.contourID.setToolTip( "Input the inspected contour ID" )
    self.contourID.text = ''
    self.contourID.visible = False
    parametersFormLayout.addRow("Contour ID:", self.contourID)
    
    self.vectorDIR = qt.QLineEdit()     
    self.vectorDIR.setToolTip( "Input the path to vector Directory" )
    self.vectorDIR.text = ''
    parametersFormLayout.addRow("Vector Field Directory:", self.vectorDIR)
    
    self.warpedDIR = qt.QLineEdit()     
    self.warpedDIR.setToolTip( "Input the path to warped images Directory" )
    self.warpedDIR.text = ''
    parametersFormLayout.addRow("Warped Images Directory:", self.warpedDIR)
    
    self.ROIfilePath = qt.QLineEdit()     
    self.ROIfilePath.setToolTip( "Input the path to ROI" )
    self.ROIfilePath.text = ''
    parametersFormLayout.addRow("ROI FilePath:", self.ROIfilePath)
    
    self.fiducialsDIR = qt.QLineEdit()     
    self.fiducialsDIR.setToolTip( "Input the path to fiducials Directory" )
    self.fiducialsDIR.text = ''
    parametersFormLayout.addRow("Fiducials Directory:", self.fiducialsDIR)
    
    #Four CT
    self.fourDCheckbox = qt.QCheckBox()
    self.fourDCheckbox.setToolTip("Check if a registration within 4DCT was done")
    self.fourDCheckbox.setCheckState(0)
    parametersFormLayout.addRow("4DCT Registration:", self.fourDCheckbox)
    

    
    #
    # Create subject hierarchy
    #
    self.createHierarchyButton = qt.QPushButton("Create Subject Hierarchy")
    self.createHierarchyButton.toolTip = "Create Subject Hierarchy from the CT files on disk."
    self.createHierarchyButton.visible = True
    parametersFormLayout.addRow(self.createHierarchyButton)
    
    
    # connections
    self.predefPatBox.connect('currentIndexChanged(int)', self.setPreDef)
    self.createHierarchyButton.connect('clicked(bool)', self.onCreateHierarchyButton)
    self.patientName.connect('textChanged(QString)',self.patNameChanged)
    self.fourDCheckbox.connect('clicked(void)',self.updateWidget)


    # Add vertical spacer
    self.layout.addStretch(1)
Esempio n. 10
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        inputModelSelectorFrame = qt.QFrame(self.parent)
        inputModelSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(inputModelSelectorFrame)

        inputModelSelectorLabel = qt.QLabel("Input Model: ",
                                            inputModelSelectorFrame)
        inputModelSelectorLabel.setToolTip("Select the input model")
        inputModelSelectorFrame.layout().addWidget(inputModelSelectorLabel)

        inputModelSelector = slicer.qMRMLNodeComboBox(inputModelSelectorFrame)
        inputModelSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        inputModelSelector.selectNodeUponCreation = False
        inputModelSelector.addEnabled = False
        inputModelSelector.removeEnabled = False
        inputModelSelector.noneEnabled = True
        inputModelSelector.showHidden = False
        inputModelSelector.showChildNodeTypes = False
        inputModelSelector.setMRMLScene(slicer.mrmlScene)
        inputModelSelectorFrame.layout().addWidget(inputModelSelector)

        outputModelSelectorFrame = qt.QFrame(self.parent)
        outputModelSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(outputModelSelectorFrame)

        outputModelSelectorLabel = qt.QLabel("Output Model: ",
                                             outputModelSelectorFrame)
        outputModelSelectorLabel.setToolTip("Select the output model")
        outputModelSelectorFrame.layout().addWidget(outputModelSelectorLabel)

        outputModelSelector = slicer.qMRMLNodeComboBox(
            outputModelSelectorFrame)
        outputModelSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        outputModelSelector.selectNodeUponCreation = False
        outputModelSelector.addEnabled = True
        outputModelSelector.renameEnabled = True
        outputModelSelector.removeEnabled = True
        outputModelSelector.noneEnabled = True
        outputModelSelector.showHidden = False
        outputModelSelector.showChildNodeTypes = False
        outputModelSelector.baseName = "Model"
        outputModelSelector.selectNodeUponCreation = True
        outputModelSelector.setMRMLScene(slicer.mrmlScene)
        outputModelSelectorFrame.layout().addWidget(outputModelSelector)

        decimationButton = qt.QPushButton("Decimation")
        decimationButton.checkable = True
        self.layout.addWidget(decimationButton)
        decimationFrame = qt.QFrame(self.parent)
        self.layout.addWidget(decimationFrame)
        decimationFormLayout = qt.QFormLayout(decimationFrame)

        reductionFrame, reductionSlider, reductionSpinBox = numericInputFrame(
            self.parent, "Reduction:", "Tooltip", 0.0, 1.0, 0.1, 1)
        decimationFormLayout.addWidget(reductionFrame)

        boundaryDeletionCheckBox = qt.QCheckBox("Boundary deletion")
        decimationFormLayout.addWidget(boundaryDeletionCheckBox)

        smoothingButton = qt.QPushButton("Smoothing")
        smoothingButton.checkable = True
        self.layout.addWidget(smoothingButton)
        smoothingFrame = qt.QFrame(self.parent)
        self.layout.addWidget(smoothingFrame)
        smoothingFormLayout = qt.QFormLayout(smoothingFrame)

        smoothingMethodCombo = qt.QComboBox(smoothingFrame)
        smoothingMethodCombo.addItem("Laplace")
        smoothingMethodCombo.addItem("Taubin")
        smoothingFormLayout.addWidget(smoothingMethodCombo)

        laplaceMethodFrame = qt.QFrame(self.parent)
        smoothingFormLayout.addWidget(laplaceMethodFrame)
        laplaceMethodFormLayout = qt.QFormLayout(laplaceMethodFrame)

        laplaceIterationsFrame, laplaceIterationsSlider, laplaceIterationsSpinBox = numericInputFrame(
            self.parent, "Iterations:", "Tooltip", 0.0, 500.0, 1.0, 0)
        laplaceMethodFormLayout.addWidget(laplaceIterationsFrame)

        laplaceRelaxationFrame, laplaceRelaxationSlider, laplaceRelaxationSpinBox = numericInputFrame(
            self.parent, "Relaxation:", "Tooltip", 0.0, 1.0, 0.1, 1)
        laplaceMethodFormLayout.addWidget(laplaceRelaxationFrame)

        taubinMethodFrame = qt.QFrame(self.parent)
        smoothingFormLayout.addWidget(taubinMethodFrame)
        taubinMethodFormLayout = qt.QFormLayout(taubinMethodFrame)

        taubinIterationsFrame, taubinIterationsSlider, taubinIterationsSpinBox = numericInputFrame(
            self.parent, "Iterations:", "Tooltip", 0.0, 100.0, 1.0, 0)
        taubinMethodFormLayout.addWidget(taubinIterationsFrame)

        taubinPassBandFrame, taubinPassBandSlider, taubinPassBandSpinBox = numericInputFrame(
            self.parent, "Pass Band:", "Tooltip", 0.0, 1.0, 0.01, 2)
        taubinMethodFormLayout.addWidget(taubinPassBandFrame)

        boundarySmoothingCheckBox = qt.QCheckBox("Boundary Smoothing")
        smoothingFormLayout.addWidget(boundarySmoothingCheckBox)

        normalsButton = qt.QPushButton("Normals")
        normalsButton.checkable = True
        self.layout.addWidget(normalsButton)
        normalsFrame = qt.QFrame(self.parent)
        self.layout.addWidget(normalsFrame)
        normalsFormLayout = qt.QFormLayout(normalsFrame)

        flipNormalsCheckBox = qt.QCheckBox("Flip Normals")
        normalsFormLayout.addWidget(flipNormalsCheckBox)

        splittingCheckBox = qt.QCheckBox("Splitting")
        normalsFormLayout.addWidget(splittingCheckBox)

        featureAngleFrame, featureAngleSlider, featureAngleSpinBox = numericInputFrame(
            self.parent, "Feature Angle:", "Tooltip", 0.0, 180.0, 1.0, 0)
        normalsFormLayout.addWidget(featureAngleFrame)

        cleanerButton = qt.QPushButton("Cleaner")
        cleanerButton.checkable = True
        self.layout.addWidget(cleanerButton)

        connectivityButton = qt.QPushButton("Connectivity")
        connectivityButton.checkable = True
        self.layout.addWidget(connectivityButton)
        #connectivityFrame = qt.QFrame(self.parent)
        #self.layout.addWidget(connectivityFrame)
        #connectivityFormLayout = qt.QFormLayout(connectivityFrame)

        # TODO: connectivity could be
        # - largest connected
        # - threshold connected (discard below point count)
        # - pick a region interactively
        # - turn a multiple connected surface into a model hierarchy

        buttonFrame = qt.QFrame(self.parent)
        buttonFrame.setLayout(qt.QHBoxLayout())
        self.layout.addWidget(buttonFrame)

        toggleModelsButton = qt.QPushButton("Toggle Models")
        toggleModelsButton.toolTip = "Show original model."
        buttonFrame.layout().addWidget(toggleModelsButton)

        applyButton = qt.QPushButton("Apply")
        applyButton.toolTip = "Filter surface."
        buttonFrame.layout().addWidget(applyButton)

        self.layout.addStretch(1)

        class state(object):
            inputModelNode = None
            outputModelNode = None
            decimation = False
            reduction = 0.8
            boundaryDeletion = False
            smoothing = False
            smoothingMethod = "Laplace"
            laplaceIterations = 100.0
            laplaceRelaxation = 0.5
            taubinIterations = 30.0
            taubinPassBand = 0.1
            boundarySmoothing = True
            normals = False
            flipNormals = False
            splitting = False
            featureAngle = 30.0
            cleaner = False
            connectivity = False

        scope_locals = locals()

        def connect(obj, evt, cmd):
            def callback(*args):
                current_locals = scope_locals.copy()
                current_locals.update({'args': args})
                exec cmd in globals(), current_locals
                updateGUI()

            obj.connect(evt, callback)

        def updateGUI():
            def button_stylesheet(active):
                if active:
                    return "background-color: green"
                else:
                    return ""

            decimationButton.checked = state.decimation
            #decimationButton.setStyleSheet(button_stylesheet(state.decimation))
            decimationFrame.visible = state.decimation
            boundaryDeletionCheckBox.checked = state.boundaryDeletion
            reductionSlider.value = state.reduction
            reductionSpinBox.value = state.reduction

            smoothingButton.checked = state.smoothing
            smoothingFrame.visible = state.smoothing
            laplaceMethodFrame.visible = state.smoothingMethod == "Laplace"
            laplaceIterationsSlider.value = state.laplaceIterations
            laplaceIterationsSpinBox.value = state.laplaceIterations
            laplaceRelaxationSlider.value = state.laplaceRelaxation
            laplaceRelaxationSpinBox.value = state.laplaceRelaxation
            taubinMethodFrame.visible = state.smoothingMethod == "Taubin"
            taubinIterationsSlider.value = state.taubinIterations
            taubinIterationsSpinBox.value = state.taubinIterations
            taubinPassBandSlider.value = state.taubinPassBand
            taubinPassBandSpinBox.value = state.taubinPassBand
            boundarySmoothingCheckBox.checked = state.boundarySmoothing

            normalsButton.checked = state.normals
            normalsFrame.visible = state.normals
            flipNormalsCheckBox.checked = state.flipNormals
            splittingCheckBox.checked = state.splitting
            featureAngleFrame.visible = state.splitting
            featureAngleSlider.value = state.featureAngle
            featureAngleSpinBox.value = state.featureAngle

            cleanerButton.checked = state.cleaner

            connectivityButton.checked = state.connectivity

            toggleModelsButton.enabled = state.inputModelNode != None and state.outputModelNode != None
            applyButton.enabled = state.inputModelNode != None and state.outputModelNode != None

        connect(inputModelSelector, 'currentNodeChanged(vtkMRMLNode*)',
                'state.inputModelNode = args[0]')
        connect(outputModelSelector, 'currentNodeChanged(vtkMRMLNode*)',
                'state.outputModelNode = args[0]')

        def initializeModelNode(node):
            displayNode = slicer.vtkMRMLModelDisplayNode()
            storageNode = slicer.vtkMRMLModelStorageNode()
            displayNode.SetScene(slicer.mrmlScene)
            storageNode.SetScene(slicer.mrmlScene)
            slicer.mrmlScene.AddNode(displayNode)
            slicer.mrmlScene.AddNode(storageNode)
            node.SetAndObserveDisplayNodeID(displayNode.GetID())
            node.SetAndObserveStorageNodeID(storageNode.GetID())

        outputModelSelector.connect('nodeAddedByUser(vtkMRMLNode*)',
                                    initializeModelNode)

        connect(decimationButton, 'clicked(bool)',
                'state.decimation = args[0]')
        connect(reductionSlider, 'valueChanged(double)',
                'state.reduction = args[0]')
        connect(reductionSpinBox, 'valueChanged(double)',
                'state.reduction = args[0]')
        connect(boundaryDeletionCheckBox, 'stateChanged(int)',
                'state.boundaryDeletion = bool(args[0])')

        connect(smoothingButton, 'clicked(bool)', 'state.smoothing = args[0]')
        connect(smoothingMethodCombo, 'currentIndexChanged(QString)',
                'state.smoothingMethod = args[0]')

        connect(laplaceIterationsSlider, 'valueChanged(double)',
                'state.laplaceIterations = int(args[0])')
        connect(laplaceIterationsSpinBox, 'valueChanged(double)',
                'state.laplaceIterations = int(args[0])')
        connect(laplaceRelaxationSlider, 'valueChanged(double)',
                'state.laplaceRelaxation = args[0]')
        connect(laplaceRelaxationSpinBox, 'valueChanged(double)',
                'state.laplaceRelaxation = args[0]')

        connect(taubinIterationsSlider, 'valueChanged(double)',
                'state.taubinIterations = int(args[0])')
        connect(taubinIterationsSpinBox, 'valueChanged(double)',
                'state.taubinIterations = int(args[0])')
        connect(taubinPassBandSlider, 'valueChanged(double)',
                'state.taubinPassBand = args[0]')
        connect(taubinPassBandSpinBox, 'valueChanged(double)',
                'state.taubinPassBand = args[0]')

        connect(boundarySmoothingCheckBox, 'stateChanged(int)',
                'state.boundarySmoothing = bool(args[0])')

        connect(normalsButton, 'clicked(bool)', 'state.normals = args[0]')

        connect(flipNormalsCheckBox, 'stateChanged(int)',
                'state.flipNormals = bool(args[0])')
        connect(splittingCheckBox, 'stateChanged(int)',
                'state.splitting = bool(args[0])')
        connect(featureAngleSlider, 'valueChanged(double)',
                'state.featureAngle = args[0]')
        connect(featureAngleSpinBox, 'valueChanged(double)',
                'state.featureAngle = args[0]')

        connect(cleanerButton, 'clicked(bool)', 'state.cleaner = args[0]')
        connect(connectivityButton, 'clicked(bool)',
                'state.connectivity = args[0]')

        def onApply():
            updateGUI()
            applyButton.text = "Working..."
            applyButton.repaint()
            slicer.app.processEvents()
            logic = SurfaceToolboxLogic()
            result = logic.applyFilters(state)
            if result:
                state.inputModelNode.GetModelDisplayNode().VisibilityOff()
                state.outputModelNode.GetModelDisplayNode().VisibilityOn()
            else:
                state.inputModelNode.GetModelDisplayNode().VisibilityOn()
                state.outputModelNode.GetModelDisplayNode().VisibilityOff()
            applyButton.text = "Apply"

        applyButton.connect('clicked()', onApply)

        def onToggleModels():
            updateGUI()
            if state.inputModelNode.GetModelDisplayNode().GetVisibility():
                state.inputModelNode.GetModelDisplayNode().VisibilityOff()
                state.outputModelNode.GetModelDisplayNode().VisibilityOn()
                toggleModelsButton.text = "Toggle Models (Output)"
            else:
                state.inputModelNode.GetModelDisplayNode().VisibilityOn()
                state.outputModelNode.GetModelDisplayNode().VisibilityOff()
                toggleModelsButton.text = "Toggle Models (Input)"

        toggleModelsButton.connect('clicked()', onToggleModels)

        updateGUI()

        self.updateGUI = updateGUI
Esempio n. 11
0
    def setup(self):
        # Collapsible button
        self.laplaceCollapsibleButton = ctk.ctkCollapsibleButton()
        self.laplaceCollapsibleButton.text = "Image Filter"
        self.layout.addWidget(self.laplaceCollapsibleButton)

        # Layout within the laplace collapsible button
        self.filterFormLayout = qt.QFormLayout(self.laplaceCollapsibleButton)

        # the volume selectors
        self.inputFrame = qt.QFrame(self.laplaceCollapsibleButton)
        self.inputFrame.setLayout(qt.QHBoxLayout())
        self.filterFormLayout.addWidget(self.inputFrame)
        self.inputSelector = qt.QLabel("Input Volume: ", self.inputFrame)
        self.inputFrame.layout().addWidget(self.inputSelector)
        self.inputSelector = slicer.qMRMLNodeComboBox(self.inputFrame)
        self.inputSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputFrame.layout().addWidget(self.inputSelector)

        # Add a reload button for debug
        reloadButton = qt.QPushButton("Reload")
        reloadButton.toolTip = "Reload this Module"
        reloadButton.name = "MedicalImageEnhancement Reload"
        reloadButton.connect('clicked()', self.onReload)
        self.reloadButton = reloadButton
        self.filterFormLayout.addWidget(self.reloadButton)

        # Add a clear screen button for debug
        clearScreenButton = qt.QPushButton("Clear Screen")
        clearScreenButton.toolTip = "Clear Python Interactor Screen"
        clearScreenButton.name = "ClearScreen"
        clearScreenButton.connect('clicked()', self.onClearScreen)
        self.clearScreenButton = clearScreenButton
        self.filterFormLayout.addWidget(self.clearScreenButton)

        # Choose the filter
        self.filter = "Smoothing"

        changeFilterFrame = qt.QFrame(self.parent)
        changeFilterFrame.setLayout(qt.QVBoxLayout())
        self.filterFormLayout.addWidget(changeFilterFrame)
        self.changeFilterFrame = changeFilterFrame

        chooseSmooth = qt.QRadioButton("Smoothing")
        chooseSmooth.setChecked(True)
        chooseSmooth.connect('clicked()', self.chooseSmooth)
        self.filterFormLayout.addWidget(chooseSmooth)
        self.chooseSmooth = chooseSmooth

        chooseSharpen = qt.QRadioButton("Sharpening")
        chooseSharpen.connect('clicked()', self.chooseSharpen)
        self.filterFormLayout.addWidget(chooseSharpen)
        self.chooseSharpen = chooseSharpen

        chooseEdge = qt.QRadioButton("Edge Detection")
        chooseEdge.connect('clicked()', self.chooseEdge)
        self.filterFormLayout.addWidget(chooseEdge)
        self.chooseEdge = chooseEdge

        # Apply button
        filterButton = qt.QPushButton("Apply")
        filterButton.toolTip = "Run the Image Filtering."
        self.filterFormLayout.addWidget(filterButton)
        filterButton.connect('clicked(bool)', self.onApply)
        self.filterButton = filterButton

        # Add vertical spacer
        self.layout.addStretch(1)
    def setup(self):
        # Instantiate and connect widgets ...

        #
        # Reload and Test area
        #
        reloadCollapsibleButton = ctk.ctkCollapsibleButton()
        reloadCollapsibleButton.text = "Reload && Test"
        self.layout.addWidget(reloadCollapsibleButton)
        reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "EpilepsyPythonModule Reload"
        reloadFormLayout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        # reload and test button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadAndTestButton = qt.QPushButton("Reload and Test")
        self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
        reloadFormLayout.addWidget(self.reloadAndTestButton)
        self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # input volume selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                        0)
        self.inputSelector.selectNodeUponCreation = True
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.noneEnabled = False
        self.inputSelector.showHidden = False
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputSelector.setToolTip("Pick the input to the algorithm.")
        parametersFormLayout.addRow("Input Volume: ", self.inputSelector)

        #
        # output volume selector
        #
        self.outputSelector = slicer.qMRMLNodeComboBox()
        self.outputSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.outputSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                         0)
        self.outputSelector.selectNodeUponCreation = False
        self.outputSelector.addEnabled = True
        self.outputSelector.removeEnabled = True
        self.outputSelector.noneEnabled = False
        self.outputSelector.showHidden = False
        self.outputSelector.showChildNodeTypes = False
        self.outputSelector.setMRMLScene(slicer.mrmlScene)
        self.outputSelector.setToolTip("Pick the output to the algorithm.")
        parametersFormLayout.addRow("Output Volume: ", self.outputSelector)

        #
        # check box to trigger taking screen shots for later use in tutorials
        #
        self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
        self.enableScreenshotsFlagCheckBox.checked = 0
        self.enableScreenshotsFlagCheckBox.setToolTip(
            "If checked, take screen shots for tutorials. Use Save Data to write them to disk."
        )
        parametersFormLayout.addRow("Enable Screenshots",
                                    self.enableScreenshotsFlagCheckBox)

        #
        # scale factor for screen shots
        #
        self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget()
        self.screenshotScaleFactorSliderWidget.singleStep = 1.0
        self.screenshotScaleFactorSliderWidget.minimum = 1.0
        self.screenshotScaleFactorSliderWidget.maximum = 50.0
        self.screenshotScaleFactorSliderWidget.value = 1.0
        self.screenshotScaleFactorSliderWidget.setToolTip(
            "Set scale factor for the screen shots.")
        parametersFormLayout.addRow("Screenshot scale factor",
                                    self.screenshotScaleFactorSliderWidget)

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = False
        parametersFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.onSelect)
        self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onSelect)

        # Add vertical spacer
        self.layout.addStretch(1)
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        # TODO: The following lines are strictly for debug purposes, should be removed when this module is done
        self.developerMode = True
        slicer.tmwidget = self

        self.logic = CollectFiducialsSupplementLogic()

        # private widget-specific things
        self.enableButtonState = 0

        # Collapsible buttons
        self.parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        self.parametersCollapsibleButton.text = "CollectFiducialsSupplement"
        self.layout.addWidget(self.parametersCollapsibleButton)

        # Layout within the collapsible button
        self.parametersFormLayout = qt.QFormLayout(
            self.parametersCollapsibleButton)

        # Transform Tool Tip To Reference combobox
        self.transformNodeSourceLabel = qt.QLabel()
        self.transformNodeSourceLabel.setText("Source transform node: ")
        self.transformNodeSourceSelector = slicer.qMRMLNodeComboBox()
        self.transformNodeSourceSelector.nodeTypes = ((
            "vtkMRMLLinearTransformNode"), "")
        self.transformNodeSourceSelector.noneEnabled = False
        self.transformNodeSourceSelector.addEnabled = False
        self.transformNodeSourceSelector.removeEnabled = False
        self.transformNodeSourceSelector.setMRMLScene(slicer.mrmlScene)
        self.transformNodeSourceSelector.setToolTip(
            "Pick the transform for going from the tool's tip to the target coordinate system"
        )
        self.parametersFormLayout.addRow(self.transformNodeSourceLabel,
                                         self.transformNodeSourceSelector)

        # Transform Target to Reference combobox
        self.transformNodeTargetLabel = qt.QLabel()
        self.transformNodeTargetLabel.setText("Target transform node: ")
        self.transformNodeTargetSelector = slicer.qMRMLNodeComboBox()
        self.transformNodeTargetSelector.nodeTypes = ((
            "vtkMRMLLinearTransformNode"), "")
        self.transformNodeTargetSelector.noneEnabled = False
        self.transformNodeTargetSelector.addEnabled = False
        self.transformNodeTargetSelector.removeEnabled = False
        self.transformNodeTargetSelector.setMRMLScene(slicer.mrmlScene)
        self.transformNodeTargetSelector.setToolTip(
            "Pick the transform for going from the tool's tip to the target coordinate system"
        )
        self.parametersFormLayout.addRow(self.transformNodeTargetLabel,
                                         self.transformNodeTargetSelector)

        # Point List combobox
        self.pointListLabel = qt.QLabel()
        self.pointListLabel.setText("Point list: ")
        self.pointListSelector = slicer.qMRMLNodeComboBox()
        self.pointListSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "")
        self.pointListSelector.noneEnabled = False
        self.pointListSelector.addEnabled = True
        self.pointListSelector.removeEnabled = False
        self.pointListSelector.setMRMLScene(slicer.mrmlScene)
        self.pointListSelector.setToolTip(
            "Pick which fiducial list to store collected points in")
        self.parametersFormLayout.addRow(self.pointListLabel,
                                         self.pointListSelector)

        # Allow point removals
        self.allowPointRemovalsLabel = qt.QLabel()
        self.allowPointRemovalsLabel.setText("Allow point removals: ")
        self.allowPointRemovalsCheckbox = qt.QCheckBox()
        self.parametersFormLayout.addRow(self.allowPointRemovalsLabel,
                                         self.allowPointRemovalsCheckbox)

        # Force constant distance
        self.forceConstantPointDistanceLabel = qt.QLabel()
        self.forceConstantPointDistanceLabel.setText(
            "Force constant point distance: ")
        self.forceConstantPointDistanceCheckbox = qt.QCheckBox()
        self.parametersFormLayout.addRow(
            self.forceConstantPointDistanceLabel,
            self.forceConstantPointDistanceCheckbox)

        # Point add distance
        minimumAddDistanceSliderMinMm = 0
        minimumAddDistanceSliderMaxMm = 50
        minimumAddDistanceSliderDefaultMm = 10
        self.minimumAddDistanceLabel = qt.QLabel(qt.Qt.Horizontal, None)
        self.minimumAddDistanceLabel.text = "Minimum point add distance: "
        self.minimumAddDistanceSlider = slicer.qMRMLSliderWidget()
        self.minimumAddDistanceSlider.minimum = minimumAddDistanceSliderMinMm
        self.minimumAddDistanceSlider.maximum = minimumAddDistanceSliderMaxMm
        self.minimumAddDistanceSlider.value = minimumAddDistanceSliderDefaultMm
        self.parametersFormLayout.addRow(self.minimumAddDistanceLabel,
                                         self.minimumAddDistanceSlider)

        self.enableButton = qt.QPushButton()
        self.enableButton.text = "Enable Automatic Fiducial Collection"
        self.enableButton.setToolTip(
            "Start the automatic collection of fiducials based on the settings"
        )
        self.parametersFormLayout.addRow(self.enableButton)

        self.removeAllPointsButton = qt.QPushButton()
        self.removeAllPointsButton.text = "Remove All Points"
        self.removeAllPointsButton.setToolTip(
            "Make the current fiducial list empty. This will delete all data in that list."
        )
        self.parametersFormLayout.addRow(self.removeAllPointsButton)

        # Add vertical spacer
        self.layout.addStretch(1)

        #Connections
        self.enableButton.connect('clicked()', self.enableButtonPressed)
        self.removeAllPointsButton.connect('clicked()',
                                           self.logic.removeAllPoints)
        self.minimumAddDistanceSlider.connect(
            'valueChanged(double)', self.logic.setMinimumAddDistanceMm)
        self.allowPointRemovalsCheckbox.connect(
            'clicked()', self.allowPointRemovalsCheckboxClicked)
        self.forceConstantPointDistanceCheckbox.connect(
            'clicked()', self.forceConstantPointDistanceCheckboxClicked)

        # Add vertical spacer
        self.layout.addStretch(1)
Esempio n. 14
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        # Instantiate and connect widgets ...

        self.logic = BreachWarningLightLogic()

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # input volume selector
        #
        self.breachWarningSelector = slicer.qMRMLNodeComboBox()
        self.breachWarningSelector.nodeTypes = (("vtkMRMLBreachWarningNode"),
                                                "")
        self.breachWarningSelector.selectNodeUponCreation = True
        self.breachWarningSelector.addEnabled = False
        self.breachWarningSelector.removeEnabled = False
        self.breachWarningSelector.noneEnabled = False
        self.breachWarningSelector.showHidden = False
        self.breachWarningSelector.showChildNodeTypes = False
        self.breachWarningSelector.setMRMLScene(slicer.mrmlScene)
        self.breachWarningSelector.setToolTip(
            "Pick the breach warning node to observe.")
        parametersFormLayout.addRow("Breach warning node: ",
                                    self.breachWarningSelector)

        #
        # output volume selector
        #
        self.connectorSelector = slicer.qMRMLNodeComboBox()
        self.connectorSelector.nodeTypes = (("vtkMRMLIGTLConnectorNode"), "")
        self.connectorSelector.selectNodeUponCreation = True
        self.connectorSelector.addEnabled = False
        self.connectorSelector.removeEnabled = False
        self.connectorSelector.noneEnabled = False
        self.connectorSelector.showHidden = False
        self.connectorSelector.showChildNodeTypes = False
        self.connectorSelector.setMRMLScene(slicer.mrmlScene)
        self.connectorSelector.setToolTip(
            "Pick the OpenIGTLink connector node to send light control commands to"
        )
        parametersFormLayout.addRow("Connector: ", self.connectorSelector)

        #
        # marginSizeMm value
        #
        self.marginSizeMmSliderWidget = ctk.ctkSliderWidget()
        self.marginSizeMmSliderWidget.singleStep = 0.1
        self.marginSizeMmSliderWidget.minimum = 0
        self.marginSizeMmSliderWidget.maximum = 10
        self.marginSizeMmSliderWidget.value = 2.0
        self.marginSizeMmSliderWidget.setToolTip(
            "Set the desired margin size in mm. Light pattern will indicate 'good position' if the distance is smaller than this value."
        )
        parametersFormLayout.addRow("Margin size (mm)",
                                    self.marginSizeMmSliderWidget)

        #
        # check box to trigger taking screen shots for later use in tutorials
        #
        self.enableLightFeedbackFlagCheckBox = qt.QCheckBox()
        self.enableLightFeedbackFlagCheckBox.checked = 0
        self.enableLightFeedbackFlagCheckBox.setToolTip(
            "If checked, then light pattern will be updated whenever the breach warning state is changed."
        )
        parametersFormLayout.addRow("Enable light feedback",
                                    self.enableLightFeedbackFlagCheckBox)

        # connections
        self.enableLightFeedbackFlagCheckBox.connect(
            'stateChanged(int)', self.setEnableLightFeedback)
        self.marginSizeMmSliderWidget.connect('valueChanged(double)',
                                              self.setMarginChanged)

        # Add vertical spacer
        self.layout.addStretch(1)
Esempio n. 15
0
    def setup(self):
        # Instantiate and connect widgets ...

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "RSNAVisTutorial Reload"
        self.layout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        # reload and test button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadAndTestButton = qt.QPushButton("Reload and Test")
        self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
        self.layout.addWidget(self.reloadAndTestButton)
        self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

        # Collapsible button
        testsCollapsibleButton = ctk.ctkCollapsibleButton()
        testsCollapsibleButton.text = "Tests"
        self.layout.addWidget(testsCollapsibleButton)

        # Layout within the collapsible button
        formLayout = qt.QFormLayout(testsCollapsibleButton)

        # test buttons
        tests = (
            ("Part 1: DICOM", self.onPart1DICOM),
            ("Part 2: Head", self.onPart2Head),
            ("Part 3: Liver", self.onPart3Liver),
            ("Part 4: Lung", self.onPart4Lung),
        )
        for text, slot in tests:
            testButton = qt.QPushButton(text)
            testButton.toolTip = "Run the test."
            formLayout.addWidget(testButton)
            testButton.connect('clicked(bool)', slot)

        # A collapsible button to hide screen shot options
        screenShotsCollapsibleButton = ctk.ctkCollapsibleButton()
        screenShotsCollapsibleButton.text = "Screen shot options"
        self.layout.addWidget(screenShotsCollapsibleButton)

        # layout within the collapsible button
        screenShotsFormLayout = qt.QFormLayout(screenShotsCollapsibleButton)

        #
        # check box to trigger taking screen shots for later use in tutorials
        #
        self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
        self.enableScreenshotsFlagCheckBox.checked = 0
        self.enableScreenshotsFlagCheckBox.setToolTip(
            "If checked, take screen shots for tutorials. Use Save Data to write them to disk."
        )
        screenShotsFormLayout.addRow("Enable Screenshots",
                                     self.enableScreenshotsFlagCheckBox)

        #
        # scale factor for screen shots
        #
        self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget()
        self.screenshotScaleFactorSliderWidget.singleStep = 1.0
        self.screenshotScaleFactorSliderWidget.minimum = 1.0
        self.screenshotScaleFactorSliderWidget.maximum = 50.0
        self.screenshotScaleFactorSliderWidget.value = 1.0
        self.screenshotScaleFactorSliderWidget.setToolTip(
            "Set scale factor for the screen shots.")
        screenShotsFormLayout.addRow("Screenshot scale factor",
                                     self.screenshotScaleFactorSliderWidget)

        # Add vertical spacer
        self.layout.addStretch(1)
Esempio n. 16
0
    def remakeWidget(self):
        """ Ideally, this would be unncessary.  But, since QScrollArea doesn't
            dynamically update, we have to update this ourselves.
        """

        #-------------------
        # Clear all of the inner widgets
        #-------------------
        if self.innerWidget:
            del self.innerWidget
        if self.innerWidgetLayout:
            del self.innerWidgetLayout
        if self.scrollWidget:
            del self.scrollWidget

        #-------------------
        # Reset the inner widget layout
        #-------------------
        self.innerWidgetLayout = qt.QFormLayout()
        self.innerWidgetLayout.setVerticalSpacing(10)

        #-------------------
        # Sort download rows by their queue positions,
        # add them to the innerWidgetLayout.
        #-------------------
        sortedRows = [None] * len(self.downloadRows)
        for key, item in self.downloadRows.iteritems():
            #print len(sortedRows), item['queuePosition']
            sortedRows[item['queuePosition']] = key
        for key in sortedRows:
            self.innerWidgetLayout.addRow(self.downloadRows[key]['widget'])

        #-------------------
        # Remake the inner widget
        #-------------------
        self.innerWidget = qt.QWidget()
        self.innerWidget.setLayout(self.innerWidgetLayout)
        self.innerWidget.setObjectName('innerWidget')
        self.innerWidget.setStyleSheet('#innerWidget {width: 100%;}')
        self.innerWidget.setSizePolicy(qt.QSizePolicy.MinimumExpanding,
                                       qt.QSizePolicy.MinimumExpanding)

        #-------------------
        # Remake the scroll widget
        #-------------------
        self.scrollWidget = qt.QScrollArea()
        self.scrollWidget.setWidget(self.innerWidget)
        self.scrollWidget.verticalScrollBar().setStyleSheet('width: 15px')
        self.scrollWidget.setObjectName('scrollWidget')
        self.scrollWidget.setStyleSheet('#scrollWidget {border: none}')
        self.scrollWidget.setSizePolicy(qt.QSizePolicy.MinimumExpanding,
                                        qt.QSizePolicy.MinimumExpanding)
        self.scrollWidget.setWidgetResizable(True)

        #-------------------
        # Clear the master widget and add the new contents.
        #-------------------
        delWidget = self.masterLayout.itemAt(0)
        while (delWidget):
            self.masterLayout.removeItem(delWidget)
            del delWidget
            delWidget = self.masterLayout.itemAt(0)

        self.innerWidget.update()
        self.masterLayout.addRow(self.scrollWidget)
        self.setSizePolicy(qt.QSizePolicy.MinimumExpanding,
                           qt.QSizePolicy.MinimumExpanding)

        calcHeight = (self.rowWidgetHeight + 12) * len(self.downloadRows)
        if calcHeight < 800:
            self.setMinimumHeight(calcHeight)
        else:
            self.setMinimumHeight(800)

        self.update()
Esempio n. 17
0
    def setup(self):

        # Tags are used to manage event ovservers
        self.tagSourceNode = None
        self.tagDestinationNode = None

        #Set up area for creating curves
        createCurveBttn = ctk.ctkCollapsibleButton()
        createCurveBttn.text = "Create Curve"
        self.layout.addWidget(createCurveBttn)
        layout = qt.QFormLayout(createCurveBttn)

        #Selecting source points from fiducials
        self.SourceSelector = slicer.qMRMLNodeComboBox()
        self.SourceSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "")
        self.SourceSelector.addEnabled = True
        self.SourceSelector.removeEnabled = True
        self.SourceSelector.noneEnabled = True
        self.SourceSelector.renameEnabled = True
        self.SourceSelector.setMRMLScene(slicer.mrmlScene)
        self.SourceSelector.setToolTip(
            "Select source of points or create a new list")
        layout.addRow("Source points: ", self.SourceSelector)

        #Selecting destination for new curve
        self.DestinationSelector = slicer.qMRMLNodeComboBox()
        self.DestinationSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        self.DestinationSelector.addEnabled = True
        self.DestinationSelector.removeEnabled = True
        self.DestinationSelector.noneEnabled = True
        self.DestinationSelector.renameEnabled = True
        self.DestinationSelector.selectNodeUponCreation = True
        self.DestinationSelector.setMRMLScene(slicer.mrmlScene)
        self.DestinationSelector.setToolTip(
            "Select existing curve model or create a new one")
        layout.addRow("Curve model: ", self.DestinationSelector)

        #x, y, z inputs for new fiducial
        self.validator = qt.QDoubleValidator()
        self.AddFiducialLayout = qt.QHBoxLayout()
        self.AddX = qt.QLineEdit("X")
        self.AddX.setValidator(self.validator)
        self.AddY = qt.QLineEdit("Y")
        self.AddY.setValidator(self.validator)
        self.AddZ = qt.QLineEdit("Z")
        self.AddZ.setValidator(self.validator)
        self.AddFiducialLayout.addWidget(self.AddX)
        self.AddFiducialLayout.addWidget(self.AddY)
        self.AddFiducialLayout.addWidget(self.AddZ)
        layout.addRow("X, Y, Z coordinates for new fiducial: ",
                      self.AddFiducialLayout)

        #Add fiducial button
        self.AddFiducialButton = qt.QPushButton("Add Fiducial")
        self.AddFiducialButton.toolTip = "Adds fiducial using given x, y, z coordinates"
        self.AddFiducialButton.enabled = True
        layout.addRow("", self.AddFiducialButton)

        #Current fiducials table
        self.FiducialTable = qt.QTableWidget(1, 4)
        self.FiducialTableHeaders = ["Name", "X (mm)", "Y (mm)", "Z (mm)"]
        self.FiducialTable.setHorizontalHeaderLabels(self.FiducialTableHeaders)
        layout.addWidget(self.FiducialTable)

        #Radius of curve
        self.RadiusSliderWidget = ctk.ctkSliderWidget()
        self.RadiusSliderWidget.singleStep = 0.5
        self.RadiusSliderWidget.minimum = 0.5
        self.RadiusSliderWidget.maximum = 20.0
        self.RadiusSliderWidget.value = 3.0
        self.RadiusSliderWidget.setToolTip(
            "Determines the thickness of the curve")
        layout.addRow("Thickness: ", self.RadiusSliderWidget)

        #Select the method of interpolation
        self.InterpolationLayout = qt.QHBoxLayout()
        self.InterpolationLinear = qt.QRadioButton("Linear")
        self.InterpolationLinear.setToolTip(
            "Straight lines from point to point")
        self.InterpolationSpline = qt.QRadioButton("Spline")
        self.InterpolationSpline.setToolTip(
            "Cardinal spline will create curvature between points")
        self.InterpolationLayout.addWidget(self.InterpolationLinear)
        self.InterpolationLayout.addWidget(self.InterpolationSpline)
        self.InterpolationGroup = qt.QButtonGroup()
        self.InterpolationGroup.addButton(self.InterpolationLinear)
        self.InterpolationGroup.addButton(self.InterpolationSpline)
        layout.addRow("Interpolation: ", self.InterpolationLayout)

        #Button for generating specified curve
        self.GenerateButton = qt.QPushButton("Generate/Update Curve")
        self.GenerateButton.toolTip = "Creates or updates curve specified"
        self.GenerateButton.enabled = True
        layout.addRow("", self.GenerateButton)

        #Linking buttons to methods
        self.InterpolationLinear.connect('clicked(bool)',
                                         self.onSelectInterpolationLinear)
        self.InterpolationSpline.connect('clicked(bool)',
                                         self.onSelectInterpolationSpline)
        self.SourceSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onSourceSelected)
        self.DestinationSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                         self.onDestinationSelected)
        self.AddX.textChanged.connect(
            lambda inputSelection: self.checkInputState('x'))
        self.AddX.textChanged.emit(self.AddX.text)
        self.AddY.textChanged.connect(
            lambda inputSelection: self.checkInputState('y'))
        self.AddY.textChanged.emit(self.AddY.text)
        self.AddZ.textChanged.connect(
            lambda inputSelection: self.checkInputState('z'))
        self.AddZ.textChanged.emit(self.AddZ.text)
        self.AddFiducialButton.connect('clicked(bool)', self.addFiducial)
        self.RadiusSliderWidget.connect("valueChanged(double)",
                                        self.onThicknessUpdated)
        self.GenerateButton.connect('clicked(bool)', self.generateCurve)

        #Default checkboxes
        self.InterpolationSpline.setChecked(True)
        self.onSelectInterpolationSpline(True)

        self.layout.addStretch(1)
Esempio n. 18
0
  def create(self,widgetType='window',showHeader=False,showPreview=False):
    """
    main window is a frame with widgets from the app
    widget repacked into it along with slicer-specific
    extra widgets
    """

    # find internals of widget for reference and repacking
    self.toolBar = slicer.util.findChildren(self.dicomBrowser, 'ToolBar')[0]
    self.databaseNameLabel = slicer.util.findChildren(self.dicomBrowser, 'DatabaseNameLabel')[0]
    self.databaseDirectoryButton = slicer.util.findChildren(self.dicomBrowser, 'DirectoryButton')[0]
    self.tableDensityLabel = qt.QLabel('Density: ')
    self.tableDensityComboBox = slicer.util.findChildren(self.dicomBrowser, 'tableDensityComboBox')[0]
    self.tableDensityComboBox.connect('currentIndexChanged(QString)', self.onTableDensityComboBox)
    index = self.tableDensityComboBox.findText(self.tableDensity)
    if  (index != -1) :
      self.tableDensityComboBox.setCurrentIndex(index)

    #self.tables = self.dicomBrowser.tableManager
    self.tables = slicer.util.findChildren(self.dicomBrowser, 'dicomTableManager')[0]
    patientTable = slicer.util.findChildren(self.tables, 'patientsTable')[0]
    patientTableView = slicer.util.findChildren(patientTable, 'tblDicomDatabaseView')[0]
    patientSearchBox = slicer.util.findChildren(patientTable, 'leSearchBox')[0]
    studyTable = slicer.util.findChildren(self.tables, 'studiesTable')[0]
    studyTableView = slicer.util.findChildren(studyTable, 'tblDicomDatabaseView')[0]
    studySearchBox = slicer.util.findChildren(studyTable, 'leSearchBox')[0]
    seriesTable = slicer.util.findChildren(self.tables, 'seriesTable')[0]
    seriesTableView = slicer.util.findChildren(seriesTable, 'tblDicomDatabaseView')[0]
    seriesSearchBox = slicer.util.findChildren(seriesTable, 'leSearchBox')[0]
    self.tableSplitter = qt.QSplitter()
    self.tableSplitter.addWidget(patientTableView)
    self.tableSplitter.addWidget(studyTableView)
    self.tableSplitter.addWidget(seriesTableView)

    # TODO: Move to this part to CTK
    patientTableView.resizeColumnsToContents()
    studyTableView.resizeColumnsToContents()
    seriesTableView.resizeColumnsToContents()

    #self.userFrame = slicer.util.findChildren(self.dicomBrowser, 'UserFrame')[0]
    self.userFrame = qt.QWidget()
    #self.thumbs = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailsWidget')[0]
    #self.widthSlider = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailWidthSlider')[0]
    self.preview = qt.QWidget()

    self.widgetType = widgetType
    if widgetType == 'dialog':
      self.window = qt.QDialog(self.dicomBrowser)
    elif widgetType == 'window':
      self.window = qt.QWidget()
    elif widgetType == 'popup':
      self.window = ctk.ctkPopupWidget(self.dicomBrowser)
      self.window.orientation = 1
      self.window.horizontalDirection = 0
      self.window.alignment = 0x82
    elif widgetType == 'dock':
      self.dock = qt.QDockWidget(slicer.util.mainWindow())
      self.dock.setFeatures( qt.QDockWidget.DockWidgetFloatable |
                                qt.QDockWidget.DockWidgetMovable |
                                qt.QDockWidget.DockWidgetClosable )
      slicer.util.mainWindow().addDockWidget(0x15, self.dock)
      self.window = qt.QFrame()
      self.dock.setWidget(self.window)
    else:
      raise "Unknown widget type - should be dialog, window, dock or popup"

    self.setModality(not self.browserPersistent)

    self.window.setWindowTitle('DICOM Browser')

    self.layout = qt.QVBoxLayout(self.window)

    # tool row at top, with commands and database
    self.toolFrame = qt.QWidget()
    self.toolFrame.setMaximumHeight(40)
    self.toolFrame.setContentsMargins(-5,-5,-5,-5)
    self.toolLayout = qt.QHBoxLayout(self.toolFrame)
    self.layout.addWidget(self.toolFrame)
    self.toolLayout.addWidget(self.toolBar)
    self.settingsButton = ctk.ctkExpandButton()
    self.toolLayout.addWidget(self.settingsButton)
    self.toolLayout.addWidget(self.databaseNameLabel)
    self.databaseNameLabel.visible = False
    self.toolLayout.addWidget(self.databaseDirectoryButton)
    self.databaseDirectoryButton.visible = False
    self.toolLayout.addWidget(self.tableDensityLabel)
    self.tableDensityLabel.visible = False
    self.toolLayout.addWidget(self.tableDensityComboBox)
    self.tableDensityComboBox.visible = False
    self.settingsButton.connect('toggled(bool)', self.onSettingsButton)

    # enable export button and make new connection
    self.actionExport = self.dicomBrowser.findChildren('QAction', 'ActionExport')[0]
    self.actionExport.enabled = 1
    self.actionExport.connect('triggered()', self.onExportAction)

    # search row
    self.searchFrame = qt.QWidget()
    self.searchFrame.setMaximumHeight(40)
    self.searchLayout = qt.QHBoxLayout(self.searchFrame)
    self.layout.addWidget(self.searchFrame)
    patinetsLabel = qt.QLabel('Patients: ')
    self.searchLayout.addWidget(patinetsLabel)
    self.searchLayout.addWidget(patientSearchBox)
    studiesLabel = qt.QLabel('Studies: ')
    self.searchLayout.addWidget(studiesLabel)
    self.searchLayout.addWidget(studySearchBox)
    seriesLabel = qt.QLabel('Series: ')
    self.searchLayout.addWidget(seriesLabel)
    self.searchLayout.addWidget(seriesSearchBox)

    # tables goes next, spread across 1 row, 2 columns
    if self.horizontalTables:
      self.tableSplitter.setOrientation(1)
    else:
      self.tableSplitter.setOrientation(0)
    self.layout.addWidget(self.tableSplitter)

    #
    # preview related column
    #
    self.previewLayout = qt.QVBoxLayout()
    #self.layout.addLayout(self.previewLayout,selectionRow,0)

    #self.previewLayout.addWidget(self.thumbs)
    #self.previewLayout.addWidget(self.widthSlider)
    if showPreview:
      self.previewLayout.addWidget(self.preview)
    else:
      self.preview.hide()

    #
    # action related column (interacting with slicer)
    #
    self.loadableTableFrame = qt.QWidget()
    self.loadableTableFrame.setMaximumHeight(200)
    self.loadableTableLayout = qt.QFormLayout(self.loadableTableFrame)
    self.layout.addWidget(self.loadableTableFrame)

    self.loadableTableLayout.addWidget(self.userFrame)
    self.userFrame.hide()

    tableWidth = 350 if showHeader else 600
    self.loadableTable = DICOMLoadableTable(self.userFrame,width=tableWidth)
    #self.loadableTableLayout.addWidget(self.loadableTable.widget)
    #self.loadableTable.widget.hide()

    #
    # button row for action column
    #
    self.actionButtonsFrame = qt.QWidget()
    self.actionButtonsFrame.setMaximumHeight(40)
    self.layout.addWidget(self.actionButtonsFrame)
    #self.layout.addStretch(1)
    self.actionButtonLayout = qt.QHBoxLayout()
    self.actionButtonsFrame.setLayout(self.actionButtonLayout)

    self.loadButton = qt.QPushButton('Load')
    self.loadButton.enabled = True
    self.loadButton.toolTip = 'Load Selection to Slicer'
    self.actionButtonLayout.addWidget(self.loadButton)
    self.loadButton.connect('clicked()', self.loadCheckedLoadables)

    self.headerPopup = DICOMLib.DICOMHeaderPopup()

    self.viewMetadataButton = qt.QPushButton('Metadata')
    self.viewMetadataButton.toolTip = 'Display Metadata of the Selected Series'
    self.viewMetadataButton.enabled = False
    self.actionButtonLayout.addWidget(self.viewMetadataButton)
    self.viewMetadataButton.connect('clicked()', self.onViewHeaderButton)
    self.viewMetadataButton.connect('clicked()', self.headerPopup.open)
    self.actionButtonLayout.addStretch(1)

    self.examineButton = qt.QPushButton('Examine')
    self.actionButtonLayout.addWidget(self.examineButton)
    self.examineButton.enabled = False
    self.examineButton.connect('clicked()', self.examineForLoading)

    self.uncheckAllButton = qt.QPushButton('Uncheck All')
    self.actionButtonLayout.addWidget(self.uncheckAllButton)
    self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables)
    self.actionButtonLayout.addStretch(1)

    self.closeButton = qt.QPushButton('Close')
    #self.actionButtonLayout.addWidget(self.closeButton)
    self.closeButton.connect('clicked()', self.close)

    self.advancedViewButton = qt.QCheckBox('Advanced')
    self.actionButtonLayout.addWidget(self.advancedViewButton)
    self.advancedViewButton.enabled = True
    self.advancedViewButton.checked = self.advancedView
    self.advancedViewButton.connect('clicked()', self.onAdvanedViewButton)

    self.horizontalViewCheckBox = qt.QCheckBox('Horizontal')
    self.horizontalViewCheckBox.checked = self.horizontalTables
    self.horizontalViewCheckBox.connect('clicked()', self.onHorizontalViewCheckBox)
    self.actionButtonLayout.addWidget(self.horizontalViewCheckBox)
    self.toolLayout.addStretch(1)

    self.browserPersistentButton = qt.QCheckBox('Browser Persistent')
    self.browserPersistentButton.toolTip = 'When enabled, DICOM Browser remains open after loading data or switching to another module'
    self.browserPersistentButton.checked = self.browserPersistent
    self.actionButtonLayout.addWidget(self.browserPersistentButton)
    self.browserPersistentButton.connect('stateChanged(int)', self.setBrowserPersistence)

    if self.advancedView:
      self.loadableTableFrame.visible = True
    else:
      self.loadableTableFrame.visible = False
      self.examineButton.visible = False
      self.uncheckAllButton.visible = False
    #
    # header related column (more details about the selected file)
    #
    if showHeader:
      self.headerLayout = qt.QVBoxLayout()
      self.layout.addLayout(self.headerLayout,selectionRow,2)
      self.header = DICOMHeaderWidget(self.window)
      self.headerLayout.addWidget(self.header.widget)

    #
    # Plugin selection widget
    #
    self.pluginSelector = DICOMPluginSelector(self.window)
    self.loadableTableLayout.addRow(self.pluginSelector.widget,self.loadableTable.widget)
    self.checkBoxByPlugins = []

    for pluginClass in slicer.modules.dicomPlugins:
      self.checkBox = self.pluginSelector.checkBoxByPlugin[pluginClass]
      self.checkBox.connect('stateChanged(int)', self.onPluginStateChanged)
      self.checkBoxByPlugins.append(self.checkBox)
Esempio n. 19
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        # Instantiate and connect widgets ...

        self.logic = MRTrackingLogic(None)
        #self.logic.setWidget(self)

        #--------------------------------------------------
        # For debugging
        #
        # Reload and Test area
        reloadCollapsibleButton = ctk.ctkCollapsibleButton()
        reloadCollapsibleButton.text = "Reload && Test"
        self.layout.addWidget(reloadCollapsibleButton)
        reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

        reloadCollapsibleButton.collapsed = True

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "Reload"
        reloadFormLayout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)
        #
        #--------------------------------------------------

        #--------------------------------------------------
        # GUI components

        self.statusWidget = StatusDisplayWidget()
        self.layout.addWidget(self.statusWidget)
        self.statusWidget.startTimer()
        self.statusWidget.setCatheterCollection(self.logic.catheters)

        #
        # Main Tab
        #
        mainTabWidget = qt.QTabWidget()
        self.layout.addWidget(mainTabWidget)

        #--------------------------------------------------
        # Connection
        #--------------------------------------------------

        connectionFrame = qt.QFrame()
        mainTabWidget.addTab(connectionFrame, "Connection")

        # Layout within the dummy collapsible button
        connectionFormLayout = qt.QFormLayout(connectionFrame)

        self.igtlConnector1 = MRTrackingIGTLConnector("Connector 1  (MRI)")
        self.igtlConnector1.port = 18944
        self.igtlConnector1.buildGUI(connectionFormLayout,
                                     minimal=True,
                                     createNode=True)
        self.statusWidget.addConnector(self.igtlConnector1)

        self.igtlConnector2 = MRTrackingIGTLConnector("Connector 2 (NavX)")
        self.igtlConnector2.port = 18945
        self.igtlConnector2.buildGUI(connectionFormLayout,
                                     minimal=True,
                                     createNode=True)
        self.statusWidget.addConnector(self.igtlConnector2)

        #--------------------------------------------------
        # Tracking Node
        #--------------------------------------------------

        catheterFrame = qt.QFrame()
        mainTabWidget.addTab(catheterFrame, "Tracking")

        catheterSpacer = qt.QSpacerItem(0, 0, qt.QSizePolicy.Expanding,
                                        qt.QSizePolicy.Expanding)
        catheterLayout = qt.QVBoxLayout(catheterFrame)
        catheterInnerFrame = qt.QFrame()
        catheterLayout.addWidget(catheterInnerFrame)
        catheterLayout.addSpacerItem(catheterSpacer)

        self.catheterConfig = MRTrackingCatheterConfig(
            "Catheter Configuration")
        self.catheterConfig.setCatheterCollection(self.logic.catheters)
        self.catheterConfig.buildGUI(catheterInnerFrame)

        #--------------------------------------------------
        # Surface Model & Mapping
        #--------------------------------------------------

        mappingFrame = qt.QFrame()
        mainTabWidget.addTab(mappingFrame, "Mapping")

        mappingSpacer = qt.QSpacerItem(0, 0, qt.QSizePolicy.Expanding,
                                       qt.QSizePolicy.Expanding)
        mappingLayout = qt.QVBoxLayout(mappingFrame)
        mappingInnerFrame = qt.QFrame()
        mappingLayout.addWidget(mappingInnerFrame)
        mappingLayout.addSpacerItem(mappingSpacer)

        self.surfaceMapping = MRTrackingSurfaceMapping("Surface Mapping")
        self.surfaceMapping.setCatheterCollection(self.logic.catheters)
        self.surfaceMapping.buildGUI(mappingInnerFrame)

        #--------------------------------------------------
        # Image Reslice
        #--------------------------------------------------

        resliceFrame = qt.QFrame()
        mainTabWidget.addTab(resliceFrame, "Reslice")

        resliceSpacer = qt.QSpacerItem(0, 0, qt.QSizePolicy.Expanding,
                                       qt.QSizePolicy.Expanding)
        resliceLayout = qt.QVBoxLayout(resliceFrame)
        resliceInnerFrame = qt.QFrame()
        resliceLayout.addWidget(resliceInnerFrame)
        resliceLayout.addSpacerItem(resliceSpacer)

        self.reslice = MRTrackingReslice("Image Reslice")
        self.reslice.setCatheterCollection(self.logic.catheters)
        self.reslice.buildGUI(resliceInnerFrame)

        #--------------------------------------------------
        # Point-to-Point registration
        #--------------------------------------------------

        registrationFrame = qt.QFrame()
        mainTabWidget.addTab(registrationFrame, "Registration")

        registrationSpacer = qt.QSpacerItem(0, 0, qt.QSizePolicy.Expanding,
                                            qt.QSizePolicy.Expanding)
        registrationLayout = qt.QVBoxLayout(registrationFrame)
        registrationInnerFrame = qt.QFrame()
        registrationLayout.addWidget(registrationInnerFrame)
        registrationLayout.addSpacerItem(registrationSpacer)

        self.registration = MRTrackingFiducialRegistration()
        self.registration.setCatheterCollection(self.logic.catheters)
        self.registration.buildGUI(registrationInnerFrame)

        #--------------------------------------------------
        # Recording
        #--------------------------------------------------

        recordingFrame = qt.QFrame()
        mainTabWidget.addTab(recordingFrame, "Recording")

        recordingSpacer = qt.QSpacerItem(0, 0, qt.QSizePolicy.Expanding,
                                         qt.QSizePolicy.Expanding)
        recordingLayout = qt.QVBoxLayout(recordingFrame)
        recordingInnerFrame = qt.QFrame()
        recordingLayout.addWidget(recordingInnerFrame)
        recordingLayout.addSpacerItem(recordingSpacer)

        self.recording = MRTrackingRecording("Recording")
        self.recording.setCatheterCollection(self.logic.catheters)
        self.recording.buildGUI(recordingInnerFrame, False)

        #--------------------------------------------------
        # Connections
        #--------------------------------------------------

        # Add vertical spacer
        self.layout.addStretch(1)
Esempio n. 20
0
    def setup(self):

        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.onVCMRMLSceneChanged)

        w = qt.QWidget()
        layout = qt.QGridLayout()
        w.setLayout(layout)
        self.layout.addWidget(w)
        w.show()
        self.layout = layout

        # create frames
        self.inputFrame = ctk.ctkCollapsibleButton()
        self.inputFrame.text = "Input"
        self.inputFrame.collapsed = 0
        inputFrameLayout = qt.QFormLayout(self.inputFrame)
        self.layout.addWidget(self.inputFrame)

        self.ctrlFrame = ctk.ctkCollapsibleButton()
        self.ctrlFrame.text = "Frame control"
        self.ctrlFrame.collapsed = 0
        ctrlFrameLayout = qt.QGridLayout(self.ctrlFrame)
        self.layout.addWidget(self.ctrlFrame)

        self.plotFrame = ctk.ctkCollapsibleButton()
        self.plotFrame.text = "Plotting"
        self.plotFrame.collapsed = 0
        plotFrameLayout = qt.QGridLayout(self.plotFrame)
        self.layout.addWidget(self.plotFrame)

        label = qt.QLabel('Input multivolume')
        self.__mvSelector = slicer.qMRMLNodeComboBox()
        self.__mvSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.__mvSelector.setMRMLScene(slicer.mrmlScene)
        self.__mvSelector.connect('mrmlSceneChanged(vtkMRMLScene*)',
                                  self.onVCMRMLSceneChanged)
        self.__mvSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                  self.onInputChanged)
        self.__mvSelector.addEnabled = 0

        inputFrameLayout.addRow(label, self.__mvSelector)
        ##self.layout.addWidget(label)
        ##self.layout.addWidget(self.__mvSelector)

        # TODO: initialize the slider based on the contents of the labels array
        # slider to scroll over metadata stored in the vector container being explored
        self.__mdSlider = ctk.ctkSliderWidget()
        #self.__mdSlider.setRange(0,10)
        #self.__mdSlider.setValue(5)

        label = qt.QLabel('Current frame number')
        ##self.layout.addWidget(label)
        ##self.layout.addWidget(self.__mdSlider)

        # "play" control
        self.playButton = qt.QPushButton('Play')
        self.playButton.toolTip = 'Iterate over multivolume frames'
        self.playButton.checkable = True

        ctrlFrameLayout.addWidget(label, 0, 0)
        ctrlFrameLayout.addWidget(self.__mdSlider, 0, 1)
        ctrlFrameLayout.addWidget(self.playButton, 0, 2)

        self.playButton.connect('toggled(bool)', self.onPlayButtonToggled)

        self.__mdSlider.connect('valueChanged(double)', self.onSliderChanged)

        label = qt.QLabel('Current frame copy')

        self.__vfSelector = slicer.qMRMLNodeComboBox()
        self.__vfSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.__vfSelector.setMRMLScene(slicer.mrmlScene)
        self.__vfSelector.connect('mrmlSceneChanged(vtkMRMLScene*)',
                                  self.onVFMRMLSceneChanged)
        self.__vfSelector.addEnabled = 1
        self.__vfSelector.enabled = 0
        # do not show "children" of vtkMRMLScalarVolumeNode
        self.__vfSelector.hideChildNodeTypes = ["vtkMRMLDiffusionWeightedVolumeNode", \
            "vtkMRMLDiffusionTensorVolumeNode", "vtkMRMLVectorVolumeNode"]

        self.extractFrame = False
        self.extractButton = qt.QPushButton('Enable current frame copying')
        self.extractButton.checkable = True
        self.extractButton.connect('toggled(bool)', self.onExtractFrameToggled)

        ctrlFrameLayout.addWidget(label, 1, 0)
        ctrlFrameLayout.addWidget(self.__vfSelector, 1, 1, 1, 2)
        ctrlFrameLayout.addWidget(self.extractButton, 2, 0, 1, 3)

        # initialize slice observers (from DataProbe.py)
        # keep list of pairs: [observee,tag] so they can be removed easily
        self.styleObserverTags = []
        # keep a map of interactor styles to sliceWidgets so we can easily get sliceLogic
        self.sliceWidgetsPerStyle = {}
        self.refreshObservers()

        # label map for probing
        label = qt.QLabel('Probed label volume')
        self.__fSelector = slicer.qMRMLNodeComboBox()
        self.__fSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.__fSelector.addAttribute('vtkMRMLScalarVolumeNode', 'LabelMap',
                                      '1')
        self.__fSelector.toolTip = 'Label map to be probed'
        self.__fSelector.setMRMLScene(slicer.mrmlScene)
        self.__fSelector.addEnabled = 0
        self.__fSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                 self.onLabelVolumeChanged)
        self.__fSelector.connect('mrmlSceneChanged(vtkMRMLScene*)',
                                 self.onLVMRMLSceneChanged)
        plotFrameLayout.addWidget(label, 0, 0, 1, 1)
        plotFrameLayout.addWidget(self.__fSelector, 0, 1, 1, 2)

        self.iCharting = qt.QPushButton()
        self.iCharting.text = 'Enable interactive charting'
        self.iCharting.checkable = True

        plotFrameLayout.addWidget(self.iCharting, 1, 0, 1, 3)
        self.iCharting.setChecked(True)
        self.iCharting.connect('toggled(bool)',
                               self.onInteractiveChartingChanged)

        label = qt.QLabel("Use intensity range to fix axis extent")
        label.toolTip = "If checked, the extent of the vertical axis of the plot will be fixed to the range of the intensities in the input MultiVolume"
        self.__fixedAxesCheckbox = qt.QCheckBox()
        self.__fixedAxesCheckbox.toolTip = "If checked, the extent of the vertical axis of the plot will be fixed to the range of the intensities in the input MultiVolume"
        self.__fixedAxesCheckbox.checked = False
        plotFrameLayout.addWidget(label, 2, 0)
        plotFrameLayout.addWidget(self.__fixedAxesCheckbox, 2, 1, 1, 2)

        # add chart container widget
        self.__chartView = ctk.ctkVTKChartView(w)
        plotFrameLayout.addWidget(self.__chartView, 3, 0, 1, 3)

        self.__chart = self.__chartView.chart()
        self.__chartTable = vtk.vtkTable()
        self.__xArray = vtk.vtkFloatArray()
        self.__yArray = vtk.vtkFloatArray()
        # will crash if there is no name
        self.__xArray.SetName('')
        self.__yArray.SetName('signal intensity')
        self.__chartTable.AddColumn(self.__xArray)
        self.__chartTable.AddColumn(self.__yArray)
Esempio n. 21
0
  def setup(self):
    # Instantiate and connect widgets
    ScriptedLoadableModuleWidget.setup(self)

    self.connectorNodeObserverTagList = []

    # Plus parameters
    plusParametersCollapsibleButton = ctk.ctkCollapsibleButton()
    plusParametersCollapsibleButton.text = "Plus parameters"
    plusParametersCollapsibleButton.collapsed = False
    self.layout.addWidget(plusParametersCollapsibleButton)
    plusParametersLayout = qt.QFormLayout(plusParametersCollapsibleButton)

    self.connectorNodeSelector = slicer.qMRMLNodeComboBox()
    self.connectorNodeSelector.nodeTypes = ["vtkMRMLIGTLConnectorNode"]
    self.connectorNodeSelector.setMRMLScene(slicer.mrmlScene)
    plusParametersLayout.addRow("Connector node:", self.connectorNodeSelector)

    self.deviceIDComboBox = qt.QComboBox()
    plusParametersLayout.addRow("Device ID:", self.deviceIDComboBox)

    # Ultrasound parameters
    ultrasoundParametersCollapsibleButton = ctk.ctkCollapsibleButton()
    ultrasoundParametersCollapsibleButton.text = "Ultrasound parameters"
    ultrasoundParametersCollapsibleButton.collapsed = False
    self.layout.addWidget(ultrasoundParametersCollapsibleButton)
    ultrasoundParametersLayout = qt.QFormLayout(ultrasoundParametersCollapsibleButton)

    self.depthSlider = slicer.qSlicerUltrasoundDoubleParameterSlider()
    self.depthSlider.setParameterName("DepthMm")
    self.depthSlider.setSuffix(" mm")
    self.depthSlider.setMinimum(10.0)
    self.depthSlider.setMaximum(150.0)
    self.depthSlider.setSingleStep(1.0)
    self.depthSlider.setPageStep(10.0)
    ultrasoundParametersLayout.addRow("Depth:",  self.depthSlider)

    self.gainSlider = slicer.qSlicerUltrasoundDoubleParameterSlider()
    self.gainSlider.setParameterName("GainPercent")
    self.gainSlider.setSuffix("%")
    self.gainSlider.setMinimum(0.0)
    self.gainSlider.setMaximum(100.0)
    self.gainSlider.setSingleStep(1.0)
    self.gainSlider.setPageStep(10.0)
    ultrasoundParametersLayout.addRow("Gain:", self.gainSlider)

    self.frequencySlider = slicer.qSlicerUltrasoundDoubleParameterSlider()
    self.frequencySlider.setParameterName("FrequencyMhz")
    self.frequencySlider.setSuffix(" MHz")
    self.frequencySlider.setMinimum(2.0)
    self.frequencySlider.setMaximum(5.0)
    self.frequencySlider.setSingleStep(0.5)
    self.frequencySlider.setPageStep(1.0)
    ultrasoundParametersLayout.addRow("Frequency:", self.frequencySlider)

    self.dynamicRangeSlider = slicer.qSlicerUltrasoundDoubleParameterSlider()
    self.dynamicRangeSlider.setParameterName("DynRangeDb")
    self.dynamicRangeSlider.setSuffix(" dB")
    self.dynamicRangeSlider.setMinimum(10.0)
    self.dynamicRangeSlider.setMaximum(100.0)
    self.dynamicRangeSlider.setSingleStep(1.0)
    self.dynamicRangeSlider.setPageStep(10.0)
    ultrasoundParametersLayout.addRow("Dynamic Range:", self.dynamicRangeSlider)

    self.powerSlider = slicer.qSlicerUltrasoundDoubleParameterSlider()
    self.powerSlider.setParameterName("PowerDb")
    self.powerSlider.setSuffix("Db")
    self.powerSlider.setMinimum(-20.0)
    self.powerSlider.setMaximum(0.0)
    self.powerSlider.setSingleStep(1.0)
    self.powerSlider.setPageStep(5.0)
    ultrasoundParametersLayout.addRow("Power:", self.powerSlider)

    self.layout.addStretch(1)

    self.parameterWidgets = [
    self.depthSlider,
    self.gainSlider,
    self.frequencySlider,
    self.dynamicRangeSlider,
    self.powerSlider
    ]

    self.connectorNodeSelector.connect("nodeActivated(vtkMRMLNode*)", self.onConnectorNodeSelected)
    self.connectorNodeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onConnectorNodeSelected)
    self.deviceIDComboBox.connect("currentIndexChanged(int)", self.onDeviceIdChanged)

    self.plusRemoteNode = slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLPlusRemoteNode')
    if self.plusRemoteNode is None:
      self.plusRemoteNode = slicer.vtkMRMLPlusRemoteNode()
      self.plusRemoteNode.SetName("PlusRemoteNode")
      slicer.mrmlScene.AddNode(self.plusRemoteNode)
    self.plusRemoteNode.AddObserver(slicer.vtkMRMLPlusRemoteNode.DeviceIdsReceivedEvent, self.requestDeviceIDsCompleted)

    self.onConnectorNodeSelected(self.connectorNodeSelector.currentNode())
  def setup(self):
    # Instantiate and connect widgets ...

    #
    # Reload and Test area
    #
    reloadCollapsibleButton = ctk.ctkCollapsibleButton()
    reloadCollapsibleButton.text = "Reload && Test"
    self.layout.addWidget(reloadCollapsibleButton)
    reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

    # reload button
    # (use this during development, but remove it when delivering
    #  your module to users)
    self.reloadButton = qt.QPushButton("Reload")
    self.reloadButton.toolTip = "Reload this module."
    self.reloadButton.name = "FiducialLayoutSwitchBug1914 Reload"
    reloadFormLayout.addWidget(self.reloadButton)
    self.reloadButton.connect('clicked()', self.onReload)

    # reload and test button
    # (use this during development, but remove it when delivering
    #  your module to users)
    self.reloadAndTestButton = qt.QPushButton("Reload and Test")
    self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
    reloadFormLayout.addWidget(self.reloadAndTestButton)
    self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

    #
    # Parameters Area
    #
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Parameters"
    self.layout.addWidget(parametersCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

    #
    # check box to trigger taking screen shots for later use in tutorials
    #
    self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
    self.enableScreenshotsFlagCheckBox.checked = 1
    self.enableScreenshotsFlagCheckBox.setToolTip("If checked, take screen shots for tutorials. Use Save Data to write them to disk.")
    parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox)

    #
    # scale factor for screen shots
    #
    self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget()
    self.screenshotScaleFactorSliderWidget.singleStep = 1.0
    self.screenshotScaleFactorSliderWidget.minimum = 1.0
    self.screenshotScaleFactorSliderWidget.maximum = 50.0
    self.screenshotScaleFactorSliderWidget.value = 1.0
    self.screenshotScaleFactorSliderWidget.setToolTip("Set scale factor for the screen shots.")
    parametersFormLayout.addRow("Screenshot scale factor", self.screenshotScaleFactorSliderWidget)

    #
    # Apply Button
    #
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the algorithm."
    self.applyButton.enabled = True
    parametersFormLayout.addRow(self.applyButton)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)

    # Add vertical spacer
    self.layout.addStretch(1)
Esempio n. 23
0
    def setup(self):
        # Instantiate and connect widgets ...

        #
        # Reload and Test area
        #
        reloadCollapsibleButton = ctk.ctkCollapsibleButton()
        reloadCollapsibleButton.text = "Reload && Test"
        self.layout.addWidget(reloadCollapsibleButton)
        reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "CompareVolumes Reload"
        reloadFormLayout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        # reload and test button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadAndTestButton = qt.QPushButton("Reload and Test")
        self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
        reloadFormLayout.addWidget(self.reloadAndTestButton)
        self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # input volume selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                        0)
        self.inputSelector.selectNodeUponCreation = True
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.noneEnabled = False
        self.inputSelector.showHidden = False
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputSelector.setToolTip("Pick the input to the algorithm.")
        parametersFormLayout.addRow("Target Volume: ", self.inputSelector)

        #
        # Reference Cursors Buttons
        #
        if False:
            self.refOn = qt.QPushButton("Reference Cursors On")
            parametersFormLayout.addRow(self.refOn)
            self.refOff = qt.QPushButton("Reference Cursors Off")
            parametersFormLayout.addRow(self.refOff)
            # connections
            self.refOn.connect('clicked(bool)', self.onRefOn)
            self.refOff.connect('clicked(bool)', self.onRefOff)

        # Add vertical spacer
        self.layout.addStretch(1)
Esempio n. 24
0
    def createUserInterface(self):
        '''
    '''
        self.__layout = self.__parent.createUserInterface()

        # the registration parameters
        registrationParametersGroupBox = qt.QGroupBox()
        registrationParametersGroupBox.setTitle(
            'Atlas-to-Input Registration Parameters')
        self.__layout.addWidget(registrationParametersGroupBox)

        registrationParametersGroupBoxLayout = qt.QFormLayout(
            registrationParametersGroupBox)

        globalParametersNode = self.mrmlManager().GetGlobalParametersNode()

        # for all input channels add a qMRMLNodeComboBox
        for i in range(self.mrmlManager().GetTargetNumberOfSelectedVolumes()):

            channelComboBox = slicer.qMRMLNodeComboBox()
            channelComboBox.setMRMLScene(slicer.mrmlScene)
            channelComboBox.nodeTypes = ['vtkMRMLScalarVolumeNode']
            channelComboBox.noneEnabled = True
            channelComboBox.addEnabled = False
            channelComboBox.removeEnabled = False
            registrationParametersGroupBoxLayout.addRow(
                globalParametersNode.GetNthTargetInputChannelName(i),
                channelComboBox)
            channelComboBox.connect('currentNodeChanged(vtkMRMLNode*)',
                                    self.propagateToMRML)
            self.__channelComboBoxList.append(channelComboBox)

        # Affine Registration comboBox
        self.__affineRegistrationComboBox = qt.QComboBox()
        self.__affineRegistrationComboBox.addItems(
            Helper.GetRegistrationTypes())
        registrationParametersGroupBoxLayout.addRow(
            'Affine Registration:', self.__affineRegistrationComboBox)
        self.__affineRegistrationComboBox.connect('currentIndexChanged(int)',
                                                  self.propagateToMRML)

        # Deformable Registration comboBox
        self.__deformableRegistrationComboBox = qt.QComboBox()
        self.__deformableRegistrationComboBox.addItems(
            Helper.GetRegistrationTypes())
        registrationParametersGroupBoxLayout.addRow(
            'Deformable Registration:', self.__deformableRegistrationComboBox)
        self.__deformableRegistrationComboBox.connect(
            'currentIndexChanged(int)', self.propagateToMRML)

        # Interpolation
        self.__interpolationComboBox = qt.QComboBox()
        self.__interpolationComboBox.addItems(Helper.GetInterpolationTypes())
        registrationParametersGroupBoxLayout.addRow(
            'Interpolation:', self.__interpolationComboBox)
        self.__interpolationComboBox.connect('currentIndexChanged(int)',
                                             self.propagateToMRML)

        # Package
        self.__packageComboBox = qt.QComboBox()
        self.__packageComboBox.addItems(Helper.GetPackages())
        registrationParametersGroupBoxLayout.addRow('Package:',
                                                    self.__packageComboBox)
        self.__packageComboBox.connect('currentIndexChanged(int)',
                                       self.propagateToMRML)
Esempio n. 25
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.amplitude = 0.
        self.frequency = 0.
        self.phase = 0.

        # Instantiate and connect widgets ...

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # render volume selector
        #
        self.renderSelector = slicer.qMRMLNodeComboBox()
        self.renderSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.renderSelector.selectNodeUponCreation = True
        self.renderSelector.addEnabled = False
        self.renderSelector.removeEnabled = False
        self.renderSelector.noneEnabled = False
        self.renderSelector.showHidden = False
        self.renderSelector.showChildNodeTypes = True
        self.renderSelector.setMRMLScene(slicer.mrmlScene)
        self.renderSelector.setToolTip("Pick volume to render.")
        parametersFormLayout.addRow("Render Volume: ", self.renderSelector)

        #
        # amplitude value
        #
        self.transformAmplitude = ctk.ctkSliderWidget()
        self.transformAmplitude.singleStep = 0.001
        self.transformAmplitude.minimum = -2
        self.transformAmplitude.maximum = 2
        self.transformAmplitude.value = 0.
        self.transformAmplitude.setToolTip("Amount of the transform to apply")
        parametersFormLayout.addRow("Transform Amplitude",
                                    self.transformAmplitude)

        #
        # frequency value
        #
        self.transformFrequency = ctk.ctkSliderWidget()
        self.transformFrequency.singleStep = 0.0001
        self.transformFrequency.minimum = -.5
        self.transformFrequency.maximum = .5
        self.transformFrequency.value = 0.1
        self.transformFrequency.setToolTip("Frequency the transform")
        parametersFormLayout.addRow("Transform Frequency",
                                    self.transformFrequency)

        #
        # phase value
        #
        self.transformPhase = ctk.ctkSliderWidget()
        self.transformPhase.singleStep = 0.001
        self.transformPhase.minimum = -5
        self.transformPhase.maximum = 5
        self.transformPhase.value = 0.1
        self.transformPhase.setToolTip("Phase the transform")
        parametersFormLayout.addRow("Transform Phase", self.transformPhase)

        #
        # check box to apply transform
        #
        self.applyTransformCheckBox = qt.QCheckBox()
        self.applyTransformCheckBox.checked = True
        self.applyTransformCheckBox.setToolTip(
            "If checked, render with transform applied.")
        parametersFormLayout.addRow("Apply Transform",
                                    self.applyTransformCheckBox)

        # connections
        self.renderSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onVolumeChange)
        self.transformAmplitude.connect("valueChanged(double)",
                                        self.onTransformChange)
        self.transformFrequency.connect("valueChanged(double)",
                                        self.onTransformChange)
        self.transformPhase.connect("valueChanged(double)",
                                    self.onTransformChange)
        self.applyTransformCheckBox.connect("toggled(bool)",
                                            self.onTransformChange)

        # Add vertical spacer
        self.layout.addStretch(1)

        # set up the scene renderer
        self.sceneRenderer = SceneRenderer()
        self.sceneRenderer.transformPointSource = self.demoTransformPointSource(
        )
Esempio n. 26
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # input volume selector
        #
        self.inputModelSelector = slicer.qMRMLNodeComboBox()
        self.inputModelSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        self.inputModelSelector.selectNodeUponCreation = True
        self.inputModelSelector.addEnabled = False
        self.inputModelSelector.removeEnabled = False
        self.inputModelSelector.noneEnabled = False
        self.inputModelSelector.showHidden = False
        self.inputModelSelector.showChildNodeTypes = False
        self.inputModelSelector.setMRMLScene(slicer.mrmlScene)
        self.inputModelSelector.setToolTip("Pick the input to the algorithm.")
        parametersFormLayout.addRow("Input Model: ", self.inputModelSelector)

        #input texture selector
        self.inputTextureSelector = slicer.qMRMLNodeComboBox()
        self.inputTextureSelector.nodeTypes = (("vtkMRMLVectorVolumeNode"), "")
        self.inputTextureSelector.selectNodeUponCreation = True
        self.inputTextureSelector.addEnabled = False
        self.inputTextureSelector.removeEnabled = False
        self.inputTextureSelector.noneEnabled = False
        self.inputTextureSelector.showHidden = False
        self.inputTextureSelector.showChildNodeTypes = False
        self.inputTextureSelector.setMRMLScene(slicer.mrmlScene)
        self.inputTextureSelector.setToolTip(
            "Pick the input to the algorithm.")
        parametersFormLayout.addRow("Input Texture: ",
                                    self.inputTextureSelector)

        #
        # output volume selector
        #
        self.outputSelector = slicer.qMRMLNodeComboBox()
        self.outputSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        self.outputSelector.selectNodeUponCreation = True
        self.outputSelector.addEnabled = True
        self.outputSelector.removeEnabled = True
        self.outputSelector.noneEnabled = True
        self.outputSelector.showHidden = False
        self.outputSelector.showChildNodeTypes = False
        self.outputSelector.setMRMLScene(slicer.mrmlScene)
        self.outputSelector.setToolTip("Pick the output to the algorithm.")
        parametersFormLayout.addRow("Output Model: ", self.outputSelector)

        # Parameters Area
        #
        parametersRGBCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersRGBCollapsibleButton.text = "RGB Parameters"
        self.layout.addWidget(parametersRGBCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersRGBFormLayout = qt.QFormLayout(
            parametersRGBCollapsibleButton)

        # redThreshold value
        #
        self.redValueSliderWidget = ctk.ctkSliderWidget()
        self.redValueSliderWidget.singleStep = 1
        self.redValueSliderWidget.minimum = 0
        self.redValueSliderWidget.maximum = 256
        self.redValueSliderWidget.value = 188
        self.redValueSliderWidget.setToolTip(
            "Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero."
        )
        parametersRGBFormLayout.addRow("Red Value", self.redValueSliderWidget)

        # greenThreshold value
        self.greenValueSliderWidget = ctk.ctkSliderWidget()
        self.greenValueSliderWidget.singleStep = 1
        self.greenValueSliderWidget.minimum = 0
        self.greenValueSliderWidget.maximum = 256
        self.greenValueSliderWidget.value = 128
        self.greenValueSliderWidget.setToolTip(
            "Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero."
        )
        parametersRGBFormLayout.addRow("Green Value",
                                       self.greenValueSliderWidget)

        # blueThreshold value
        self.blueValueSliderWidget = ctk.ctkSliderWidget()
        self.blueValueSliderWidget.singleStep = 1
        self.blueValueSliderWidget.minimum = 0
        self.blueValueSliderWidget.maximum = 256
        self.blueValueSliderWidget.value = 60
        self.blueValueSliderWidget.setToolTip(
            "Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero."
        )
        parametersRGBFormLayout.addRow("Blue Value",
                                       self.blueValueSliderWidget)

        # threshold value
        #
        self.imageThresholdSliderWidget = ctk.ctkSliderWidget()
        self.imageThresholdSliderWidget.singleStep = 1
        self.imageThresholdSliderWidget.minimum = 0
        self.imageThresholdSliderWidget.maximum = 256
        self.imageThresholdSliderWidget.value = 30
        self.imageThresholdSliderWidget.setToolTip(
            "Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero."
        )
        parametersRGBFormLayout.addRow("Color Threshold",
                                       self.imageThresholdSliderWidget)

        #
        # check box to trigger taking screen shots for later use in tutorials
        #
        self.enableScreenshotsFlagCheckBox = qt.QRadioButton()
        self.enableScreenshotsFlagCheckBox.checked = 0
        self.enableScreenshotsFlagCheckBox.setToolTip(
            "If checked, take screen shots for tutorials. Use Save Data to write them to disk."
        )
        parametersFormLayout.addRow("Screen shots",
                                    self.enableScreenshotsFlagCheckBox)

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = False
        parametersFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.inputModelSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                        self.onSelect)
        self.inputTextureSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                          self.onSelect)
        self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onSelect)

        # Add vertical spacer
        self.layout.addStretch(1)

        # Refresh Apply button state
        self.onSelect()
Esempio n. 27
0
    def setup(self):
        # Instantiate and connect widgets ...
        self.RingOff = None
        self.RingOn = None

        # Tags to manage event observers
        self.tagSourceNode = None
        self.tagDestinationNode = None

        #####################
        ## For debugging
        ##
        ## Reload and Test area
        reloadCollapsibleButton = ctk.ctkCollapsibleButton()
        reloadCollapsibleButton.text = "Reload && Test"
        self.layout.addWidget(reloadCollapsibleButton)
        reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

        ## reload button
        ## (use this during development, but remove it when delivering
        ##  your module to users)
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "CurveMaker Reload"
        reloadFormLayout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)
        ##
        #####################

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # Source points (vtkMRMLMarkupsFiducialNode)
        #
        self.SourceSelector = slicer.qMRMLNodeComboBox()
        self.SourceSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "")
        self.SourceSelector.addEnabled = True
        self.SourceSelector.removeEnabled = False
        self.SourceSelector.noneEnabled = True
        self.SourceSelector.showHidden = False
        self.SourceSelector.renameEnabled = True
        self.SourceSelector.showChildNodeTypes = False
        self.SourceSelector.setMRMLScene(slicer.mrmlScene)
        self.SourceSelector.setToolTip(
            "Pick up a Markups node listing fiducials.")
        parametersFormLayout.addRow("Source points: ", self.SourceSelector)

        #
        # Target point (vtkMRMLMarkupsFiducialNode)
        #
        self.DestinationSelector = slicer.qMRMLNodeComboBox()
        self.DestinationSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        self.DestinationSelector.addEnabled = True
        self.DestinationSelector.removeEnabled = False
        self.DestinationSelector.noneEnabled = True
        self.DestinationSelector.showHidden = False
        self.DestinationSelector.renameEnabled = True
        self.DestinationSelector.selectNodeUponCreation = True
        self.DestinationSelector.showChildNodeTypes = False
        self.DestinationSelector.setMRMLScene(slicer.mrmlScene)
        self.DestinationSelector.setToolTip("Pick up or create a Model node.")
        parametersFormLayout.addRow("Curve model: ", self.DestinationSelector)

        #
        # Radius for the tube
        #
        self.RadiusSliderWidget = ctk.ctkSliderWidget()
        self.RadiusSliderWidget.singleStep = 1.0
        self.RadiusSliderWidget.minimum = 1.0
        self.RadiusSliderWidget.maximum = 50.0
        self.RadiusSliderWidget.value = 5.0
        self.RadiusSliderWidget.setToolTip("Set the raidus of the tube.")
        parametersFormLayout.addRow("Radius (mm): ", self.RadiusSliderWidget)

        #
        # Radio button to select interpolation method
        #
        self.InterpolationLayout = qt.QHBoxLayout()
        self.InterpolationNone = qt.QRadioButton("None")
        self.InterpolationCardinalSpline = qt.QRadioButton("Cardinal Spline")
        self.InterpolationHermiteSpline = qt.QRadioButton(
            "Hermite Spline (for Endoscopy)")
        self.InterpolationLayout.addWidget(self.InterpolationNone)
        self.InterpolationLayout.addWidget(self.InterpolationCardinalSpline)
        self.InterpolationLayout.addWidget(self.InterpolationHermiteSpline)

        self.InterpolationGroup = qt.QButtonGroup()
        self.InterpolationGroup.addButton(self.InterpolationNone)
        self.InterpolationGroup.addButton(self.InterpolationCardinalSpline)
        self.InterpolationGroup.addButton(self.InterpolationHermiteSpline)

        parametersFormLayout.addRow("Interpolation: ",
                                    self.InterpolationLayout)

        #
        # Interpolation Resolution
        #
        self.InterpResolutionSliderWidget = ctk.ctkSliderWidget()
        self.InterpResolutionSliderWidget.singleStep = 1.0
        self.InterpResolutionSliderWidget.minimum = 3.0
        self.InterpResolutionSliderWidget.maximum = 50.0
        self.InterpResolutionSliderWidget.value = 25.0
        self.InterpResolutionSliderWidget.setToolTip(
            "Number of interpolation points between control points. Default is 25."
        )
        parametersFormLayout.addRow("Resolution: ",
                                    self.InterpResolutionSliderWidget)

        #
        # Radio button for ring mode
        #
        self.RingLayout = qt.QHBoxLayout()
        self.RingOff = qt.QRadioButton("Off")
        self.RingOn = qt.QRadioButton("On")
        self.RingLayout.addWidget(self.RingOff)
        self.RingLayout.addWidget(self.RingOn)
        self.RingGroup = qt.QButtonGroup()
        self.RingGroup.addButton(self.RingOff)
        self.RingGroup.addButton(self.RingOn)

        parametersFormLayout.addRow("Ring mode: ", self.RingLayout)

        #
        # Check box to start curve visualization
        #
        self.EnableAutoUpdateCheckBox = qt.QCheckBox()
        self.EnableAutoUpdateCheckBox.checked = 0
        self.EnableAutoUpdateCheckBox.setToolTip(
            "If checked, the CurveMaker module keeps updating the model as the points are updated."
        )
        parametersFormLayout.addRow("Auto update:",
                                    self.EnableAutoUpdateCheckBox)

        #
        # Button to generate a curve
        #
        self.GenerateButton = qt.QPushButton("Generate Curve")
        self.GenerateButton.toolTip = "Generate Curve"
        self.GenerateButton.enabled = True
        parametersFormLayout.addRow("", self.GenerateButton)

        # Connections
        self.InterpolationNone.connect('clicked(bool)',
                                       self.onSelectInterpolationNone)
        self.InterpolationCardinalSpline.connect(
            'clicked(bool)', self.onSelectInterpolationCardinalSpline)
        self.InterpolationHermiteSpline.connect(
            'clicked(bool)', self.onSelectInterpolationHermiteSpline)
        self.RingOff.connect('clicked(bool)', self.onRingOff)
        self.RingOn.connect('clicked(bool)', self.onRingOn)
        self.EnableAutoUpdateCheckBox.connect('toggled(bool)',
                                              self.onEnableAutoUpdate)
        self.SourceSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onSourceSelected)
        self.DestinationSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                         self.onDestinationSelected)
        self.RadiusSliderWidget.connect("valueChanged(double)",
                                        self.onTubeUpdated)
        self.InterpResolutionSliderWidget.connect(
            "valueChanged(double)", self.onInterpResolutionUpdated)
        self.GenerateButton.connect('clicked(bool)', self.onGenerateCurve)

        # Set default
        ## default interpolation method
        self.InterpolationCardinalSpline.setChecked(True)
        self.onSelectInterpolationCardinalSpline(True)

        ## default ring mode
        self.RingOff.setChecked(True)
        self.onRingOff(True)

        #
        # Curve Length area
        #
        lengthCollapsibleButton = ctk.ctkCollapsibleButton()
        lengthCollapsibleButton.text = "Length"
        self.layout.addWidget(lengthCollapsibleButton)
        lengthFormLayout = qt.QFormLayout(lengthCollapsibleButton)
        lengthCollapsibleButton.collapsed = True

        #-- Curve length
        self.lengthLineEdit = qt.QLineEdit()
        self.lengthLineEdit.text = '--'
        self.lengthLineEdit.readOnly = True
        self.lengthLineEdit.frame = True
        self.lengthLineEdit.styleSheet = "QLineEdit { background:transparent; }"
        self.lengthLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor)

        lengthFormLayout.addRow("Curve Length (mm):", self.lengthLineEdit)

        #
        # Distance Area
        #
        distanceCollapsibleButton = ctk.ctkCollapsibleButton()
        distanceCollapsibleButton.text = "Distance"
        distanceCollapsibleButton.collapsed = True
        self.layout.addWidget(distanceCollapsibleButton)
        distanceFormLayout = qt.QFormLayout(distanceCollapsibleButton)

        #-- Point-to-curve distance

        #  - Markups selector for input points
        distanceLayout = qt.QVBoxLayout()

        self.targetFiducialsSelector = slicer.qMRMLNodeComboBox()
        self.targetFiducialsSelector.nodeTypes = ((
            "vtkMRMLMarkupsFiducialNode"), "")
        self.targetFiducialsSelector.selectNodeUponCreation = True
        self.targetFiducialsSelector.addEnabled = True
        self.targetFiducialsSelector.removeEnabled = True
        self.targetFiducialsSelector.noneEnabled = True
        self.targetFiducialsSelector.showHidden = False
        self.targetFiducialsSelector.showChildNodeTypes = False
        self.targetFiducialsSelector.setMRMLScene(slicer.mrmlScene)
        self.targetFiducialsSelector.setToolTip("Select Markups for targets")
        distanceLayout.addWidget(self.targetFiducialsSelector)

        self.targetFiducialsNode = None
        self.tagDestinationDispNode = None

        self.targetFiducialsSelector.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onTargetFiducialsSelected)

        self.fiducialsTable = qt.QTableWidget(1, 3)
        self.fiducialsTable.setSelectionBehavior(
            qt.QAbstractItemView.SelectRows)
        self.fiducialsTable.setSelectionMode(
            qt.QAbstractItemView.SingleSelection)
        self.fiducialsTableHeaders = ["Name", "Position (mm)", "Distance (mm)"]
        self.fiducialsTable.setHorizontalHeaderLabels(
            self.fiducialsTableHeaders)
        self.fiducialsTable.horizontalHeader().setStretchLastSection(True)
        distanceLayout.addWidget(self.fiducialsTable)

        self.extrapolateCheckBox = qt.QCheckBox()
        self.extrapolateCheckBox.checked = 0
        self.extrapolateCheckBox.setToolTip(
            "Extrapolate the first and last segment to calculate the distance")
        self.extrapolateCheckBox.connect('toggled(bool)',
                                         self.updateTargetFiducialsTable)
        self.extrapolateCheckBox.text = 'Extrapolate curves to measure the distances'

        self.showErrorVectorCheckBox = qt.QCheckBox()
        self.showErrorVectorCheckBox.checked = 0
        self.showErrorVectorCheckBox.setToolTip(
            "Show error vectors, which is defined by the target point and the closest point on the curve. The vector is perpendicular to the curve, unless the closest point is one end of the curve."
        )
        self.showErrorVectorCheckBox.connect('toggled(bool)',
                                             self.updateTargetFiducialsTable)
        self.showErrorVectorCheckBox.text = 'Show error vectors'

        distanceLayout.addWidget(self.extrapolateCheckBox)
        distanceLayout.addWidget(self.showErrorVectorCheckBox)
        distanceFormLayout.addRow("Distance from:", distanceLayout)

        #
        # Curvature Area
        #
        curvatureCollapsibleButton = ctk.ctkCollapsibleButton()
        curvatureCollapsibleButton.text = "Curvature"
        curvatureCollapsibleButton.collapsed = True
        self.layout.addWidget(curvatureCollapsibleButton)
        curvatureFormLayout = qt.QFormLayout(curvatureCollapsibleButton)

        #-- Curvature
        self.curvatureLayout = qt.QHBoxLayout()
        self.curvatureOff = qt.QRadioButton("Off")
        self.curvatureOff.connect('clicked(bool)', self.onCurvatureOff)
        self.curvatureOn = qt.QRadioButton("On")
        self.curvatureOn.connect('clicked(bool)', self.onCurvatureOn)
        self.curvatureLayout.addWidget(self.curvatureOff)
        self.curvatureLayout.addWidget(self.curvatureOn)
        self.curvatureGroup = qt.QButtonGroup()
        self.curvatureGroup.addButton(self.curvatureOff)
        self.curvatureGroup.addButton(self.curvatureOn)

        curvatureFormLayout.addRow("Curvature mode:", self.curvatureLayout)

        autoCurvatureRangeFormLayout = qt.QFormLayout(
            curvatureCollapsibleButton)
        self.autoCurvatureRangeLayout = qt.QHBoxLayout()
        self.autoCurvatureRangeOff = qt.QRadioButton("Manual")
        self.autoCurvatureRangeOff.connect('clicked(bool)',
                                           self.onAutoCurvatureRangeOff)
        self.autoCurvatureRangeOn = qt.QRadioButton("Auto")
        self.autoCurvatureRangeOn.connect('clicked(bool)',
                                          self.onAutoCurvatureRangeOn)
        self.autoCurvatureRangeLayout.addWidget(self.autoCurvatureRangeOff)
        self.autoCurvatureRangeLayout.addWidget(self.autoCurvatureRangeOn)
        self.autoCurvatureRangeGroup = qt.QButtonGroup()
        self.autoCurvatureRangeGroup.addButton(self.autoCurvatureRangeOff)
        self.autoCurvatureRangeGroup.addButton(self.autoCurvatureRangeOn)

        curvatureFormLayout.addRow("Color range:",
                                   self.autoCurvatureRangeLayout)

        #-- Color range
        self.curvatureColorRangeWidget = ctk.ctkRangeWidget()
        self.curvatureColorRangeWidget.setToolTip("Set color range")
        self.curvatureColorRangeWidget.setDecimals(3)
        self.curvatureColorRangeWidget.singleStep = 0.001
        self.curvatureColorRangeWidget.minimumValue = 0.0
        self.curvatureColorRangeWidget.maximumValue = 0.5
        self.curvatureColorRangeWidget.minimum = 0.0
        self.curvatureColorRangeWidget.maximum = 1.0
        curvatureFormLayout.addRow("Color range: ",
                                   self.curvatureColorRangeWidget)
        self.curvatureColorRangeWidget.connect(
            'valuesChanged(double, double)', self.onUpdateCurvatureColorRange)

        #-- Curvature data
        self.meanCurvatureLineEdit = qt.QLineEdit()
        self.meanCurvatureLineEdit.text = '--'
        self.meanCurvatureLineEdit.readOnly = True
        self.meanCurvatureLineEdit.frame = True
        self.meanCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }"
        self.meanCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor)
        self.meanCurvatureLineEdit.enabled = False
        curvatureFormLayout.addRow("Mean (mm^-1):", self.meanCurvatureLineEdit)

        self.minCurvatureLineEdit = qt.QLineEdit()
        self.minCurvatureLineEdit.text = '--'
        self.minCurvatureLineEdit.readOnly = True
        self.minCurvatureLineEdit.frame = True
        self.minCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }"
        self.minCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor)
        self.minCurvatureLineEdit.enabled = False
        curvatureFormLayout.addRow("Minimum (mm^-1):",
                                   self.minCurvatureLineEdit)

        self.maxCurvatureLineEdit = qt.QLineEdit()
        self.maxCurvatureLineEdit.text = '--'
        self.maxCurvatureLineEdit.readOnly = True
        self.maxCurvatureLineEdit.frame = True
        self.maxCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }"
        self.maxCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor)
        self.maxCurvatureLineEdit.enabled = False
        curvatureFormLayout.addRow("Maximum (mm^-1):",
                                   self.maxCurvatureLineEdit)

        ## Create a scale for curvature
        self.scalarBarWidget = vtk.vtkScalarBarWidget()
        actor = self.scalarBarWidget.GetScalarBarActor()
        actor.SetOrientationToVertical()
        actor.SetNumberOfLabels(11)
        actor.SetTitle("Curvature (mm^-1)")
        actor.SetLabelFormat(" %#8.3f")
        actor.SetPosition(0.1, 0.1)
        actor.SetWidth(0.1)
        actor.SetHeight(0.8)
        self.scalarBarWidget.SetEnabled(0)

        layout = slicer.app.layoutManager()
        view = layout.threeDWidget(0).threeDView()
        renderer = layout.activeThreeDRenderer()
        self.scalarBarWidget.SetInteractor(
            renderer.GetRenderWindow().GetInteractor())
        self.lookupTable = vtk.vtkLookupTable()
        self.lookupTable.SetRange(0.0, 100.0)
        self.scalarBarWidget.GetScalarBarActor().SetLookupTable(
            self.lookupTable)

        ## default curvature mode: off
        self.curvatureOff.setChecked(True)
        self.onCurvatureOff(True)
        self.autoCurvatureRangeOff.setChecked(True)
        self.onAutoCurvatureRangeOff(True)

        # Add vertical spacer
        self.layout.addStretch(1)
Esempio n. 28
0
    def createUserInterface(self):
        '''
    '''
        self.__layout = super(EMSegmentQuickStep3, self).createUserInterface()

        self.__top = qt.QWidget()
        self.__topLayout = qt.QHBoxLayout(self.__top)

        # the anatomical tree
        anatomicalTreeGroupBox = qt.QGroupBox()
        anatomicalTreeGroupBox.setTitle('Anatomical Tree')
        self.__topLayout.addWidget(anatomicalTreeGroupBox)

        anatomicalTreeGroupBoxLayout = qt.QFormLayout(anatomicalTreeGroupBox)

        self.__anatomicalTree = slicer.modulewidget.qSlicerEMSegmentAnatomicalTreeWidget(
        )
        self.__anatomicalTree.structureNameEditable = False
        self.__anatomicalTree.labelColumnVisible = False
        self.__anatomicalTree.probabilityMapColumnVisible = False
        self.__anatomicalTree.classWeightColumnVisible = False
        self.__anatomicalTree.updateClassWeightColumnVisible = False
        self.__anatomicalTree.atlasWeightColumnVisible = False
        self.__anatomicalTree.alphaColumnVisible = False
        self.__anatomicalTree.displayAlphaCheckBoxVisible = False
        self.__anatomicalTree.setMinimumHeight(200)
        self.__anatomicalTree.toolTip = 'Select a structure to configure the intensity distribution.'
        self.__anatomicalTree.setSizePolicy(qt.QSizePolicy.MinimumExpanding,
                                            qt.QSizePolicy.MinimumExpanding)
        self.__anatomicalTree.connect('currentTreeNodeChanged(vtkMRMLNode*)',
                                      self.onTreeSelectionChanged)
        anatomicalTreeGroupBoxLayout.addWidget(self.__anatomicalTree)

        #
        # overview of class weights panel
        #
        self.__overviewBox = qt.QGroupBox()
        self.__overviewBox.title = 'Guesses of Probability'
        self.__overviewBox.toolTip = 'These are your guesses of probability relations between structures. Which structure takes how much percentage of the volume?'
        self.__overviewBoxLayout = qt.QVBoxLayout(self.__overviewBox)
        self.__topLayout.addWidget(self.__overviewBox)

        self.__layout.addWidget(self.__top)

        self.__tabWidget = qt.QTabWidget()
        self.__layout.addWidget(self.__tabWidget)

        #
        # manualSamplingPage
        #
        manualSamplingPage = qt.QWidget()
        manualSamplingPageLayout = qt.QFormLayout(manualSamplingPage)

        self.__classLabel2 = qt.QLabel("Class: XX")
        manualSamplingPageLayout.addWidget(self.__classLabel2)

        self.__infoLabel = qt.QLabel(
            "left mouse Click in a slice window to pick a sample")
        manualSamplingPageLayout.addWidget(self.__infoLabel)

        self.__manualSampleTable = qt.QTableWidget()
        manualSamplingPageLayout.addWidget(self.__manualSampleTable)

        self.__tabWidget.addTab(manualSamplingPage, "Manual Sampling")

        self.__plotDistributionButton = qt.QPushButton()
        self.__plotDistributionButton.text = "Plot Distribution"
        self.__plotDistributionButton.toolTip = 'Click to plot the intensity distributions for all structures.'
        self.__layout.addRow(self.__plotDistributionButton)
        self.__plotDistributionButton.connect('clicked()',
                                              self.plotDistribution)
    def setup(self):
        print(" ")
        print("=======================================================")
        print("   Automatic Cochlea Image Segmentation               ")
        print("=======================================================")

        ScriptedLoadableModuleWidget.setup(self)

        # to access logic class functions and setup global variables
        self.logic = CochleaSegLogic()

        # Set default VisSIm location in the user home
        #TODO: add option user-defined path when installed first time
        self.vsc = VisSimCommon.VisSimCommonLogic()
        self.vsc.setGlobalVariables(0)

        #-----------------------------------------------------------------
        #                     Create the GUI interface
        #-----------------------------------------------------------------
        # Create main collapsible Button
        self.mainCollapsibleBtn = ctk.ctkCollapsibleButton()
        self.mainCollapsibleBtn.setStyleSheet(
            "ctkCollapsibleButton { background-color: DarkSeaGreen  }")
        self.mainCollapsibleBtn.text = "ACIR: Automatic Cochlea Image segmentation"
        self.layout.addWidget(self.mainCollapsibleBtn)
        self.mainFormLayout = qt.QFormLayout(self.mainCollapsibleBtn)

        # Create input Volume Selector
        self.inputSelectorCoBx = slicer.qMRMLNodeComboBox()
        self.inputSelectorCoBx.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.inputSelectorCoBx.selectNodeUponCreation = True
        self.inputSelectorCoBx.addEnabled = False
        self.inputSelectorCoBx.removeEnabled = False
        self.inputSelectorCoBx.noneEnabled = False
        self.inputSelectorCoBx.showHidden = False
        self.inputSelectorCoBx.showChildNodeTypes = False
        self.inputSelectorCoBx.setMRMLScene(slicer.mrmlScene)
        self.inputSelectorCoBx.setToolTip("select the input image")
        self.mainFormLayout.addRow("Input image: ", self.inputSelectorCoBx)

        # Create a time label
        self.timeLbl = qt.QLabel("                 Time: 00:00")
        self.timeLbl.setFixedWidth(500)
        self.tmLbl = self.timeLbl

        # Create a textbox for cochlea location
        # TODO activate input IJK values as well
        self.inputPointEdt = qt.QLineEdit()
        self.inputPointEdt.setFixedHeight(40)
        self.inputPointEdt.setText("[0,0,0]")

        # Create a cochlea locator button
        self.inputFiducialBtn = qt.QPushButton(
            "Pick cochlea location in input image    ")
        self.inputFiducialBtn.setFixedHeight(40)
        self.inputFiducialBtn.setToolTip(
            "Pick the input fiducial point that will be the center of the cropped image"
        )
        self.inputFiducialBtn.connect(
            'clicked(bool)', lambda: self.onInputFiducialBtnClick("input"))
        self.mainFormLayout.addRow(self.inputFiducialBtn, self.inputPointEdt)

        # Create a button to run segmentation
        self.applyBtn = qt.QPushButton("Run")
        self.applyBtn.setFixedHeight(50)
        self.applyBtn.setFixedWidth(250)
        self.applyBtn.setStyleSheet(
            "QPushButton{ background-color: DarkSeaGreen  }")
        self.applyBtn.toolTip = (
            'How to use:'
            ' Load an images into Slicer. Pick cochlea locations using the buttons and the Slicer Fiducial tool '
        )
        self.applyBtn.connect('clicked(bool)', self.onApplyBtnClick)
        self.mainFormLayout.addRow(self.applyBtn, self.timeLbl)
        self.runBtn = self.applyBtn

        # Add check box for right ear side
        self.sideChkBox = qt.QCheckBox()
        self.sideChkBox.text = "Right side cochlea"
        self.sideChkBox.stateChanged.connect(self.onSideChkBoxChange)
        self.mainFormLayout.addRow(self.sideChkBox)

        # Create and link Btn to update measuerments
        self.updateLengthBtn = qt.QPushButton("Update Length")
        self.updateLengthBtn.setFixedHeight(40)
        self.updateLengthBtn.setFixedWidth(250)
        self.updateLengthBtn.toolTip = ('How to use:'
                                        ' Run segmentation first. ')
        self.updateLengthBtn.connect('clicked(bool)',
                                     self.onUpdateLengthBtnClick)
        self.mainFormLayout.addRow(self.updateLengthBtn)
        #enddef

        self.layout.addStretch(
            1
        )  # Collapsible button is held in place when collapsing/expanding.
Esempio n. 30
0
    def setup(self):
        # Instantiate and connect widgets ...

        #
        # Reload and Test area
        #
        reloadCollapsibleButton = ctk.ctkCollapsibleButton()
        reloadCollapsibleButton.text = "Reload && Test"
        self.layout.addWidget(reloadCollapsibleButton)
        reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "PortPlanningAnalysis Reload"
        reloadFormLayout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        # reload and test button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadAndTestButton = qt.QPushButton("Reload and Test")
        self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
        reloadFormLayout.addWidget(self.reloadAndTestButton)
        self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # Target point (vtkMRMLMarkupsFiducialNode)
        #
        self.targetSelector = slicer.qMRMLNodeComboBox()
        self.targetSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "")
        self.targetSelector.addEnabled = False
        self.targetSelector.removeEnabled = False
        self.targetSelector.noneEnabled = True
        self.targetSelector.showHidden = False
        self.targetSelector.showChildNodeTypes = False
        self.targetSelector.setMRMLScene(slicer.mrmlScene)
        self.targetSelector.setToolTip("Pick up the target point")
        parametersFormLayout.addRow("Target Point: ", self.targetSelector)

        #
        # target model (vtkMRMLScalarVolumeNode)
        #
        self.targetLabelSelector = slicer.qMRMLNodeComboBox()
        self.targetLabelSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.targetLabelSelector.addEnabled = False
        self.targetLabelSelector.removeEnabled = False
        self.targetLabelSelector.noneEnabled = True
        self.targetLabelSelector.showHidden = False
        self.targetLabelSelector.showChildNodeTypes = False
        self.targetLabelSelector.setMRMLScene(slicer.mrmlScene)
        self.targetLabelSelector.setToolTip(
            "Pick the target label to the algorithm.")
        parametersFormLayout.addRow("Target Label: ", self.targetLabelSelector)

        ##
        ## output volume selector
        ##
        #self.outputModelSelector = slicer.qMRMLNodeComboBox()
        #self.outputModelSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
        #self.outputModelSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 0 )
        #self.outputModelSelector.selectNodeUponCreation = False
        #self.outputModelSelector.addEnabled = True
        #self.outputModelSelector.removeEnabled = True
        #self.outputModelSelector.noneEnabled =  True
        #self.outputModelSelector.showHidden = False
        #self.outputModelSelector.showChildNodeTypes = False
        #self.outputModelSelector.setMRMLScene( slicer.mrmlScene )
        #self.outputModelSelector.setToolTip( "Pick the output to the algorithm." )
        #parametersFormLayout.addRow("Output Volume: ", self.outputSelector)

        #
        # Obstacle model (vtkMRMLModelNode)
        #
        self.obstacleModelSelector = slicer.qMRMLNodeComboBox()
        self.obstacleModelSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        self.obstacleModelSelector.addEnabled = False
        self.obstacleModelSelector.removeEnabled = False
        self.obstacleModelSelector.noneEnabled = True
        self.obstacleModelSelector.showHidden = False
        self.obstacleModelSelector.showChildNodeTypes = False
        self.obstacleModelSelector.setMRMLScene(slicer.mrmlScene)
        self.obstacleModelSelector.setToolTip(
            "Pick the input to the algorithm.")
        parametersFormLayout.addRow("Obstacle Model: ",
                                    self.obstacleModelSelector)

        ##
        ## scale factor for Obstacle level
        ##
        #self.ObstacleScaleFactorSliderWidget = ctk.ctkSliderWidget()
        #self.ObstacleScaleFactorSliderWidget.singleStep = 1.0
        #self.ObstacleScaleFactorSliderWidget.minimum = 1.0
        #self.ObstacleScaleFactorSliderWidget.maximum = 50.0
        #self.ObstacleScaleFactorSliderWidget.value = 1.0
        #self.ObstacleScaleFactorSliderWidget.setToolTip("Set the Obstacle scale.")
        #parametersFormLayout.addRow("Obstacle scale factor", self.ObstacleScaleFactorSliderWidget)

        #
        # Skin model (vtkMRMLModelNode)
        #
        self.skinModelSelector = slicer.qMRMLNodeComboBox()
        self.skinModelSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        self.skinModelSelector.addEnabled = False
        self.skinModelSelector.removeEnabled = False
        self.skinModelSelector.noneEnabled = True
        self.skinModelSelector.showHidden = False
        self.skinModelSelector.showChildNodeTypes = False
        self.skinModelSelector.setMRMLScene(slicer.mrmlScene)
        self.skinModelSelector.setToolTip("Pick the input to the algorithm.")
        parametersFormLayout.addRow("Skin Model: ", self.skinModelSelector)

        ##
        ## check box to trigger taking screen shots for later use in tutorials
        ##
        #self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
        #self.enableScreenshotsFlagCheckBox.checked = 0
        #self.enableScreenshotsFlagCheckBox.setToolTip("If checked, take screen shots for tutorials. Use Save Data to write them to disk.")
        #parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox)

        ##
        ## scale factor for screen shots
        ##
        #self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget()
        #self.screenshotScaleFactorSliderWidget.singleStep = 1.0
        #self.screenshotScaleFactorSliderWidget.minimum = 1.0
        #self.screenshotScaleFactorSliderWidget.maximum = 50.0
        #self.screenshotScaleFactorSliderWidget.value = 1.0
        #self.screenshotScaleFactorSliderWidget.setToolTip("Set scale factor for the screen shots.")
        #parametersFormLayout.addRow("Screenshot scale factor", self.screenshotScaleFactorSliderWidget)

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = False
        parametersFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.targetSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onSelect)
        self.targetLabelSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                         self.onSelect)
        self.obstacleModelSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                           self.onSelect)
        self.skinModelSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                       self.onSelect)

        #
        # Output Area
        #
        outputCollapsibleButton = ctk.ctkCollapsibleButton()
        outputCollapsibleButton.text = "Output / Results"
        self.layout.addWidget(outputCollapsibleButton)

        # Layout within the dummy collapsible button
        outputFormLayout = qt.QFormLayout(outputCollapsibleButton)

        # Accessibility score results
        self.accessibilityScore = qt.QLineEdit()
        self.accessibilityScore.toolTip = "Accessibility Score"
        self.accessibilityScore.enabled = True
        self.accessibilityScore.maximumWidth = 70
        self.accessibilityScore.setReadOnly(True)
        self.accessibilityScore.inputMask = "0.000"
        self.accessibilityScore.maxLength = 4
        outputFormLayout.addRow("Accesibility Score:", self.accessibilityScore)

        # Minimum distance results
        self.minimumDistance = qt.QLineEdit()
        self.minimumDistance.toolTip = "Minimum Distance"
        self.minimumDistance.enabled = True
        self.minimumDistance.maximumWidth = 70
        self.minimumDistance.setReadOnly(True)
        self.minimumDistance.inputMask = "0.000"
        self.minimumDistance.maxLength = 4
        outputFormLayout.addRow("Minimum Distance:", self.minimumDistance)

        #
        # Minimum distance point (vtkMRMLMarkupsFiducialNode)
        #
        self.minimumDistancePoint = slicer.qMRMLNodeComboBox()
        self.minimumDistancePoint.nodeTypes = (("vtkMRMLMarkupsFiducialNode"),
                                               "")
        self.minimumDistancePoint.addEnabled = True
        self.minimumDistancePoint.removeEnabled = True
        self.minimumDistancePoint.noneEnabled = True
        self.minimumDistancePoint.showHidden = False
        self.minimumDistancePoint.showChildNodeTypes = False
        self.minimumDistancePoint.setMRMLScene(slicer.mrmlScene)
        self.minimumDistancePoint.setToolTip(
            "Display the minimum distance point")
        self.minimumDistancePoint.baseName = "PAA-MinimumDistance"
        outputFormLayout.addRow("Minimum Distance Point: ",
                                self.minimumDistancePoint)

        # Add vertical spacer
        self.layout.addStretch(1)