Ejemplo n.º 1
0
    def makePyramidWidgets(self):
        self.pyramidTab = qt.QWidget()
        self.parametersTabWidget.addTab(self.pyramidTab, 'Pyramid levels')
        self.pyramidLayout = qt.QGridLayout(self.pyramidTab)

        self.pyramidHighestSpinBox = qt.QSpinBox()
        self.pyramidHighestSpinBox.value = 3
        self.pyramidHighestSpinBox.setAlignment(qt.Qt.AlignCenter)
        self.pyramidHighestSpinBox.valueChanged.connect(
            self.onPyramidLevelsChanged)
        self.pyramidHighestLabel = qt.QLabel()
        self.pyramidHighestLabel.setAlignment(qt.Qt.AlignCenter)
        self.pyramidLayout.addWidget(qt.QLabel('Highest:'), 0, 0)
        self.pyramidLayout.addWidget(self.pyramidHighestSpinBox, 0, 1)
        self.pyramidLayout.addWidget(self.pyramidHighestLabel, 0, 2)

        self.pyramidLowestSpinBox = qt.QSpinBox()
        self.pyramidLowestSpinBox.value = 2
        self.pyramidLowestSpinBox.setAlignment(qt.Qt.AlignCenter)
        self.pyramidLowestSpinBox.valueChanged.connect(
            self.onPyramidLevelsChanged)
        self.pyramidLowestLabel = qt.QLabel()
        self.pyramidLowestLabel.setAlignment(qt.Qt.AlignCenter)
        self.pyramidLayout.addWidget(qt.QLabel('Lowest:'), 1, 0)
        self.pyramidLayout.addWidget(self.pyramidLowestSpinBox, 1, 1)
        self.pyramidLayout.addWidget(self.pyramidLowestLabel, 1, 2)

        self.pyramidGaussianFilteringCheckBox = qt.QCheckBox()
        self.pyramidLayout.addWidget(qt.QLabel('Gaussian filtering:'), 2, 0)
        self.pyramidLayout.addWidget(self.pyramidGaussianFilteringCheckBox, 2,
                                     1)
Ejemplo n.º 2
0
    def setupOptionsFrame(self):

        # input volume selector
        self.inputVolumeSelector = slicer.qMRMLNodeComboBox()
        self.inputVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.inputVolumeSelector.selectNodeUponCreation = True
        self.inputVolumeSelector.addEnabled = True
        self.inputVolumeSelector.removeEnabled = True
        self.inputVolumeSelector.noneEnabled = True
        self.inputVolumeSelector.noneDisplay = "(Master volume)"
        self.inputVolumeSelector.showHidden = False
        self.inputVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.inputVolumeSelector.setToolTip(
            "Volume to split. Default is current master volume node.")
        self.inputVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                         self.updateMRMLFromGUI)

        inputLayout = qt.QHBoxLayout()
        inputLayout.addWidget(self.inputVolumeSelector)
        self.scriptedEffect.addLabeledOptionsWidget("Input Volume: ",
                                                    inputLayout)

        # Pad size
        self.padEdit = qt.QSpinBox()
        self.padEdit.setToolTip(
            "Choose the number of voxels used to pad the image in each dimension"
        )
        self.padEdit.minimum = 0
        self.padEdit.maximum = 1000
        self.padEdit.connect("valueChanged(int)", self.updateMRMLFromGUI)
        self.padLabel = qt.QLabel("Pad voxels: ")

        # Fill value layouts
        # addWidget(*Widget, row, column, rowspan, colspan)
        padValueLayout = qt.QFormLayout()
        padValueLayout.addRow(self.padLabel, self.padEdit)

        self.scriptedEffect.addOptionsWidget(padValueLayout)

        self.fillValueEdit = qt.QSpinBox()
        self.fillValueEdit.setToolTip(
            "Choose the voxel intensity that will be used to pad the output volumes."
        )
        self.fillValueEdit.minimum = -32768
        self.fillValueEdit.maximum = 65535
        self.fillValueEdit.value = 0
        self.fillValueEdit.connect("valueChanged(int)", self.updateMRMLFromGUI)
        self.fillValueLabel = qt.QLabel("Fill value: ")

        fillValueLayout = qt.QFormLayout()
        fillValueLayout.addRow(self.fillValueLabel, self.fillValueEdit)
        self.scriptedEffect.addOptionsWidget(fillValueLayout)

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.objectName = self.__class__.__name__ + 'Apply'
        self.applyButton.setToolTip(
            "Generate a volume for each visible segment")
        self.scriptedEffect.addOptionsWidget(self.applyButton)
        self.applyButton.connect('clicked()', self.onApply)
Ejemplo n.º 3
0
    def SetupDoubleSliderControl(self,
                                 WidgetName='Set Threshold',
                                 SpinBoxStep=5):
        self.Slider = ctk.ctkDoubleRangeSlider()
        self.Label = qt.QLabel(WidgetName)
        self.Slider.orientation = 1

        self.SpinBoxL = qt.QSpinBox()
        self.SpinBoxL.prefix = 'Min: '
        self.SpinBoxL.setSingleStep(SpinBoxStep)

        self.SpinBoxR = qt.QSpinBox()
        self.SpinBoxR.prefix = 'Max: '
        self.SpinBoxR.setSingleStep(SpinBoxStep)

        ControlHBox = qt.QHBoxLayout()
        ControlHBox.addWidget(self.Label)
        ControlHBox.addWidget(self.SpinBoxL)
        ControlHBox.addWidget(self.Slider)
        ControlHBox.addWidget(self.SpinBoxR)
        self.DisplayLayout.addRow(ControlHBox)

        self.Slider.minimum = 0
        self.SpinBoxL.setRange(0, 0)

        self.Slider.maximum = 0
        self.SpinBoxR.setRange(0, 0)
Ejemplo n.º 4
0
    def __init__(self):
        columnNames = ['Convergence', 'Smoothing Sigmas', 'Shrink Factors']
        layout = CustomTable.__init__(self, columnNames)

        self.view.setItemDelegateForColumn(0, SpinBoxDelegate(self.model))
        self.view.setItemDelegateForColumn(1, SpinBoxDelegate(self.model))
        self.view.setItemDelegateForColumn(2, SpinBoxDelegate(self.model))

        self.smoothingSigmasUnitComboBox = qt.QComboBox()
        self.smoothingSigmasUnitComboBox.addItems(['vox', 'mm'])

        self.convergenceThresholdSpinBox = qt.QSpinBox()

        self.convergenceWindowSizeSpinBox = qt.QSpinBox()

        levelsSettingsFrame = qt.QFrame()
        levelsSettingsFrame.setLayout(qt.QFormLayout())
        levelsSettingsFrame.layout().addRow('Smoothing Sigmas Unit: ',
                                            self.smoothingSigmasUnitComboBox)
        levelsSettingsFrame.layout().addRow('Convergence Threshold (1e-N): ',
                                            self.convergenceThresholdSpinBox)
        levelsSettingsFrame.layout().addRow('Convergence Window Size: ',
                                            self.convergenceWindowSizeSpinBox)

        layout.addWidget(levelsSettingsFrame)
