def setup(self):
    # Collapsible button
    self.adjustCollapsibleButton = ctk.ctkCollapsibleButton()
    self.adjustCollapsibleButton.text = "Adjust Slice Thickness"
    self.layout.addWidget(self.adjustCollapsibleButton)
    
    # Layout within the adjust Slice Thickness inputs collapsible button
    self.adjustFormLayout = qt.QFormLayout(self.adjustCollapsibleButton)

    #
    # the volume and spacing selectors
    #
    self.inputFrame = qt.QFrame(self.adjustCollapsibleButton)
    self.inputFrame.setLayout(qt.QHBoxLayout())
    self.adjustFormLayout.addWidget(self.inputFrame)
    self.inputSelector = qt.QLabel("Input Volume: ", self.inputFrame)
    self.inputFrame.layout().addWidget(self.inputSelector)
    self.inputSelector = slicer.qMRMLNodeComboBox(self.inputFrame)
    self.inputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    self.inputSelector.addEnabled = False
    self.inputSelector.removeEnabled = False
    self.inputSelector.setMRMLScene( slicer.mrmlScene )
    self.inputFrame.layout().addWidget(self.inputSelector)
    
    self.SpacingFrame = qt.QFrame(self.adjustCollapsibleButton)
    self.SpacingFrame.setLayout(qt.QHBoxLayout())
    self.adjustFormLayout.addWidget(self.SpacingFrame)
    self.SpinBox = qt.QLabel("New  Slice Thickness: ", self.SpacingFrame)
    self.SpacingFrame.layout().addWidget(self.SpinBox)
    self.SpinBox = ctk.ctkSpinBox()
    self.SpinBox.decimals = 5
    self.SpacingFrame.layout().addWidget(self.SpinBox)
    
    self.outputFrame = qt.QFrame(self.adjustCollapsibleButton)
    self.outputFrame.setLayout(qt.QHBoxLayout())
    self.adjustFormLayout.addWidget(self.outputFrame)
    self.outputSelector = qt.QLabel("Output Volume: ", self.outputFrame)
    self.outputFrame.layout().addWidget(self.outputSelector)
    self.outputSelector = slicer.qMRMLNodeComboBox(self.outputFrame)
    self.outputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    self.outputSelector.setMRMLScene( slicer.mrmlScene )
    self.outputFrame.layout().addWidget(self.outputSelector)
    
    #Radio button
    self.registrationTypeBox = qt.QGroupBox("Interpolation Type")
    self.registrationTypeBox.setLayout(qt.QFormLayout())
    self.registrationTypeButtons = {}
    self.registrationTypes = ("Linear", "Lanczos")
    for registrationType in self.registrationTypes:
      self.registrationTypeButtons[registrationType] = qt.QRadioButton()
      self.registrationTypeButtons[registrationType].text = registrationType
      self.registrationTypeButtons[registrationType].setToolTip("Pick the type of registration")
      self.registrationTypeBox.layout().addWidget(self.registrationTypeButtons[registrationType])
    self.adjustFormLayout.addWidget(self.registrationTypeBox)
    self.registrationTypeButtons["Linear"].setChecked(True)
    
    # Apply button
    adjustButton = qt.QPushButton("Adjust Slice Thickness")
    adjustButton.toolTip = "Adjusts the thickness of MRI slices in an image"
    self.adjustFormLayout.addWidget(adjustButton)
    adjustButton.connect('clicked(bool)', self.onApply)
    

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

    # Set local var as instance attribute
    self.adjustButton = adjustButton
Exemple #2
0
    def create(self):
        super(PaintEffectOptions, self).create()

        labelVolume = self.editUtil.getLabelVolume()
        if labelVolume and labelVolume.GetImageData():
            spacing = labelVolume.GetSpacing()
            dimensions = labelVolume.GetImageData().GetDimensions()
            self.minimumRadius = 0.5 * min(spacing)
            bounds = [a * b for a, b in zip(spacing, dimensions)]
            self.maximumRadius = 0.5 * max(bounds)
        else:
            self.minimumRadius = 0.01
            self.maximumRadius = 100

        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 = ctk.ctkSpinBox(self.radiusFrame)
        self.radiusSpinBox.setToolTip("Set the radius of the paint brush in millimeters")
        self.radiusSpinBox.minimum = self.minimumRadius
        self.radiusSpinBox.maximum = self.maximumRadius
        self.radiusSpinBox.suffix = "mm"
        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.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.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.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.smudge = qt.QCheckBox("Smudge", self.frame)
        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.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)

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

        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)

        # set the node parameters that are dependent on the input data
        self.parameterNode.SetParameter("PaintEffect,radius", str(self.minimumRadius * 10))
