def addFiducialToTable(self, observer, event):
      logging.debug("Modified - {0}".format(event))
      self.fiducial = self.fiducialNode()
      self.fidNumber = self.fiducial.GetNumberOfFiducials()
      slicer.modules.markups.logic().SetAllMarkupsVisibility(self.fiducial,1)
      logging.debug(self.fidNumber)
      self.fidLabels = []
      self.items = []
      self.Label = qt.QTableWidgetItem()

      self.table2.setRowCount(self.fidNumber)


      for i in range(0,self.fidNumber):
          self.Label = qt.QTableWidgetItem(self.fiducial.GetNthFiducialLabel(i))
          self.items.append(self.Label)
          self.table2.setItem(i, 0, self.Label)
          self.comboLevel = qt.QComboBox()
          self.comboLevel.addItems(self.levelselection)
          self.comboSide = qt.QComboBox()
          self.comboSide.addItems(["Left","Right"])
          self.table2.setCellWidget(i,1, self.comboLevel)
          self.table2.setCellWidget(i,2, self.comboSide)
          if i == 0 or i == 1:
            self.table2.cellWidget(i,1).setCurrentIndex(0)
            if i == 1:
              self.table2.cellWidget(i,2).setCurrentIndex(1)
          elif i == 2 or i == 3:
            self.table2.cellWidget(i,1).setCurrentIndex(1)
            if i == 3:
              self.table2.cellWidget(i,2).setCurrentIndex(1)
          elif i == 4 or i == 5:
            self.table2.cellWidget(i,1).setCurrentIndex(2)
            if i == 5:
              self.table2.cellWidget(i,2).setCurrentIndex(1)
    def updateTable(self):
        #print pNode.GetParameter('vertebrae')
        self.fiducial = slicer.mrmlScene.GetNodeByID(
            'vtkMRMLMarkupsFiducialNode1')
        self.fidNumber = self.fiducial.GetNumberOfFiducials()
        self.fidLabels = []
        self.fidLevels = []
        self.fidSides = []
        self.itemsLabels = []
        self.itemsLevels = []
        self.itemsSides = []
        self.rulerList = []
        self.lengthCombo = []
        self.widthCombo = []

        self.angleTable.setRowCount(self.fidNumber)

        for i in range(0, self.fidNumber):
            self.fidLabels.append(
                slicer.modules.PedicleScrewSimulator_v3Widget.landmarksStep.
                table2.item(i, 0).text())
            self.fidLevels.append(
                slicer.modules.PedicleScrewSimulator_v3Widget.landmarksStep.
                table2.cellWidget(i, 1).currentText)
            self.fidSides.append(
                slicer.modules.PedicleScrewSimulator_v3Widget.landmarksStep.
                table2.cellWidget(i, 2).currentText)

        for i in range(0, self.fidNumber):
            Label = str(self.fidLabels[i])
            Level = str(self.fidLevels[i])
            Side = str(self.fidSides[i])
            #print Label
            #print Level
            #print Side
            #print self.levelselection[i] + "loop"
            qtLabel = qt.QTableWidgetItem(Label)
            qtLevel = qt.QTableWidgetItem(Level)
            qtSide = qt.QTableWidgetItem(Side)
            self.itemsLabels.append(qtLabel)
            self.itemsLevels.append(qtLevel)
            self.itemsSides.append(qtSide)
            #print self.items
            self.angleTable.setItem(i, 0, qtLabel)
            self.angleTable.setItem(i, 1, qtLevel)
            self.angleTable.setItem(i, 2, qtSide)

            self.lengthCombo.insert(i, qt.QComboBox())
            self.widthCombo.insert(i, qt.QComboBox())
            self.lengthCombo[i].addItem(" ")
            self.widthCombo[i].addItem(" ")
            #self.rulerMeasures()
            #self.measuresLength = qt.QComboBox()
            #self.measuresLength.addItems(self.rulerList)
            #self.measuresWidth = qt.QComboBox()
            #self.measuresWidth.addItems(self.rulerList)
            if self.entryCount == 0:
                self.angleTable.setCellWidget(i, 3, self.lengthCombo[i])
                self.angleTable.setCellWidget(i, 4, self.widthCombo[i])
        self.entryCount = 1
Exemple #3
0
    def createUserInterface(self):

        font =qt.QFont("Sans Serif", 12, qt.QFont.Bold)

        self.__layout = qt.QFormLayout( self )
        self.__layout.addRow(" ",qt.QWidget())
       
        self.nombreRegistro = qt.QLabel("Nombre: ")
        self.nombreRegistroTextEdit = qt.QLineEdit()
        self.nombreRegistroTextEdit.setFixedWidth(200)
        self.nombreRegistroTextEdit.textChanged.connect(self.textchanged1)
        self.__layout.addRow(self.nombreRegistro,self.nombreRegistroTextEdit)

        self.contrasenaRegistro = qt.QLabel("Contrasena: ")
        self.contrasenaRegistroTextEdit = qt.QLineEdit()
        self.contrasenaRegistroTextEdit.setFixedWidth(200)
        self.contrasenaRegistroTextEdit.setEchoMode(qt.QLineEdit.Password)
        self.contrasenaRegistroTextEdit.textChanged.connect(self.textchanged2)
        self.__layout.addRow(self.contrasenaRegistro,self.contrasenaRegistroTextEdit)

        self.contrasenaRegistro1 = qt.QLabel("Repetir contrasena: ")
        self.contrasenaRegistro1TextEdit = qt.QLineEdit()
        self.contrasenaRegistro1TextEdit.setFixedWidth(200)
        self.contrasenaRegistro1TextEdit.setEchoMode(qt.QLineEdit.Password)
        self.contrasenaRegistro1TextEdit.textChanged.connect(self.textchanged3)
        self.__layout.addRow(self.contrasenaRegistro1,self.contrasenaRegistro1TextEdit)

        self.vinculoRegistro = qt.QLabel("Tipo de vinculo: ")
        self.vinculoComboBox = qt.QComboBox()
        self.vinculoComboBox.addItem('Estudiante')
        self.vinculoComboBox.addItem('Profesor')
        self.__layout.addRow(self.vinculoRegistro,self.vinculoComboBox)

        self.cursoRegistro = qt.QLabel('Curso al que pertenece')
        self.cursoRegistroComboBox = qt.QComboBox()
        self.mypath="C:\Users\Camilo_Q\Documents\GitHub\workFlows\Cursos" #Se crea path para busqueda de cursos
        self.onlyfiles = [f for f in listdir(self.mypath) if isfile(join(self.mypath, f))] #Lista los archivos que estan dentro del path
        for curso in self.onlyfiles: #Muestra en el comboBox de cursos los archivos que estan presentes en el path
            self.cursoRegistroComboBox.addItem(curso)
        self.__layout.addRow(self.cursoRegistro,self.cursoRegistroComboBox)

        self.__layout.addRow(" ",qt.QWidget())

        self.botonRegistro = qt.QPushButton('Realizar Registro')
        self.botonRegistro.connect('clicked(bool)',self.onApplyRegistro)

        self.botonReiniciarRegistro = qt.QPushButton('Reiniciar Registro')
        self.botonReiniciarRegistro.connect('clicked(bool)',self.onApplyReiniciarRegistro)
        self.__layout.addRow(self.botonRegistro)
        self.__layout.addRow(self.botonReiniciarRegistro)