Ejemplo n.º 5
0
 def setupManualIndexesGroupBox(self):
   self.zFrameRegistrationManualIndexesGroupBox = qt.QGroupBox("Use manual start/end indexes")
   self.zFrameRegistrationManualIndexesGroupBox.setCheckable(True)
   self.zFrameRegistrationManualIndexesGroupBoxLayout = qt.QGridLayout()
   self.zFrameRegistrationManualIndexesGroupBox.setLayout(self.zFrameRegistrationManualIndexesGroupBoxLayout)
   self.zFrameRegistrationManualIndexesGroupBox.checked = False
   self.zFrameRegistrationStartIndex = qt.QSpinBox()
   self.zFrameRegistrationEndIndex = qt.QSpinBox()
   hBox = self.createHLayout([qt.QLabel("start"), self.zFrameRegistrationStartIndex,
                              qt.QLabel("end"), self.zFrameRegistrationEndIndex])
   self.zFrameRegistrationManualIndexesGroupBoxLayout.addWidget(hBox, 1, 1, qt.Qt.AlignRight)
 def setupGUIAndConnections(self):
     iconSize = qt.QSize(36, 36)
     self.inputVolumeGroupBox = qt.QGroupBox()
     self.inputVolumeGroupBoxLayout = qt.QFormLayout()
     self.inputVolumeGroupBox.setLayout(self.inputVolumeGroupBoxLayout)
     self.inputVolumeGroupBox.setFlat(True)
     self.zFrameTemplateVolumeSelector = self.createComboBox(
         nodeTypes=["vtkMRMLScalarVolumeNode", ""])
     self.inputVolumeGroupBoxLayout.addRow(
         "ZFrame template volume: ", self.zFrameTemplateVolumeSelector)
     self.layout.addWidget(self.inputVolumeGroupBox)
     self.layout.addStretch()
     self.zFrameRegistrationManualIndexesGroupBox = qt.QGroupBox(
         "Use manual start/end indexes")
     self.zFrameRegistrationManualIndexesGroupBox.setCheckable(True)
     self.zFrameRegistrationManualIndexesGroupBoxLayout = qt.QGridLayout()
     self.zFrameRegistrationManualIndexesGroupBox.setLayout(
         self.zFrameRegistrationManualIndexesGroupBoxLayout)
     self.zFrameRegistrationManualIndexesGroupBox.checked = False
     self.zFrameRegistrationStartIndex = qt.QSpinBox()
     self.zFrameRegistrationEndIndex = qt.QSpinBox()
     hBox = qt.QWidget()
     hBox.setLayout(qt.QHBoxLayout())
     hBox.layout().addWidget(qt.QLabel("start"))
     hBox.layout().addWidget(self.zFrameRegistrationStartIndex)
     hBox.layout().addWidget(qt.QLabel("end"))
     hBox.layout().addWidget(self.zFrameRegistrationEndIndex)
     self.zFrameRegistrationManualIndexesGroupBoxLayout.addWidget(
         hBox, 1, 1, qt.Qt.AlignRight)
     self.runZFrameRegistrationButton = self.createButton(
         "",
         enabled=False,
         icon=Icons.apply,
         iconSize=iconSize,
         toolTip="Run ZFrame Registration")
     self.retryZFrameRegistrationButton = self.createButton(
         "",
         enabled=False,
         icon=Icons.retry,
         iconSize=iconSize,
         toolTip="Reset")
     self.layout.addWidget(self.zFrameRegistrationManualIndexesGroupBox)
     widget = qt.QWidget()
     widget.setLayout(qt.QHBoxLayout())
     widget.layout().addWidget(self.runZFrameRegistrationButton)
     widget.layout().addWidget(self.retryZFrameRegistrationButton)
     self.layout.addWidget(widget)
     self.layout.addStretch(1)
     self.zFrameTemplateVolumeSelector.connect(
         'currentNodeChanged(bool)', self.loadVolumeAndEnableEditor)
     self.retryZFrameRegistrationButton.clicked.connect(
         self.onRetryZFrameRegistrationButtonClicked)
     self.runZFrameRegistrationButton.clicked.connect(
         self.onApplyZFrameRegistrationButtonClicked)
Ejemplo n.º 7
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

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

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

        # label(mask) value
        self.labelROISpin = qt.QSpinBox()
        self.labelROISpin.setMinimum(0)
        self.labelROISpin.setMaximum(2048)
        self.labelROISpin.setToolTip("Valor do Label (cor) para o ROI.")
        mainFormLayout.addRow("ROI Label Value", self.labelROISpin)

        # label(mask) value
        self.labelCortSpin = qt.QSpinBox()
        self.labelCortSpin.setMinimum(0)
        self.labelCortSpin.setMaximum(2048)
        self.labelCortSpin.setToolTip("valor do Label (cor) para o Osso Cortical")
        mainFormLayout.addRow("Osso Cortical Label Value", self.labelCortSpin)

        # Apply Button
        self.applyButton = qt.QPushButton("Iniciar")
        self.applyButton.toolTip = "Inicie o processamento."
        #self.applyButton.enabled = False
        mainFormLayout.addRow(self.applyButton)

        # Progress Bar
        self.progressBar = qt.QProgressBar()
        self.progressBar.setMinimum(0)
        self.progressBar.setMaximum(100)
        self.progressBar.setVisible(False)
        mainFormLayout.addRow(self.progressBar)

        self.resultButton = qt.QPushButton("Salvar imagens")
        #self.resultButton.enabled = False
        mainFormLayout.addRow(self.resultButton)

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

        # Conexoes
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.resultButton.connect('clicked(bool)', self.onResultButton)

        # Refresh Apply button state
        self.onSelect()
Ejemplo n.º 8
0
  def setupUI(self):
    self.setWindowTitle("Case Number Selection")
    self.spinbox = qt.QSpinBox()
    self.spinbox.setRange(self.minimum, int("9" * self.CASE_NUMBER_OF_DIGITS))

    self.hideInvisibleUnneededComponents()

    self.textLabel = qt.QLabel("Please select a case number for the new case.")
    self.textLabel.setStyleSheet("font-weight: bold;")
    self.previewLabel = qt.QLabel("New case directory:")
    self.preview = qt.QLabel()
    self.notice = qt.QLabel()
    self.notice.setStyleSheet("color:red;")

    self.okButton = self.addButton(self.Ok)
    self.okButton.enabled = False
    self.cancelButton = self.addButton(self.Cancel)
    self.setDefaultButton(self.okButton)

    self.groupBox = qt.QGroupBox()
    self.groupBox.setLayout(qt.QGridLayout())
    self.groupBox.layout().addWidget(self.textLabel, 0, 0, 1, 2)
    self.groupBox.layout().addWidget(qt.QLabel("Proposed Case Number"), 1, 0)
    self.groupBox.layout().addWidget(self.spinbox, 1, 1)
    self.groupBox.layout().addWidget(self.previewLabel, 2, 0, 1, 2)
    self.groupBox.layout().addWidget(self.preview, 3, 0, 1, 2)
    self.groupBox.layout().addWidget(self.notice, 4, 0, 1, 2)

    self.groupBox.layout().addWidget(self.okButton, 5, 0)
    self.groupBox.layout().addWidget(self.cancelButton, 5, 1)

    self.layout().addWidget(self.groupBox, 1, 1)
