def create(self):
    super(InterpolateROIsEffectOptions,self).create()

    self.minimumSigma = 0.01
    self.maximumSigma = 1.5

    self.sigmaFrame = qt.QFrame(self.frame)
    self.sigmaFrame.setLayout(qt.QHBoxLayout())
    self.frame.layout().addWidget(self.sigmaFrame)
    self.widgets.append(self.sigmaFrame)
    self.sigmaLabel = qt.QLabel("Sigma:", self.sigmaFrame)
    self.sigmaLabel.setToolTip("Set the sigma of the gaussian filter")
    self.sigmaFrame.layout().addWidget(self.sigmaLabel)
    self.widgets.append(self.sigmaLabel)
    self.sigmaSpinBox = slicer.qMRMLSpinBox(self.sigmaFrame)
    self.sigmaSpinBox.objectName = 'SpinBox_Sigma'
    self.sigmaSpinBox.setToolTip("Set the sigma of the gaussian filter")
    #self.sigmaSpinBox.quantity = "length"
    # QFlags not wrapped in python. Equivalent to Prefix | Suffix
    # See qMRMLSpinBox for more details.
    self.sigmaSpinBox.unitAwareProperties = 0x01 | 0x02
    self.sigmaSpinBox.decimals = 2
    self.sigmaSpinBox.minimum = self.minimumSigma
    self.sigmaSpinBox.maximum = self.maximumSigma
    self.sigmaSpinBox.singleStep = self.minimumSigma
    self.sigmaSpinBox.setMRMLScene(slicer.mrmlScene)
    self.sigmaFrame.layout().addWidget(self.sigmaSpinBox)
    self.widgets.append(self.sigmaSpinBox)

    self.sigma = ctk.ctkDoubleSlider(self.frame)
    self.sigma.objectName = 'DoubleSlider_Sigma'
    self.sigma.minimum = self.minimumSigma
    self.sigma.maximum = self.maximumSigma
    self.sigma.orientation = 1
    self.sigma.singleStep = self.minimumSigma
    self.frame.layout().addWidget(self.sigma)
    self.widgets.append(self.sigma)


    self.apply = qt.QPushButton("Apply", self.frame)
    self.apply.objectName = self.__class__.__name__ + 'Apply'
    self.apply.setToolTip("Interpolate current label")
    self.frame.layout().addWidget(self.apply)
    self.widgets.append(self.apply)

    EditorLib.HelpButton(self.frame, "Use this tool to remove pixels from the boundary of the current label.")

    self.connections.append( (self.sigma, 'valueChanged(double)', self.onSigmaValueChanged) )
    self.connections.append( (self.sigmaSpinBox, 'valueChanged(double)', self.onSigmaSpinBoxChanged) )
    self.connections.append( (self.apply, 'clicked()', self.onApply) )

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

    self.parameterNode.SetParameter("MorphologyEffect,neighborMode","8")
    self.parameterNode.SetParameter("InterpolateROIsEffect,sigma","1.0")
Ejemplo n.º 2
0
def numericInputFrame(parent, label, tooltip, minimum, maximum, step, decimals):
  inputFrame = qt.QFrame(parent)
  inputFrame.setLayout(qt.QHBoxLayout())
  inputLabel = qt.QLabel(label, inputFrame)
  inputLabel.setToolTip(tooltip)
  inputFrame.layout().addWidget(inputLabel)
  inputSpinBox = qt.QDoubleSpinBox(inputFrame)
  inputSpinBox.setToolTip(tooltip)
  inputSpinBox.minimum = minimum
  inputSpinBox.maximum = maximum
  inputSpinBox.singleStep = step
  inputSpinBox.decimals = decimals
  inputFrame.layout().addWidget(inputSpinBox)
  inputSlider = ctk.ctkDoubleSlider(inputFrame)
  inputSlider.minimum = minimum
  inputSlider.maximum = maximum
  inputSlider.orientation = 1
  inputSlider.singleStep = step
  inputSlider.setToolTip(tooltip)
  inputFrame.layout().addWidget(inputSlider)
  return inputFrame, inputSlider, inputSpinBox