Exemple #3
0
  def create(self):
    super(WandEffectOptions,self).create()

    self.toleranceFrame = qt.QFrame(self.frame)
    self.toleranceFrame.setLayout(qt.QHBoxLayout())
    self.frame.layout().addWidget(self.toleranceFrame)
    self.widgets.append(self.toleranceFrame)
    self.toleranceLabel = qt.QLabel("Tolerance:", self.toleranceFrame)
    self.toleranceLabel.setToolTip("Set the tolerance of the wand in terms of background pixel values")
    self.toleranceFrame.layout().addWidget(self.toleranceLabel)
    self.widgets.append(self.toleranceLabel)
    self.toleranceSpinBox = ctk.ctkSpinBox(self.toleranceFrame)
    self.toleranceSpinBox.setToolTip("Set the tolerance of the wand in terms of background pixel values")
    self.toleranceSpinBox.minimum = 0
    self.toleranceSpinBox.maximum = 1000
    self.toleranceSpinBox.suffix = ""
    self.toleranceFrame.layout().addWidget(self.toleranceSpinBox)
    self.widgets.append(self.toleranceSpinBox)

    self.maxPixelsFrame = qt.QFrame(self.frame)
    self.maxPixelsFrame.setLayout(qt.QHBoxLayout())
    self.frame.layout().addWidget(self.maxPixelsFrame)
    self.widgets.append(self.maxPixelsFrame)
    self.maxPixelsLabel = qt.QLabel("Max Pixels per click:", self.maxPixelsFrame)
    self.maxPixelsLabel.setToolTip("Set the maxPixels for each click")
    self.maxPixelsFrame.layout().addWidget(self.maxPixelsLabel)
    self.widgets.append(self.maxPixelsLabel)
    self.maxPixelsSpinBox = ctk.ctkSpinBox(self.maxPixelsFrame)
    self.maxPixelsSpinBox.setToolTip("Set the maxPixels for each click")
    self.maxPixelsSpinBox.minimum = 1
    self.maxPixelsSpinBox.maximum = 100000
    self.maxPixelsSpinBox.suffix = ""
    self.maxPixelsFrame.layout().addWidget(self.maxPixelsSpinBox)
    self.widgets.append(self.maxPixelsSpinBox)

    self.fillModeFrame = qt.QFrame(self.frame)
    self.fillModeFrame.setLayout(qt.QHBoxLayout())
    self.frame.layout().addWidget(self.fillModeFrame)
    self.widgets.append(self.fillModeFrame)
    self.fillModeCheckBox = qt.QCheckBox(self.fillModeFrame)
    self.fillModeCheckBox.text = "Fill Volume"
    self.fillModeCheckBox.setToolTip("Fill in 3D when checked, else fill plane")
    self.fillModeFrame.layout().addWidget(self.fillModeCheckBox)
    self.widgets.append(self.fillModeCheckBox)

    EditorLib.HelpButton(self.frame, "Use this tool to label all voxels that are within a tolerance of where you click")

    # don't connect the signals and slots directly - instead, add these
    # to the list of connections so that gui callbacks can be cleanly
    # disabled while the gui is being updated.  This allows several gui
    # elements to be interlinked with signal/slots but still get updated
    # as a unit to the new value of the mrml node.
    self.connections.append(
        (self.toleranceSpinBox, 'valueChanged(double)', self.onToleranceSpinBoxChanged) )
    self.connections.append(
        (self.maxPixelsSpinBox, 'valueChanged(double)', self.onMaxPixelsSpinBoxChanged) )
    self.connections.append(
        (self.fillModeCheckBox, 'clicked()', self.onFillModeClicked) )

    # Add vertical spacer
    self.frame.layout().addStretch(1)