Ejemplo n.º 9
0
    def setup(self):
        # Instantiate and connect widgets ...

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

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

        # fiber
        self.fiberSelector = slicer.qMRMLNodeComboBox(
            parametersCollapsibleButton)
        self.fiberSelector.nodeTypes = ["vtkMRMLFiberBundleNode"]
        self.fiberSelector.selectNodeUponCreation = False
        self.fiberSelector.addEnabled = False
        self.fiberSelector.removeEnabled = False
        self.fiberSelector.noneEnabled = True
        self.fiberSelector.showHidden = False
        self.fiberSelector.showChildNodeTypes = False
        self.fiberSelector.setMRMLScene(slicer.mrmlScene)
        self.fiberSelector.setToolTip("Pick the fiber bundle to be converted.")
        parametersFormLayout.addRow("Fiber Bundle", self.fiberSelector)

        # label map
        self.labelSelector = slicer.qMRMLNodeComboBox(
            parametersCollapsibleButton)
        self.labelSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.labelSelector.selectNodeUponCreation = False
        self.labelSelector.addEnabled = False
        self.labelSelector.removeEnabled = False
        self.labelSelector.noneEnabled = True
        self.labelSelector.showHidden = False
        self.labelSelector.showChildNodeTypes = False
        self.labelSelector.setMRMLScene(slicer.mrmlScene)
        self.labelSelector.setToolTip(
            "Pick the target label volume.  Must already exists in order to define sampling grid.  If needed, create one in the Editor module based on template volume."
        )
        parametersFormLayout.addRow("Target LabelMap", self.labelSelector)

        # label value
        self.labelValue = qt.QSpinBox(parametersCollapsibleButton)
        self.labelValue.setToolTip(
            "The numerical value for the rasterized fiber label.")
        self.labelValue.setValue(1)
        parametersFormLayout.addRow("Label Value", self.labelValue)

        # apply
        self.applyButton = qt.QPushButton(parametersCollapsibleButton)
        self.applyButton.text = "Apply"
        parametersFormLayout.addWidget(self.applyButton)

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

        # Add vertical spacer
        self.layout.addStretch(1)
Ejemplo n.º 10
0
    def __init__(self, parent=None):

        self._window = qt.QDialog(parent)
        self._window.setIcon(getPixmap("smart"))
        self._window.setCaption(_("New Package Priority"))
        self._window.setModal(True)

        #self._window.setMinimumSize(600, 400)

        vbox = qt.QVBox(self._window)
        vbox.setMargin(10)
        vbox.setSpacing(10)
        vbox.show()

        table = qt.QGrid(2, vbox)
        table.setSpacing(10)
        table.show()

        label = qt.QLabel(_("Package Name:"), table)

        self._name = qt.QLineEdit(table)
        self._name.show()

        label = qt.QLabel(_("Channel Alias:"), table)

        self._alias = qt.QLineEdit(table)
        self._alias.setText("*")
        self._alias.show()

        label = qt.QLabel(_("Priority:"), table)

        self._priority = qt.QSpinBox(table)
        self._priority.setSteps(1, 10)
        self._priority.setRange(-100000,+100000)
        self._priority.show()

        sep = qt.QFrame(vbox)
        sep.setFrameShape(qt.QFrame.HLine)
        sep.setFrameShadow(qt.QFrame.Sunken)
        sep.show()

        bbox = qt.QHBox(vbox)
        bbox.setSpacing(10)
        bbox.layout().addStretch(1)
        bbox.show()

        button = qt.QPushButton(_("Cancel"), bbox)
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("reject()"))

        button = qt.QPushButton(_("OK"), bbox)
        qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()"))

        button.setDefault(True)
        vbox.adjustSize()
        self._window.adjustSize()
Ejemplo n.º 11
0
    def setup(self):
        self.coefficientsSlider = slicer.qMRMLSliderWidget()
        self.coefficientsSlider.singleStep = 0.01
        self.coefficientsSlider.maximum = 2
        self.coefficientsSlider.value = self.getDefaultValue('coefficients')
        self.layout.addRow('Coefficients: ', self.coefficientsSlider)

        self.orderSpinBox = qt.QSpinBox()
        self.orderSpinBox.maximum = 6
        self.orderSpinBox.value = self.getDefaultValue('order')
        self.layout.addRow('Polynomial order: ', self.orderSpinBox)
Ejemplo n.º 12
0
    def setup(self):
        self.numSpikesSpinBox = qt.QSpinBox()
        self.numSpikesSpinBox.maximum = 10
        self.numSpikesSpinBox.value = self.getDefaultValue('num_spikes')
        self.layout.addRow('Spikes: ', self.numSpikesSpinBox)

        self.intensitySlider = slicer.qMRMLSliderWidget()
        self.intensitySlider.singleStep = 0.01
        self.intensitySlider.maximum = 5
        self.intensitySlider.value = np.mean(self.getDefaultValue('intensity'))
        self.layout.addRow('Intensity: ', self.intensitySlider)
Ejemplo n.º 13
0
  def _setupColorFrame(self):
    self.colorGroupBox = qt.QGroupBox("Color")
    self.colorGroupBoxLayout = qt.QHBoxLayout()
    self.colorGroupBox.setLayout(self.colorGroupBoxLayout)

    self.colorSpin = qt.QSpinBox()
    self.colorSpin.objectName = 'ColorSpinBox'
    self.colorSpin.setMaximum(64000) # TODO: should be detected from colorNode maximum value
    self.colorSpin.setToolTip( "Click colored patch at right to bring up color selection pop up window." )
    self.colorGroupBoxLayout.addWidget(self.colorSpin)

    self.colorPatch = self.createButton("", objectName="ColorPatchButton")
    self.colorGroupBoxLayout.addWidget(self.colorPatch)
    self.layout.addWidget(self.colorGroupBox)
Ejemplo n.º 14
0
 def setupUI(self):
   self.setWindowTitle("Case Number Selection")
   self.setText("Please select a case number for the new case.")
   self.setIcon(qt.QMessageBox.Question)
   self.spinbox = qt.QSpinBox()
   self.spinbox.setRange(self.minimum, int("9"*self.CASE_NUMBER_DIGITS))
   self.preview = qt.QLabel()
   self.notice = qt.QLabel()
   self.layout().addWidget(self.createVLayout([self.createHLayout([qt.QLabel("Proposed Case Number"), self.spinbox]),
                                               self.preview, self.notice]), 2, 1)
   self.okButton = self.addButton(self.Ok)
   self.okButton.enabled = False
   self.cancelButton = self.addButton(self.Cancel)
   self.setDefaultButton(self.okButton)
    def setup(self):
        self.numGhostsSpinBox = qt.QSpinBox()
        self.numGhostsSpinBox.maximum = 50
        default = int(np.mean(self.getDefaultValue('num_ghosts')))
        self.numGhostsSpinBox.value = default
        self.layout.addRow('Ghosts: ', self.numGhostsSpinBox)

        self.axesLayout, self.axesDict = self.makeAxesLayout()
        self.layout.addRow('Axes: ', self.axesLayout)

        self.intensitySlider = slicer.qMRMLSliderWidget()
        self.intensitySlider.singleStep = 0.01
        self.intensitySlider.maximum = 1
        self.intensitySlider.value = np.mean(self.getDefaultValue('intensity'))
        self.layout.addRow('Intensity: ', self.intensitySlider)
Ejemplo n.º 16
0
    def addField(self,
                 key,
                 label,
                 value,
                 ftype,
                 editable=True,
                 tip=None,
                 needed=False):

        if ftype is bool:
            spacer = qt.QWidget(self._table)
            spacer.show()
            widget = qt.QCheckBox(label, self._table)
            widget.setChecked(value)
        else:
            _label = qt.QLabel("%s:" % label, self._table)
            _label.show()
            if tip:
                qt.QToolTip.add(_label, tip)
            if ftype is int:
                widget = qt.QSpinBox(self._table)
                widget.setSteps(1, 10)
                widget.setRange(-100000, +100000)
                widget.setValue(value)
            elif ftype is str:
                widget = qt.QLineEdit(self._table)
                widget.setText(value)
                if key in ("alias", "type"):
                    #widget.setMaxLength(20)
                    pass  # "usually enough for about 15 to 20 characters"
                else:
                    widget.resize(
                        qt.QSize(widget.sizeHint().width() * 2,
                                 widget.sizeHint().height()))
            else:
                raise Error, _("Don't know how to handle %s fields") % ftype

        widget.show()

        widget.setEnabled(bool(editable))
        if tip:
            qt.QToolTip.add(widget, tip)

        self._fields[key] = widget
        self._fieldn += 1