Exemple #4
0
    def __init__(self, parent, View):
        """ 
        @param parent: Parent widget.
        @type parent: qt.QWidget

        @param View: The View module of XNATSlicer.
        @type View: View
        """

        #--------------------
        # Call parent init.
        #--------------------
        super(FolderMaker, self).__init__(parent)

        #--------------------
        # Params
        #--------------------
        self.View = View
        self.Events = MokaUtils.Events(self.EVENT_TYPES)
        self.__xsiList = qt.QComboBox()
        self.__xsiList.addItems([key for key, value in \
                               Xnat.xsi.DEFAULT_TYPES.items()])
        self.__levelLabels = {}
        self.__lineEdits = {}
        self.__errorLines = {}
        self.__levelTracker = {}
        self.__nextLevelList = []

        #--------------------
        # Inits
        #--------------------
        self.__initWindow()
        self.__createWidgets()
        self.__createButtons()
        self.__setLayout()
Exemple #5
0
    def addConfigurationsSelector(self):
        self.configurationsComboBox = qt.QComboBox()
        configurationsLabel = qt.QLabel("Select Configuration: ")
        hBox = qt.QHBoxLayout()
        hBox.addWidget(configurationsLabel)
        hBox.addWidget(self.configurationsComboBox)
        hBox.setStretch(1, 2)
        self.launcherFormLayout.addRow(hBox)

        # Populate configurationsComboBox with available configurations
        settings = slicer.app.userSettings()
        settings.beginGroup(self.moduleName + '/Configurations')
        configurations = settings.childGroups()
        for configuration in configurations:
            self.configurationsComboBox.addItem(configuration)
        settings.endGroup()

        # Set latest used configuration
        if settings.value(self.moduleName + '/MostRecentConfiguration'):
            self.selectedConfigurationName = settings.value(
                self.moduleName + '/MostRecentConfiguration')
            idx = self.configurationsComboBox.findText(
                settings.value(self.moduleName + '/MostRecentConfiguration'))
            self.configurationsComboBox.setCurrentIndex(idx)

        self.configurationsComboBox.connect(
            'currentIndexChanged(const QString &)',
            self.onConfigurationChanged)