Exemple #4
0
    def create(self):
        super(PaintEffectOptions, self).create()

        labelVolume = self.editUtil.getLabelVolume()
        if labelVolume and labelVolume.GetImageData():
            spacing = labelVolume.GetSpacing()
            dimensions = labelVolume.GetImageData().GetDimensions()
            self.minimumRadius = 0.5 * min(spacing)
            bounds = [a * b for a, b in zip(spacing, dimensions)]
            self.maximumRadius = 0.5 * max(bounds)
        else:
            self.minimumRadius = 0.01
            self.maximumRadius = 100

        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 = ctk.ctkSpinBox(self.radiusFrame)
        self.radiusSpinBox.setToolTip(
            "Set the radius of the paint brush in millimeters")
        self.radiusSpinBox.minimum = self.minimumRadius
        self.radiusSpinBox.maximum = self.maximumRadius
        self.radiusSpinBox.suffix = "mm"
        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.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.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.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.smudge = qt.QCheckBox("Smudge", self.frame)
        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.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)

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

        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)

        # set the node parameters that are dependent on the input data
        self.parameterNode.SetParameter("PaintEffect,radius",
                                        str(self.minimumRadius * 10))
Exemple #5
0
    def create(self):
        super(WandEffectOptions, self).create()

        self.toleranceFrame = qt.QFrame(self.frame)
        self.toleranceFrame.setLayout(qt.QHBoxLayout())
        self.frame.layout().addWidget(self.toleranceFrame)
        self.widgets.append(self.toleranceFrame)
        self.toleranceLabel = qt.QLabel("Tolerance:", self.toleranceFrame)
        self.toleranceLabel.setToolTip(
            "Set the tolerance of the wand in terms of background pixel values"
        )
        self.toleranceFrame.layout().addWidget(self.toleranceLabel)
        self.widgets.append(self.toleranceLabel)
        self.toleranceSpinBox = ctk.ctkSpinBox(self.toleranceFrame)
        self.toleranceSpinBox.setToolTip(
            "Set the tolerance of the wand in terms of background pixel values"
        )
        self.toleranceSpinBox.minimum = 0
        self.toleranceSpinBox.maximum = 1000
        self.toleranceSpinBox.suffix = ""
        self.toleranceFrame.layout().addWidget(self.toleranceSpinBox)
        self.widgets.append(self.toleranceSpinBox)

        self.maxPixelsFrame = qt.QFrame(self.frame)
        self.maxPixelsFrame.setLayout(qt.QHBoxLayout())
        self.frame.layout().addWidget(self.maxPixelsFrame)
        self.widgets.append(self.maxPixelsFrame)
        self.maxPixelsLabel = qt.QLabel("Max Pixels per click:",
                                        self.maxPixelsFrame)
        self.maxPixelsLabel.setToolTip("Set the maxPixels for each click")
        self.maxPixelsFrame.layout().addWidget(self.maxPixelsLabel)
        self.widgets.append(self.maxPixelsLabel)
        self.maxPixelsSpinBox = ctk.ctkSpinBox(self.maxPixelsFrame)
        self.maxPixelsSpinBox.setToolTip("Set the maxPixels for each click")
        self.maxPixelsSpinBox.minimum = 1
        self.maxPixelsSpinBox.maximum = 100000
        self.maxPixelsSpinBox.suffix = ""
        self.maxPixelsFrame.layout().addWidget(self.maxPixelsSpinBox)
        self.widgets.append(self.maxPixelsSpinBox)

        self.fillModeFrame = qt.QFrame(self.frame)
        self.fillModeFrame.setLayout(qt.QHBoxLayout())
        self.frame.layout().addWidget(self.fillModeFrame)
        self.widgets.append(self.fillModeFrame)
        self.fillModeCheckBox = qt.QCheckBox(self.fillModeFrame)
        self.fillModeCheckBox.text = "Fill Volume"
        self.fillModeCheckBox.setToolTip(
            "Fill in 3D when checked, else fill plane")
        self.fillModeFrame.layout().addWidget(self.fillModeCheckBox)
        self.widgets.append(self.fillModeCheckBox)

        EditorLib.HelpButton(
            self.frame,
            "Use this tool to label all voxels that are within a tolerance of where you click"
        )

        # don't connect the signals and slots directly - instead, add these
        # to the list of connections so that gui callbacks can be cleanly
        # disabled while the gui is being updated.  This allows several gui
        # elements to be interlinked with signal/slots but still get updated
        # as a unit to the new value of the mrml node.
        self.connections.append((self.toleranceSpinBox, 'valueChanged(double)',
                                 self.onToleranceSpinBoxChanged))
        self.connections.append((self.maxPixelsSpinBox, 'valueChanged(double)',
                                 self.onMaxPixelsSpinBoxChanged))
        self.connections.append(
            (self.fillModeCheckBox, 'clicked()', self.onFillModeClicked))

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