Ejemplo n.º 17
0
    def create(self):
        self.frame = qt.QFrame(self.parent)
        self.frame.objectName = 'EditColorFrame'
        self.frame.setLayout(qt.QVBoxLayout())
        self.parent.layout().addWidget(self.frame)

        self.colorFrame = qt.QFrame(self.frame)
        self.colorFrame.setLayout(qt.QHBoxLayout())
        self.frame.layout().addWidget(self.colorFrame)

        self.label = qt.QLabel(self.colorFrame)
        self.label.setText("Label: ")
        self.colorFrame.layout().addWidget(self.label)

        self.labelName = qt.QLabel(self.colorFrame)
        self.labelName.setText("")
        self.colorFrame.layout().addWidget(self.labelName)

        self.colorSpin = qt.QSpinBox(self.colorFrame)
        self.colorSpin.objectName = 'ColorSpinBox'
        self.colorSpin.setMaximum(64000)
        self.colorSpin.setValue(EditUtil.getLabel())
        self.colorSpin.setToolTip(
            "Click colored patch at right to bring up color selection pop up window.  Use the 'c' key to bring up color popup menu."
        )
        self.colorFrame.layout().addWidget(self.colorSpin)

        self.colorPatch = qt.QPushButton(self.colorFrame)
        self.colorPatch.setObjectName('ColorPatchButton')
        self.colorFrame.layout().addWidget(self.colorPatch)

        self.updateParameterNode(slicer.mrmlScene,
                                 vtk.vtkCommand.ModifiedEvent)
        self.updateGUIFromMRML(self.parameterNode,
                               vtk.vtkCommand.ModifiedEvent)

        self.frame.connect('destroyed()', self.cleanup)
        self.colorSpin.connect('valueChanged(int)', self.updateMRMLFromGUI)
        self.colorPatch.connect('clicked()', self.showColorBox)

        # TODO: change this to look for specfic events (added, removed...)
        # but this requires being able to access events by number from wrapped code
        self.addObserver(slicer.mrmlScene, vtk.vtkCommand.ModifiedEvent,
                         self.updateParameterNode)
Ejemplo n.º 18
0
  def buildGUI(self, parent):

    connectorGroupBox = ctk.ctkCollapsibleGroupBox()
    connectorGroupBox.title = self.cname
    parent.addWidget(connectorGroupBox)
    connectorFormLayout = qt.QFormLayout(connectorGroupBox)
    
    
    if self.connectorSelector == None:
      self.connectorSelector = slicer.qMRMLNodeComboBox()
      self.connectorSelector.nodeTypes = ( ("vtkMRMLIGTLConnectorNode"), "" )
      self.connectorSelector.selectNodeUponCreation = True
      self.connectorSelector.addEnabled = True
      self.connectorSelector.removeEnabled = False
      self.connectorSelector.noneEnabled = False
      self.connectorSelector.showHidden = False
      self.connectorSelector.showChildNodeTypes = False
      self.connectorSelector.setMRMLScene( slicer.mrmlScene )
      self.connectorSelector.setToolTip( "Establish a connection with the server" )
      connectorFormLayout.addRow("Connector: ", self.connectorSelector)

    if self.portSpinBox == None:
      self.portSpinBox = qt.QSpinBox()
      self.portSpinBox.objectName = 'PortSpinBox'
      self.portSpinBox.setMaximum(64000)
      self.portSpinBox.setValue(self.port)
      self.portSpinBox.setToolTip("Port number of the server")
      connectorFormLayout.addRow("Port: ", self.portSpinBox)

    # check box to trigger transform conversion
    if self.activeConnectionCheckBox == None:
      self.activeConnectionCheckBox = qt.QCheckBox()
      self.activeConnectionCheckBox.checked = 0
      self.activeConnectionCheckBox.enabled = 0
      self.activeConnectionCheckBox.setToolTip("Activate OpenIGTLink connection")
      connectorFormLayout.addRow("Active: ", self.activeConnectionCheckBox)


    #--------------------------------------------------
    # Connections
    #--------------------------------------------------
    self.connectorSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onConnectorSelected)
    self.activeConnectionCheckBox.connect('toggled(bool)', self.onActiveConnection)
Ejemplo n.º 19
0
    def setup(self):
        degrees = self.getDefaultValue('degrees')
        self.degreesSlider = self.makeRangeWidget(-180, -degrees, degrees, 180,
                                                  1, 'degrees')
        self.layout.addRow('Degrees: ', self.degreesSlider)

        translation = self.getDefaultValue('translation')
        self.translationSlider = self.makeRangeWidget(-50, -translation,
                                                      translation, 50, 1,
                                                      'translation')
        self.layout.addRow('Translation: ', self.translationSlider)

        self.numTransformsSpinBox = qt.QSpinBox()
        self.numTransformsSpinBox.maximum = 10
        self.numTransformsSpinBox.value = self.getDefaultValue(
            'num_transforms')
        self.layout.addRow('Number of motions: ', self.numTransformsSpinBox)

        self.interpolationComboBox = self.makeInterpolationComboBox()
        self.layout.addRow('Interpolation: ', self.interpolationComboBox)
    def setupOptionsFrame(self):
        # mask inside/outside the surface checkbox
        self.maskOutsideSurfaceCheckBox = qt.QCheckBox()
        self.maskOutsideSurfaceCheckBox.checked = False
        self.maskOutsideSurfaceCheckBox.setToolTip(
            "If checked, voxel values will be filled outside the segment.")
        self.scriptedEffect.addLabeledOptionsWidget(
            "Mask outside: ", self.maskOutsideSurfaceCheckBox)

        # outside fill value
        self.fillValueEdit = qt.QSpinBox()
        self.fillValueEdit.setToolTip(
            "Choose the voxel intensity that will be used to fill the masked region."
        )
        self.fillValueEdit.minimum = -32768
        self.fillValueEdit.maximum = 65535
        self.scriptedEffect.addLabeledOptionsWidget("Fill value: ",
                                                    self.fillValueEdit)

        # output volume selector
        self.outputVolumeSelector = slicer.qMRMLNodeComboBox()
        self.outputVolumeSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.outputVolumeSelector.selectNodeUponCreation = True
        self.outputVolumeSelector.addEnabled = True
        self.outputVolumeSelector.removeEnabled = True
        self.outputVolumeSelector.noneEnabled = False
        self.outputVolumeSelector.showHidden = False
        self.outputVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.outputVolumeSelector.setToolTip(
            "Masked output volume. It may be the same as the input volume for cumulative masking."
        )
        self.scriptedEffect.addLabeledOptionsWidget("Output Volume: ",
                                                    self.outputVolumeSelector)

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.objectName = self.__class__.__name__ + 'Apply'
        self.applyButton.setToolTip("Apply segment as volume mask")
        self.scriptedEffect.addOptionsWidget(self.applyButton)
        self.applyButton.connect('clicked()', self.onApply)
Ejemplo n.º 21
0
  def __init__( self, parent = None ):
    qt.QFrame.__init__( self )
  
    self.parameterNode = None

    #
    # Parameters area
    #    
    self.parametersLayout = qt.QFormLayout( self )
    self.setLayout( self.parametersLayout )
        
    #
    # Polynomial regression order spin box
    #    
    self.regressionOrderSpinBox = qt.QSpinBox()
    self.regressionOrderSpinBox.setRange( 1, 10 )
    self.regressionOrderSpinBox.setSingleStep( 1 )
    self.regressionOrderSpinBox.setToolTip( "Choose the order of polynomial fit for the regression model." )
    self.parametersLayout.addRow( "Order ", self.regressionOrderSpinBox )
    
    # connections
    self.regressionOrderSpinBox.connect( 'valueChanged(int)', self.onRegressionOrderChanged )