Exemple #6
0
    def createUserInterface(self):
        self.__layout = qt.QFormLayout(self)
        self.__layout.addRow("", qt.QWidget())
        self.__layout.addRow("", qt.QWidget())
        self.__layout.addRow("", qt.QWidget())

        self.nombreLabel = qt.QLabel("         Nombre:")
        self.nombreTextEdit = qt.QLineEdit()
        self.nombreTextEdit.setFixedWidth(200)
        self.nombreTextEdit.textChanged.connect(self.textchanged1)
        self.__layout.addRow(self.nombreLabel, self.nombreTextEdit)
        self.contrasenaLabeL = qt.QLabel("         Password:"******"C:\Users\Camilo_Q\Documents\GitHub\workFlows\Cursos"  #Se crea path para busqueda de cursos
        self.onlyfiles = [
            f for f in listdir(self.mypath) if isfile(join(self.mypath, f))
        ]  #Lista los archivos que estan dentro del path
        for curso in self.onlyfiles:  #Muestra en el comboBox de cursos los archivos que estan presentes en el path
            self.cursoLoginComboBox.addItem(curso)
        self.__layout.addRow(self.cursoRegistro, self.cursoLoginComboBox)
        sys.argv = ["Nombre", "Contrasena", "Curso", "Fecha"]
Exemple #7
0
  def setupAdvancedPanel(self):
    logging.debug('setupAdvancedPanel')

    self.advancedCollapsibleButton.setProperty('collapsedHeight', 20)
    self.advancedCollapsibleButton.text = "Settings"
    self.sliceletPanelLayout.addWidget(self.advancedCollapsibleButton)

    self.advancedLayout = qt.QFormLayout(self.advancedCollapsibleButton)
    self.advancedLayout.setContentsMargins(12, 4, 4, 4)
    self.advancedLayout.setSpacing(4)

    # Layout selection combo box
    self.viewSelectorComboBox = qt.QComboBox(self.advancedCollapsibleButton)
    self.setupViewerLayouts()
    self.advancedLayout.addRow("Layout: ", self.viewSelectorComboBox)

    self.registerCustomLayouts()

    self.selectView(self.VIEW_ULTRASOUND_3D)

    # OpenIGTLink connector node selection
    self.linkInputSelector = slicer.qMRMLNodeComboBox()
    self.linkInputSelector.nodeTypes = ("vtkMRMLIGTLConnectorNode", "")
    self.linkInputSelector.selectNodeUponCreation = True
    self.linkInputSelector.addEnabled = False
    self.linkInputSelector.removeEnabled = True
    self.linkInputSelector.noneEnabled = False
    self.linkInputSelector.showHidden = False
    self.linkInputSelector.showChildNodeTypes = False
    self.linkInputSelector.setMRMLScene( slicer.mrmlScene )
    self.linkInputSelector.setToolTip( "Select connector node" )
    self.advancedLayout.addRow("OpenIGTLink connector: ", self.linkInputSelector)

    self.showFullSlicerInterfaceButton = qt.QPushButton()
    self.showFullSlicerInterfaceButton.setText("Show 3D Slicer user interface")
    self.advancedLayout.addRow(self.showFullSlicerInterfaceButton)

    self.showGuideletFullscreenButton = qt.QPushButton()
    self.showGuideletFullscreenButton.setText("Show guidelet in full screen")
    self.advancedLayout.addRow(self.showGuideletFullscreenButton)

    self.saveSceneButton = qt.QPushButton()
    self.saveSceneButton.setText("Save slicelet scene")
    self.advancedLayout.addRow(self.saveSceneButton)

    self.saveDirectoryLineEdit = qt.QLineEdit()
    node = self.logic.getParameterNode()
    sceneSaveDirectory = node.GetParameter('SavedScenesDirectory')
    self.saveDirectoryLineEdit.setText(sceneSaveDirectory)
    saveLabel = qt.QLabel()
    saveLabel.setText("Save scene directory:")
    hbox = qt.QHBoxLayout()
    hbox.addWidget(saveLabel)
    hbox.addWidget(self.saveDirectoryLineEdit)
    self.advancedLayout.addRow(hbox)

    self.exitButton = qt.QPushButton()
    self.exitButton.setText("Exit")
    self.advancedLayout.addRow(self.exitButton)
Exemple #8
0
def makeHostDropdown(LoginMenu):
    """ Initiates the dropdown that allows the user to select hosts
    """

    hostDropdown = qt.QComboBox()
    hostDropdown.setFont(LoginMenu.LABEL_FONT)
    hostDropdown.toolTip = "Select Xnat host"
    return hostDropdown
Exemple #9
0
    def createFontSizeDropdown(self, title = "Font Size:" ):
        """ 
        Adds a fontSize dropdown to the layout of the XnatSetting.  The 
        subclass then needs to specify how to connect the events of the 
        dropdown.

        @param title: The title of the dropdown.
        @type title: str
        """

        if not hasattr(self, 'fontDropdowns'):
            self.fontDropdowns = {}

        fontStorageTag = self.getFontStorageTag(title)

        #--------------------
        # Derive the storage.
        #--------------------
        if not fontStorageTag in self.fontDropdowns:
            self.fontDropdowns[fontStorageTag] = []
        

        #--------------------
        # Create the object
        #--------------------
        comboBox = qt.QComboBox()
        comboBox.addItems([str(i) \
                        for i in range(self.MAX_FONT_SIZE, \
                                       self.MIN_FONT_SIZE)])
        comboBox.setFixedWidth(100)
            


        #--------------------
        # Callbacks
        #--------------------
        comboBox.connect('currentIndexChanged(const QString&)', 
                         self.__onFontSizeChanged)


        #--------------------
        # Add sync methods
        #--------------------
        self.addSyncCallback_ToFile(fontStorageTag, self.__syncToFile)
        self.addSyncCallback_FileTo(fontStorageTag, self.__syncFileTo)


        #--------------------
        # Defaults
        #--------------------
        self.__constructDefaults(fontStorageTag)


        #--------------------
        # Add to UI and store
        #--------------------
        self.addSection(title, comboBox)
        self.fontDropdowns[fontStorageTag].append(comboBox)
    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 = "TCIABrowser 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)

        #
        # Step 1: selection of the data directory
        #
        self.collectionSelector = qt.QComboBox()
        self.layout.addWidget(self.collectionSelector)
        self.collectionSelector.connect('currentIndexChanged(QString)',
                                        self.collectionSelected)

        self.studyTable = ItemTable(self.parent, headerName='Study Name')
        self.layout.addWidget(self.studyTable.widget)
        self.studyTable.widget.connect('cellClicked(int,int)',
                                       self.onStudyCellClicked)

        self.seriesTable = ItemTable(self.parent, headerName="Series Name")
        self.layout.addWidget(self.seriesTable.widget)

        self.loadButton = qt.QPushButton('Load series')
        self.layout.addWidget(self.loadButton)
        self.loadButton.connect('clicked()', self.onLoadButtonClicked)

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

        # set up temporary directory
        self.tempDir = slicer.app.temporaryPath + '/TCIABrowser-tmp'
        print('Temporary directory location: ' + self.tempDir)
        qt.QDir().mkpath(self.tempDir)
Exemple #11
0
    def setup(self):

        # Set the grayscaleNode and labelNode to the current active volume and label
        selectionNode = slicer.app.applicationLogic().GetSelectionNode()
        self.grayscaleNode = slicer.util.getNode(
            selectionNode.GetActiveVolumeID())
        self.labelNode = slicer.util.getNode(
            selectionNode.GetActiveLabelVolumeID())

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Calculate Statistics."
        self.applyButton.setStyleSheet("background-color: rgb(230,241,255)")
        self.applyButton.enabled = True
        self.parent.layout().addWidget(self.applyButton)

        # model and view for stats table
        self.view = qt.QTableView()
        self.view.sortingEnabled = True
        self.parent.layout().addWidget(self.view)

        # Chart button
        self.chartFrame = qt.QFrame()
        self.chartFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.chartFrame)
        self.chartButton = qt.QPushButton("Chart")
        self.chartButton.toolTip = "Make a chart from the current statistics."
        self.chartFrame.layout().addWidget(self.chartButton)
        self.chartOption = qt.QComboBox()
        self.chartOption.addItems(self.chartOptions)
        self.chartFrame.layout().addWidget(self.chartOption)
        self.chartIgnoreZero = qt.QCheckBox()
        self.chartIgnoreZero.setText('Ignore Zero')
        self.chartIgnoreZero.checked = False
        self.chartIgnoreZero.setToolTip(
            'Do not include the zero index in the chart to avoid dwarfing other bars'
        )
        self.chartFrame.layout().addWidget(self.chartIgnoreZero)
        self.chartFrame.enabled = False

        # Save button
        self.saveButton = qt.QPushButton("Save")
        self.saveButton.toolTip = "Calculate Statistics."
        self.saveButton.setStyleSheet("background-color: rgb(230,241,255)")
        self.saveButton.enabled = False
        self.parent.layout().addWidget(self.saveButton)

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

        # connections
        self.applyButton.connect('clicked()', self.onApply)
        self.chartButton.connect('clicked()', self.onChart)
        self.saveButton.connect('clicked()', self.onSave)
    def setup(self):

        # settings
        settingsButton = ctk.ctkCollapsibleButton()
        settingsButton.text = "Settings"
        settingsButton.collapsed = False
        self.parent.layout().addWidget(settingsButton)

        settingsLayout = qt.QFormLayout(settingsButton)

        self.__dirButton = ctk.ctkDirectoryButton()
        settingsLayout.addRow("Output directory:", self.__dirButton)

        self.__viewCheckbox = qt.QCheckBox()
        self.__viewCheckbox.setChecked(True)
        settingsLayout.addRow("View after export:", self.__viewCheckbox)

        # advanced
        advancedButton = ctk.ctkCollapsibleButton()
        advancedButton.text = "Advanced"
        advancedButton.collapsed = True
        self.parent.layout().addWidget(advancedButton)

        advancedLayout = qt.QFormLayout(advancedButton)

        self.__copyCheckbox = qt.QCheckBox()
        self.__copyCheckbox.setChecked(True)
        advancedLayout.addRow("Copy models to output directory:",
                              self.__copyCheckbox)

        self.__captionCombobox = qt.QComboBox()
        self.__captionCombobox.addItems(
            ['None', 'Model name', 'Hierarchy name'])
        self.__captionCombobox.currentIndex = 1  # Model name by default
        advancedLayout.addRow("Set captions from:", self.__captionCombobox)

        self.__serverCheckbox = qt.QCheckBox()
        self.__serverCheckbox.setChecked(useWebserver)
        if not useWebserver:
            self.__serverCheckbox.setEnabled(False)
        advancedLayout.addRow("Run internal web server:",
                              self.__serverCheckbox)

        # Apply button
        self.__exportButton = qt.QPushButton("Export to WebGL")
        self.__exportButton.toolTip = "Export to WebGL using XTK."
        self.__exportButton.enabled = True
        self.parent.layout().addWidget(self.__exportButton)

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

        # connections
        self.__exportButton.connect('clicked()', self.onExport)
    def updateTable(self):
      #logging.debug(pNode.GetParameter('vertebrae'))
      self.fiducial = self.fiducialNode()
      self.fidNumber = self.fiducial.GetNumberOfFiducials()
      logging.debug(self.fidNumber)
      self.fidLabels = []
      self.items = []
      self.Label = qt.QTableWidgetItem()

      self.table2.setRowCount(self.fidNumber)


      for i in range(0,self.fidNumber):
          self.Label = qt.QTableWidgetItem(self.fiducial.GetNthFiducialLabel(i))
          self.items.append(self.Label)
          self.table2.setItem(i, 0, self.Label)
          self.comboLevel = qt.QComboBox()
          self.comboLevel.addItems(self.levelselection)
          self.comboSide = qt.QComboBox()
          self.comboSide.addItems(["Left","Right"])
          self.table2.setCellWidget(i,1, self.comboLevel)
          self.table2.setCellWidget(i,2, self.comboSide)
      logging.debug(self.Label.text())