Ejemplo n.º 3
0
  def setupOpacity(self):
    self.opacitySpinBox = qt.QDoubleSpinBox()
    self.opacitySpinBox.minimum = 0
    self.opacitySpinBox.maximum = 1.0
    self.opacitySpinBox.value = 1
    self.opacitySpinBox.singleStep = 0.05
    self.opacitySliderPopup = ctk.ctkPopupWidget(self.opacitySpinBox)
    popupLayout = qt.QHBoxLayout(self.opacitySliderPopup)

    self.opacitySlider = ctk.ctkDoubleSlider(self.opacitySliderPopup)
    self.opacitySlider.orientation = qt.Qt.Horizontal
    self.opacitySlider.minimum = 0
    self.opacitySlider.maximum = 1.0
    self.opacitySlider.value = 1
    self.opacitySlider.singleStep = 0.05
    popupLayout.addWidget(self.opacitySlider)
    self.opacitySliderPopup.verticalDirection = ctk.ctkBasePopupWidget.TopToBottom
    self.opacitySliderPopup.animationEffect = ctk.ctkBasePopupWidget.FadeEffect
    self.opacitySliderPopup.orientation = qt.Qt.Horizontal
    #self.opacitySliderPopup.easingCurve = qt.QEasingCurve.OutQuart
    self.opacitySliderPopup.effectDuration = 100
Ejemplo n.º 4
0
def numericInputFrame(parent, label, tooltip, minimum, maximum, step,
                      decimals):
    inputFrame = qt.QFrame(parent)
    inputFrame.setLayout(qt.QHBoxLayout())
    inputLabel = qt.QLabel(label, inputFrame)
    inputLabel.setToolTip(tooltip)
    inputFrame.layout().addWidget(inputLabel)
    inputSpinBox = qt.QDoubleSpinBox(inputFrame)
    inputSpinBox.setToolTip(tooltip)
    inputSpinBox.minimum = minimum
    inputSpinBox.maximum = maximum
    inputSpinBox.singleStep = step
    inputSpinBox.decimals = decimals
    inputFrame.layout().addWidget(inputSpinBox)
    inputSlider = ctk.ctkDoubleSlider(inputFrame)
    inputSlider.minimum = minimum
    inputSlider.maximum = maximum
    inputSlider.orientation = 1
    inputSlider.singleStep = step
    inputSlider.setToolTip(tooltip)
    inputFrame.layout().addWidget(inputSlider)
    return inputFrame, inputSlider, inputSpinBox