Ejemplo n.º 22
0
    def setup(self):
        self.setLayout(qt.QGridLayout())
        settingNames = self.getSettingNames()
        for index, setting in enumerate(settingNames):
            label = self.createLabel(setting)
            value = self.getSetting(setting)
            if value.lower() in ["true", "false"]:
                element = qt.QCheckBox()
                element.checked = value.lower() == "true"
            elif value.isdigit():
                element = qt.QSpinBox()
                element.value = int(value)
            elif os.path.exists(value):
                element = ctk.ctkPathLineEdit()
                if os.path.isdir(value):
                    element.filters = ctk.ctkPathLineEdit.Dirs
                else:
                    element.filters = ctk.ctkPathLineEdit.Files
                element.currentPath = value
            else:
                element = self.createLineEdit(value)
                element.minimumWidth = self.getMinimumTextWidth(
                    element.text) + 10

            self.layout().addWidget(label, index, 0)
            self.layout().addWidget(element, index, 1, 1,
                                    qt.QSizePolicy.ExpandFlag)
            self.keyElementPairs.append((label.text, element))

        self.okButton = self.createButton("OK")
        self.cancelButton = self.createButton("Cancel")

        self.addButton(self.okButton, qt.QMessageBox.AcceptRole)
        self.addButton(self.cancelButton, qt.QMessageBox.NoRole)

        self.layout().addWidget(
            self.createHLayout([self.okButton, self.cancelButton]),
            len(settingNames), 1)
        self.okButton.clicked.connect(self.onOkButtonClicked)
Ejemplo n.º 23
0
    def __init__(self, parent=None):
        qt.QFrame.__init__(self)

        self.parameterNode = None

        #
        # Parameters area
        #
        self.parametersLayout = qt.QFormLayout(self)
        self.setLayout(self.parametersLayout)

        #
        # Combination method combo box
        #
        self.neighborWeightComboBox = qt.QComboBox()
        self.neighborWeightComboBox.addItem(NEIGHBOR_WEIGHT_EQUAL)
        self.neighborWeightComboBox.addItem(NEIGHBOR_WEIGHT_DISTANCE)
        self.neighborWeightComboBox.addItem(NEIGHBOR_WEIGHT_RANK)
        self.neighborWeightComboBox.setToolTip(
            "Choose the weighting scheme for neighbors.")
        self.parametersLayout.addRow("Weighting ", self.neighborWeightComboBox)

        #
        # Number of neighbors
        #
        self.numberOfNeighborsSpinBox = qt.QSpinBox()
        self.numberOfNeighborsSpinBox.setRange(1, 100)
        self.numberOfNeighborsSpinBox.setSingleStep(1)
        self.numberOfNeighborsSpinBox.setToolTip(
            "Choose the number of neighbors (k).")
        self.parametersLayout.addRow("Neighbors  ",
                                     self.numberOfNeighborsSpinBox)

        # connections
        self.neighborWeightComboBox.connect('currentIndexChanged(QString)',
                                            self.onNeighborWeightChanged)
        self.numberOfNeighborsSpinBox.connect('valueChanged(int)',
                                              self.onNumberOfNeighborsChanged)
Ejemplo n.º 24
0
    def setup(self):
        self.controlPointsWidget = CoordinatesWidget(
            decimals=0,
            coordinates=self.getDefaultValue('num_control_points'),
        )
        self.layout.addRow('Control points: ', self.controlPointsWidget.widget)

        self.maxDisplacementWidget = CoordinatesWidget(
            decimals=2,
            coordinates=self.getDefaultValue('max_displacement'),
            step=0.1,
        )
        self.layout.addRow('Maximum displacement: ',
                           self.maxDisplacementWidget.widget)

        self.lockedBordersSpinBox = qt.QSpinBox()
        self.lockedBordersSpinBox.maximum = 2
        self.lockedBordersSpinBox.value = self.getDefaultValue(
            'locked_borders')
        self.layout.addRow('Locked borders: ', self.lockedBordersSpinBox)

        self.interpolationComboBox = self.makeInterpolationComboBox()
        self.layout.addRow('Interpolation: ', self.interpolationComboBox)
    def onInputShapesDirectoryChanged(self):
        inputShapesDirectory = self.shapeInputDirectory.directory.encode(
            'utf-8')
        row = 0
        for file in sorted(os.listdir(inputShapesDirectory)):
            if file.endswith(".vtk"):
                self.tableWidget_inputShapeParameters.setRowCount(row + 1)

                # Column 0:
                rootname = os.path.basename(file).split(".")[0]
                labelVTKFile = qt.QLabel(rootname)
                labelVTKFile.setAlignment(0x84)
                self.tableWidget_inputShapeParameters.setCellWidget(
                    row, 0, labelVTKFile)

                # Column 1-2-3-4:
                for column in range(1, 5):
                    widget = qt.QWidget()
                    layout = qt.QHBoxLayout(widget)
                    if not column == 2:
                        spinBox = qt.QSpinBox()
                        if column == 1:
                            spinBox.connect('valueChanged(int)',
                                            self.onDefaultTimePointRange)
                        if column == 4:
                            spinBox.value = 1
                    else:
                        spinBox = qt.QDoubleSpinBox()
                    spinBox.setMinimum(0)
                    layout.addWidget(spinBox)
                    layout.setAlignment(0x84)
                    layout.setContentsMargins(0, 0, 0, 0)
                    widget.setLayout(layout)
                    self.tableWidget_inputShapeParameters.setCellWidget(
                        row, column, widget)

                row = row + 1
Ejemplo n.º 26
0
 def onSelectInputModels(self):
     InputModelsDirectory = self.GroupsInputModelsDirectory.directory.encode(
         'utf-8')
     self.InputModelsDirectory = InputModelsDirectory
     self.PropertiesNames = []
     listMesh = os.listdir(InputModelsDirectory)
     if listMesh.count(".DS_Store"):
         listMesh.remove(".DS_Store")
     #VTKfilepath = os.path.join( modelsDir, listMesh[0])
     VTKfilepath = InputModelsDirectory + '/' + listMesh[0]
     if os.path.exists(VTKfilepath):
         reader = vtk.vtkPolyDataReader()
         reader.SetFileName(VTKfilepath)
         reader.Update()
         polydata = reader.GetOutput()
         for i in range(polydata.GetPointData().GetNumberOfArrays()):
             self.PropertiesNames.append(
                 polydata.GetPointData().GetArrayName(i))
     row = 0
     for PropertyName in self.PropertiesNames:
         self.GroupsProperties.setRowCount(row + 1)
         # Column 0:
         labelPropertyName = qt.QLabel(PropertyName)
         labelPropertyName.setAlignment(0x84)
         self.GroupsProperties.setCellWidget(row, 0, labelPropertyName)
         # Column 1:
         widget = qt.QWidget()
         layout = qt.QHBoxLayout(widget)
         spinBox = qt.QSpinBox()
         spinBox.setMinimum(0)
         layout.addWidget(spinBox)
         layout.setAlignment(0x84)
         layout.setContentsMargins(0, 0, 0, 0)
         widget.setLayout(layout)
         self.GroupsProperties.setCellWidget(row, 1, widget)
         row = row + 1