Exemple #14
0
  def createUserInterface( self ):
    '''
    '''
    self.buttonBoxHints = self.ButtonBoxHidden

    self.__layout = self.__parent.createUserInterface()

    # let's load all tasks
    self.loadTasks()
    self.loadPreprocessingTasks()

    selectTaskLabel = qt.QLabel( 'Select Task' )
    selectTaskLabel.setFont( self.__parent.getBoldFont() )
    self.__layout.addRow( selectTaskLabel )

    self.__taskComboBox = qt.QComboBox()
    self.__taskComboBox.toolTip = "Choose a task."

    # fill the comboBox with the taskNames
    self.__taskComboBox.addItems( self.getTaskNames() )
    # TODO select MRI Human Brain as default
    self.__taskComboBox.connect( 'currentIndexChanged(int)', self.onTaskSelected )
    self.__layout.addRow( Helper.CreateSpace( 20 ), self.__taskComboBox )

    # add empty row
    self.__layout.addRow( "", qt.QWidget() )

    chooseModeLabel = qt.QLabel( 'Choose Mode' )
    chooseModeLabel.setFont( self.__parent.getBoldFont() )
    self.__layout.addRow( chooseModeLabel )

    self.__buttonBox = qt.QDialogButtonBox()
    simpleButton = self.__buttonBox.addButton( self.__buttonBox.Discard )
    simpleButton.setIcon( qt.QIcon() )
    simpleButton.text = "Simple"
    simpleButton.toolTip = "Click to use the simple mode."
    advancedButton = self.__buttonBox.addButton( self.__buttonBox.Apply )
    advancedButton.setIcon( qt.QIcon() )
    advancedButton.text = "Advanced"
    advancedButton.toolTip = "Click to use the advanced mode."
    self.__layout.addWidget( self.__buttonBox )

    # connect the simple and advanced buttons
    simpleButton.connect( 'clicked()', self.goSimple )
    advancedButton.connect( 'clicked()', self.goAdvanced )
    def __init__(self, name, configurationCB, models, hsize):
        ## target and entry point
        self.target = []
        self.entry = []

        #### Create a new GroupBOX i.e. a line
        self.row = qt.QGroupBox(configurationCB)
        self.hlayout = qt.QHBoxLayout(self.row)
        self.hlayout.setMargin(1)
        #### Create a new label
        self.name = qt.QLabel(name, self.row)
        self.name.setMaximumWidth(hsize[0])
        self.name.setMaximumHeight(20)
        self.hlayout.addWidget(self.name)
        # Eletrode Length
        self.length = 0

        #### Set the model list combo box
        self.model = qt.QComboBox(self.row)

        self.keys = list(models.keys())

        self.keys.sort(reverse=True)

        self.model.addItems(self.keys)

        self.model.setMaximumWidth(hsize[1])
        self.model.setMaximumHeight(20)
        self.model.setStyleSheet("qproperty-alignment: AlignCenter;")
        self.hlayout.addWidget(self.model)

        #### Tail Check Box
        self.tailCheckBox = qt.QCheckBox(self.row)
        self.tailCheckBox.setMaximumWidth(hsize[2])
        self.tailCheckBox.setMaximumHeight(20)
        self.tailCheckBox.setStyleSheet("qproperty-alignment: AlignCenter;")
        self.hlayout.addWidget(self.tailCheckBox)

        ### Head CheckBox
        self.headCheckBox = qt.QCheckBox(self.row)
        self.headCheckBox.setMaximumWidth(hsize[3])
        self.headCheckBox.setMaximumHeight(20)
        self.headCheckBox.setStyleSheet("qproperty-alignment: AlignCenter;")
        self.hlayout.addWidget(self.headCheckBox)
Exemple #16
0
    def addFontSizeDropdown(self, title="Font Size:"):
        """ Adds a fontSize dropdown to the layout
            of the XnatSetting.  The subclass then
            needs to specify how to connect the events
            of the dropdown.
        """
        try:
            self.fontDropdowns.append(qt.QComboBox())
            self.fontDropdowns[-1].addItems([str(i) for i in range(8, 21)])
            self.fontDropdowns[-1].setFixedWidth(100)
            self.addSection(title, self.fontDropdowns[-1])

        #--------------------
        # If there's no 'fontDropdowns' variable
        # then we create one and call the function again.
        #--------------------
        except Exception, e:
            self.fontDropdowns = []
            self.addFontSizeDropdown(title)
Exemple #17
0
  def create(self):
    super(GrowCutCLOptions,self).create()

    self.deviceTypeComboBox = qt.QComboBox()
    self.deviceTypeComboBox.addItem('CPU')
    self.deviceTypeComboBox.addItem('GPU')
    self.deviceTypeComboBox.connect('currentIndexChanged(int)', self.onDeviceTypeChanged)
    self.frame.layout().addWidget(self.deviceTypeComboBox)

    self.botButton = qt.QPushButton(self.frame)
    if hasattr(slicer.modules, 'editorBot'):
      self.botButton.text = "Stop Bot"
    else:
      self.botButton.text = "Start Bot"
    self.frame.layout().addWidget(self.botButton)

    self.acceptButton = qt.QPushButton(self.frame)
    self.acceptButton.text = "Accept Steered Label"
    self.frame.layout().addWidget(self.acceptButton)

    HelpButton(self.frame, "This is an interactive segmentation tool that is actively calculating a region-growing method as you provide additional input.  Starting the Bot will cause the segmentation to grow using your current labels as input.")

    self.botButton.connect('clicked()', self.onStartBot)
    self.acceptButton.connect('clicked()', self.onAccept)

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

    # TODO: the functionality for the steered volume should migrate to
    # the edit helper class when functionality is finalized.
    backgroundVolume = self.editUtil.getBackgroundVolume()
    labelVolume = self.editUtil.getLabelVolume()
    steeredName = backgroundVolume.GetName() + '-steered'
    steeredVolume = slicer.util.getNode(steeredName)
    if not steeredVolume:
      volumesLogic = slicer.modules.volumes.logic()
      steeredVolume = volumesLogic.CloneVolume(
                           slicer.mrmlScene, labelVolume, steeredName)
    compositeNodes = slicer.util.getNodes('vtkMRMLSliceCompositeNode*')
    for compositeNode in compositeNodes.values():
      compositeNode.SetForegroundVolumeID(steeredVolume.GetID())
      compositeNode.SetForegroundOpacity(0.5)
    def addFiducialToTable(self, observer, event):
        logging.debug("Modified - {0}".format(event))

        self.fidNumber = self.fidNode.GetNumberOfFiducials()
        slicer.modules.markups.logic().SetAllMarkupsVisibility(self.fidNode, 1)
        logging.debug(self.fidNumber)
        self.fidLabels = []
        self.items = []
        self.Label = qt.QTableWidgetItem()

        self.table2.setRowCount(self.fidNumber)

        for i in range(0, self.fidNumber):
            self.Label = qt.QTableWidgetItem(
                self.fidNode.GetNthFiducialLabel(i))
            self.items.append(self.Label)
            self.table2.setItem(i, 0, self.Label)
            self.combofidlist = qt.QComboBox()
            self.combofidlist.addItems(self.fiduciallist)
            self.table2.setCellWidget(i, 1, self.combofidlist)
    def updateTable(self):
        # logging.debug(pNode.GetParameter('vertebrae'))
        self.fiducial = self.fiducialNode()
        self.fidNumber = self.fiducial.GetNumberOfFiducials()
        logging.debug(self.fidNumber)
        self.fidLabels = []
        self.items = []
        self.Label = qt.QTableWidgetItem()

        self.table2.setRowCount(self.fidNumber)
        logging.debug(self.fiduciallist)
        for i in range(0, self.fidNumber):
            self.Label = qt.QTableWidgetItem(
                self.fiducial.GetNthFiducialLabel(i))
            self.items.append(self.Label)
            self.table2.setItem(i, 0, self.Label)
            self.combofidlist = qt.QComboBox()
            self.combofidlist.addItems(self.fiduciallist)
            self.table2.setCellWidget(i, 1, self.combofidlist)
        logging.debug(self.fiduciallist)