Ejemplo n.º 5
0
    def create(self):
        super(PaintEffectOptions, self).create()

        self.radiusFrame = qt.QFrame(self.frame)
        self.radiusFrame.setLayout(qt.QHBoxLayout())
        self.frame.layout().addWidget(self.radiusFrame)
        self.widgets.append(self.radiusFrame)
        self.radiusLabel = qt.QLabel("Radius:", self.radiusFrame)
        self.radiusLabel.setToolTip(
            "Set the radius of the paint brush in millimeters")
        self.radiusFrame.layout().addWidget(self.radiusLabel)
        self.widgets.append(self.radiusLabel)
        self.radiusSpinBox = slicer.qMRMLSpinBox(self.radiusFrame)
        self.radiusSpinBox.objectName = 'SpinBox_Radius'
        self.radiusSpinBox.setToolTip(
            "Set the radius of the paint brush in millimeters")
        self.radiusSpinBox.quantity = "length"
        # QFlags not wrapped in python. Equivalent to Prefix | Suffix
        # See qMRMLSpinBox for more details.
        self.radiusSpinBox.unitAwareProperties = 0x01 | 0x02
        self.radiusSpinBox.minimum = self.minimumRadius
        self.radiusSpinBox.maximum = self.maximumRadius
        self.radiusSpinBox.setMRMLScene(slicer.mrmlScene)
        from math import log, floor
        decimals = floor(log(self.minimumRadius, 10))
        if decimals < 0:
            self.radiusSpinBox.decimals = -decimals + 2
        self.radiusFrame.layout().addWidget(self.radiusSpinBox)
        self.widgets.append(self.radiusSpinBox)
        self.radiusUnitsToggle = qt.QPushButton("px:")
        self.radiusUnitsToggle.objectName = 'PushButton_RadiusUnitsToggle'
        self.radiusUnitsToggle.setToolTip(
            "Toggle radius quick set buttons between mm and label volume pixel size units"
        )
        self.radiusUnitsToggle.setFixedWidth(35)
        self.radiusFrame.layout().addWidget(self.radiusUnitsToggle)
        self.radiusUnitsToggle.connect('clicked()', self.onRadiusUnitsToggle)
        self.radiusQuickies = {}
        quickies = ((2, self.onQuickie2Clicked), (3, self.onQuickie3Clicked),
                    (4, self.onQuickie4Clicked), (5, self.onQuickie5Clicked),
                    (10, self.onQuickie10Clicked), (20,
                                                    self.onQuickie20Clicked))
        for rad, callback in quickies:
            self.radiusQuickies[rad] = qt.QPushButton(str(rad))
            self.radiusQuickies[
                rad].objectName = 'PushButton_QuickRadius_{0}'.format(rad)
            self.radiusFrame.layout().addWidget(self.radiusQuickies[rad])
            self.radiusQuickies[rad].setFixedWidth(25)
            self.radiusQuickies[rad].connect('clicked()', callback)
            self.radiusQuickies[rad].setToolTip(
                "Set radius based on mm or label voxel size units depending on toggle value"
            )

        self.radius = ctk.ctkDoubleSlider(self.frame)
        self.radius.objectName = 'DoubleSlider_Radius'
        self.radius.minimum = self.minimumRadius
        self.radius.maximum = self.maximumRadius
        self.radius.orientation = 1
        self.radius.singleStep = self.minimumRadius
        self.frame.layout().addWidget(self.radius)
        self.widgets.append(self.radius)

        self.sphere = qt.QCheckBox("Sphere", self.frame)
        self.sphere.objectName = 'CheckBox_Sphere'
        self.sphere.setToolTip(
            "Use a 3D spherical brush rather than a 2D circular brush.")
        self.frame.layout().addWidget(self.sphere)
        self.widgets.append(self.sphere)

        self.smudge = qt.QCheckBox("Smudge", self.frame)
        self.smudge.objectName = 'CheckBox_Smudge'
        self.smudge.setToolTip(
            "Set the label number automatically by sampling the pixel location where the brush stroke starts."
        )
        self.frame.layout().addWidget(self.smudge)
        self.widgets.append(self.smudge)

        self.pixelMode = qt.QCheckBox("Pixel Mode", self.frame)
        self.pixelMode.objectName = 'CheckBox_PixelMode'
        self.pixelMode.setToolTip(
            "Paint exactly the pixel under the cursor, ignoring the radius, threshold, and paint over."
        )
        self.frame.layout().addWidget(self.pixelMode)
        self.widgets.append(self.pixelMode)

        HelpButton(
            self.frame,
            "Use this tool to paint with a round brush of the selected radius")

        self.connections.append(
            (self.sphere, 'clicked()', self.updateMRMLFromGUI))
        self.connections.append(
            (self.smudge, 'clicked()', self.updateMRMLFromGUI))
        self.connections.append(
            (self.pixelMode, 'clicked()', self.updateMRMLFromGUI))
        self.connections.append(
            (self.radius, 'valueChanged(double)', self.onRadiusValueChanged))
        self.connections.append((self.radiusSpinBox, 'valueChanged(double)',
                                 self.onRadiusSpinBoxChanged))

        # Add vertical spacer
        self.frame.layout().addStretch(1)