Ejemplo n.º 27
0
    def create(self):
        super(IslandEffectOptions, self).create()
        self.fullyConnected = qt.QCheckBox("Fully Connected", self.frame)
        self.fullyConnected.setToolTip(
            "When set, only pixels that share faces (not corners or edges) are considered connected."
        )
        self.frame.layout().addWidget(self.fullyConnected)
        self.widgets.append(self.fullyConnected)

        self.sizeLabel = qt.QLabel("Minimum Size", self.frame)
        self.sizeLabel.setToolTip("Minimum size of islands to be considered.")
        self.frame.layout().addWidget(self.sizeLabel)
        self.widgets.append(self.sizeLabel)
        self.minimumSize = qt.QSpinBox(self.frame)
        self.minimumSize.minimum = 0
        self.minimumSize.maximum = vtk.VTK_INT_MAX
        self.minimumSize.value = 0
        self.frame.layout().addWidget(self.minimumSize)
        self.widgets.append(self.minimumSize)

        self.connections.append(
            (self.fullyConnected, "clicked()", self.updateMRMLFromGUI))
        self.connections.append(
            (self.minimumSize, "valueChanged(int)", self.updateMRMLFromGUI))
  def setupOptionsFrame(self):
    self.operationRadioButtons = []

    # Fill operation buttons
    self.fillInsideButton = qt.QRadioButton("Fill inside")
    self.operationRadioButtons.append(self.fillInsideButton)
    self.buttonToOperationNameMap[self.fillInsideButton] = 'FILL_INSIDE'

    self.fillOutsideButton = qt.QRadioButton("Fill outside")
    self.operationRadioButtons.append(self.fillOutsideButton)
    self.buttonToOperationNameMap[self.fillOutsideButton] = 'FILL_OUTSIDE'

    self.binaryMaskFillButton = qt.QRadioButton("Fill inside and outside")
    self.binaryMaskFillButton.setToolTip("Create a labelmap volume with specified inside and outside fill values.")
    self.operationRadioButtons.append(self.binaryMaskFillButton)
    self.buttonToOperationNameMap[self.binaryMaskFillButton] = 'FILL_INSIDE_AND_OUTSIDE'

    # Operation buttons layout
    operationLayout = qt.QGridLayout()
    operationLayout.addWidget(self.fillInsideButton, 0, 0)
    operationLayout.addWidget(self.fillOutsideButton, 1, 0)
    operationLayout.addWidget(self.binaryMaskFillButton, 0, 1)
    self.scriptedEffect.addLabeledOptionsWidget("Operation:", operationLayout)

    # fill value
    self.fillValueEdit = qt.QSpinBox()
    self.fillValueEdit.setToolTip("Choose the voxel intensity that will be used to fill the masked region.")
    self.fillValueEdit.minimum = -32768
    self.fillValueEdit.maximum = 65535
    self.fillValueEdit.connect("valueChanged(int)", self.fillValueChanged)
    self.fillValueLabel = qt.QLabel("Fill value: ")

    # Binary mask fill outside value
    self.binaryMaskFillOutsideEdit = qt.QSpinBox()
    self.binaryMaskFillOutsideEdit.setToolTip("Choose the voxel intensity that will be used to fill outside the mask.")
    self.binaryMaskFillOutsideEdit.minimum = -32768
    self.binaryMaskFillOutsideEdit.maximum = 65535
    self.binaryMaskFillOutsideEdit.connect("valueChanged(int)", self.fillValueChanged)
    self.fillOutsideLabel = qt.QLabel("Outside fill value: ")

    # Binary mask fill outside value
    self.binaryMaskFillInsideEdit = qt.QSpinBox()
    self.binaryMaskFillInsideEdit.setToolTip("Choose the voxel intensity that will be used to fill inside the mask.")
    self.binaryMaskFillInsideEdit.minimum = -32768
    self.binaryMaskFillInsideEdit.maximum = 65535
    self.binaryMaskFillInsideEdit.connect("valueChanged(int)", self.fillValueChanged)
    self.fillInsideLabel = qt.QLabel(" Inside fill value: ")

    # Fill value layouts
    fillValueLayout = qt.QFormLayout()
    fillValueLayout.addRow(self.fillValueLabel, self.fillValueEdit)

    fillOutsideLayout = qt.QFormLayout()
    fillOutsideLayout.addRow(self.fillOutsideLabel, self.binaryMaskFillOutsideEdit)

    fillInsideLayout = qt.QFormLayout()
    fillInsideLayout.addRow(self.fillInsideLabel, self.binaryMaskFillInsideEdit)

    binaryMaskFillLayout = qt.QHBoxLayout()
    binaryMaskFillLayout.addLayout(fillOutsideLayout)
    binaryMaskFillLayout.addLayout(fillInsideLayout)
    fillValuesSpinBoxLayout = qt.QFormLayout()
    fillValuesSpinBoxLayout.addRow(binaryMaskFillLayout)
    fillValuesSpinBoxLayout.addRow(fillValueLayout)
    self.scriptedEffect.addOptionsWidget(fillValuesSpinBoxLayout)

    # input volume selector
    self.inputVolumeSelector = slicer.qMRMLNodeComboBox()
    self.inputVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputVolumeSelector.selectNodeUponCreation = True
    self.inputVolumeSelector.addEnabled = True
    self.inputVolumeSelector.removeEnabled = True
    self.inputVolumeSelector.noneEnabled = True
    self.inputVolumeSelector.noneDisplay = "(Master volume)"
    self.inputVolumeSelector.showHidden = False
    self.inputVolumeSelector.setMRMLScene(slicer.mrmlScene)
    self.inputVolumeSelector.setToolTip("Volume to mask. Default is current master volume node.")
    self.inputVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onInputVolumeChanged)

    self.inputVisibilityButton = qt.QToolButton()
    self.inputVisibilityButton.setIcon(qt.QIcon(":/Icons/Small/SlicerInvisible.png"))
    self.inputVisibilityButton.setAutoRaise(True)
    self.inputVisibilityButton.setCheckable(True)
    self.inputVisibilityButton.connect('clicked()', self.onInputVisibilityButtonClicked)
    inputLayout = qt.QHBoxLayout()
    inputLayout.addWidget(self.inputVisibilityButton)
    inputLayout.addWidget(self.inputVolumeSelector)
    self.scriptedEffect.addLabeledOptionsWidget("Input Volume: ", inputLayout)

    # output volume selector
    self.outputVolumeSelector = slicer.qMRMLNodeComboBox()
    self.outputVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode", "vtkMRMLLabelMapVolumeNode"]
    self.outputVolumeSelector.selectNodeUponCreation = True
    self.outputVolumeSelector.addEnabled = True
    self.outputVolumeSelector.removeEnabled = True
    self.outputVolumeSelector.renameEnabled = True
    self.outputVolumeSelector.noneEnabled = True
    self.outputVolumeSelector.noneDisplay = "(Create new Volume)"
    self.outputVolumeSelector.showHidden = False
    self.outputVolumeSelector.setMRMLScene( slicer.mrmlScene )
    self.outputVolumeSelector.setToolTip("Masked output volume. It may be the same as the input volume for cumulative masking.")
    self.outputVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onOutputVolumeChanged)

    self.outputVisibilityButton = qt.QToolButton()
    self.outputVisibilityButton.setIcon(qt.QIcon(":/Icons/Small/SlicerInvisible.png"))
    self.outputVisibilityButton.setAutoRaise(True)
    self.outputVisibilityButton.setCheckable(True)
    self.outputVisibilityButton.connect('clicked()', self.onOutputVisibilityButtonClicked)
    outputLayout = qt.QHBoxLayout()
    outputLayout.addWidget(self.outputVisibilityButton)
    outputLayout.addWidget(self.outputVolumeSelector)
    self.scriptedEffect.addLabeledOptionsWidget("Output Volume: ", outputLayout)

    # Apply button
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.objectName = self.__class__.__name__ + 'Apply'
    self.applyButton.setToolTip("Apply segment as volume mask. No undo operation available once applied.")
    self.scriptedEffect.addOptionsWidget(self.applyButton)
    self.applyButton.connect('clicked()', self.onApply)

    for button in self.operationRadioButtons:
      button.connect('toggled(bool)',
      lambda toggle, widget=self.buttonToOperationNameMap[button]: self.onOperationSelectionChanged(widget, toggle))