Exemple #20
0
  def onTaskSelected( self ):
    '''
    '''
    index = self.__taskComboBox.currentIndex
    taskName = self.__taskComboBox.currentText

    # re-enable the simple and advanced buttons
    self.__buttonBox.enabled = True

    if taskName == self.__newTaskString:
      # create new task was selected

      # disable the simple and advanced buttons
      self.__buttonBox.enabled = False

      # create new dialog
      self.__d = qt.QDialog()
      dLayout = qt.QFormLayout( self.__d )

      self.__nameEdit = qt.QLineEdit()
      dLayout.addRow( 'New Task Name:', self.__nameEdit )

      self.__preprocessingComboBox = qt.QComboBox()
      list = self.__preprocessingTasksList.keys()
      list.sort( lambda x, y: cmp( x.lower(), y.lower() ) )
      self.__preprocessingComboBox.addItems( list )
      # also, add None
      self.__preprocessingComboBox.addItem( 'None' )
      dLayout.addRow( 'Pre-processing:', self.__preprocessingComboBox )

      buttonBox = qt.QDialogButtonBox()
      #cancelButton = buttonBox.addButton(buttonBox.Discard)
      #cancelButton.text = 'Cancel'
      okButton = buttonBox.addButton( buttonBox.Apply )
      okButton.setIcon( qt.QIcon() )
      okButton.text = 'Apply'
      okButton.connect( 'clicked()', self.createNewTask )
      dLayout.addWidget( buttonBox )

      self.__d.setModal( True )
      self.__d.show()
    def __init__(self, parent):
        self.vLayout = qt.QVBoxLayout(parent)
        self.formLayout = qt.QFormLayout()

        self.componentName = qt.QLineEdit()
        self.formLayout.addRow("Name:", self.componentName)

        self.componentType = qt.QComboBox()
        self.formLayout.addRow("Type:", self.componentType)

        self.destination = ctk.ctkPathLineEdit()
        self.destination.filters = ctk.ctkPathLineEdit.Dirs
        self.formLayout.addRow("Destination:", self.destination)

        self.vLayout.addLayout(self.formLayout)
        self.vLayout.addStretch(1)

        self.buttonBox = qt.QDialogButtonBox()
        self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok
                                          | qt.QDialogButtonBox.Cancel)
        self.vLayout.addWidget(self.buttonBox)
Exemple #22
0
    def create(self):
        super(EffectOptions, self).create()

        # interface for the scope options
        self.scopeFrame = qt.QFrame(self.frame)
        self.scopeFrame.setLayout(qt.QHBoxLayout())
        self.frame.layout().addWidget(self.scopeFrame)
        self.scopeLabel = qt.QLabel('Scope:')
        self.scopeFrame.layout().addWidget(self.scopeLabel)
        self.scopeComboBox = qt.QComboBox(self.scopeFrame)
        for scopeOption in self.scopeOptions:
            self.scopeComboBox.addItem(scopeOption)
        self.scopeComboBox.toolTip = "Choose the scope for applying this tool.  Scope of 'visible' refers to contents of Red slice by default (or slice clicked in)"
        self.scopeFrame.layout().addWidget(self.scopeComboBox)
        self.widgets.append(self.scopeComboBox)
        if len(self.scopeOptions) <= 1:
            self.scopeFrame.hide()

        self.connections.append(
            (self.scopeComboBox, 'currentIndexChanged(int)',
             self.onScopeChanged))
 def setupValvesSection(self):
     self.valvesCollapsibleButton = ctk.ctkCollapsibleButton()
     self.valvesCollapsibleButton.objectName = "Valves"
     self.valvesCollapsibleButton.text = "Valves"
     self.layout.addWidget(self.valvesCollapsibleButton)
     self.valvesCollapsibleButton.connect(
         'toggled(bool)', lambda toggle: self.onWorkflowStepChanged(
             self.valvesCollapsibleButton, toggle))
     valvesFormLayout = qt.QFormLayout(self.valvesCollapsibleButton)
     self.presetSelector = qt.QComboBox()
     for preset in self.logic.measurementPresets:
         self.presetSelector.addItem(preset.name, preset.id)
     valvesFormLayout.addRow("Preset", self.presetSelector)
     self.presetSelector.connect('currentIndexChanged(int)',
                                 self.onPresetChanged)
     # Input valve selectors will be inserted into this frame
     self.valveSelectorsFrame = qt.QFrame()
     self.valveSelectorsFrame.setFrameShape(qt.QFrame.NoFrame)
     self.valveSelectorsFormLayout = qt.QFormLayout(
         self.valveSelectorsFrame)
     self.valveSelectorsFormLayout.setContentsMargins(0, 0, 0, 0)
     valvesFormLayout.addRow(self.valveSelectorsFrame)