Ejemplo n.º 6
0
  def create(self):
    super(PaintEffectOptions,self).create()

    self.radiusFrame = qt.QFrame(self.frame)
    self.radiusFrame.setLayout(qt.QHBoxLayout())
    self.frame.layout().addWidget(self.radiusFrame)
    self.widgets.append(self.radiusFrame)
    self.radiusLabel = qt.QLabel("Radius:", self.radiusFrame)
    self.radiusLabel.setToolTip("Set the radius of the paint brush in millimeters")
    self.radiusFrame.layout().addWidget(self.radiusLabel)
    self.widgets.append(self.radiusLabel)
    self.radiusSpinBox = slicer.qMRMLSpinBox(self.radiusFrame)
    self.radiusSpinBox.objectName = 'SpinBox_Radius'
    self.radiusSpinBox.setToolTip("Set the radius of the paint brush in millimeters")
    self.radiusSpinBox.quantity = "length"
    # QFlags not wrapped in python. Equivalent to Prefix | Suffix
    # See qMRMLSpinBox for more details.
    self.radiusSpinBox.unitAwareProperties = 0x01 | 0x02
    self.radiusSpinBox.minimum = self.minimumRadius
    self.radiusSpinBox.maximum = self.maximumRadius
    self.radiusSpinBox.setMRMLScene(slicer.mrmlScene)
    from math import log,floor
    decimals = floor(log(self.minimumRadius,10))
    if decimals < 0:
      self.radiusSpinBox.decimals = -decimals + 2
    self.radiusFrame.layout().addWidget(self.radiusSpinBox)
    self.widgets.append(self.radiusSpinBox)
    self.radiusUnitsToggle = qt.QPushButton("px:")
    self.radiusUnitsToggle.objectName = 'PushButton_RadiusUnitsToggle'
    self.radiusUnitsToggle.setToolTip("Toggle radius quick set buttons between mm and label volume pixel size units")
    self.radiusUnitsToggle.setFixedWidth(35)
    self.radiusFrame.layout().addWidget(self.radiusUnitsToggle)
    self.radiusUnitsToggle.connect('clicked()',self.onRadiusUnitsToggle)
    self.radiusQuickies = {}
    quickies = ( (2, self.onQuickie2Clicked), (3,self.onQuickie3Clicked),
                 (4, self.onQuickie4Clicked), (5, self.onQuickie5Clicked),
                 (10, self.onQuickie10Clicked), (20, self.onQuickie20Clicked) )
    for rad,callback in quickies:
      self.radiusQuickies[rad] = qt.QPushButton(str(rad))
      self.radiusQuickies[rad].objectName = 'PushButton_QuickRadius_{0}'.format(rad)
      self.radiusFrame.layout().addWidget(self.radiusQuickies[rad])
      self.radiusQuickies[rad].setFixedWidth(25)
      self.radiusQuickies[rad].connect('clicked()', callback)
      self.radiusQuickies[rad].setToolTip("Set radius based on mm or label voxel size units depending on toggle value")

    self.radius = ctk.ctkDoubleSlider(self.frame)
    self.radius.objectName = 'DoubleSlider_Radius'
    self.radius.minimum = self.minimumRadius
    self.radius.maximum = self.maximumRadius
    self.radius.orientation = 1
    self.radius.singleStep = self.minimumRadius
    self.frame.layout().addWidget(self.radius)
    self.widgets.append(self.radius)

    self.sphere = qt.QCheckBox("Sphere", self.frame)
    self.sphere.objectName = 'CheckBox_Sphere'
    self.sphere.setToolTip("Use a 3D spherical brush rather than a 2D circular brush.")
    self.frame.layout().addWidget(self.sphere)
    self.widgets.append(self.sphere)

    self.smudge = qt.QCheckBox("Smudge", self.frame)
    self.smudge.objectName = 'CheckBox_Smudge'
    self.smudge.setToolTip("Set the label number automatically by sampling the pixel location where the brush stroke starts.")
    self.frame.layout().addWidget(self.smudge)
    self.widgets.append(self.smudge)

    self.pixelMode = qt.QCheckBox("Pixel Mode", self.frame)
    self.pixelMode.objectName = 'CheckBox_PixelMode'
    self.pixelMode.setToolTip("Paint exactly the pixel under the cursor, ignoring the radius, threshold, and paint over.")
    self.frame.layout().addWidget(self.pixelMode)
    self.widgets.append(self.pixelMode)

    HelpButton(self.frame, "Use this tool to paint with a round brush of the selected radius")

    self.connections.append( (self.sphere, 'clicked()', self.updateMRMLFromGUI) )
    self.connections.append( (self.smudge, 'clicked()', self.updateMRMLFromGUI) )
    self.connections.append( (self.pixelMode, 'clicked()', self.updateMRMLFromGUI) )
    self.connections.append( (self.radius, 'valueChanged(double)', self.onRadiusValueChanged) )
    self.connections.append( (self.radiusSpinBox, 'valueChanged(double)', self.onRadiusSpinBoxChanged) )

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