Ejemplo n.º 29
0
    def setupOptionsFrame(self):
        self.operationRadioButtons = []

        self.keepLargestOptionRadioButton = qt.QRadioButton(
            "Keep largest island")
        self.keepLargestOptionRadioButton.setToolTip(
            "Keep only the largest island in selected segment, remove all other islands in the segment."
        )
        self.operationRadioButtons.append(self.keepLargestOptionRadioButton)
        self.widgetToOperationNameMap[
            self.keepLargestOptionRadioButton] = KEEP_LARGEST_ISLAND

        self.keepSelectedOptionRadioButton = qt.QRadioButton(
            "Keep selected island")
        self.keepSelectedOptionRadioButton.setToolTip(
            "Click on an island in a slice viewer to keep that island and remove all other islands in selected segment."
        )
        self.operationRadioButtons.append(self.keepSelectedOptionRadioButton)
        self.widgetToOperationNameMap[
            self.keepSelectedOptionRadioButton] = KEEP_SELECTED_ISLAND

        self.removeSmallOptionRadioButton = qt.QRadioButton(
            "Remove small islands")
        self.removeSmallOptionRadioButton.setToolTip(
            "Remove all islands from the selected segment that are smaller than the specified minimum size."
        )
        self.operationRadioButtons.append(self.removeSmallOptionRadioButton)
        self.widgetToOperationNameMap[
            self.removeSmallOptionRadioButton] = REMOVE_SMALL_ISLANDS

        self.removeSelectedOptionRadioButton = qt.QRadioButton(
            "Remove selected island")
        self.removeSelectedOptionRadioButton.setToolTip(
            "Click on an island to remove it from selected segment.")
        self.operationRadioButtons.append(self.removeSelectedOptionRadioButton)
        self.widgetToOperationNameMap[
            self.removeSelectedOptionRadioButton] = REMOVE_SELECTED_ISLAND

        self.addSelectedOptionRadioButton = qt.QRadioButton(
            "Add selected island")
        self.addSelectedOptionRadioButton.setToolTip(
            "Click on a region to add it to selected segment.")
        self.operationRadioButtons.append(self.addSelectedOptionRadioButton)
        self.widgetToOperationNameMap[
            self.addSelectedOptionRadioButton] = ADD_SELECTED_ISLAND

        self.splitAllOptionRadioButton = qt.QRadioButton(
            "Split islands to segments")
        self.splitAllOptionRadioButton.setToolTip(
            "Create a new segment for each island of selected segment. Islands smaller than minimum size will be removed. "
            + "Segments will be ordered by island size.")
        self.operationRadioButtons.append(self.splitAllOptionRadioButton)
        self.widgetToOperationNameMap[
            self.splitAllOptionRadioButton] = SPLIT_ISLANDS_TO_SEGMENTS

        operationLayout = qt.QGridLayout()
        operationLayout.addWidget(self.keepLargestOptionRadioButton, 0, 0)
        operationLayout.addWidget(self.removeSmallOptionRadioButton, 1, 0)
        operationLayout.addWidget(self.splitAllOptionRadioButton, 2, 0)
        operationLayout.addWidget(self.keepSelectedOptionRadioButton, 0, 1)
        operationLayout.addWidget(self.removeSelectedOptionRadioButton, 1, 1)
        operationLayout.addWidget(self.addSelectedOptionRadioButton, 2, 1)

        self.operationRadioButtons[0].setChecked(True)
        self.scriptedEffect.addOptionsWidget(operationLayout)

        self.minimumSizeSpinBox = qt.QSpinBox()
        self.minimumSizeSpinBox.setToolTip(
            "Minimum size of islands to be considered.")
        self.minimumSizeSpinBox.setMinimum(0)
        self.minimumSizeSpinBox.setMaximum(vtk.VTK_INT_MAX)
        self.minimumSizeSpinBox.setValue(1000)
        self.minimumSizeLabel = self.scriptedEffect.addLabeledOptionsWidget(
            "Minimum size:", self.minimumSizeSpinBox)

        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.objectName = self.__class__.__name__ + 'Apply'
        self.scriptedEffect.addOptionsWidget(self.applyButton)

        for operationRadioButton in self.operationRadioButtons:
            operationRadioButton.connect(
                'toggled(bool)',
                lambda toggle, widget=self.widgetToOperationNameMap[
                    operationRadioButton]: self.onOperationSelectionChanged(
                        widget, toggle))

        self.minimumSizeSpinBox.connect('valueChanged(int)',
                                        self.updateMRMLFromGUI)

        self.applyButton.connect('clicked()', self.onApply)