Exemple #24
0
    def setup(self):
        # Instantiate and connect widgets ...

        # Collapsible button
        sampleCollapsibleButton = ctk.ctkCollapsibleButton()
        sampleCollapsibleButton.text = "A collapsible button"
        self.layout.addWidget(sampleCollapsibleButton)

        # Layout within the sample collapsible button
        sampleFormLayout = qt.QFormLayout(sampleCollapsibleButton)
        self.layout.addStretch(1)
        labelSeleccionCargarGuardar = qt.QLabel(
            "Desea cargar o guardar? "
        )  #Se crea label para seleccion de tornillo a manipular
        sampleFormLayout.addWidget(
            labelSeleccionCargarGuardar)  #Se añade label

        self.comboBoxSeleccionCargarGuardar = qt.QComboBox(
        )  #Se crea comboBox para seleccionar tornillo
        self.comboBoxSeleccionCargarGuardar.addItem(
            "Cargar Scene")  #Se añade opciones
        self.comboBoxSeleccionCargarGuardar.addItem("Guardar Scene")
        sampleFormLayout.addWidget(self.comboBoxSeleccionCargarGuardar)

        labelNombreScene = qt.QLabel(
            "Nombre: ")  #Se crea label para seleccion de tornillo a manipular
        sampleFormLayout.addWidget(labelNombreScene)

        self.nombreSceceTextEdit = qt.QLineEdit()

        self.nombreSceceTextEdit.textChanged.connect(self.textchanged1)
        sampleFormLayout.addWidget(self.nombreSceceTextEdit)

        self.cargarGuardarButton = qt.QPushButton(
            "Cargar/Guardar Scene")  #Se crea boton pulsable, con texto "Apply"
        sampleFormLayout.addWidget(
            self.cargarGuardarButton
        )  #Se añade el boton al layout del boton colapsable
        self.cargarGuardarButton.connect('clicked(bool)', self.onApply3)
    def createEnumWidget(self, name, enumList, valueList=None):

        w = qt.QComboBox()
        self.widgets.append(w)

        exec 'default=self.filter.Get{0}()'.format(name) in globals(), locals()

        if valueList is None:
            valueList = ["self.filter." + e for e in enumList]

        for e, v in zip(enumList, valueList):
            w.addItem(e, v)

            # check if current item is default, set if it is
            exec 'itemValue=' + v in globals(), locals()
            if itemValue == default:
                w.setCurrentIndex(w.count - 1)

        w.connect("currentIndexChanged(int)",
                  lambda selectorIndex, n=name, selector=w: self.onEnumChanged(
                      n, selectorIndex, selector))
        return w
    def createEnumWidget(self, name, enumList, valueList=None):

        w = qt.QComboBox()
        self.widgets.append(w)

        default = self._getParameterValue(name)

        if valueList is None:
            valueList = ["self.filter." + e for e in enumList]

        for e, v in zip(enumList, valueList):
            w.addItem(e, v)

            # check if current item is default, set if it is
            ldict = locals().copy()
            exec('itemValue=' + v, globals(), ldict)
            if ldict['itemValue'] == default:
                w.setCurrentIndex(w.count - 1)

        w.connect("currentIndexChanged(int)",
                  lambda selectorIndex, n=name, selector=w: self.onEnumChanged(
                      n, selectorIndex, selector))
        self.widgetConnections.append((w, "currentIndexChanged(int)"))
        return w
    def createUserInterface(self):

        self.__layout = self.__parent.createUserInterface()

        vText = qt.QLabel("1st Instrumented Level:")
        iText = qt.QLabel("# to Instrument:")
        aText = qt.QLabel("Approach Direction:")
        self.vSelector = qt.QComboBox()
        self.vSelector.setMaximumWidth(120)
        self.levels = ("C1", "C2", "C3", "C4", "C5", "C6", "C7", "T1", "T2",
                       "T3", "T4", "T5", "T6", "T7", "T8", "T9", "T10", "T11",
                       "T12", "L1", "L2", "L3", "L4", "L5", "S1")
        self.vSelector.addItems(self.levels)
        self.iSelector = qt.QComboBox()
        self.iSelector.setMaximumWidth(120)
        self.iSelector.addItems(
            ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'])
        self.aSelector = qt.QComboBox()
        self.aSelector.setMaximumWidth(120)
        self.aSelector.addItems(['Posterior', 'Anterior', 'Left', 'Right'])
        blank = qt.QLabel("  ")
        blank.setMaximumWidth(30)
        #self.__layout.addWidget(vText)
        #self.__layout.addWidget(self.vSelector)
        #self.__layout.addWidget(iText)
        #self.__layout.addWidget(self.iSelector)

        self.vertebraeGridBox = qt.QGridLayout()
        self.vertebraeGridBox.addWidget(vText, 0, 0)
        self.vertebraeGridBox.addWidget(self.vSelector, 1, 0)
        self.vertebraeGridBox.addWidget(blank, 0, 1)
        self.vertebraeGridBox.addWidget(iText, 0, 2)
        self.vertebraeGridBox.addWidget(blank, 1, 1)
        self.vertebraeGridBox.addWidget(self.iSelector, 1, 2)
        self.vertebraeGridBox.addWidget(blank, 0, 3)
        self.vertebraeGridBox.addWidget(aText, 0, 4)
        self.vertebraeGridBox.addWidget(blank, 1, 3)
        self.vertebraeGridBox.addWidget(self.aSelector, 1, 4)
        self.__layout.addRow(self.vertebraeGridBox)

        #self.__layout.addRow("Starting Instrumented Vertebra:",self.vSelector)
        #self.__layout.addRow("Number of Vertebrae to Instrument:",self.iSelector)

        # Hide ROI Details
        roiCollapsibleButton = ctk.ctkCollapsibleButton()
        #roiCollapsibleButton.setMaximumWidth(320)
        roiCollapsibleButton.text = "ROI Details"
        self.__layout.addWidget(roiCollapsibleButton)
        roiCollapsibleButton.collapsed = True

        # Layout
        roiLayout = qt.QFormLayout(roiCollapsibleButton)

        #label for ROI selector
        roiLabel = qt.QLabel('Select ROI:')
        font = roiLabel.font
        font.setBold(True)
        roiLabel.setFont(font)

        #creates combobox and populates it with all vtkMRMLAnnotationROINodes in the scene
        self.__roiSelector = slicer.qMRMLNodeComboBox()
        self.__roiSelector.nodeTypes = ['vtkMRMLAnnotationROINode']
        self.__roiSelector.toolTip = "ROI defining the structure of interest"
        self.__roiSelector.setMRMLScene(slicer.mrmlScene)
        self.__roiSelector.addEnabled = 1

        #add label + combobox
        roiLayout.addRow(roiLabel, self.__roiSelector)

        self.__roiSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.onROIChanged)

        # the ROI parameters
        # GroupBox to hold ROI Widget
        voiGroupBox = qt.QGroupBox()
        voiGroupBox.setTitle('Define VOI')
        roiLayout.addRow(voiGroupBox)

        # create form layout for GroupBox
        voiGroupBoxLayout = qt.QFormLayout(voiGroupBox)

        # create ROI Widget and add it to the form layout of the GroupBox
        self.__roiWidget = PythonQt.qSlicerAnnotationsModuleWidgets.qMRMLAnnotationROIWidget(
        )
        voiGroupBoxLayout.addRow(self.__roiWidget)

        # # Hide VR Details
        # vrCollapsibleButton = ctk.ctkCollapsibleButton()
        # #roiCollapsibleButton.setMaximumWidth(320)
        # vrCollapsibleButton.text = "Rendering Details"
        # self.__layout.addWidget(vrCollapsibleButton)
        # vrCollapsibleButton.collapsed = True

        # # Layout
        # vrLayout = qt.QFormLayout(vrCollapsibleButton)

        # # the ROI parameters
        # # GroupBox to hold ROI Widget
        # vrGroupBox = qt.QGroupBox()
        # vrGroupBox.setTitle( 'Define Rendering' )
        # vrLayout.addRow( vrGroupBox )

        # # create form layout for GroupBox
        # vrGroupBoxLayout = qt.QFormLayout( vrGroupBox )

        # # create ROI Widget and add it to the form layout of the GroupBox
        # self.__vrWidget = PythonQt.qSlicerVolumeRenderingModuleWidgets.qSlicerPresetComboBox()
        # #self.__vrWidget = PythonQt.qSlicerVolumeRenderingModuleWidgets.qMRMLVolumePropertyNodeWidget()
        # vrGroupBoxLayout.addRow( self.__vrWidget )

        # # initialize VR
        # self.__vrLogic = slicer.modules.volumerendering.logic()

        # self.updateWidgetFromParameters(self.parameterNode())
        qt.QTimer.singleShot(0, self.killButton)
