def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = LeapControllerLogic() controllerCollapsibleButton = ctk.ctkCollapsibleButton() controllerCollapsibleButton.text = 'Controller' self.layout.addWidget(controllerCollapsibleButton) controllerFormLayout = qt.QFormLayout(controllerCollapsibleButton) self.startButton = qt.QPushButton('Start') self.startButton.toolTip = 'Start running the Leap' self.startButton.connect('clicked()', self.onStartButton) controllerFormLayout.addWidget(self.startButton) self.stopButton = qt.QPushButton('Stop') self.stopButton.toolTip = 'Stop running the Leap' self.stopButton.connect('clicked()', self.onStopButton) controllerFormLayout.addWidget(self.stopButton) self.radioFree = qt.QRadioButton('Free Rotation') self.radioFree.connect('clicked()', self.onFreeRotate) self.radioFree.checked = True self.radioXY = qt.QRadioButton('Lock XY') self.radioXY.connect('clicked()', self.onLockXY) self.radioXZ = qt.QRadioButton('Lock XZ') self.radioXZ.connect('clicked()', self.onLockXZ) self.radioYZ = qt.QRadioButton('Lock YZ') self.radioYZ.connect('clicked()', self.onLockYZ) controllerFormLayout.addWidget(self.radioFree) controllerFormLayout.addWidget(self.radioXY) controllerFormLayout.addWidget(self.radioXZ) controllerFormLayout.addWidget(self.radioYZ)
def setupOptionsFrame(self): operationLayout = qt.QVBoxLayout() self.shrinkOptionRadioButton = qt.QRadioButton("Shrink") self.growOptionRadioButton = qt.QRadioButton("Grow") operationLayout.addWidget(self.shrinkOptionRadioButton) operationLayout.addWidget(self.growOptionRadioButton) self.growOptionRadioButton.setChecked(True) self.scriptedEffect.addLabeledOptionsWidget("Operation:", operationLayout) self.marginSizeMMSpinBox = slicer.qMRMLSpinBox() self.marginSizeMMSpinBox.setMRMLScene(slicer.mrmlScene) self.marginSizeMMSpinBox.setToolTip( "Segment boundaries will be shifted by this distance. Positive value means the segments will grow, negative value means segment will shrink." ) self.marginSizeMMSpinBox.quantity = "length" self.marginSizeMMSpinBox.value = 3.0 self.marginSizeMMSpinBox.singleStep = 1.0 self.marginSizeLabel = qt.QLabel() self.marginSizeLabel.setToolTip( "Size change in pixel. Computed from the segment's spacing and the specified margin size." ) marginSizeFrame = qt.QHBoxLayout() marginSizeFrame.addWidget(self.marginSizeMMSpinBox) self.marginSizeMMLabel = self.scriptedEffect.addLabeledOptionsWidget( "Margin size:", marginSizeFrame) self.scriptedEffect.addLabeledOptionsWidget("", self.marginSizeLabel) self.applyToAllVisibleSegmentsCheckBox = qt.QCheckBox() self.applyToAllVisibleSegmentsCheckBox.setToolTip( "Grow or shrink all visible segments in this segmentation node. \ This operation may take a while." ) self.applyToAllVisibleSegmentsCheckBox.objectName = self.__class__.__name__ + 'ApplyToAllVisibleSegments' self.applyToAllVisibleSegmentsLabel = self.scriptedEffect.addLabeledOptionsWidget( "Apply to all segments:", self.applyToAllVisibleSegmentsCheckBox) self.applyButton = qt.QPushButton("Apply") self.applyButton.objectName = self.__class__.__name__ + 'Apply' self.applyButton.setToolTip( "Grows or shrinks selected segment /default) or all segments (checkbox) by the specified margin." ) self.scriptedEffect.addOptionsWidget(self.applyButton) self.applyButton.connect('clicked()', self.onApply) self.marginSizeMMSpinBox.connect("valueChanged(double)", self.updateMRMLFromGUI) self.growOptionRadioButton.connect("toggled(bool)", self.growOperationToggled) self.shrinkOptionRadioButton.connect("toggled(bool)", self.shrinkOperationToggled) self.applyToAllVisibleSegmentsCheckBox.connect("stateChanged(int)", self.updateMRMLFromGUI)
def create(self, registrationState): """Make the plugin-specific user interface""" super(LocalSimpleITKPlugin, self).create(registrationState) # To avoid the overhead of importing SimpleITK during application # startup, the import of SimpleITK is delayed until it is needed. global sitk import SimpleITK as sitk global sitkUtils import sitkUtils print("LocalSimpleITKPlugin.create") self.LocalSimpleITKMode = "Small" self.VerboseMode = "Quiet" # # Local Refinment Pane - initially hidden # - interface options for linear registration # self.LocalSimpleITKCollapsibleButton = ctk.ctkCollapsibleButton() self.LocalSimpleITKCollapsibleButton.text = "Local SimpleITK" LocalSimpleITKFormLayout = qt.QFormLayout() self.LocalSimpleITKCollapsibleButton.setLayout( LocalSimpleITKFormLayout) self.widgets.append(self.LocalSimpleITKCollapsibleButton) buttonLayout = qt.QVBoxLayout() self.LocalSimpleITKModeButtons = {} self.LocalSimpleITKModes = ("Small", "Large") for mode in self.LocalSimpleITKModes: self.LocalSimpleITKModeButtons[mode] = qt.QRadioButton() self.LocalSimpleITKModeButtons[mode].text = mode self.LocalSimpleITKModeButtons[mode].setToolTip( "Run the refinement in a %s local region." % mode.lower()) buttonLayout.addWidget(self.LocalSimpleITKModeButtons[mode]) self.widgets.append(self.LocalSimpleITKModeButtons[mode]) self.LocalSimpleITKModeButtons[mode].connect( 'clicked()', lambda m=mode: self.onLocalSimpleITKMode(m)) self.LocalSimpleITKModeButtons[self.LocalSimpleITKMode].checked = True LocalSimpleITKFormLayout.addRow("Local SimpleITK Mode ", buttonLayout) buttonLayout = qt.QVBoxLayout() self.VerboseModeButtons = {} self.VerboseModes = ("Quiet", "Verbose", "Full Verbose") for mode in self.VerboseModes: self.VerboseModeButtons[mode] = qt.QRadioButton() self.VerboseModeButtons[mode].text = mode self.VerboseModeButtons[mode].setToolTip( "Run the refinement in %s mode." % mode.lower()) buttonLayout.addWidget(self.VerboseModeButtons[mode]) self.widgets.append(self.VerboseModeButtons[mode]) self.VerboseModeButtons[mode].connect( 'clicked()', lambda m=mode: self.onVerboseMode(m)) self.VerboseModeButtons[self.VerboseMode].checked = True LocalSimpleITKFormLayout.addRow("Verbose Mode ", buttonLayout) self.parent.layout().addWidget(self.LocalSimpleITKCollapsibleButton)
def makeEzHemisphereButton(self): self.leftEzRadioButton = qt.QRadioButton('Left') self.rightEzRadioButton = qt.QRadioButton('Right') self.leftEzRadioButton.setChecked(True) ezHemisphereLayout = qt.QHBoxLayout() ezHemisphereLayout.addWidget(self.leftEzRadioButton) ezHemisphereLayout.addWidget(self.rightEzRadioButton) self.leftEzRadioButton.toggled.connect(self.onAutoUpdateButton) self.rightEzRadioButton.toggled.connect(self.onAutoUpdateButton) self.settingsLayout.addRow('Epileptogenic zone: ', ezHemisphereLayout)
def create(self, registrationState): """Make the plugin-specific user interface""" super(LocalBRAINSFitPlugin, self).create(registrationState) self.LocalBRAINSFitMode = "Small" self.VerboseMode = "Quiet" # # Local Refinment Pane - initially hidden # - interface options for linear registration # localBRAINSFitCollapsibleButton = ctk.ctkCollapsibleButton() localBRAINSFitCollapsibleButton.text = "Local BRAINSFit" localBRAINSFitFormLayout = qt.QFormLayout() localBRAINSFitCollapsibleButton.setLayout(localBRAINSFitFormLayout) self.widgets.append(localBRAINSFitCollapsibleButton) buttonGroup = qt.QButtonGroup() self.widgets.append(buttonGroup) buttonLayout = qt.QVBoxLayout() localBRAINSFitModeButtons = {} self.LocalBRAINSFitModes = ("Small", "Large") for mode in self.LocalBRAINSFitModes: localBRAINSFitModeButtons[mode] = qt.QRadioButton() localBRAINSFitModeButtons[mode].text = mode localBRAINSFitModeButtons[mode].setToolTip( "Run the refinement in a %s local region." % mode.lower()) buttonLayout.addWidget(localBRAINSFitModeButtons[mode]) buttonGroup.addButton(localBRAINSFitModeButtons[mode]) self.widgets.append(localBRAINSFitModeButtons[mode]) localBRAINSFitModeButtons[mode].connect( 'clicked()', lambda m=mode: self.onLocalBRAINSFitMode(m)) localBRAINSFitModeButtons[self.LocalBRAINSFitMode].checked = True localBRAINSFitFormLayout.addRow("Local BRAINSFit Mode ", buttonLayout) buttonGroup = qt.QButtonGroup() self.widgets.append(buttonGroup) buttonLayout = qt.QVBoxLayout() verboseModeButtons = {} self.VerboseModes = ("Quiet", "Verbose") for mode in self.VerboseModes: verboseModeButtons[mode] = qt.QRadioButton() verboseModeButtons[mode].text = mode verboseModeButtons[mode].setToolTip( "Run the refinement in %s mode." % mode.lower()) buttonLayout.addWidget(verboseModeButtons[mode]) buttonGroup.addButton(verboseModeButtons[mode]) self.widgets.append(verboseModeButtons[mode]) verboseModeButtons[mode].connect( 'clicked()', lambda m=mode: self.onVerboseMode(m)) verboseModeButtons[self.VerboseMode].checked = True localBRAINSFitFormLayout.addRow("Verbose Mode ", buttonLayout) self.parent.layout().addWidget(localBRAINSFitCollapsibleButton)
def makeDominantHemisphereButton(self): self.leftDominantRadioButton = qt.QRadioButton('Left') self.rightDominantRadioButton = qt.QRadioButton('Right') self.leftDominantRadioButton.setChecked(True) dominantHemisphereLayout = qt.QHBoxLayout() dominantHemisphereLayout.addWidget(self.leftDominantRadioButton) dominantHemisphereLayout.addWidget(self.rightDominantRadioButton) self.leftDominantRadioButton.toggled.connect(self.onAutoUpdateButton) self.rightDominantRadioButton.toggled.connect(self.onAutoUpdateButton) self.settingsLayout.addRow('Dominant hemisphere: ', dominantHemisphereLayout)
def setupOptionsFrame(self): operationLayout = qt.QVBoxLayout() self.insideSurfaceOptionRadioButton = qt.QRadioButton("inside surface") self.medialSurfaceOptionRadioButton = qt.QRadioButton("medial surface") self.outsideSurfaceOptionRadioButton = qt.QRadioButton( "outside surface") operationLayout.addWidget(self.insideSurfaceOptionRadioButton) operationLayout.addWidget(self.medialSurfaceOptionRadioButton) operationLayout.addWidget(self.outsideSurfaceOptionRadioButton) self.insideSurfaceOptionRadioButton.setChecked(True) self.scriptedEffect.addLabeledOptionsWidget("Use current segment as:", operationLayout) self.shellThicknessMMSpinBox = slicer.qMRMLSpinBox() self.shellThicknessMMSpinBox.setMRMLScene(slicer.mrmlScene) self.shellThicknessMMSpinBox.setToolTip( "Thickness of the hollow shell.") self.shellThicknessMMSpinBox.quantity = "length" self.shellThicknessMMSpinBox.minimum = 0.0 self.shellThicknessMMSpinBox.value = 3.0 self.shellThicknessMMSpinBox.singleStep = 1.0 self.shellThicknessLabel = qt.QLabel() self.shellThicknessLabel.setToolTip( "Closest achievable thickness. Constrained by the segmentation's binary labelmap representation spacing." ) shellThicknessFrame = qt.QHBoxLayout() shellThicknessFrame.addWidget(self.shellThicknessMMSpinBox) self.shellThicknessMMLabel = self.scriptedEffect.addLabeledOptionsWidget( "Shell thickness:", shellThicknessFrame) self.scriptedEffect.addLabeledOptionsWidget("", self.shellThicknessLabel) self.applyButton = qt.QPushButton("Apply") self.applyButton.objectName = self.__class__.__name__ + 'Apply' self.applyButton.setToolTip( "Makes the segment hollow by replacing it with a thick shell at the segment boundary." ) self.scriptedEffect.addOptionsWidget(self.applyButton) self.applyButton.connect('clicked()', self.onApply) self.shellThicknessMMSpinBox.connect("valueChanged(double)", self.updateMRMLFromGUI) self.insideSurfaceOptionRadioButton.connect( "toggled(bool)", self.insideSurfaceModeToggled) self.medialSurfaceOptionRadioButton.connect( "toggled(bool)", self.medialSurfaceModeToggled) self.outsideSurfaceOptionRadioButton.connect( "toggled(bool)", self.outsideSurfaceModeToggled)
def getSemiologiesDict(self, semiologies, slot): semiologiesDict = {} for semiology in semiologies: # leftCheckBox = qt.QCheckBox() # rightCheckBox = qt.QCheckBox() leftCheckBox = qt.QRadioButton() rightCheckBox = qt.QRadioButton() leftCheckBox.toggled.connect(slot) rightCheckBox.toggled.connect(slot) semiologiesDict[semiology] = dict( leftCheckBox=leftCheckBox, rightCheckBox=rightCheckBox, ) return semiologiesDict
def updateState(self): """ Refresh the markups state, activate the right fiducials list node (depending on the current selected type) and creates it when necessary :return: """ # Load the subtypes for this type subtypesDict = self.logic.getSubtypes( self.typesRadioButtonGroup.checkedId()) # Remove all the existing buttons for b in self.subtypesRadioButtonGroup.buttons(): b.hide() b.delete() # Add all the subtypes with the full description for subtype in subtypesDict.iterkeys(): rbitem = qt.QRadioButton( self.logic.getSubtypeFullDescription(subtype)) self.subtypesRadioButtonGroup.addButton(rbitem, subtype) self.subtypesLayout.addWidget(rbitem, SlicerUtil.ALIGNMENT_VERTICAL_TOP) # Check first element by default self.subtypesRadioButtonGroup.buttons()[0].setChecked(True) # Set the correct state for fiducials if self.currentVolumeLoaded is not None: self.logic.setActiveFiducialsListNode( self.currentVolumeLoaded, self.typesRadioButtonGroup.checkedId(), self.subtypesRadioButtonGroup.checkedId(), self.artifactsRadioButtonGroup.checkedId())
def create(self, registrationState): """Make the plugin-specific user interface""" super(AffinePlugin, self).create(registrationState) self.linearMode = "Rigid" # # Linear Registration Pane - initially hidden # - interface options for linear registration # - TODO: move registration code into separate plugins # linearCollapsibleButton = ctk.ctkCollapsibleButton() linearCollapsibleButton.text = "Linear Registration" linearFormLayout = qt.QFormLayout() linearCollapsibleButton.setLayout(linearFormLayout) self.widgets.append(linearCollapsibleButton) buttonLayout = qt.QVBoxLayout() linearModeButtons = {} self.linearModes = ("Rigid", "Similarity", "Affine") for mode in self.linearModes: linearModeButtons[mode] = qt.QRadioButton() linearModeButtons[mode].text = mode linearModeButtons[mode].setToolTip( "Run the registration in %s mode." % mode) buttonLayout.addWidget(linearModeButtons[mode]) self.widgets.append(linearModeButtons[mode]) linearModeButtons[mode].connect( 'clicked()', lambda m=mode: self.onLinearTransform(m)) linearModeButtons[self.linearMode].checked = True linearFormLayout.addRow("Registration Mode ", buttonLayout) self.parent.layout().addWidget(linearCollapsibleButton)
def create(self): super(MorphologyEffectOptions,self).create() # TODO: provide an entry for label to replace with (defaults to zero) self.eightNeighbors = qt.QRadioButton("Eight Neighbors", self.frame) self.eightNeighbors.setToolTip("Treat diagonally adjacent voxels as neighbors.") self.frame.layout().addWidget(self.eightNeighbors) self.widgets.append(self.eightNeighbors) self.fourNeighbors = qt.QRadioButton("Four Neighbors", self.frame) self.fourNeighbors.setToolTip("Do not treat diagonally adjacent voxels as neighbors.") self.frame.layout().addWidget(self.fourNeighbors) self.widgets.append(self.fourNeighbors) # TODO: fill option not yet supported # TODO: iterations option not yet supported self.connections.append( (self.eightNeighbors, 'clicked()', self.updateMRMLFromGUI) ) self.connections.append( (self.fourNeighbors, 'clicked()', self.updateMRMLFromGUI) )
def __init__(self, master, name, text, tr, active): self.this = qt.QRadioButton(text, master.group[-1][0]) self.master = master self.active = active self.name = name self.transistor = tr tr.addradio(name, self, active) if (active): self.this.setChecked(1) master.win.connect(self.this, qt.SIGNAL("toggled(bool)"), self.dostuff)
def build_radio_button(title, on_click, checked=False, tooltip=None, width=None): b = qt.QRadioButton(title) b.connect('clicked(bool)', on_click) b.setChecked(checked) if width is not None: b.setFixedWidth(width) return b
def makeTransformationTypeWidgets(self): self.trsfTypeTab = qt.QWidget() self.parametersTabWidget.addTab(self.trsfTypeTab, 'Transformation type') trsfTypeLayout = qt.QVBoxLayout(self.trsfTypeTab) self.trsfTypeRadioButtons = [] for trsfType in TRANSFORMATIONS: radioButton = qt.QRadioButton(trsfType) radioButton.clicked.connect(self.onTransformationTypeChanged) self.trsfTypeRadioButtons.append(radioButton) trsfTypeLayout.addWidget(radioButton) self.trsfTypeRadioButtons[0].setChecked(True)
def __init__(self, options, destination): super(RadioButtonWidget, self).__init__() for i, option in enumerate(options): radio = qt.QRadioButton(option) radio.clicked.connect(self.updateValue(radio)) if i == 0: radio.setChecked(True) self.value = option self.addWidget(radio) self.destination = destination self.type = 'RadioButtonWidget'
def show(self): for item in self._mpvbox.children(): if isinstance(item, qt.QWidget): self._mpvbox.removeChild(item) del item self._mp = None group = qt.QButtonGroup(None, "mp") n = 0 for media in iface.getControl().getMediaSet(): mp = media.getMountPoint() if not self._mp: self._mp = mp qt.QObject.connect(radio, qt.SIGNAL("clicked()"), self.ok) radio = qt.QRadioButton(mp, self._mpvbox) group.insert(radio) act = RadioAction(radio, mp) act.connect(self, "_mp", mp) radio.show() n += 1 if n == 0: iface.error(_("No local media found!")) return None elif n == 1: return self._mp self._window.show() self._window.raiseW() mp = None while True: self._result = self._window.exec_loop() if self._result == qt.QDialog.Accepted: mp = self._mp break mp = None break self._window.hide() return mp
def create(self,registationState): """Make the plugin-specific user interface""" super(AffineAndThinPlatePlugin,self).create(registationState) # # Thin Plate Spline Registration Pane # self.thinPlateCollapsibleButton = ctk.ctkCollapsibleButton() self.thinPlateCollapsibleButton.text = "Affine And Thin Plate Spline Registration" affineAndThinPlateFormLayout = qt.QFormLayout() self.thinPlateCollapsibleButton.setLayout(affineAndThinPlateFormLayout) self.widgets.append(self.thinPlateCollapsibleButton) self.linearMode = "Rigid" self.registrationModeBox = qt.QGroupBox("Registration Mode") self.registrationModeBox.setLayout(qt.QFormLayout()) buttonLayout = qt.QVBoxLayout() self.linearModeButtons = {} self.linearModes = ("Rigid", "Similarity", "Affine") for mode in self.linearModes: self.linearModeButtons[mode] = qt.QRadioButton() self.linearModeButtons[mode].text = mode self.linearModeButtons[mode].setToolTip( "Run the registration in %s mode." % mode ) self.linearModeButtons[mode].connect('clicked()', lambda m=mode : self.onLinearTransform(m)) self.registrationModeBox.layout().addWidget(self.linearModeButtons[mode]) self.linearModeButtons[self.linearMode].checked = True affineAndThinPlateFormLayout.addWidget(self.registrationModeBox) self.hotUpdateButton = qt.QCheckBox("Hot Update") affineAndThinPlateFormLayout.addWidget(self.hotUpdateButton) self.widgets.append(self.hotUpdateButton) self.exportGridButton = qt.QPushButton("Export to Grid Transform") self.exportGridButton.toolTip = "To save this transform or use it in other Slicer modules you can export the current Thin Plate transform to a Grid Transform." affineAndThinPlateFormLayout.addWidget(self.exportGridButton) self.exportGridButton.connect("clicked()",self.onExportGrid) self.widgets.append(self.exportGridButton) self.parent.layout().addWidget(self.thinPlateCollapsibleButton)
def setup(self): """This is called one time when the module GUI is initialized """ CIP_ParenchymaSubtypeTrainingWidget.setup(self) self.volumeSelectionLayout.addRow("Slice size:", None) self.sliceSelectionRadioButtonGroup = qt.QButtonGroup() for id in range(len(self.sliceMeasurements)): button = qt.QRadioButton("{} mm".format( self.sliceMeasurements[id])) self.sliceSelectionRadioButtonGroup.addButton(button, id) self.volumeSelectionLayout.addRow("", button) # Add button for reslicing self.resliceButton = qt.QPushButton("Reslice") self.volumeSelectionLayout.addRow("", self.resliceButton) self.resliceButton.connect('clicked()', self.__onResliceButtonClicked__) # Select by default the airway type self.typesRadioButtonGroup.buttons()[2].setChecked(True) self.updateState()
def show(self): for item in self._typevbox.children(): if isinstance(item, qt.QWidget): self._typevbox.removeChild(item) del item self._type = None infos = [(info.name, type) for type, info in getAllChannelInfos().items()] infos.sort() for name, type in infos: if not self._type: self._type = type radio = qt.QRadioButton(name, self._typevbox, type) qt.QObject.connect(radio, qt.SIGNAL("clicked()"), self.ok) act = RadioAction(radio, type, name) act.connect(self, "_type", type) radio.show() self._typevbox.adjustSize() self._table.adjustSize() self._vbox.adjustSize() self._window.adjustSize() self._window.show() self._window.raiseW() type = None while True: self._result = self._window.exec_loop() if self._result == qt.QDialog.Accepted: type = self._type break type = None break self._window.hide() return type
def setup(self): """This is called one time when the module GUI is initialized """ CIP_PointsLabellingWidget.setup(self) # Part of the GUI will be inherited. We just fill the radio buttons area # Radio buttons frame self.radioButtonsLayout = qt.QHBoxLayout(self.radioButtonsFrame) self.typesFrame = qt.QFrame() self.radioButtonsLayout.addWidget(self.typesFrame) self.typesLayout = qt.QVBoxLayout(self.typesFrame) labelsStyle = "font-weight: bold; margin: 0 0 10px 0px;" # Types Radio Buttons typesLabel = qt.QLabel("Select type") typesLabel.setStyleSheet(labelsStyle) self.typesLayout.addWidget(typesLabel) self.typesRadioButtonGroup = qt.QButtonGroup() for key in self.logic.params.mainTypes.iterkeys(): rbitem = qt.QRadioButton(self.logic.params.getMainTypeLabel(key)) self.typesRadioButtonGroup.addButton(rbitem, key) self.typesLayout.addWidget(rbitem) self.typesRadioButtonGroup.buttons()[0].setChecked(True) # Subtypes Radio buttons # The content will be loaded dynamically every time the main type is modified self.subtypesFrame = qt.QFrame() self.radioButtonsLayout.addWidget(self.subtypesFrame) self.subtypesLayout = qt.QVBoxLayout(self.subtypesFrame) subtypesLabel = qt.QLabel("Select subtype") subtypesLabel.setStyleSheet(labelsStyle) self.subtypesLayout.addWidget(subtypesLabel) self.subtypesLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP) self.subtypesRadioButtonGroup = qt.QButtonGroup() # Add all the subtypes (we will filter later in "updateState" function) for key in self.logic.params.subtypes.iterkeys(): # Build the description rbitem = qt.QRadioButton(self.logic.params.getSubtypeLabel(key)) self.subtypesRadioButtonGroup.addButton(rbitem, key) self.subtypesLayout.addWidget(rbitem, SlicerUtil.ALIGNMENT_VERTICAL_TOP) self.subtypesLayout.addStretch() # Region radio buttons self.regionsFrame = qt.QFrame() self.radioButtonsLayout.addWidget(self.regionsFrame) self.regionsLayout = qt.QVBoxLayout(self.regionsFrame) regionsLabel = qt.QLabel("Select region") regionsLabel.setStyleSheet(labelsStyle) self.regionsLayout.addWidget(regionsLabel) self.regionsLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP) self.regionsLayout.setStretch(0, 0) self.regionsRadioButtonGroup = qt.QButtonGroup() self.regionsFrame = qt.QFrame() # Add all the regions for key in self.logic.params.regions.iterkeys(): # Build the description rbitem = qt.QRadioButton(self.logic.params.getRegionLabel(key)) self.regionsRadioButtonGroup.addButton(rbitem, key) self.regionsLayout.addWidget(rbitem, SlicerUtil.ALIGNMENT_VERTICAL_TOP) self.regionsLayout.addStretch() self.regionsRadioButtonGroup.buttons()[0].setChecked(True) # Artifact radio buttons (Add them to the same layout as the type) self.separatorLabel = qt.QLabel("------------") labelsStyle = "margin: 5px 0 5px 0;" self.separatorLabel.setStyleSheet(labelsStyle) self.typesLayout.addWidget(self.separatorLabel) self.artifactsLabel = qt.QLabel("Select artifact") labelsStyle = "font-weight: bold; margin: 15px 0 10px 0;" self.artifactsLabel.setStyleSheet(labelsStyle) self.typesLayout.addWidget(self.artifactsLabel) self.artifactsRadioButtonGroup = qt.QButtonGroup() for artifactId in self.logic.params.artifacts.iterkeys(): rbitem = qt.QRadioButton(self.logic.params.getArtifactLabel(artifactId)) self.artifactsRadioButtonGroup.addButton(rbitem, artifactId) self.typesLayout.addWidget(rbitem) self.artifactsRadioButtonGroup.buttons()[0].setChecked(True) self.typesLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP) self.typesLayout.addStretch() # Connections self.typesRadioButtonGroup.connect("buttonClicked (QAbstractButton*)", self.__onTypesRadioButtonClicked__) self.subtypesRadioButtonGroup.connect("buttonClicked (QAbstractButton*)", self.__onSecondaryRadioButtonClicked__) self.regionsRadioButtonGroup.connect("buttonClicked (QAbstractButton*)", self.__onSecondaryRadioButtonClicked__) self.artifactsRadioButtonGroup.connect("buttonClicked (QAbstractButton*)", self.__onSecondaryRadioButtonClicked__) self.updateState()
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))
def setupOptionsFrame(self): self.frame = qt.QFrame(self.scriptedEffect.optionsFrame()) qt.QFormLayout(self.frame) #Save space in the GUI self.frame.layout().setSpacing(0) self.frame.layout().setMargin(0) # self.helpLabel = qt.QLabel(self.frame) # self.helpLabel.setWordWrap(True) # #self.helpLabel.sizePolicy.setHorizontalPolicy(qt.QSizePolicy.Ignored) # #self.helpLabel.sizePolicy.setVerticalPolicy(qt.QSizePolicy.Ignored) # self.helpLabel.text = "Click on a lesion to start segmentation. \ # Depending on refinement settings, click again to refine globally and/or locally. Options may help deal \ # with cases such as segmenting individual lesions in a chain. \ # See <a href=\"https://www.slicer.org/wiki/Documentation/Nightly/Extensions/PETTumorSegmentation\">the documentation</a> for more information." # self.scriptedEffect.addOptionsWidget(self.helpLabel) # refinementBoxesFrame contains the options for how clicks are handled self.refinementBoxesFrame = qt.QFrame(self.frame) self.refinementBoxesFrame.setLayout(qt.QHBoxLayout()) self.refinementBoxesFrame.layout().setSpacing(0) self.refinementBoxesFrame.layout().setMargin(0) #default is global refinement (threshold refinement) self.noRefinementRadioButton = qt.QRadioButton( "Create new", self.refinementBoxesFrame) self.noRefinementRadioButton.setToolTip( "On click, always segment a new object.") self.globalRefinementRadioButton = qt.QRadioButton( "Global refinement", self.refinementBoxesFrame) self.globalRefinementRadioButton.setToolTip( "On click, refine globally (adjusting then entire boundary) if no center point for the label, otherwise segment a new object." ) self.localRefinementRadioButton = qt.QRadioButton( "Local refinement", self.refinementBoxesFrame) self.localRefinementRadioButton.setToolTip( "On click, refine locally (adjusting part of the boundary) if no center point for the label, otherwise segment a new object." ) self.globalRefinementRadioButton.setChecked(True) #radio button so only one can be applied self.refinementBoxesFrame.layout().addWidget( qt.QLabel("Interaction style: ", self.refinementBoxesFrame)) self.refinementBoxesFrame.layout().addWidget( self.noRefinementRadioButton) self.refinementBoxesFrame.layout().addWidget( self.globalRefinementRadioButton) self.refinementBoxesFrame.layout().addWidget( self.localRefinementRadioButton) self.refinementBoxesFrame.layout().addStretch(1) self.scriptedEffect.addOptionsWidget(self.refinementBoxesFrame) #options are hidden (collapsed) until requested self.optFrame = ctk.ctkCollapsibleGroupBox(self.frame) self.optFrame.setTitle("Options") self.optFrame.setLayout(qt.QVBoxLayout()) self.optFrame.visible = True self.optFrame.collapsed = True self.optFrame.setToolTip("Displays algorithm options.") #most useful options are kept on top: Splitting, Sealing, Assist Centering, Allow #Overwriting; to save vertical space, put 2 ina row, so subframes here with #horizontal layout are used #first row self.commonCheckBoxesFrame1 = qt.QFrame(self.optFrame) self.commonCheckBoxesFrame1.setLayout(qt.QHBoxLayout()) self.commonCheckBoxesFrame1.layout().setSpacing(0) self.commonCheckBoxesFrame1.layout().setMargin(0) self.optFrame.layout().addWidget(self.commonCheckBoxesFrame1) #top left self.splittingCheckBox = qt.QCheckBox("Splitting", self.commonCheckBoxesFrame1) self.splittingCheckBox.setToolTip( "Cut off adjacent objects to the target via watershed or local minimum. Useful for lymph node chains." ) self.splittingCheckBox.checked = False self.commonCheckBoxesFrame1.layout().addWidget(self.splittingCheckBox) #top right self.sealingCheckBox = qt.QCheckBox("Sealing", self.commonCheckBoxesFrame1) self.sealingCheckBox.setToolTip( "Close single-voxel gaps in the object or between the object and other objects, if above the threshold. Useful for lymph node chains." ) self.sealingCheckBox.checked = False self.commonCheckBoxesFrame1.layout().addWidget(self.sealingCheckBox) #second row self.commonCheckBoxesFrame2 = qt.QFrame(self.optFrame) self.commonCheckBoxesFrame2.setLayout(qt.QHBoxLayout()) self.commonCheckBoxesFrame2.layout().setSpacing(0) self.commonCheckBoxesFrame2.layout().setMargin(0) self.optFrame.layout().addWidget(self.commonCheckBoxesFrame2) #bottom left self.assistCenteringCheckBox = qt.QCheckBox( "Assist Centering", self.commonCheckBoxesFrame2) self.assistCenteringCheckBox.setToolTip( "Move the center to the highest voxel within 7 physical units, without being on or next to other object labels. Improves consistency." ) self.assistCenteringCheckBox.checked = True self.commonCheckBoxesFrame2.layout().addWidget( self.assistCenteringCheckBox) #bottom right self.allowOverwritingCheckBox = qt.QCheckBox( "Allow Overwriting", self.commonCheckBoxesFrame2) self.allowOverwritingCheckBox.setToolTip("Ignore other object labels.") self.allowOverwritingCheckBox.checked = False self.commonCheckBoxesFrame2.layout().addWidget( self.allowOverwritingCheckBox) self.scriptedEffect.addOptionsWidget(self.optFrame) #advanced options, for abnormal cases such as massive necrotic objects or #low-transition scans like phantoms #infrequently used, just keep vertical self.advFrame = ctk.ctkCollapsibleGroupBox(self.frame) self.advFrame.setTitle("Advanced") self.advFrame.setLayout(qt.QVBoxLayout()) self.advFrame.visible = True self.advFrame.collapsed = True self.advFrame.setToolTip( "Displays more advanced algorithm options. Do not use if you don't know what they mean." ) #top self.necroticRegionCheckBox = qt.QCheckBox("Necrotic Region", self.advFrame) self.necroticRegionCheckBox.setToolTip( "Prevents cutoff from low uptake. Use if placing a center inside a necrotic region." ) self.necroticRegionCheckBox.checked = False self.advFrame.layout().addWidget(self.necroticRegionCheckBox) #middle self.denoiseThresholdCheckBox = qt.QCheckBox("Denoise Threshold", self.advFrame) self.denoiseThresholdCheckBox.setToolTip( "Calculates threshold based on median-filtered image. Use only if scan is very noisey." ) self.denoiseThresholdCheckBox.checked = False self.advFrame.layout().addWidget(self.denoiseThresholdCheckBox) #bottom self.linearCostCheckBox = qt.QCheckBox("Linear Cost", self.advFrame) self.linearCostCheckBox.setToolTip( "Cost function below threshold is linear rather than based on region. Use only if little/no transition region in uptake." ) self.linearCostCheckBox.checked = False self.advFrame.layout().addWidget(self.linearCostCheckBox) self.optFrame.layout().addWidget(self.advFrame) #apply button kept at bottom of all options self.applyButton = qt.QPushButton("Apply", self.frame) self.optFrame.layout().addWidget(self.applyButton) self.applyButton.connect('clicked()', self.onApplyParameters) self.applyButton.setToolTip( "Redo last segmentation with the same center and refinement points with any changes in options." )
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)
def setup(self): """This is called one time when the module GUI is initialized """ ScriptedLoadableModuleWidget.setup(self) # Create objects that can be used anywhere in the module. Example: in most cases there should be just one # object of the logic class self.logic = CIP_PAARatioLogic() # # Create all the widgets. Example Area mainAreaCollapsibleButton = ctk.ctkCollapsibleButton() mainAreaCollapsibleButton.text = "Main parameters" self.layout.addWidget(mainAreaCollapsibleButton) self.mainAreaLayout = qt.QGridLayout(mainAreaCollapsibleButton) self.label = qt.QLabel("Select the volume") self.label.setStyleSheet("margin:10px 0 20px 7px") self.mainAreaLayout.addWidget(self.label, 0, 0) self.volumeSelector = slicer.qMRMLNodeComboBox() self.volumeSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "") self.volumeSelector.name = "paa_volumeSelector" self.volumeSelector.selectNodeUponCreation = True self.volumeSelector.autoFillBackground = True self.volumeSelector.addEnabled = True self.volumeSelector.noneEnabled = False self.volumeSelector.removeEnabled = False self.volumeSelector.showHidden = False self.volumeSelector.showChildNodeTypes = False self.volumeSelector.setMRMLScene(slicer.mrmlScene) self.volumeSelector.setStyleSheet( "margin:0px 0 0px 0; padding:2px 0 2px 5px") self.mainAreaLayout.addWidget(self.volumeSelector, 0, 1) self.jumptToTemptativeSliceButton = ctk.ctkPushButton() self.jumptToTemptativeSliceButton.name = "jumptToTemptativeSliceButton" self.jumptToTemptativeSliceButton.text = "Jump to temptative slice" self.jumptToTemptativeSliceButton.toolTip = "Jump to the best estimated slice to place the rulers" self.jumptToTemptativeSliceButton.setIcon( qt.QIcon("{0}/ruler.png".format(SlicerUtil.CIP_ICON_DIR))) self.jumptToTemptativeSliceButton.setIconSize(qt.QSize(20, 20)) self.jumptToTemptativeSliceButton.setStyleSheet("font-weight: bold;") # self.jumptToTemptativeSliceButton.setFixedWidth(140) self.mainAreaLayout.addWidget(self.jumptToTemptativeSliceButton, 1, 1) ### Structure Selector self.structuresGroupbox = qt.QGroupBox("Select the structure") self.groupboxLayout = qt.QVBoxLayout() self.structuresGroupbox.setLayout(self.groupboxLayout) self.mainAreaLayout.addWidget(self.structuresGroupbox, 2, 0) self.structuresButtonGroup = qt.QButtonGroup() # btn = qt.QRadioButton("None") # btn.visible = False # self.structuresButtonGroup.addButton(btn) # self.groupboxLayout.addWidget(btn) btn = qt.QRadioButton("Both") btn.name = "paaButton" btn.checked = True self.structuresButtonGroup.addButton(btn, 0) self.groupboxLayout.addWidget(btn) btn = qt.QRadioButton("Pulmonary Arterial") btn.name = "paRadioButton" self.structuresButtonGroup.addButton(btn, 1) self.groupboxLayout.addWidget(btn) btn = qt.QRadioButton("Aorta") btn.name = "aortaRadioButton" self.structuresButtonGroup.addButton(btn, 2) self.groupboxLayout.addWidget(btn) ### Buttons toolbox self.buttonsToolboxFrame = qt.QFrame() self.buttonsToolboxLayout = qt.QGridLayout() self.buttonsToolboxFrame.setLayout(self.buttonsToolboxLayout) self.mainAreaLayout.addWidget(self.buttonsToolboxFrame, 2, 1) self.placeRulersButton = ctk.ctkPushButton() self.placeRulersButton.text = "Place ruler/s" self.placeRulersButton.name = "placeRulersButton" self.placeRulersButton.toolTip = "Place the ruler/s for the selected structure/s in the current slice" self.placeRulersButton.setIcon( qt.QIcon("{0}/ruler.png".format(SlicerUtil.CIP_ICON_DIR))) self.placeRulersButton.setIconSize(qt.QSize(20, 20)) self.placeRulersButton.setFixedWidth(105) self.placeRulersButton.setStyleSheet("font-weight:bold") self.buttonsToolboxLayout.addWidget(self.placeRulersButton, 0, 0) self.moveUpButton = ctk.ctkPushButton() self.moveUpButton.text = "Move up" self.moveUpButton.toolTip = "Move the selected ruler/s one slice up" self.moveUpButton.setIcon( qt.QIcon("{0}/move_up.png".format(SlicerUtil.CIP_ICON_DIR))) self.moveUpButton.setIconSize(qt.QSize(20, 20)) self.moveUpButton.setFixedWidth(95) self.buttonsToolboxLayout.addWidget(self.moveUpButton, 0, 1) self.moveDownButton = ctk.ctkPushButton() self.moveDownButton.text = "Move down" self.moveDownButton.toolTip = "Move the selected ruler/s one slice down" self.moveDownButton.setIcon( qt.QIcon("{0}/move_down.png".format(SlicerUtil.CIP_ICON_DIR))) self.moveDownButton.setIconSize(qt.QSize(20, 20)) self.moveDownButton.setFixedWidth(95) self.buttonsToolboxLayout.addWidget(self.moveDownButton, 0, 2) self.removeButton = ctk.ctkPushButton() self.removeButton.text = "Remove ALL rulers" self.removeButton.toolTip = "Remove all the rulers for this volume" self.removeButton.setIcon( qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR))) self.removeButton.setIconSize(qt.QSize(20, 20)) self.buttonsToolboxLayout.addWidget(self.removeButton, 1, 1, 1, 2, 2) ### Textboxes self.textboxesFrame = qt.QFrame() self.textboxesLayout = qt.QFormLayout() self.textboxesFrame.setLayout(self.textboxesLayout) self.textboxesFrame.setFixedWidth(190) self.mainAreaLayout.addWidget(self.textboxesFrame, 3, 0) self.paTextBox = qt.QLineEdit() self.paTextBox.setReadOnly(True) self.textboxesLayout.addRow("PA (mm): ", self.paTextBox) self.aortaTextBox = qt.QLineEdit() self.aortaTextBox.setReadOnly(True) self.textboxesLayout.addRow("Aorta (mm): ", self.aortaTextBox) self.ratioTextBox = qt.QLineEdit() self.ratioTextBox.name = "ratioTextBox" self.ratioTextBox.setReadOnly(True) self.textboxesLayout.addRow("Ratio PA/A: ", self.ratioTextBox) # Save case data self.reportsCollapsibleButton = ctk.ctkCollapsibleButton() self.reportsCollapsibleButton.text = "Reporting" self.layout.addWidget(self.reportsCollapsibleButton) self.reportsLayout = qt.QHBoxLayout(self.reportsCollapsibleButton) self.storedColumnNames = [ "caseId", "paDiameterMm", "aortaDiameterMm", "pa1r", "pa1a", "pa1s", "pa2r", "pa2a", "pa2s", "a1r", "a1a", "a1s", "a2r", "a2a", "a2s" ] columns = CaseReportsWidget.getColumnKeysNormalizedDictionary( self.storedColumnNames) self.reportsWidget = CaseReportsWidget( self.moduleName, columns, parentWidget=self.reportsCollapsibleButton) self.reportsWidget.setup() # Init state self.resetModuleState() self.preventSavingState = False self.saveStateBeforeEnteringModule() self.preventSavingState = True self.switchToRedView() ##### # Case navigator if SlicerUtil.isSlicerACILLoaded(): caseNavigatorAreaCollapsibleButton = ctk.ctkCollapsibleButton() caseNavigatorAreaCollapsibleButton.text = "Case navigator" self.layout.addWidget(caseNavigatorAreaCollapsibleButton, 0x0020) # caseNavigatorLayout = qt.QVBoxLayout(caseNavigatorAreaCollapsibleButton) # Add a case list navigator from ACIL.ui import CaseNavigatorWidget self.caseNavigatorWidget = CaseNavigatorWidget( self.moduleName, caseNavigatorAreaCollapsibleButton) self.caseNavigatorWidget.setup() self.layout.addStretch() # Connections self.observers = [] self.volumeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onVolumeSelectorChanged) self.jumptToTemptativeSliceButton.connect( 'clicked()', self.onJumpToTemptativeSliceButtonClicked) self.placeRulersButton.connect('clicked()', self.onPlaceRulersClicked) self.moveUpButton.connect('clicked()', self.onMoveUpRulerClicked) self.moveDownButton.connect('clicked()', self.onMoveDownRulerClicked) self.removeButton.connect('clicked()', self.onRemoveRulerClicked) self.reportsWidget.addObservable( self.reportsWidget.EVENT_SAVE_BUTTON_CLICKED, self.onSaveReport) # Init state self.resetModuleState() self.preventSavingState = False self.saveStateBeforeEnteringModule() self.preventSavingState = True
def setupOptionsFrame(self): self.operationRadioButtons = [] #Fiducial Placement widget self.fiducialPlacementToggle = slicer.qSlicerMarkupsPlaceWidget() self.fiducialPlacementToggle.setMRMLScene(slicer.mrmlScene) self.fiducialPlacementToggle.placeMultipleMarkups = self.fiducialPlacementToggle.ForcePlaceMultipleMarkups self.fiducialPlacementToggle.buttonsVisible = False self.fiducialPlacementToggle.show() self.fiducialPlacementToggle.placeButton().show() self.fiducialPlacementToggle.deleteButton().show() # Edit surface button self.editButton = qt.QPushButton("Edit") self.editButton.objectName = self.__class__.__name__ + 'Edit' self.editButton.setToolTip( "Edit the previously placed group of fiducials.") fiducialAction = qt.QHBoxLayout() fiducialAction.addWidget(self.fiducialPlacementToggle) fiducialAction.addWidget(self.editButton) self.scriptedEffect.addLabeledOptionsWidget("Fiducial Placement: ", fiducialAction) #Operation buttons self.eraseInsideButton = qt.QRadioButton("Erase inside") self.operationRadioButtons.append(self.eraseInsideButton) self.buttonToOperationNameMap[self.eraseInsideButton] = 'ERASE_INSIDE' self.eraseOutsideButton = qt.QRadioButton("Erase outside") self.operationRadioButtons.append(self.eraseOutsideButton) self.buttonToOperationNameMap[ self.eraseOutsideButton] = 'ERASE_OUTSIDE' 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.setButton = qt.QRadioButton("Set") self.operationRadioButtons.append(self.setButton) self.buttonToOperationNameMap[self.setButton] = 'SET' #Operation buttons layout operationLayout = qt.QGridLayout() operationLayout.addWidget(self.eraseInsideButton, 0, 0) operationLayout.addWidget(self.eraseOutsideButton, 1, 0) operationLayout.addWidget(self.fillInsideButton, 0, 1) operationLayout.addWidget(self.fillOutsideButton, 1, 1) operationLayout.addWidget(self.setButton, 0, 2) self.scriptedEffect.addLabeledOptionsWidget("Operation:", operationLayout) # Apply button self.applyButton = qt.QPushButton("Apply") self.applyButton.objectName = self.__class__.__name__ + 'Apply' self.applyButton.setToolTip("Generate surface from markup fiducials.") self.scriptedEffect.addOptionsWidget(self.applyButton) # Cancel button self.cancelButton = qt.QPushButton("Cancel") self.cancelButton.objectName = self.__class__.__name__ + 'Cancel' self.cancelButton.setToolTip("Clear fiducials and remove from scene.") #Finish action buttons finishAction = qt.QHBoxLayout() finishAction.addWidget(self.cancelButton) finishAction.addWidget(self.applyButton) self.scriptedEffect.addOptionsWidget(finishAction) # connections for button in self.operationRadioButtons: button.connect( 'toggled(bool)', lambda toggle, widget=self.buttonToOperationNameMap[ button]: self.onOperationSelectionChanged(widget, toggle)) self.applyButton.connect('clicked()', self.onApply) self.cancelButton.connect('clicked()', self.onCancel) self.editButton.connect('clicked()', self.onEdit) self.fiducialPlacementToggle.placeButton().clicked.connect( self.onFiducialPlacementToggleChanged)
def setupOptionsFrame(self): self.modeRadioButtons = [] # Text line edit self.textLineEdit = qt.QLineEdit() self.textLineEdit.setToolTip("Text to be added") self.textLineEdit.text = "Text" self.textLineEditLabel = self.scriptedEffect.addLabeledOptionsWidget("Text:", self.textLineEdit) # Fiducial Placement widget self.markupsPlacementToggle = slicer.qSlicerMarkupsPlaceWidget() self.markupsPlacementToggle.setMRMLScene(slicer.mrmlScene) self.markupsPlacementToggle.placeMultipleMarkups = self.markupsPlacementToggle.ForcePlaceSingleMarkup self.markupsPlacementToggle.buttonsVisible = False self.markupsPlacementToggle.show() self.markupsPlacementToggle.placeButton().show() self.markupsPlacementToggle.deleteButton().show() # Edit surface button self.editButton = qt.QPushButton("Edit") self.editButton.objectName = self.__class__.__name__ + 'Edit' self.editButton.setToolTip("Edit the previously placed plane.") markupsActionLayout = qt.QHBoxLayout() markupsActionLayout.addWidget(self.markupsPlacementToggle) markupsActionLayout.addWidget(self.editButton) self.scriptedEffect.addLabeledOptionsWidget("Placement: ", markupsActionLayout) # Resize button self.interactionResizeButton = qt.QPushButton("Resize") self.interactionResizeButton.objectName = self.__class__.__name__ + 'Resize' self.interactionResizeButton.checkable = True self.interactionResizeButton.setToolTip("Enable/disable resize of the text plane.") # Move button self.interactionMoveButton = qt.QPushButton("Move") self.interactionMoveButton.objectName = self.__class__.__name__ + 'Move' self.interactionMoveButton.checkable = True self.interactionMoveButton.setToolTip("Enable/disable translation and rotation of the text plane.") interactionLayout = qt.QHBoxLayout() interactionLayout.addWidget(self.interactionResizeButton) interactionLayout.addWidget(self.interactionMoveButton) self.scriptedEffect.addLabeledOptionsWidget("Interaction: ", interactionLayout) # Text depth slider self.textDepthSlider = ctk.ctkSliderWidget() self.textDepthSlider.setToolTip("Thickness of the generated text.") self.textDepthSlider.minimum = 0.1 self.textDepthSlider.maximum = 20.0 self.textDepthSlider.value = 5 self.textDepthSlider.singleStep = 0.1 self.textDepthSlider.pageStep = 1.0 self.textDepthLabel = self.scriptedEffect.addLabeledOptionsWidget("Depth:", self.textDepthSlider) # Mode buttons self.engraveButton = qt.QRadioButton("Engrave") self.modeRadioButtons.append(self.engraveButton) self.buttonToModeTypeMap[self.engraveButton] = "ENGRAVE" self.embossButton = qt.QRadioButton("Emboss") self.modeRadioButtons.append(self.embossButton) self.buttonToModeTypeMap[self.embossButton] = "EMBOSS" # Mode buttons layout modeLayout = qt.QVBoxLayout() modeLayout.addWidget(self.engraveButton) modeLayout.addWidget(self.embossButton) self.scriptedEffect.addLabeledOptionsWidget("Mode:", modeLayout) # Apply button self.applyButton = qt.QPushButton("Apply") self.applyButton.objectName = self.__class__.__name__ + 'Apply' self.applyButton.setToolTip("Generate tube from markup fiducials.") self.scriptedEffect.addOptionsWidget(self.applyButton) # Cancel button self.cancelButton = qt.QPushButton("Cancel") self.cancelButton.objectName = self.__class__.__name__ + 'Cancel' self.cancelButton.setToolTip("Clear fiducials and remove from scene.") # Finish action buttons finishAction = qt.QHBoxLayout() finishAction.addWidget(self.cancelButton) finishAction.addWidget(self.applyButton) self.scriptedEffect.addOptionsWidget(finishAction) # Connections for button in self.modeRadioButtons: button.connect('toggled(bool)', lambda toggle, widget=self.buttonToModeTypeMap[button]: self.onModeSelectionChanged(widget, toggle)) self.applyButton.connect('clicked()', self.onApply) self.cancelButton.connect('clicked()', self.onCancel) self.editButton.connect('clicked()', self.onEdit) self.markupsPlacementToggle.placeButton().clicked.connect(self.onmarkupsPlacementToggleChanged) self.interactionResizeButton.connect('toggled(bool)', self.onInteractionResizeEnabled) self.interactionMoveButton.connect('toggled(bool)', self.onInteractionMoveEnabled) self.textLineEdit.connect("textEdited(QString)", self.onTextChanged) self.textDepthSlider.connect('valueChanged(double)', self.onTextDepthChanged)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Select base mesh # self.modelSelector = slicer.qMRMLNodeComboBox() self.modelSelector.nodeTypes = (("vtkMRMLModelNode"), "") self.modelSelector.selectNodeUponCreation = False self.modelSelector.addEnabled = False self.modelSelector.removeEnabled = False self.modelSelector.noneEnabled = True self.modelSelector.showHidden = False self.modelSelector.setMRMLScene(slicer.mrmlScene) parametersFormLayout.addRow("Base mesh: ", self.modelSelector) # # Select base landmark file # #self.baseLMFile=ctk.ctkPathLineEdit() #self.baseLMFile.setToolTip( "Select file specifying base landmarks" ) #parametersFormLayout.addRow("Base landmark file: ", self.baseLMFile) self.baseLMSelect = slicer.qMRMLNodeComboBox() self.baseLMSelect.nodeTypes = (('vtkMRMLMarkupsFiducialNode'), "") self.baseLMSelect.selectNodeUponCreation = False self.baseLMSelect.addEnabled = False self.baseLMSelect.removeEnabled = False self.baseLMSelect.noneEnabled = True self.baseLMSelect.showHidden = False self.baseLMSelect.showChildNodeTypes = False self.baseLMSelect.setMRMLScene(slicer.mrmlScene) parametersFormLayout.addRow("Base landmarks: ", self.baseLMSelect) # # Select base semi-landmark file # #self.baseLMFile=ctk.ctkPathLineEdit() #self.baseLMFile.setToolTip( "Select file specifying base landmarks" ) #parametersFormLayout.addRow("Base landmark file: ", self.baseLMFile) self.baseSLMSelect = slicer.qMRMLNodeComboBox() self.baseSLMSelect.nodeTypes = (('vtkMRMLMarkupsFiducialNode'), "") self.baseSLMSelect.selectNodeUponCreation = False self.baseSLMSelect.addEnabled = False self.baseSLMSelect.removeEnabled = False self.baseSLMSelect.noneEnabled = True self.baseSLMSelect.showHidden = False self.baseSLMSelect.showChildNodeTypes = False self.baseSLMSelect.setMRMLScene(slicer.mrmlScene) parametersFormLayout.addRow("Base semi-landmarks: ", self.baseSLMSelect) # # Select meshes directory # self.meshDirectory = ctk.ctkPathLineEdit() self.meshDirectory.filters = ctk.ctkPathLineEdit.Dirs self.meshDirectory.setToolTip("Select directory containing meshes") parametersFormLayout.addRow("Mesh directory: ", self.meshDirectory) # # Select landmarks directory # self.landmarkDirectory = ctk.ctkPathLineEdit() self.landmarkDirectory.filters = ctk.ctkPathLineEdit.Dirs self.landmarkDirectory.setToolTip( "Select directory containing landmarks") parametersFormLayout.addRow("Landmark directory: ", self.landmarkDirectory) # # Select semi-landmarks directory # self.semilandmarkDirectory = ctk.ctkPathLineEdit() self.semilandmarkDirectory.filters = ctk.ctkPathLineEdit.Dirs self.semilandmarkDirectory.setToolTip( "Select directory containing semi-landmarks") self.semilandmarkDirectory.enabled = False parametersFormLayout.addRow("Semi-landmark directory: ", self.semilandmarkDirectory) # # Select output directory # self.outputDirectory = ctk.ctkPathLineEdit() self.outputDirectory.filters = ctk.ctkPathLineEdit.Dirs self.outputDirectory.currentPath = slicer.app.temporaryPath self.outputDirectory.setToolTip( "Select directory to save output distance maps") parametersFormLayout.addRow("Output directory: ", self.outputDirectory) # # Select distance metric # self.unSignedDistanceOption = qt.QRadioButton() self.unSignedDistanceOption.setChecked(True) parametersFormLayout.addRow("Unsigned Distance: ", self.unSignedDistanceOption) self.signedDistanceOption = qt.QRadioButton() self.signedDistanceOption.setChecked(False) parametersFormLayout.addRow("Signed Distance: ", self.signedDistanceOption) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Generate MeshDistanceMeasurements." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # connections self.modelSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onSelect) self.baseLMSelect.connect('currentNodeChanged(vtkMRMLNode*)', self.onSelect) self.meshDirectory.connect('validInputChanged(bool)', self.onSelect) self.baseSLMSelect.connect('currentNodeChanged(bool)', self.onSelectBaseSLM) self.semilandmarkDirectory.connect('validInputChanged(bool)', self.onSelect) self.applyButton.connect('clicked(bool)', self.onApplyButton) # Add vertical spacer self.layout.addStretch(1)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Select landmark file to import # self.inputDirectory = ctk.ctkPathLineEdit() self.inputDirectory.filters = ctk.ctkPathLineEdit.Dirs self.inputDirectory.setToolTip( "Select directory containing curves to resample") parametersFormLayout.addRow("Input Directory:", self.inputDirectory) # # output directory selector # self.outputDirectory = ctk.ctkPathLineEdit() self.outputDirectory.filters = ctk.ctkPathLineEdit.Dirs self.outputDirectory.currentPath = slicer.app.temporaryPath parametersFormLayout.addRow("Output Directory:", self.outputDirectory) # # Get Resample number # self.ResampleRateWidget = ctk.ctkDoubleSpinBox() self.ResampleRateWidget.value = 50 self.ResampleRateWidget.minimum = 3 self.ResampleRateWidget.maximum = 5000 self.ResampleRateWidget.singleStep = 1 self.ResampleRateWidget.setDecimals(0) self.ResampleRateWidget.setToolTip( "Select the number of points for resampling: ") parametersFormLayout.addRow("Output sample number: ", self.ResampleRateWidget) # # Get open or closed curve option # curveTypeSelector = qt.QHBoxLayout() self.curveTypeOpen = qt.QRadioButton("open") self.curveTypeOpen.setToolTip( "Select option for no interpolation between first and last points") self.curveTypeOpen.setChecked(True) self.curveTypeClosed = qt.QRadioButton("closed") self.curveTypeClosed.setToolTip( "Select option to interpolate between first and last points") curveTypeSelector.addWidget(self.curveTypeOpen) curveTypeSelector.addWidget(self.curveTypeClosed) curveTypeSelector.addStretch() parametersFormLayout.addRow("Curve Type: ", curveTypeSelector) # # check box to trigger taking screen shots for later use in tutorials # self.enableScreenshotsFlagCheckBox = qt.QCheckBox() self.enableScreenshotsFlagCheckBox.checked = 0 self.enableScreenshotsFlagCheckBox.setToolTip( "If checked, take screen shots for tutorials. Use Save Data to write them to disk." ) parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the conversion." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.inputDirectory.connect('validInputChanged(bool)', self.onSelectInput) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelectInput()
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = PFileParserLogic() # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # input volume selector # self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.inputSelector.selectNodeUponCreation = True self.inputSelector.addEnabled = False self.inputSelector.removeEnabled = False self.inputSelector.noneEnabled = False self.inputSelector.showHidden = False self.inputSelector.showChildNodeTypes = False self.inputSelector.setMRMLScene(slicer.mrmlScene) self.inputSelector.setToolTip("Pick the input to the algorithm.") parametersFormLayout.addRow("Input Volume: ", self.inputSelector) # %%%%%%%%%%%%%%% Read PFile button section %%%%%%%%%%%%%% # Collapsible bar pCollapsibleBar = ctk.ctkCollapsibleButton() pCollapsibleBar.text = "fMRSI data" self.layout.addWidget(pCollapsibleBar) # Layout within the sample collapsible button formLayout = qt.QFormLayout(pCollapsibleBar) # Frame input edit sub-layout frameLayout = qt.QHBoxLayout(pCollapsibleBar) pStartAtFrameText = self.createFrameText( frameLayout, "From frame: ", 100, "First frame to be read from fMRSI file (1 = first).") # Add spacer frameLayout.addStretch(1) # Text input frame end pStopAtFrameText = self.createFrameText( frameLayout, "To frame: ", 100, "Last frame to be read from fMRSI file.") # Add horizontal frame to form layout formLayout.addRow(frameLayout) # ============== Buttons ============== # Button widget code pFileButton = qt.QPushButton("Read PFile...") pFileButton.toolTip = "Load raw PFile (.7) data" pFileButton.enabled = False formLayout.addRow(pFileButton) # =============== Radio Buttons ======== self.units = ("ppm", "hz", "points") pUnitsBox = qt.QGroupBox("Units") pUnitsBox.enabled = False pUnitsBox.setLayout(qt.QFormLayout()) pUnitsButtons = {} for units in self.units: pUnitsButtons[units] = qt.QRadioButton() pUnitsButtons[units].text = units pUnitsBox.layout().addRow(pUnitsButtons[units]) self.selectedUnits = self.units[0] pUnitsButtons[self.selectedUnits].checked = True formLayout.addRow(pUnitsBox) # =============== Sliders ============== # Frame slider pFrameSlider = ctk.ctkSliderWidget() pFrameSlider.decimals = 0 pFrameSlider.minimum = 1 pFrameSlider.maximum = 1 pFrameSlider.enabled = False formLayout.addRow("Frame:", pFrameSlider) # X axis Slider pXAxisRange = ctk.ctkRangeWidget() pXAxisRange.enabled = False pXAxisRange.minimum = 0.0 pXAxisRange.maximum = 0.0 formLayout.addRow("X axis range:", pXAxisRange) # Button widget code pPlotSpectrumButton = qt.QPushButton("Plot Spectrum...") pPlotSpectrumButton.toolTip = "Plot mean single voxel spectrum from PFile (.7) data" pPlotSpectrumButton.enabled = False formLayout.addRow(pPlotSpectrumButton) # ============== Info Text ============== # Text Info pInfoText = qt.QTextEdit() pInfoText.setReadOnly(True) pInfoText.setToolTip("Data read from fMRSI file.") formLayout.addRow(pInfoText) # connections pFileButton.connect('clicked(bool)', self.onPFileButtonClicked) pPlotSpectrumButton.connect('clicked(bool)', self.onPlotSpectrumButtonClicked) self.inputSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onSelect) for units in self.units: pUnitsButtons[units].connect( 'clicked()', lambda u=units: self.onPUnitsButtonsClicked(u)) # Set local var as instance attribute self.pFileButton = pFileButton self.pPlotSpectrumButton = pPlotSpectrumButton self.pInfoText = pInfoText self.pStartAtFrameText = pStartAtFrameText self.pStopAtFrameText = pStopAtFrameText self.pFrameSlider = pFrameSlider self.pXAxisRange = pXAxisRange self.pUnitsBox = pUnitsBox self.pUnitsButtons = pUnitsButtons # Add spacer self.layout.addStretch(1) # Refresh button status self.onSelect()
def buildGUI(self, parent): registrationLayout = qt.QFormLayout(parent) self.fromTrackingDataSelector = slicer.qMRMLNodeComboBox() self.fromTrackingDataSelector.nodeTypes = (( "vtkMRMLIGTLTrackingDataBundleNode"), "") self.fromTrackingDataSelector.selectNodeUponCreation = True self.fromTrackingDataSelector.addEnabled = True self.fromTrackingDataSelector.removeEnabled = False self.fromTrackingDataSelector.noneEnabled = False self.fromTrackingDataSelector.showHidden = True self.fromTrackingDataSelector.showChildNodeTypes = False self.fromTrackingDataSelector.setMRMLScene(slicer.mrmlScene) self.fromTrackingDataSelector.setToolTip("Tracking Data (From)") registrationLayout.addRow("TrackingData (From): ", self.fromTrackingDataSelector) self.toTrackingDataSelector = slicer.qMRMLNodeComboBox() self.toTrackingDataSelector.nodeTypes = (( "vtkMRMLIGTLTrackingDataBundleNode"), "") self.toTrackingDataSelector.selectNodeUponCreation = True self.toTrackingDataSelector.addEnabled = True self.toTrackingDataSelector.removeEnabled = False self.toTrackingDataSelector.noneEnabled = False self.toTrackingDataSelector.showHidden = True self.toTrackingDataSelector.showChildNodeTypes = False self.toTrackingDataSelector.setMRMLScene(slicer.mrmlScene) self.toTrackingDataSelector.setToolTip("Tracking data (To)") registrationLayout.addRow("TrackingData (To): ", self.toTrackingDataSelector) pointBoxLayout = qt.QHBoxLayout() self.pointGroup = qt.QButtonGroup() self.useTipRadioButton = qt.QRadioButton("Tip") self.useAllRadioButton = qt.QRadioButton("All ") self.useTipRadioButton.checked = 1 pointBoxLayout.addWidget(self.useTipRadioButton) self.pointGroup.addButton(self.useTipRadioButton) pointBoxLayout.addWidget(self.useAllRadioButton) self.pointGroup.addButton(self.useAllRadioButton) registrationLayout.addRow("Points: ", pointBoxLayout) # # Fiducial points visibility # visibilityBoxLayout = qt.QHBoxLayout() self.visibilityGroup = qt.QButtonGroup() self.visibilityOnRadioButton = qt.QRadioButton("ON") self.visibilityOffRadioButton = qt.QRadioButton("Off") self.visibilityOnRadioButton.checked = 1 visibilityBoxLayout.addWidget(self.visibilityOnRadioButton) self.visibilityGroup.addButton(self.visibilityOnRadioButton) visibilityBoxLayout.addWidget(self.visibilityOffRadioButton) self.visibilityGroup.addButton(self.visibilityOffRadioButton) registrationLayout.addRow("Visibility: ", visibilityBoxLayout) # # Collect/Clear button # buttonBoxLayout = qt.QHBoxLayout() self.collectButton = qt.QPushButton() self.collectButton.setCheckable(False) self.collectButton.text = 'Collect' self.collectButton.setToolTip("Collect points from the catheters.") buttonBoxLayout.addWidget(self.collectButton) self.clearButton = qt.QPushButton() self.clearButton.setCheckable(False) self.clearButton.text = 'Clear' self.clearButton.setToolTip( "Clear the collected points from the list.") buttonBoxLayout.addWidget(self.clearButton) registrationLayout.addRow("", buttonBoxLayout) # # Registration button # #runBoxLayout = qt.QHBoxLayout() self.runButton = qt.QPushButton() self.runButton.setCheckable(False) self.runButton.text = 'Run Registration' self.runButton.setToolTip("Run fiducial registration.") #buttonBoxLayout.addWidget(self.runButton) registrationLayout.addRow("", self.runButton) # # Connect signals and slots # self.fromTrackingDataSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onTrackingDataFromSelected) self.toTrackingDataSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onTrackingDataToSelected) self.collectButton.connect(qt.SIGNAL("clicked()"), self.onCollectPoints) self.clearButton.connect(qt.SIGNAL("clicked()"), self.onClearPoints) self.runButton.connect(qt.SIGNAL("clicked()"), self.onRunRegistration) self.visibilityOnRadioButton.connect("clicked(bool)", self.onVisibilityChanged) self.visibilityOffRadioButton.connect("clicked(bool)", self.onVisibilityChanged)