Ejemplo n.º 30
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        try:
            import vtkvmtkSegmentationPython as vtkvmtkSegmentation
        except ImportError:
            self.layout.addWidget(qt.QLabel("Failed to load VMTK libraries"))
            return

        #
        # the I/O panel
        #

        ioCollapsibleButton = ctk.ctkCollapsibleButton()
        ioCollapsibleButton.text = "Input/Output"
        self.layout.addWidget(ioCollapsibleButton)
        ioFormLayout = qt.QFormLayout(ioCollapsibleButton)

        # inputVolume selector
        self.inputVolumeNodeSelector = slicer.qMRMLNodeComboBox()
        self.inputVolumeNodeSelector.objectName = 'inputVolumeNodeSelector'
        self.inputVolumeNodeSelector.toolTip = "Select the input volume."
        self.inputVolumeNodeSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.inputVolumeNodeSelector.noneEnabled = False
        self.inputVolumeNodeSelector.addEnabled = False
        self.inputVolumeNodeSelector.removeEnabled = False
        ioFormLayout.addRow("Input Volume:", self.inputVolumeNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.inputVolumeNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        # seed selector
        self.seedFiducialsNodeSelector = slicer.qSlicerSimpleMarkupsWidget()
        self.seedFiducialsNodeSelector.objectName = 'seedFiducialsNodeSelector'
        self.seedFiducialsNodeSelector = slicer.qSlicerSimpleMarkupsWidget()
        self.seedFiducialsNodeSelector.objectName = 'seedFiducialsNodeSelector'
        self.seedFiducialsNodeSelector.toolTip = "Select a point in the largest vessel. Preview will be shown around this point. This is point is also used for determining maximum vessel diameter if automatic filtering parameters computation is enabled."
        self.seedFiducialsNodeSelector.setNodeBaseName("DiameterSeed")
        self.seedFiducialsNodeSelector.tableWidget().hide()
        self.seedFiducialsNodeSelector.defaultNodeColor = qt.QColor(255, 0,
                                                                    0)  # red
        self.seedFiducialsNodeSelector.markupsSelectorComboBox(
        ).noneEnabled = False
        self.seedFiducialsNodeSelector.markupsPlaceWidget(
        ).placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceSingleMarkup
        ioFormLayout.addRow("Seed point:", self.seedFiducialsNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.seedFiducialsNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        # outputVolume selector
        self.outputVolumeNodeSelector = slicer.qMRMLNodeComboBox()
        self.outputVolumeNodeSelector.toolTip = "Select the output labelmap."
        self.outputVolumeNodeSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.outputVolumeNodeSelector.baseName = "VesselnessFiltered"
        self.outputVolumeNodeSelector.noneEnabled = True
        self.outputVolumeNodeSelector.noneDisplay = "Create new volume"
        self.outputVolumeNodeSelector.addEnabled = True
        self.outputVolumeNodeSelector.selectNodeUponCreation = True
        self.outputVolumeNodeSelector.removeEnabled = True
        ioFormLayout.addRow("Output Volume:", self.outputVolumeNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.outputVolumeNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        #
        # Advanced area
        #

        self.advancedCollapsibleButton = ctk.ctkCollapsibleButton()
        self.advancedCollapsibleButton.text = "Advanced"
        self.advancedCollapsibleButton.collapsed = True
        self.layout.addWidget(self.advancedCollapsibleButton)
        advancedFormLayout = qt.QFormLayout(self.advancedCollapsibleButton)

        # previewVolume selector
        self.previewVolumeNodeSelector = slicer.qMRMLNodeComboBox()
        self.previewVolumeNodeSelector.toolTip = "Select the preview volume."
        self.previewVolumeNodeSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.previewVolumeNodeSelector.baseName = "VesselnessPreview"
        self.previewVolumeNodeSelector.noneEnabled = True
        self.previewVolumeNodeSelector.noneDisplay = "Create new volume"
        self.previewVolumeNodeSelector.addEnabled = True
        self.previewVolumeNodeSelector.selectNodeUponCreation = True
        self.previewVolumeNodeSelector.removeEnabled = True
        advancedFormLayout.addRow("Preview volume:",
                                  self.previewVolumeNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.previewVolumeNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        self.displayThresholdSlider = ctk.ctkSliderWidget()
        self.displayThresholdSlider.decimals = 2
        self.displayThresholdSlider.minimum = 0
        self.displayThresholdSlider.maximum = 1.0
        self.displayThresholdSlider.singleStep = 0.01
        self.displayThresholdSlider.toolTip = "Voxels below this vesselness value will be hidden. It does not change the voxel values, only how the vesselness volume is displayed."
        advancedFormLayout.addRow("Display threshold:",
                                  self.displayThresholdSlider)
        self.displayThresholdSlider.connect('valueChanged(double)',
                                            self.onDisplayThresholdChanged)

        self.previewVolumeDiameterVoxelSlider = ctk.ctkSliderWidget()
        self.previewVolumeDiameterVoxelSlider.decimals = 0
        self.previewVolumeDiameterVoxelSlider.minimum = 10
        self.previewVolumeDiameterVoxelSlider.maximum = 200
        self.previewVolumeDiameterVoxelSlider.singleStep = 5
        self.previewVolumeDiameterVoxelSlider.suffix = " voxels"
        self.previewVolumeDiameterVoxelSlider.toolTip = "Diameter of the preview area in voxels."
        advancedFormLayout.addRow("Preview volume size:",
                                  self.previewVolumeDiameterVoxelSlider)

        # detect filterint parameters
        self.detectPushButton = qt.QPushButton()
        self.detectPushButton.text = "Compute vessel diameters and contrast from seed point"
        self.detectPushButton.checkable = True
        self.detectPushButton.checked = True
        advancedFormLayout.addRow(self.detectPushButton)
        self.detectPushButton.connect("clicked()", self.onNodeSelectionChanged)

        self.minimumDiameterSpinBox = qt.QSpinBox()
        self.minimumDiameterSpinBox.minimum = 1
        self.minimumDiameterSpinBox.maximum = 1000
        self.minimumDiameterSpinBox.singleStep = 1
        self.minimumDiameterSpinBox.suffix = " voxels"
        self.minimumDiameterSpinBox.enabled = False
        self.minimumDiameterSpinBox.toolTip = "Tubular structures that have minimum this diameter will be enhanced."
        advancedFormLayout.addRow("Minimum vessel diameter:",
                                  self.minimumDiameterSpinBox)
        self.detectPushButton.connect("toggled(bool)",
                                      self.minimumDiameterSpinBox.setDisabled)

        self.maximumDiameterSpinBox = qt.QSpinBox()
        self.maximumDiameterSpinBox.minimum = 0
        self.maximumDiameterSpinBox.maximum = 1000
        self.maximumDiameterSpinBox.singleStep = 1
        self.maximumDiameterSpinBox.suffix = " voxels"
        self.maximumDiameterSpinBox.enabled = False
        self.maximumDiameterSpinBox.toolTip = "Tubular structures that have maximum this diameter will be enhanced."
        advancedFormLayout.addRow("Maximum vessel diameter:",
                                  self.maximumDiameterSpinBox)
        self.detectPushButton.connect("toggled(bool)",
                                      self.maximumDiameterSpinBox.setDisabled)

        self.contrastSlider = ctk.ctkSliderWidget()
        self.contrastSlider.decimals = 0
        self.contrastSlider.minimum = 0
        self.contrastSlider.maximum = 500
        self.contrastSlider.singleStep = 10
        self.contrastSlider.enabled = False
        self.contrastSlider.toolTip = "If the intensity contrast in the input image between vessel and background is high, choose a high value else choose a low value."
        advancedFormLayout.addRow("Vessel contrast:", self.contrastSlider)
        self.detectPushButton.connect("toggled(bool)",
                                      self.contrastSlider.setDisabled)

        self.suppressPlatesSlider = ctk.ctkSliderWidget()
        self.suppressPlatesSlider.decimals = 0
        self.suppressPlatesSlider.minimum = 0
        self.suppressPlatesSlider.maximum = 100
        self.suppressPlatesSlider.singleStep = 1
        self.suppressPlatesSlider.suffix = " %"
        self.suppressPlatesSlider.toolTip = "A higher value filters out more plate-like structures."
        advancedFormLayout.addRow("Suppress plates:",
                                  self.suppressPlatesSlider)

        self.suppressBlobsSlider = ctk.ctkSliderWidget()
        self.suppressBlobsSlider.decimals = 0
        self.suppressBlobsSlider.minimum = 0
        self.suppressBlobsSlider.maximum = 100
        self.suppressBlobsSlider.singleStep = 1
        self.suppressBlobsSlider.suffix = " %"
        self.suppressBlobsSlider.toolTip = "A higher value filters out more blob-like structures."
        advancedFormLayout.addRow("Suppress blobs:", self.suppressBlobsSlider)

        #
        # Reset, preview and apply buttons
        #

        self.buttonBox = qt.QDialogButtonBox()
        self.resetButton = self.buttonBox.addButton(
            self.buttonBox.RestoreDefaults)
        self.resetButton.toolTip = "Click to reset all input elements to default."
        self.previewButton = self.buttonBox.addButton(self.buttonBox.Discard)
        self.previewButton.setIcon(qt.QIcon())
        self.previewButton.text = "Preview"
        self.startButton = self.buttonBox.addButton(self.buttonBox.Apply)
        self.startButton.setIcon(qt.QIcon())
        self.startButton.text = "Start"
        self.startButton.enabled = False
        self.layout.addWidget(self.buttonBox)
        self.resetButton.connect("clicked()", self.restoreDefaults)
        self.previewButton.connect("clicked()", self.onPreviewButtonClicked)
        self.startButton.connect("clicked()", self.onStartButtonClicked)

        self.inputVolumeNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.seedFiducialsNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.outputVolumeNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.previewVolumeNodeSelector.setMRMLScene(slicer.mrmlScene)

        self.inputVolumeNodeSelector.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onNodeSelectionChanged)
        self.seedFiducialsNodeSelector.markupsSelectorComboBox().connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onNodeSelectionChanged)
        self.seedFiducialsNodeSelector.connect("updateFinished()",
                                               self.onNodeSelectionChanged)

        # set default values
        self.restoreDefaults()

        self.onNodeSelectionChanged()

        # compress the layout
        self.layout.addStretch(1)