Exemple #28
0
    def setup(self):
        #
        # the grayscale volume selector
        #
        self.grayscaleSelectorFrame = qt.QFrame(self.parent)
        self.grayscaleSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.grayscaleSelectorFrame)

        self.grayscaleSelectorLabel = qt.QLabel("Inspiratory CT: ",
                                                self.grayscaleSelectorFrame)
        self.grayscaleSelectorLabel.setToolTip(
            "Select the grayscale volume (background grayscale scalar volume node) for statistics calculations"
        )
        self.grayscaleSelectorFrame.layout().addWidget(
            self.grayscaleSelectorLabel)

        self.grayscaleSelector = slicer.qMRMLNodeComboBox(
            self.grayscaleSelectorFrame)
        self.grayscaleSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.grayscaleSelector.addAttribute("vtkMRMLScalarVolumeNode",
                                            "LabelMap", 0)
        self.grayscaleSelector.selectNodeUponCreation = False
        self.grayscaleSelector.addEnabled = False
        self.grayscaleSelector.removeEnabled = False
        self.grayscaleSelector.noneEnabled = True
        self.grayscaleSelector.showHidden = False
        self.grayscaleSelector.showChildNodeTypes = False
        self.grayscaleSelector.setMRMLScene(slicer.mrmlScene)
        # TODO: need to add a QLabel
        # self.grayscaleSelector.SetLabelText( "Master Volume:" )
        self.grayscaleSelectorFrame.layout().addWidget(self.grayscaleSelector)

        #
        # the label volume selector
        #
        self.labelSelectorFrame = qt.QFrame()
        self.labelSelectorFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.labelSelectorFrame)

        self.labelSelectorLabel = qt.QLabel()
        self.labelSelectorLabel.setText("Emphysema Subtypes: ")
        self.labelSelectorFrame.layout().addWidget(self.labelSelectorLabel)

        self.labelSelector = slicer.qMRMLNodeComboBox()
        self.labelSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.labelSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap",
                                        "1")
        # todo addAttribute
        self.labelSelector.selectNodeUponCreation = False
        self.labelSelector.addEnabled = False
        self.labelSelector.noneEnabled = True
        self.labelSelector.removeEnabled = False
        self.labelSelector.showHidden = False
        self.labelSelector.showChildNodeTypes = False
        self.labelSelector.setMRMLScene(slicer.mrmlScene)
        self.labelSelector.setToolTip("Pick the label map to edit")
        self.labelSelectorFrame.layout().addWidget(self.labelSelector)

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Calculate Statistics."
        self.applyButton.enabled = False
        self.parent.layout().addWidget(self.applyButton)

        # model and view for stats table
        self.view = qt.QTableView()
        self.view.sortingEnabled = True
        self.parent.layout().addWidget(self.view)

        # Chart button
        self.chartFrame = qt.QFrame()
        self.chartFrame.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.chartFrame)
        self.chartButton = qt.QPushButton("Chart")
        self.chartButton.toolTip = "Make a chart from the current statistics."
        self.chartFrame.layout().addWidget(self.chartButton)
        self.chartOption = qt.QComboBox()
        self.chartOption.addItems(self.chartOptions)
        self.chartFrame.layout().addWidget(self.chartOption)
        self.chartIgnoreZero = qt.QCheckBox()
        self.chartIgnoreZero.setText('Ignore Zero')
        self.chartIgnoreZero.checked = False
        self.chartIgnoreZero.setToolTip(
            'Do not include the zero index in the chart to avoid dwarfing other bars'
        )
        self.chartFrame.layout().addWidget(self.chartIgnoreZero)
        self.chartFrame.enabled = False

        # Save button
        self.saveButton = qt.QPushButton("Save")
        self.saveButton.toolTip = "Calculate Statistics."
        self.saveButton.enabled = False
        self.parent.layout().addWidget(self.saveButton)

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

        # connections
        self.applyButton.connect('clicked()', self.onApply)
        self.chartButton.connect('clicked()', self.onChart)
        self.saveButton.connect('clicked()', self.onSave)
        self.grayscaleSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                       self.onGrayscaleSelect)
        self.labelSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.onLabelSelect)
Exemple #29
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)

    transformWarningLabel = qt.QLabel( "Note: Parent transforms of models are not used. Models should be defined in the coordinate system that is being registered." )
    transformWarningLabel.setWordWrap( True )
    parametersFormLayout.addRow(transformWarningLabel)

    #
    # input target (fixed, dense) model selector
    #
    self.inputTargetModelSelector = slicer.qMRMLNodeComboBox()
    self.inputTargetModelSelector.nodeTypes = ( ("vtkMRMLModelNode"), "" )
    self.inputTargetModelSelector.selectNodeUponCreation = True
    self.inputTargetModelSelector.addEnabled = False
    self.inputTargetModelSelector.removeEnabled = False
    self.inputTargetModelSelector.noneEnabled = False
    self.inputTargetModelSelector.showHidden = False
    self.inputTargetModelSelector.showChildNodeTypes = False
    self.inputTargetModelSelector.setMRMLScene( slicer.mrmlScene )
    self.inputTargetModelSelector.setToolTip( "Select the model the other will be transformed to. This model required to contain a dense set of points." )
    parametersFormLayout.addRow("Input fixed (dense) model: ", self.inputTargetModelSelector)

    #
    # input source (moving) model selector
    #
    self.inputSourceModelSelector = slicer.qMRMLNodeComboBox()
    self.inputSourceModelSelector.nodeTypes = ( ("vtkMRMLModelNode"), "" )
    self.inputSourceModelSelector.selectNodeUponCreation = True
    self.inputSourceModelSelector.addEnabled = False
    self.inputSourceModelSelector.removeEnabled = False
    self.inputSourceModelSelector.noneEnabled = False
    self.inputSourceModelSelector.showHidden = False
    self.inputSourceModelSelector.showChildNodeTypes = False
    self.inputSourceModelSelector.setMRMLScene( slicer.mrmlScene )
    self.inputSourceModelSelector.setToolTip( "Select the model that will be transformed. This model may require a sparse set of points." )
    parametersFormLayout.addRow("Input moving (sparse) model: ", self.inputSourceModelSelector)

    #
    # output transform selector
    #
    self.outputSourceToTargetTransformSelector = slicer.qMRMLNodeComboBox()
    self.outputSourceToTargetTransformSelector.nodeTypes = ( ("vtkMRMLLinearTransformNode"), "" )
    self.outputSourceToTargetTransformSelector.selectNodeUponCreation = True
    self.outputSourceToTargetTransformSelector.addEnabled = True
    self.outputSourceToTargetTransformSelector.removeEnabled = True
    self.outputSourceToTargetTransformSelector.noneEnabled = False
    self.outputSourceToTargetTransformSelector.showHidden = False
    self.outputSourceToTargetTransformSelector.showChildNodeTypes = False
    self.outputSourceToTargetTransformSelector.renameEnabled = True
    self.outputSourceToTargetTransformSelector.setMRMLScene( slicer.mrmlScene )
    self.outputSourceToTargetTransformSelector.setToolTip( "Pick the moving to fixed transform computed by the algorithm." )
    parametersFormLayout.addRow("Output transform: ", self.outputSourceToTargetTransformSelector)

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

    #
    # Output panel
    #
    outputCollapsibleButton = ctk.ctkCollapsibleButton()
    outputCollapsibleButton.text = "Output"
    self.layout.addWidget( outputCollapsibleButton )
    outputFormLayout = qt.QFormLayout( outputCollapsibleButton )

    self.outputLine = qt.QLineEdit()
    self.outputLine.setReadOnly( True )
    outputFormLayout.addRow( "Mean distance after registration:", self.outputLine )

    #
    # Advanced parameters
    #
    advancedCollapsibleButton = ctk.ctkCollapsibleButton()
    advancedCollapsibleButton.text = "Advanced"
    self.layout.addWidget(advancedCollapsibleButton)

    # Layout
    advancedCollapsibleButton.collapsed = True
    advancedFormLayout = qt.QFormLayout(advancedCollapsibleButton)

    #
    # Transform type selector
    #
    self.typeSelector = qt.QComboBox()
    self.typeSelector.insertItem( 0, "Rigid" )
    self.typeSelector.insertItem( 1, "Similarity" )
    self.typeSelector.insertItem( 2, "Affine" )
    advancedFormLayout.addRow("Transform type: ", self.typeSelector)

    #
    # Iteration selector
    #
    self.iterationSpin = qt.QSpinBox()
    self.iterationSpin.setMaximum( 1000 )
    self.iterationSpin.setValue( 100 )
    advancedFormLayout.addRow("Number of iterations:", self.iterationSpin)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.inputTargetModelSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.inputSourceModelSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.outputSourceToTargetTransformSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

    # Add vertical spacer
    self.layout.addStretch(1)
Exemple #30
0
    def setup(self):
        for cervicalVertebrae in range(
                1, self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE + 1):
            self.verterbraeNames.append("C" + str(cervicalVertebrae))

        for thoracicVertebrae in range(
                1, self.CONST_NUMBER_OF_THORACIC_VERTERBRAE + 1):
            self.verterbraeNames.append("T" + str(thoracicVertebrae))

        for lumbarVertebrae in range(
                1, self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE + 1):
            self.verterbraeNames.append("L" + str(lumbarVertebrae))

        self.superiorAnglesList = [
            None
        ] * self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE * self.CONST_NUMBER_OF_THORACIC_VERTERBRAE * self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE
        self.inferiorAnglesList = [
            None
        ] * self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE * self.CONST_NUMBER_OF_THORACIC_VERTERBRAE * self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE

        # Instantiate and connect widgets
        #
        # Brief Explanation Text
        instructionsCollapsibleButton = ctk.ctkCollapsibleButton()
        instructionsCollapsibleButton.text = "Instructions"
        self.layout.addWidget(instructionsCollapsibleButton)

        instructionsLayout = qt.QVBoxLayout(instructionsCollapsibleButton)

        self.namingInstructions = ctk.ctkFittedTextBrowser()
        self.namingInstructions.setReadOnly(True)
        self.namingInstructions.setPlainText(
            "C - Cervical, T - Thoracic, L - Lumbar\ns - Superior, i - Inferior\nName ruler annotations like so: T1-s, T1-i, T2-s, etc."
        )
        instructionsLayout.addWidget(self.namingInstructions)

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

        # Layout
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        # Input Selector
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = (("vtkMRMLAnnotationHierarchyNode"), "")
        self.inputSelector.selectNodeUponCreation = True
        self.inputSelector.addEnabled = True
        self.inputSelector.removeEnabled = True
        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 Rulers: ", self.inputSelector)

        self.projectionPlaneBox = qt.QComboBox()
        self.projectionPlaneBox.addItems(["Coronal", "Axial", "Sagittal"])
        parametersFormLayout.addRow("Projection Plane: ",
                                    self.projectionPlaneBox)

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

        # Layout
        outputVerticalLayout = qt.QGridLayout(outputCollapsibleButton)

        # Calculate Button
        self.calculateButton = qt.QPushButton("Start Calculating")
        outputVerticalLayout.addWidget(self.calculateButton, 0, 0, 1, 5)

        # Save Button
        self.saveButton = qt.QPushButton("Save as CSV")
        outputVerticalLayout.addWidget(self.saveButton, 1, 0, 1, 5)

        # Angle Table
        horizontalHeaders = [
            "Vertebrae", "Superior Angles (degrees)",
            "Inferior Angles (degrees)"
        ]

        self.angleTable = qt.QTableWidget(
            self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE +
            self.CONST_NUMBER_OF_THORACIC_VERTERBRAE +
            self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE, 3)
        self.angleTable.sortingEnabled = False
        self.angleTable.setEditTriggers(0)
        self.angleTable.setMinimumHeight(
            self.angleTable.verticalHeader().length() + 25)
        self.angleTable.horizontalHeader().setResizeMode(
            qt.QHeaderView.Stretch)
        self.angleTable.setSizePolicy(qt.QSizePolicy.MinimumExpanding,
                                      qt.QSizePolicy.Preferred)
        outputVerticalLayout.addWidget(self.angleTable, 2, 0, 1, 5)

        self.angleTable.setHorizontalHeaderLabels(horizontalHeaders)

        self.labelReferences = []
        self.superiorAngleReferences = []
        self.inferiorAngleReferences = []
        for verterbraeIndex, verterbraeName in enumerate(self.verterbraeNames):
            vertebraeLabel = qt.QTableWidgetItem(verterbraeName)
            self.labelReferences.append(vertebraeLabel)
            self.angleTable.setItem(verterbraeIndex, 0, vertebraeLabel)

            superiorAngleItem = qt.QTableWidgetItem("")
            self.superiorAngleReferences.append(superiorAngleItem)
            self.angleTable.setItem(verterbraeIndex, 1, superiorAngleItem)

            inferiorAngleItem = qt.QTableWidgetItem("")
            self.inferiorAngleReferences.append(inferiorAngleItem)
            self.angleTable.setItem(verterbraeIndex, 2, inferiorAngleItem)

        # connections
        self.calculateButton.connect('clicked(bool)', self.onCalculateButton)
        self.saveButton.connect('clicked(bool)', self.onSaveButton)
        self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.onSelect)

        self.layout.addStretch(1)