def setup(self): # Instantiate and connect widgets ... # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "RSNAVisTutorial Reload" self.layout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # reload and test button # (use this during development, but remove it when delivering # your module to users) self.reloadAndTestButton = qt.QPushButton("Reload and Test") self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests." self.layout.addWidget(self.reloadAndTestButton) self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest) # Collapsible button testsCollapsibleButton = ctk.ctkCollapsibleButton() testsCollapsibleButton.text = "Tests" self.layout.addWidget(testsCollapsibleButton) # Layout within the collapsible button formLayout = qt.QFormLayout(testsCollapsibleButton) # test buttons tests = ( ("Part 1: DICOM", self.onPart1DICOM), ("Part 2: Head", self.onPart2Head), ("Part 3: Liver", self.onPart3Liver), ("Part 4: Lung", self.onPart4Lung), ) for text, slot in tests: testButton = qt.QPushButton(text) testButton.toolTip = "Run the test." formLayout.addWidget(testButton) testButton.connect('clicked(bool)', slot) # A collapsible button to hide screen shot options screenShotsCollapsibleButton = ctk.ctkCollapsibleButton() screenShotsCollapsibleButton.text = "Screen shot options" self.layout.addWidget(screenShotsCollapsibleButton) # layout within the collapsible button screenShotsFormLayout = qt.QFormLayout(screenShotsCollapsibleButton) # # 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." ) screenShotsFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox) # # scale factor for screen shots # self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget() self.screenshotScaleFactorSliderWidget.singleStep = 1.0 self.screenshotScaleFactorSliderWidget.minimum = 1.0 self.screenshotScaleFactorSliderWidget.maximum = 50.0 self.screenshotScaleFactorSliderWidget.value = 1.0 self.screenshotScaleFactorSliderWidget.setToolTip( "Set scale factor for the screen shots.") screenShotsFormLayout.addRow("Screenshot scale factor", self.screenshotScaleFactorSliderWidget) # 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) # # node type to add # self.nodeTypeComboBox = qt.QComboBox() self.nodeTypeComboBox.addItem("vtkMRMLMarkupsFiducialNode") self.nodeTypeComboBox.addItem("vtkMRMLMarkupsLineNode") self.nodeTypeComboBox.addItem("vtkMRMLMarkupsAngleNode") self.nodeTypeComboBox.addItem("vtkMRMLMarkupsCurveNode") self.nodeTypeComboBox.addItem("vtkMRMLMarkupsClosedCurveNode") self.nodeTypeComboBox.addItem("vtkMRMLMarkupsROINode") parametersFormLayout.addRow("Node type: ", self.nodeTypeComboBox) # # number of nodes to add # self.numberOfNodesSliderWidget = ctk.ctkSliderWidget() self.numberOfNodesSliderWidget.singleStep = 1.0 self.numberOfNodesSliderWidget.decimals = 0 self.numberOfNodesSliderWidget.minimum = 0.0 self.numberOfNodesSliderWidget.maximum = 1000.0 self.numberOfNodesSliderWidget.value = 1.0 self.numberOfNodesSliderWidget.toolTip = "Set the number of nodes to add." parametersFormLayout.addRow("Number of nodes: ", self.numberOfNodesSliderWidget) # # number of fiducials to add # self.numberOfControlPointsSliderWidget = ctk.ctkSliderWidget() self.numberOfControlPointsSliderWidget.singleStep = 1.0 self.numberOfControlPointsSliderWidget.decimals = 0 self.numberOfControlPointsSliderWidget.minimum = 0.0 self.numberOfControlPointsSliderWidget.maximum = 10000.0 self.numberOfControlPointsSliderWidget.value = 500.0 self.numberOfControlPointsSliderWidget.toolTip = "Set the number of control points to add per node." parametersFormLayout.addRow("Number of control points: ", self.numberOfControlPointsSliderWidget) # # check box to trigger fewer modify events, adding all the new points # is wrapped inside of a StartModify/EndModify block # self.fewerModifyFlagCheckBox = qt.QCheckBox() self.fewerModifyFlagCheckBox.checked = 0 self.fewerModifyFlagCheckBox.toolTip = 'If checked, wrap adding points inside of a StartModify - EndModify block' parametersFormLayout.addRow("Fewer modify events: ", self.fewerModifyFlagCheckBox) # # markups locked # self.lockedFlagCheckBox = qt.QCheckBox() self.lockedFlagCheckBox.checked = 0 self.lockedFlagCheckBox.toolTip = 'If checked, markups will be locked for editing' parametersFormLayout.addRow("Locked nodes: ", self.lockedFlagCheckBox) # # markups labels hidden # self.labelsHiddenFlagCheckBox = qt.QCheckBox() self.labelsHiddenFlagCheckBox.checked = 0 self.labelsHiddenFlagCheckBox.toolTip = 'If checked, markups labels will be forced to be hidden, regardless of default markups properties' parametersFormLayout.addRow("Labels hidden: ", self.labelsHiddenFlagCheckBox) # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = True parametersFormLayout.addRow(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) # Add vertical spacer self.layout.addStretch(1)
def setupTrainingTab(self): self.trainingLayout = qt.QVBoxLayout(self.trainingTabWidget) gridLayoutTrain = qt.QGridLayout() self.lr_spinbox = qt.QDoubleSpinBox() self.lr_spinbox.setSingleStep(0.001) self.lr_spinbox.setValue(0.01) self.lr_spinbox.setDecimals(3) self.num_epochs_spinbox = qt.QSpinBox() self.num_epochs_spinbox.setSingleStep(1) self.num_epochs_spinbox.setValue(1) gridLayoutTrain.addWidget(qt.QLabel("Learning Rate"), 0, 0) gridLayoutTrain.addWidget(self.lr_spinbox, 0, 1) gridLayoutTrain.addWidget(qt.QLabel("Number of Epochs"), 1, 0) gridLayoutTrain.addWidget(self.num_epochs_spinbox, 1, 1) gridLayoutSumdir = qt.QGridLayout() self.sumDirTrainSelector = qt.QPushButton("Browse") self.sumDirTrain = qt.QLineEdit("") self.modelDirTrainSelector = qt.QPushButton("Browse") self.modelDirTrain = qt.QLineEdit("") self.dataDirTrainSelector = qt.QPushButton("Browse") self.dataDirTrain = qt.QLineEdit("") gridLayoutSumdir.addWidget(qt.QLabel("Data Directory"), 1, 0) gridLayoutSumdir.addWidget(self.dataDirTrain, 1, 1) gridLayoutSumdir.addWidget(self.dataDirTrainSelector, 1, 2) gridLayoutSumdir.addWidget(qt.QLabel("Model Directory"), 2, 0) gridLayoutSumdir.addWidget(self.modelDirTrain, 2, 1) gridLayoutSumdir.addWidget(self.modelDirTrainSelector, 2, 2) gridLayoutSumdir.addWidget(qt.QLabel("Summary Directory"), 3, 0) gridLayoutSumdir.addWidget(self.sumDirTrain, 3, 1) gridLayoutSumdir.addWidget(self.sumDirTrainSelector, 3, 2) gridResTrain = qt.QGridLayout() self.trainReset = qt.QPushButton("RESET") self.trainTrain = qt.QPushButton("TRAIN") gridResTrain.addWidget(self.trainReset, 0, 0) gridResTrain.addWidget(self.trainTrain, 0, 1) self.trainingLayout.addLayout(gridLayoutTrain) self.trainingLayout.addLayout(gridLayoutSumdir) self.trainingLayout.addLayout(gridResTrain) self.trainingLayout.addStretch(1) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # CONNECTIONS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # self.trainReset.connect("clicked(bool)", self.OnTrainReset) self.trainTrain.connect("clicked(bool)", self.OnTrainTrain) self.dataDirTrainSelector.connect("clicked(bool)", self.OnDataDirTrain) self.modelDirTrainSelector.connect("clicked(bool)", self.OnModelDirTrain) self.sumDirTrainSelector.connect("clicked(bool)", self.OnSumDirTrain) self.dataDirTrain.connect("editingFinished()", self.CheckDataDirTrain) self.modelDirTrain.connect("editingFinished()", self.CheckModelDirTrain) self.sumDirTrain.connect("editingFinished()", self.CheckSumDirTrain) # self.trainingWidget = widget return
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = VectorToScalarVolumeLogic() # This will use createParameterNode with the provided default options self.setParameterNode(self.logic.getParameterNode()) # Collapsible button self.selectionCollapsibleButton = ctk.ctkCollapsibleButton() self.selectionCollapsibleButton.text = "Selection" self.layout.addWidget(self.selectionCollapsibleButton) # Layout within the "Selection" collapsible button parametersFormLayout = qt.QFormLayout(self.selectionCollapsibleButton) # # the volume selectors # self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"] self.inputSelector.addEnabled = False self.inputSelector.removeEnabled = False self.inputSelector.setMRMLScene(slicer.mrmlScene) parametersFormLayout.addRow("Input Vector Volume: ", self.inputSelector) self.outputSelector = slicer.qMRMLNodeComboBox() self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.outputSelector.hideChildNodeTypes = ["vtkMRMLVectorVolumeNode"] self.outputSelector.setMRMLScene(slicer.mrmlScene) self.outputSelector.addEnabled = True self.outputSelector.renameEnabled = True self.outputSelector.baseName = "Scalar Volume" parametersFormLayout.addRow("Output Scalar Volume: ", self.outputSelector) # # Options to extract single components # self.conversionMethodWidget = VectorToScalarVolumeConversionMethodWidget( ) parametersFormLayout.addRow("Conversion Method: ", self.conversionMethodWidget) # Apply button self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run Convert the vector to scalar." parametersFormLayout.addRow(self.applyButton) # Parameter set selector (inspired by SegmentStatistics.py) self.parameterNodeSelector = slicer.qMRMLNodeComboBox() self.parameterNodeSelector.nodeTypes = (("vtkMRMLScriptedModuleNode"), "") self.parameterNodeSelector.addAttribute("vtkMRMLScriptedModuleNode", "ModuleName", "VectorToScalarVolume") self.parameterNodeSelector.selectNodeUponCreation = True self.parameterNodeSelector.addEnabled = True self.parameterNodeSelector.renameEnabled = True self.parameterNodeSelector.removeEnabled = True self.parameterNodeSelector.noneEnabled = False self.parameterNodeSelector.showHidden = True self.parameterNodeSelector.showChildNodeTypes = False self.parameterNodeSelector.baseName = "VectorToScalarVolume" self.parameterNodeSelector.setMRMLScene(slicer.mrmlScene) self.parameterNodeSelector.toolTip = "Pick parameter set" parametersFormLayout.addRow("Parameter set: ", self.parameterNodeSelector) # Add vertical spacer self.layout.addStretch(1) # Connections self.parameterNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.setParameterNode) self.parameterNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.updateGuiFromMRML) # updateParameterNodeFromGui self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.updateParameterNodeFromGui) self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.updateParameterNodeFromGui) self.applyButton.connect('clicked(bool)', self.onApply) # conversion widget self.conversionMethodWidget.methodSelectorComboBox.connect( 'currentIndexChanged(int)', lambda currentIndex: self. conversionMethodWidget.setGuiBasedOnOptions( self.conversionMethodWidget.methodSelectorComboBox.itemData( currentIndex), self.inputVolumeNode())) self.conversionMethodWidget.methodSelectorComboBox.connect( 'currentIndexChanged(int)', self.updateParameterNodeFromGui) self.conversionMethodWidget.componentsComboBox.connect( 'currentIndexChanged(int)', self.updateParameterNodeFromGui) # The parameter node had defaults at creation, propagate them to the GUI. self.updateGuiFromMRML()
def setup(self): # this is the function that implements all GUI ScriptedLoadableModuleWidget.setup(self) # This sets the view being used to the red view only slicer.app.layoutManager().setLayout( slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView) l = slicer.modules.createmodels.logic() self.needleModel = l.CreateNeedle(150, 0.4, 0, False) #This code block creates a collapsible button #This defines which type of button you are using self.usContainer = ctk.ctkCollapsibleButton() #This is what the button will say self.usContainer.text = "Ultrasound Information" #Thiss actually creates that button self.layout.addWidget(self.usContainer) #This creates a variable that describes layout within this collapsible button self.usLayout = qt.QFormLayout(self.usContainer) #This descirbes the type of widget self.inputIPLineEdit = qt.QLineEdit() #This sets a placehoder example of what should be inputted to the line edit self.inputIPLineEdit.setPlaceholderText("127.0.0.1") #This is the help tooltip self.inputIPLineEdit.toolTip = "Put the IP address of your ultrasound device here" #This is the text that is input inot the line self.IPLabel = qt.QLabel("Server IP:") if slicer.mrmlScene.GetNodesByClass( "vtkMRMLSequenceNode").GetNumberOfItems() == 0: self.usLayout.addRow(self.IPLabel, self.inputIPLineEdit) #This code block is the exact same as the one above only it asks for the server port self.layout.addWidget(self.usContainer) self.inputPortLineEdit = qt.QLineEdit() self.inputPortLineEdit.setPlaceholderText("18944") self.inputPortLineEdit.setValidator(qt.QIntValidator()) self.inputPortLineEdit.toolTip = "Put the Port of your ultrasound device here" self.portLabel = qt.QLabel("Sever Port:") if slicer.mrmlScene.GetNodesByClass( "vtkMRMLSequenceNode").GetNumberOfItems() == 0: self.usLayout.addRow(self.portLabel, self.inputPortLineEdit) #This is a push button self.connectButton = qt.QPushButton() self.connectButton.setDefault(False) #This button says connect self.connectButton.text = "Connect" #help tooltip that explains the funciton self.connectButton.toolTip = "Connects to Ultrasound" #adds the widget to the layout if slicer.mrmlScene.GetNodesByClass( "vtkMRMLSequenceNode").GetNumberOfItems() == 0: self.usLayout.addWidget(self.connectButton) # Combobox for image selection self.imageSelector = slicer.qMRMLNodeComboBox() self.imageSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.imageSelector.selectNodeUponCreation = True self.imageSelector.addEnabled = False self.imageSelector.removeEnabled = False self.imageSelector.noneEnabled = True self.imageSelector.showHidden = False self.imageSelector.showChildNodeTypes = False self.imageSelector.setMRMLScene(slicer.mrmlScene) self.imageSelector.setToolTip("Pick the image to be used.") self.usLayout.addRow("US Volume: ", self.imageSelector) #add combo box for linear transform node self.TransformSelector = slicer.qMRMLNodeComboBox() self.TransformSelector.nodeTypes = ["vtkMRMLLinearTransformNode"] self.TransformSelector.selectNodeUponCreation = True self.TransformSelector.addEnabled = False self.TransformSelector.removeEnabled = False self.TransformSelector.noneEnabled = True self.TransformSelector.showHidden = False self.TransformSelector.showChildNodeTypes = False self.TransformSelector.setMRMLScene(slicer.mrmlScene) self.TransformSelector.setToolTip( "Pick the transform representing the straw line.") self.usLayout.addRow("Tip to Probe: ", self.TransformSelector) self.calibrationContainer = ctk.ctkCollapsibleButton() #This is what the button will say self.calibrationContainer.text = "Calibration Parameters" #Thiss actually creates that button self.layout.addWidget(self.calibrationContainer) #This creates a variable that describes layout within this collapsible button self.calibrationLayout = qt.QFormLayout(self.calibrationContainer) self.segLabel = qt.QLabel() self.calibrationLayout.addRow(qt.QLabel("Type of segmentation:"), self.segLabel) self.recordContainer = ctk.ctkCollapsibleButton() #This is what the button will say self.recordContainer.text = "Recording Options" #Thiss actually creates that button #This creates a variable that describes layout within this collapsible button self.recordLayout = qt.QFormLayout(self.recordContainer) self.RecordButton = qt.QPushButton() self.RecordButton.text = "Start Recording" self.recordLayout.addWidget(self.RecordButton) self.StopRecordButton = qt.QPushButton() self.StopRecordButton.text = "Stop Recording" self.recordLayout.addWidget(self.StopRecordButton) self.pathInput = qt.QLineEdit() self.pathInput.setPlaceholderText("Enter the path to save files to") self.pathText = qt.QLabel("File Path:") self.recordLayout.addRow(self.pathText, self.pathInput) self.SaveRecordButton = qt.QPushButton() self.SaveRecordButton.text = "Save Recording" self.recordLayout.addWidget(self.SaveRecordButton) # This creates another collapsible button self.fiducialContainer = ctk.ctkCollapsibleButton() self.fiducialContainer.text = "Registration" self.fiducialLayout = qt.QFormLayout(self.fiducialContainer) #This is the exact same as the code block below but it freezes the US to capture a screenshot self.freezeButton = qt.QPushButton() if slicer.mrmlScene.GetNodesByClass( "vtkMRMLSequenceNode").GetNumberOfItems() == 0: self.freezeButton.text = "Freeze" else: self.freezeButton.text = "Place Fiducial" self.freezeButton.toolTip = "Freeze the ultrasound image for fiducial placement" self.fiducialLayout.addRow(self.freezeButton) self.shortcut = qt.QShortcut(qt.QKeySequence('f'), slicer.util.mainWindow()) self.numFidLabel = qt.QLabel() self.fiducialLayout.addRow(qt.QLabel("Fiducials collected:"), self.numFidLabel) self.transformTable = qt.QTableWidget() self.transTableItem = qt.QTableWidgetItem() self.fidError = qt.QLabel() self.transformTable.setRowCount(4) self.transformTable.setColumnCount(4) self.transformTable.horizontalHeader().hide() self.transformTable.verticalHeader().hide() self.transformTable.setItem(0, 0, qt.QTableWidgetItem("1")) self.transformTable.setItem(0, 1, qt.QTableWidgetItem("0")) self.transformTable.setItem(0, 2, qt.QTableWidgetItem("0")) self.transformTable.setItem(0, 3, qt.QTableWidgetItem("0")) self.transformTable.setItem(1, 0, qt.QTableWidgetItem("0")) self.transformTable.setItem(1, 1, qt.QTableWidgetItem("1")) self.transformTable.setItem(1, 2, qt.QTableWidgetItem("0")) self.transformTable.setItem(1, 3, qt.QTableWidgetItem("0")) self.transformTable.setItem(2, 0, qt.QTableWidgetItem("0")) self.transformTable.setItem(2, 1, qt.QTableWidgetItem("0")) self.transformTable.setItem(2, 2, qt.QTableWidgetItem("1")) self.transformTable.setItem(2, 3, qt.QTableWidgetItem("0")) self.transformTable.setItem(3, 0, qt.QTableWidgetItem("0")) self.transformTable.setItem(3, 1, qt.QTableWidgetItem("0")) self.transformTable.setItem(3, 2, qt.QTableWidgetItem("0")) self.transformTable.setItem(3, 3, qt.QTableWidgetItem("1")) self.transformTable.setSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.MinimumExpanding) self.copyIcon = qt.QIcon(":Icons/Medium/SlicerEditCopy.png") self.copyButton = qt.QPushButton() self.copyButton.setIcon(self.copyIcon) self.copyButton.toolTip = "Copy" self.copyButton.setMaximumWidth(64) self.copyHbox = qt.QHBoxLayout() self.copyHbox.addWidget(self.copyButton) self.copyButton.enabled = False if self.numFidLabel >= 2: self.copyButton.enabled = True self.fiducialLayout.addRow(qt.QLabel("Image to probe transform:")) self.fiducialLayout.addRow(self.transformTable) # Add vertical spacer self.layout.addStretch(1) # Add vertical spacer self.layout.addStretch(1) self.fiducialLayout.addRow("Copy:", self.copyHbox) self.validationContainer = ctk.ctkCollapsibleButton() self.validationContainer.text = "Validation" self.validationLayout = qt.QFormLayout(self.validationContainer) self.visualizeButton = qt.QPushButton('Show 3D Scene') self.visualizeButton.toolTip = "This button enables the 3D view for visual validation" self.validationLayout.addRow(self.visualizeButton) self.visualizeButton.connect('clicked(bool)', self.onVisualizeButtonClicked) self.resetButton = qt.QPushButton('Reset') self.resetButton.setDefault(False) self.resetButton.toolTip = "This Button Resets the Module" self.validationLayout.addRow(self.resetButton) # Add the containers to the parent self.layout.addWidget(self.usContainer) self.layout.addWidget(self.calibrationContainer) if slicer.mrmlScene.GetNodesByClass( "vtkMRMLSequenceNode").GetNumberOfItems() == 0: self.layout.addWidget(self.recordContainer) self.layout.addWidget(self.fiducialContainer) #self.layout.addWidget(self.transformContainer) self.layout.addWidget(self.validationContainer) # Add vertical spacer self.layout.addStretch(1) # Connections if slicer.mrmlScene.GetNodesByClass( "vtkMRMLSequenceNode").GetNumberOfItems() == 0: self.connectButton.connect('clicked(bool)', self.onConnectButtonClicked) self.freezeButton.connect('clicked(bool)', self.onConnectButtonClicked) self.shortcut.connect('activated()', self.onConnectButtonClicked) else: self.shortcut.connect('activated()', self.onFiducialClicked) self.freezeButton.connect('clicked(bool)', self.onFiducialClicked) self.RecordButton.connect('clicked(bool)', self.onRecordButtonClicked) self.StopRecordButton.connect('clicked(bool)', self.onStopRecordButtonClicked) self.SaveRecordButton.connect('clicked(bool)', self.onSaveRecordButtonClicked) self.copyButton.connect('clicked(bool)', self.onCopyButtonClicked) self.inputIPLineEdit.connect('textChanged(QString)', self.onInputChanged) self.inputPortLineEdit.connect('textChanged(QString)', self.onInputChanged) self.imageSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onImageChanged) self.TransformSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onTransformChanged) self.resetButton.connect('clicked(bool)', self.onResetButtonClicked) # Disable buttons until conditions are met self.connectButton.setEnabled(True) if slicer.mrmlScene.GetNodesByClass( "vtkMRMLSequenceNode").GetNumberOfItems() == 0: self.freezeButton.setEnabled(False) self.StopRecordButton.setEnabled(False) self.sceneObserverTag = slicer.mrmlScene.AddObserver( slicer.mrmlScene.NodeAddedEvent, self.onNodeAdded)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # Parameters Area parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parametros" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # input volume selector self.baseSelector = slicer.qMRMLNodeComboBox() self.baseSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.baseSelector.selectNodeUponCreation = False self.baseSelector.addEnabled = False self.baseSelector.removeEnabled = False self.baseSelector.noneEnabled = False self.baseSelector.showHidden = False self.baseSelector.showChildNodeTypes = False self.baseSelector.setMRMLScene(slicer.mrmlScene) self.baseSelector.setToolTip("Volume base para comparacao") parametersFormLayout.addRow("Volume Base: ", self.baseSelector) # input fiducial selector self.fiducialSelector = slicer.qMRMLNodeComboBox() self.fiducialSelector.nodeTypes = ["vtkMRMLMarkupsFiducialNode"] self.fiducialSelector.selectNodeUponCreation = True self.fiducialSelector.addEnabled = False self.fiducialSelector.removeEnabled = False self.fiducialSelector.noneEnabled = False self.fiducialSelector.showHidden = False self.fiducialSelector.showChildNodeTypes = False self.fiducialSelector.setMRMLScene(slicer.mrmlScene) self.fiducialSelector.setToolTip( "Ponto fiducial base para criacao da ROI") parametersFormLayout.addRow("Ponto Fiducial: ", self.fiducialSelector) # Buttons self.setROIButton = qt.QPushButton("Criar ROI") self.setROIButton.toolTip = "" self.setROIButton.enabled = False parametersFormLayout.addRow(self.setROIButton) self.applyButton = qt.QPushButton("Iniciar") self.applyButton.toolTip = "Executar." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # Progress Bar self.progressBar = qt.QProgressBar() self.progressBar.setMinimum(0) self.progressBar.setMaximum(0) self.progressBar.setVisible(False) parametersFormLayout.addRow(self.progressBar) # Add vertical spacer self.layout.addStretch(1) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.setROIButton.connect('clicked(bool)', self.createROI) self.fiducialSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.baseSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.setBackground) # Refresh Apply button state self.onSelect()
def setup(self): # Instantiate and connect widgets ... # Collapsible button parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the parameters collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # fiber self.fiberSelector = slicer.qMRMLNodeComboBox( parametersCollapsibleButton) self.fiberSelector.nodeTypes = ["vtkMRMLFiberBundleNode"] self.fiberSelector.selectNodeUponCreation = False self.fiberSelector.addEnabled = False self.fiberSelector.removeEnabled = False self.fiberSelector.noneEnabled = True self.fiberSelector.showHidden = False self.fiberSelector.showChildNodeTypes = False self.fiberSelector.setMRMLScene(slicer.mrmlScene) self.fiberSelector.setToolTip("Pick the fiber bundle to be converted.") parametersFormLayout.addRow("Fiber Bundle", self.fiberSelector) # label map self.labelSelector = slicer.qMRMLNodeComboBox( parametersCollapsibleButton) self.labelSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] self.labelSelector.selectNodeUponCreation = False self.labelSelector.addEnabled = False self.labelSelector.removeEnabled = False self.labelSelector.noneEnabled = True self.labelSelector.showHidden = False self.labelSelector.showChildNodeTypes = False self.labelSelector.setMRMLScene(slicer.mrmlScene) self.labelSelector.setToolTip( "Pick the target label volume. Must already exists in order to define sampling grid. If needed, create one in the Editor module based on template volume." ) parametersFormLayout.addRow("Target LabelMap", self.labelSelector) # label value self.labelValue = qt.QSpinBox(parametersCollapsibleButton) self.labelValue.setToolTip( "The numerical value for the rasterized fiber label.") self.labelValue.setValue(1) parametersFormLayout.addRow("Label Value", self.labelValue) # apply self.applyButton = qt.QPushButton(parametersCollapsibleButton) self.applyButton.text = "Apply" parametersFormLayout.addWidget(self.applyButton) self.applyButton.connect('clicked()', self.onApply) # 'Advanced' collapsible button advancedCollapsibleButton = ctk.ctkCollapsibleButton() advancedCollapsibleButton.text = "Advanced" advancedCollapsibleButton.collapsed = True self.layout.addWidget(advancedCollapsibleButton) advancedFormLayout = qt.QFormLayout(advancedCollapsibleButton) self.samplingDistance = ctk.ctkDoubleSpinBox() self.samplingDistance.minimum = 0.01 self.samplingDistance.maximum = 5.0 self.samplingDistance.decimals = 2 self.samplingDistance.singleStep = 0.1 self.samplingDistance.value = 0.1 self.samplingDistance.decimalsOption = ( ctk.ctkDoubleSpinBox.ReplaceDecimals | ctk.ctkDoubleSpinBox.DecimalsByKey) advancedFormLayout.addRow("Sampling distance (mm)", self.samplingDistance) # 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) self.meshDirectory = ctk.ctkPathLineEdit() self.meshDirectory.filters = ctk.ctkPathLineEdit.Dirs self.meshDirectory.setToolTip("Select directory containing landmarks") parametersFormLayout.addRow("Mesh directory: ", self.meshDirectory) self.landmarkDirectory = ctk.ctkPathLineEdit() self.landmarkDirectory.filters = ctk.ctkPathLineEdit.Dirs self.landmarkDirectory.setToolTip("Select directory containing meshes") parametersFormLayout.addRow("Landmark directory: ", self.landmarkDirectory) self.gridFile = ctk.ctkPathLineEdit() self.gridFile.filters = ctk.ctkPathLineEdit().Files self.gridFile.setToolTip( "Select file specifying semi-landmark connectivity") parametersFormLayout.addRow("Grid connectivity file: ", self.gridFile) # Select output directory self.outputDirectory = ctk.ctkPathLineEdit() self.outputDirectory.filters = ctk.ctkPathLineEdit.Dirs self.outputDirectory.setToolTip("Select directory for output models: ") parametersFormLayout.addRow("Output directory: ", self.outputDirectory) # # set sample rate value # self.sampleRate = ctk.ctkDoubleSpinBox() self.sampleRate.singleStep = 1 self.sampleRate.minimum = 1 self.sampleRate.maximum = 100 self.sampleRate.setDecimals(0) self.sampleRate.value = 10 self.sampleRate.setToolTip( "Select sample rate for semi-landmark interpolation") parametersFormLayout.addRow("Sample rate for interpolation:", self.sampleRate) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Generate PlaceSemiLMPatchess." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # connections self.meshDirectory.connect('validInputChanged(bool)', self.onSelect) self.landmarkDirectory.connect('validInputChanged(bool)', self.onSelect) self.gridFile.connect('validInputChanged(bool)', self.onSelect) self.outputDirectory.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) # # input volume selector # self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = ["vtkMRMLSequenceNode"] 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 a sequence node of volumes that will be cropped and resampled." ) parametersFormLayout.addRow("Input volume sequence: ", self.inputSelector) # # output volume selector # self.outputSelector = slicer.qMRMLNodeComboBox() self.outputSelector.nodeTypes = ["vtkMRMLSequenceNode"] self.outputSelector.selectNodeUponCreation = True self.outputSelector.addEnabled = True self.outputSelector.removeEnabled = True self.outputSelector.noneEnabled = True self.outputSelector.noneDisplay = "(Overwrite input)" self.outputSelector.showHidden = False self.outputSelector.showChildNodeTypes = False self.outputSelector.setMRMLScene(slicer.mrmlScene) self.outputSelector.setToolTip( "Pick a sequence node where the cropped and resampled volumes will be stored." ) parametersFormLayout.addRow("Output volume sequence: ", self.outputSelector) # # Crop parameters selector # self.cropParametersSelector = slicer.qMRMLNodeComboBox() self.cropParametersSelector.nodeTypes = [ "vtkMRMLCropVolumeParametersNode" ] self.cropParametersSelector.selectNodeUponCreation = True self.cropParametersSelector.addEnabled = True self.cropParametersSelector.removeEnabled = True self.cropParametersSelector.renameEnabled = True self.cropParametersSelector.noneEnabled = False self.cropParametersSelector.showHidden = True self.cropParametersSelector.showChildNodeTypes = False self.cropParametersSelector.setMRMLScene(slicer.mrmlScene) self.cropParametersSelector.setToolTip( "Select a crop volumes parameters.") self.editCropParametersButton = qt.QPushButton() self.editCropParametersButton.setIcon(qt.QIcon(':Icons/Go.png')) #self.editCropParametersButton.setMaximumWidth(60) self.editCropParametersButton.enabled = True self.editCropParametersButton.toolTip = "Go to Crop Volume module to edit cropping parameters." hbox = qt.QHBoxLayout() hbox.addWidget(self.cropParametersSelector) hbox.addWidget(self.editCropParametersButton) parametersFormLayout.addRow("Crop volume settings: ", hbox) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.cropParametersSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.editCropParametersButton.connect("clicked()", self.onEditCropParameters) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelect()
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = WebSocketLogic(self) # Websocket self.host = "localhost" self.port = 8180 self.socket = None # Instantiate and connect widgets ... # # Parameters Area # websocketCollapsibleButton = ctk.ctkCollapsibleButton() websocketCollapsibleButton.text = "Websocket" self.layout.addWidget(websocketCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(websocketCollapsibleButton) # # Apply Button # self.connectButton = qt.QPushButton("Connect") self.connectButton.toolTip = "Run the algorithm." parametersFormLayout.addRow(self.connectButton) # # Disconnect Button # self.disconnectButton = qt.QPushButton("Disconnect") parametersFormLayout.addRow(self.disconnectButton) # # Python Console # self.pythonConsole = qt.QTextEdit() self.pythonConsole.readOnly = True parametersFormLayout.addRow(self.pythonConsole) # connections self.connectButton.connect('clicked(bool)', self.onConnectButton) self.disconnectButton.connect('clicked(bool)', self.onDisconnectButton) # self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) # self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # =-=-=-=-=-=-=-=-=-= QT SOCKET =-=-=-=-=-=-=-=-=-= # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # Doc: http://pyqt.sourceforge.net/Docs/PyQt4/qabstractsocket.html self.socket = qt.QTcpSocket() self.socket.connect('connected()', self.on_connect) self.socket.connect('disconnected()', self.on_disconnect) self.socket.connect('hostFound()', self.on_hostFound) self.socket.connect('readyRead()', self.handleRead) # Need to be fixed self.socket.connect("error( ::QAbstractSocket::SocketError)", self.on_error) # self.socket.connect('bytesWritten()', self.on_written) # Add vertical spacer self.layout.addStretch(1)
def setupOptionsFrame(self): self.interpolationRadioButtons = [] # 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.") fiducialActionLayout = qt.QHBoxLayout() fiducialActionLayout.addWidget(self.fiducialPlacementToggle) fiducialActionLayout.addWidget(self.editButton) self.scriptedEffect.addLabeledOptionsWidget("Fiducial Placement: ", fiducialActionLayout) # Radius spinbox self.radiusSpinBox = slicer.qMRMLSpinBox() self.radiusSpinBox.value = self.logic.radius self.radiusSpinBox.quantity = 'length' self.radiusSpinBox.unitAwareProperties = slicer.qMRMLSpinBox.MaximumValue | slicer.qMRMLSpinBox.Precision | slicer.qMRMLSpinBox.Prefix | slicer.qMRMLSpinBox.Suffix self.scriptedEffect.addLabeledOptionsWidget("Radius: ", self.radiusSpinBox) # Interpolation buttons self.piecewiseLinearButton = qt.QRadioButton("Piecewise linear") self.interpolationRadioButtons.append(self.piecewiseLinearButton) self.buttonToInterpolationTypeMap[ self.piecewiseLinearButton] = "LINEAR" self.cardinalSplineButton = qt.QRadioButton("Cardinal spline") self.interpolationRadioButtons.append(self.cardinalSplineButton) self.buttonToInterpolationTypeMap[ self.cardinalSplineButton] = "CARDINAL_SPLINE" self.kochanekSplineButton = qt.QRadioButton("Kochanek spline") self.interpolationRadioButtons.append(self.kochanekSplineButton) self.buttonToInterpolationTypeMap[ self.kochanekSplineButton] = "KOCHANEK_SPLINE" self.globalPolynomialButton = qt.QRadioButton("Global polynomial") self.interpolationRadioButtons.append(self.globalPolynomialButton) self.buttonToInterpolationTypeMap[ self.globalPolynomialButton] = "GLOBAL_POLYNOMIAL" self.movingPolynomialButton = qt.QRadioButton("Moving polynomial") self.interpolationRadioButtons.append(self.movingPolynomialButton) self.buttonToInterpolationTypeMap[ self.movingPolynomialButton] = "MOVING_POLYNOMIAL" # Segments per point spinbox self.numberOfLineSegmentsSpinBox = qt.QSpinBox() self.numberOfLineSegmentsSpinBox.value = 15 # To keep GUI simple, we do not show numberOfLineSegmentsSpinBox. # Default value should work for most cases and modules can programmatically change this value, if needed. # If user feedback confirms that this parameter must be exposed then the next line can be uncommented. # self.scriptedEffect.addLabeledOptionsWidget("Segments between points: ", self.numberOfLineSegmentsSpinBox) # Interpolation buttons layout interpolationLayout = qt.QGridLayout() interpolationLayout.addWidget(self.piecewiseLinearButton, 0, 0) interpolationLayout.addWidget(self.cardinalSplineButton, 1, 0) interpolationLayout.addWidget(self.kochanekSplineButton, 0, 1) interpolationLayout.addWidget(self.globalPolynomialButton, 1, 1) interpolationLayout.addWidget(self.movingPolynomialButton, 0, 2) self.scriptedEffect.addLabeledOptionsWidget("Interpolation:", interpolationLayout) # 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.interpolationRadioButtons: button.connect('toggled(bool)', lambda toggle, widget=self. buttonToInterpolationTypeMap[button]: self. onInterpolationSelectionChanged(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) self.radiusSpinBox.connect('valueChanged(double)', self.onRadiusChanged) self.numberOfLineSegmentsSpinBox.connect( 'valueChanged(int)', self.onNumberOfLineSegmentsChanged)
def buildInterface(self): self.layout = qt.QHBoxLayout(self) self.titleLabel = QubLabel("<B>Title<B>", self) self.titleLabel.setAlignment(qt.Qt.AlignCenter) self.titleLabel.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)) self.layout.addWidget(self.titleLabel) """ move and configure appearence """ self.radioGroup = QubRadioGroup(QubRadioGroup.Horizontal, self) self.radioGroup.hide() self.connect(self.radioGroup, qt.PYSIGNAL("PositionClicked"), self.positionClicked) self.layout.addWidget(self.radioGroup) self.setButton = qt.QPushButton("Set", self) self.setButton.hide() self.connect(self.setButton, qt.SIGNAL("clicked()"), self.setPosition) self.setButton.setEnabled(False) self.layout.addWidget(self.setButton) """ display appearence """ self.valueLabel = qt.QLabel("no value", self) self.valueLabel.hide() self.valueLabel.setAlignment(qt.Qt.AlignCenter) self.layout.addWidget(self.valueLabel) """ incremental appearence """ self.frame = qt.QFrame(self) self.frame.hide() self.frame.setFrameShape(qt.QFrame.NoFrame) self.frame.setFrameShadow(qt.QFrame.Plain) self.layout.addWidget(self.frame) vlayout = qt.QVBoxLayout(self.frame) vlayout.setMargin(10) self.valueWidget = QubValue(self.frame, titleType=QubValue.Label, valueType=QubValue.Label, orientation=QubValue.Horizontal) self.valueWidget.setTitle("Current Position") vlayout.addWidget(self.valueWidget) vlayout.addSpacing(5) hlayout = qt.QHBoxLayout(vlayout) self.positionList = qt.QListBox(self.frame) hlayout.addWidget(self.positionList) hlayout.addSpacing(5) vlayout1 = qt.QVBoxLayout(hlayout) self.gotoButton = qt.QPushButton("Go", self.frame) self.connect(self.gotoButton, qt.SIGNAL("clicked()"), self.gotoPosition) vlayout1.addWidget(self.gotoButton) vlayout1.addStretch(1) self.addButton = qt.QPushButton("Add", self.frame) self.connect(self.addButton, qt.SIGNAL("clicked()"), self.addPosition) vlayout1.addWidget(self.addButton) vlayout1.addSpacing(5) self.remButton = qt.QPushButton("Delete", self.frame) self.connect(self.remButton, qt.SIGNAL("clicked()"), self.remPosition) vlayout1.addWidget(self.remButton) """ popup config """ self.configWindow = MultiplePositionConfigurator(self) self.popupMenu = qt.QPopupMenu(self.titleLabel) self.popupMenu.insertItem("Configure", self.configWindow.show)
def __init__(self, parent=None, name="data_collect", selection_changed=None): qt.QWidget.__init__(self, parent, name) # Internal members self.collecting = False self.centring_method = 0 self.queue_hwobj = None self.queue_model_hwobj = None self.beamline_setup_hwobj = None self.sample_centring_result = gevent.event.AsyncResult() # HW-Object set by TreeBrick self.sample_changer_hwobj = None self.hl_motor_hwobj = None self.tree_brick = self.parent() self.sample_item_list = [] self.collect_tree_task = None self.user_stopped = False # Callbacks TODO:Document better self.selection_changed_cb = None self.collect_stop_cb = None #self.clear_centred_positions_cb = None self.run_cb = None # Layout self.setCaption("Data collect") self.confirm_dialog = ConfirmDialog(self, 'Confirm Dialog') self.confirm_dialog.setModal(True) self.pin_pixmap = Icons.load("sample_axis.png") self.task_pixmap = Icons.load("task.png") self.play_pixmap = Icons.load("VCRPlay.png") self.stop_pixmap = Icons.load("Stop.png") self.up_pixmap = Icons.load("Up2.png") self.down_pixmap = Icons.load("Down2.png") self.delete_pixmap = Icons.load("bin_small.png") self.ispyb_pixmap = Icons.load("SampleChanger2.png") self.caution_pixmap = Icons.load("Caution2.png") self.up_button = qt.QPushButton(self, "up_button") self.up_button.setPixmap(self.up_pixmap) self.up_button.setFixedHeight(25) self.delete_button = qt.QPushButton(self, "delete_button") self.delete_button.setPixmap(self.delete_pixmap) self.delete_button.setDisabled(True) qt.QToolTip.add(self.delete_button, "Delete highlighted queue entries") self.down_button = qt.QPushButton(self, "down_button") self.down_button.setPixmap(self.down_pixmap) self.down_button.setFixedHeight(25) self.collect_button = qt.QPushButton(self, "collect_button") self.collect_button.setText("Collect Queue") self.collect_button.setFixedWidth(125) self.collect_button.setIconSet(qt.QIconSet(self.play_pixmap)) self.collect_button.setPaletteBackgroundColor( widget_colors.LIGHT_GREEN) self.continue_button = qt.QPushButton(self, "ok_button") self.continue_button.setText('Pause') self.continue_button.setEnabled(True) self.continue_button.setFixedWidth(75) qt.QToolTip.add(self.continue_button, "Pause after current data collection") self.sample_list_view = qt.QListView(self, "sample_list_view") self.sample_list_view.setSelectionMode(qt.QListView.Extended) self.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Expanding)) self.sample_list_view.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Expanding)) self.sample_list_view.setSorting(-1) self.sample_list_view.addColumn("", 280) self.sample_list_view.addColumn("", 130) self.sample_list_view.header().hide() self.sample_list_view.header().hide() self.sample_list_view.setFrameShape(qt.QListView.StyledPanel) self.sample_list_view.setFrameShadow(qt.QListView.Sunken) self.sample_list_view.setRootIsDecorated(1) self.sample_list_view.setSelected(self.sample_list_view.firstChild(), True) layout = qt.QVBoxLayout(self, 0, 0, 'main_layout') button_layout = qt.QHBoxLayout(None, 0, 0, 'button_layout') button_layout.addWidget(self.up_button) button_layout.addWidget(self.down_button) layout.setSpacing(10) layout.addWidget(self.sample_list_view) self.buttons_grid_layout = qt.QGridLayout(2, 5) layout.addLayout(self.buttons_grid_layout) self.buttons_grid_layout.addLayout(button_layout, 0, 0) self.buttons_grid_layout.addWidget(self.delete_button, 0, 4) self.buttons_grid_layout.addWidget(self.collect_button, 1, 0) self.buttons_grid_layout.addWidget(self.continue_button, 1, 4) self.clearWState(qt.Qt.WState_Polished) qt.QObject.connect(self.up_button, qt.SIGNAL("clicked()"), self.up_click) qt.QObject.connect(self.down_button, qt.SIGNAL("clicked()"), self.down_click) qt.QObject.connect(self.delete_button, qt.SIGNAL("clicked()"), self.delete_click) qt.QObject.connect(self.collect_button, qt.SIGNAL("clicked()"), self.collect_stop_toggle) qt.QObject.connect(self.sample_list_view, qt.SIGNAL("selectionChanged()"), self.sample_list_view_selection) qt.QObject.connect( self.sample_list_view, qt.SIGNAL( "contextMenuRequested(QListViewItem *, const QPoint& , int)"), self.show_context_menu) qt.QObject.connect( self.sample_list_view, qt.SIGNAL("itemRenamed(QListViewItem *, int , const QString& )"), self.item_renamed) qt.QObject.connect( self.sample_list_view, qt.SIGNAL("doubleClicked(QListViewItem *, const QPoint &, int)"), self.item_double_click) qt.QObject.connect( self.sample_list_view, qt.SIGNAL( "mouseButtonClicked(int, QListViewItem *, const QPoint &, int)" ), self.item_click) qt.QObject.connect(self.confirm_dialog, qt.PYSIGNAL("continue_clicked"), self.collect_items) qt.QObject.connect(self.continue_button, qt.SIGNAL("clicked()"), self.continue_button_click) self.sample_list_view.viewport().installEventFilter(self) self.setFixedWidth(415)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Input/Export Area # IOCollapsibleButton = ctk.ctkCollapsibleButton() IOCollapsibleButton.text = "Input and Export" self.layout.addWidget(IOCollapsibleButton) # Layout within the dummy collapsible button #IOFormLayout = qt.QFormLayout(IOCollapsibleButton) IOFormLayout = qt.QGridLayout(IOCollapsibleButton) # # Table volume selector # tableSelectorLable = qt.QLabel("Input table: ") self.tableSelector = ctk.ctkPathLineEdit() self.tableSelector.nameFilters = ["*.csv"] self.tableSelector.setToolTip("Select table with filenames to process") #IOFormLayout.addRow("Input table: ", self.tableSelector) self.selectorButton = qt.QPushButton("Load Table") self.selectorButton.toolTip = "Load the table of image filenames to process" self.selectorButton.enabled = False #IOFormLayout.addRow(self.selectorButton) IOFormLayout.addWidget(tableSelectorLable, 1, 1) IOFormLayout.addWidget(self.tableSelector, 1, 2) IOFormLayout.addWidget(self.selectorButton, 1, 3) # # Import Volume Button # self.importVolumeButton = qt.QPushButton("Import image") self.importVolumeButton.toolTip = "Import the image selected in the table" self.importVolumeButton.enabled = False IOFormLayout.addWidget(self.importVolumeButton, 2, 1, 1, 3) # # Image editing Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Image Editing" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # input volume selector # self.volumeSelector = slicer.qMRMLNodeComboBox() self.volumeSelector.nodeTypes = [ "vtkMRMLScalarVolumeNode", "vtkMRMLVectorVolumeNode" ] self.volumeSelector.selectNodeUponCreation = True self.volumeSelector.addEnabled = True self.volumeSelector.removeEnabled = True self.volumeSelector.noneEnabled = True self.volumeSelector.showHidden = False self.volumeSelector.showChildNodeTypes = False self.volumeSelector.renameEnabled = True self.volumeSelector.setMRMLScene(slicer.mrmlScene) self.volumeSelector.setToolTip("Select volume to resample") parametersFormLayout.addRow("Input Volume: ", self.volumeSelector) # # # # input spacing # # # spacingLayout= qt.QGridLayout() # self.spacingX = ctk.ctkDoubleSpinBox() # self.spacingX.value = 1 # self.spacingX.minimum = 0 # self.spacingX.singleStep = 1 # self.spacingX.setDecimals(2) # self.spacingX.setToolTip("Input spacing X") # # self.spacingY = ctk.ctkDoubleSpinBox() # self.spacingY.value = 1 # self.spacingY.minimum = 0 # self.spacingY.singleStep = 1 # self.spacingY.setDecimals(2) # self.spacingY.setToolTip("Input spacing Y") # # self.spacingZ = ctk.ctkDoubleSpinBox() # self.spacingZ.value = 1 # self.spacingZ.minimum = 0 # self.spacingZ.singleStep = 1 # self.spacingZ.setDecimals(2) # self.spacingZ.setToolTip("Input spacing Z") # # spacingLayout.addWidget(self.spacingX,1,2) # spacingLayout.addWidget(self.spacingY,1,3) # spacingLayout.addWidget(self.spacingZ,1,4) # # parametersFormLayout.addRow("Spacing (mm):", spacingLayout) # # # # Apply Button # # # self.applySpacingButton = qt.QPushButton("Apply Spacing") # self.applySpacingButton.toolTip = "Run the algorithm." # self.applySpacingButton.enabled = False # parametersFormLayout.addRow(self.applySpacingButton) # # Flip X-axis Button # self.flipXButton = qt.QPushButton("Flip X-axis") self.flipXButton.toolTip = "Flip the loaded volume across the X-axis" self.flipXButton.enabled = False parametersFormLayout.addRow(self.flipXButton) # # Flip Y-axis Button # self.flipYButton = qt.QPushButton("Flip Y-axis") self.flipYButton.toolTip = "Flip the loaded volume across the Y-axis" self.flipYButton.enabled = False parametersFormLayout.addRow(self.flipYButton) # # Flip Z-axis Button # self.flipZButton = qt.QPushButton("Flip Z-axis") self.flipZButton.toolTip = "Flip the loaded volume across the x-axis" self.flipZButton.enabled = False parametersFormLayout.addRow(self.flipZButton) # # Annotations area # annotationsButton = ctk.ctkCollapsibleButton() annotationsButton.text = "Annotations" self.layout.addWidget(annotationsButton) annotationsLayout = qt.QGridLayout(annotationsButton) # Set up tabs to split workflow tabsWidget = qt.QTabWidget() landmarkTab = qt.QWidget() landmarkTabLayout = qt.QFormLayout(landmarkTab) segmentTab = qt.QWidget() segmentTabLayout = qt.QFormLayout(segmentTab) tabsWidget.addTab(landmarkTab, "Landmark") tabsWidget.addTab(segmentTab, "Segment") annotationsLayout.addWidget(tabsWidget) # # Markups Launch Button # self.launchMarkupsButton = qt.QPushButton("Start landmarking") self.launchMarkupsButton.toolTip = "Pop up the markups view for placing landmarks" self.launchMarkupsButton.enabled = False landmarkTabLayout.addRow(self.launchMarkupsButton) # # Export Landmarks Button # self.exportLandmarksButton = qt.QPushButton("Export landmarks") self.exportLandmarksButton.toolTip = "Export landmarks placed on the selected image" self.exportLandmarksButton.enabled = False landmarkTabLayout.addRow(self.exportLandmarksButton) # # Initiate Segmentation # self.startSegmentationButton = qt.QPushButton("Start segmenation") self.startSegmentationButton.toolTip = "Initialize segmentation and view Segment Editor" self.startSegmentationButton.enabled = False segmentTabLayout.addRow(self.startSegmentationButton) # # Export Segmentation # self.exportSegmentationButton = qt.QPushButton("Export segmenation") self.exportSegmentationButton.toolTip = "Export segmentation as a model" self.exportSegmentationButton.enabled = False segmentTabLayout.addRow(self.exportSegmentationButton) # connections #self.applySpacingButton.connect('clicked(bool)', self.onApplySpacingButton) self.flipXButton.connect('clicked(bool)', self.onFlipX) self.flipYButton.connect('clicked(bool)', self.onFlipY) self.flipZButton.connect('clicked(bool)', self.onFlipZ) self.selectorButton.connect('clicked(bool)', self.onLoadTable) self.volumeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.tableSelector.connect("validInputChanged(bool)", self.onSelectTablePath) self.importVolumeButton.connect('clicked(bool)', self.onImportVolume) self.exportLandmarksButton.connect('clicked(bool)', self.onExportLandmarks) self.launchMarkupsButton.connect('clicked(bool)', self.onLaunchMarkups) self.startSegmentationButton.connect('clicked(bool)', self.onStartSegmentation) self.exportSegmentationButton.connect('clicked(bool)', self.onExportSegmentation) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelect()
def setup(self): # Instantiate and connect widgets ... # # Reload and Test area # reloadCollapsibleButton = ctk.ctkCollapsibleButton() reloadCollapsibleButton.text = "Reload && Test" self.layout.addWidget(reloadCollapsibleButton) reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "FiducialLayoutSwitchBug1914 Reload" reloadFormLayout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # reload and test button # (use this during development, but remove it when delivering # your module to users) self.reloadAndTestButton = qt.QPushButton("Reload and Test") self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests." reloadFormLayout.addWidget(self.reloadAndTestButton) self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest) # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # check box to trigger taking screen shots for later use in tutorials # self.enableScreenshotsFlagCheckBox = qt.QCheckBox() self.enableScreenshotsFlagCheckBox.checked = 1 self.enableScreenshotsFlagCheckBox.setToolTip( "If checked, take screen shots for tutorials. Use Save Data to write them to disk." ) parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox) # # scale factor for screen shots # self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget() self.screenshotScaleFactorSliderWidget.singleStep = 1.0 self.screenshotScaleFactorSliderWidget.minimum = 1.0 self.screenshotScaleFactorSliderWidget.maximum = 50.0 self.screenshotScaleFactorSliderWidget.value = 1.0 self.screenshotScaleFactorSliderWidget.setToolTip( "Set scale factor for the screen shots.") parametersFormLayout.addRow("Screenshot scale factor", self.screenshotScaleFactorSliderWidget) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = True parametersFormLayout.addRow(self.applyButton) # connections 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) # # check box to trigger taking screen shots for later use in tutorials # self.continuousCurvesCheckBox = qt.QCheckBox() self.continuousCurvesCheckBox.checked = 0 self.continuousCurvesCheckBox.setToolTip( "If checked, redundant points will be removed on merging.") parametersFormLayout.addRow("Contiuous curves", self.continuousCurvesCheckBox) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Generate semilandmarks." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # # markups view # self.markupsView = slicer.qMRMLSubjectHierarchyTreeView() self.markupsView.setMRMLScene(slicer.mrmlScene) self.markupsView.setMultiSelection(True) self.markupsView.setAlternatingRowColors(True) self.markupsView.setDragDropMode(qt.QAbstractItemView().DragDrop) self.markupsView.setColumnHidden( self.markupsView.model().transformColumn, True) self.markupsView.sortFilterProxyModel().setNodeTypes( ["vtkMRMLMarkupsCurveNode"]) parametersFormLayout.addRow(self.markupsView) # # Merge Button # self.mergeButton = qt.QPushButton("Merge highlighted nodes") self.mergeButton.toolTip = "Generate a single merged markup file from the selected nodes" self.mergeButton.enabled = False parametersFormLayout.addRow(self.mergeButton) # connections self.mergeButton.connect('clicked(bool)', self.onMergeButton) self.markupsView.connect('currentItemChanged(vtkIdType)', self.updateMergeButton) # Add vertical spacer self.layout.addStretch(1)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... inputModelSelectorFrame = qt.QFrame(self.parent) inputModelSelectorFrame.setLayout(qt.QHBoxLayout()) self.parent.layout().addWidget(inputModelSelectorFrame) inputModelSelectorLabel = qt.QLabel("Input Model: ", inputModelSelectorFrame) inputModelSelectorLabel.setToolTip("Select the input model") inputModelSelectorFrame.layout().addWidget(inputModelSelectorLabel) inputModelSelector = slicer.qMRMLNodeComboBox(inputModelSelectorFrame) inputModelSelector.nodeTypes = ["vtkMRMLModelNode"] inputModelSelector.selectNodeUponCreation = False inputModelSelector.addEnabled = False inputModelSelector.removeEnabled = False inputModelSelector.noneEnabled = True inputModelSelector.showHidden = False inputModelSelector.showChildNodeTypes = False inputModelSelector.setMRMLScene(slicer.mrmlScene) inputModelSelectorFrame.layout().addWidget(inputModelSelector) outputModelSelectorFrame = qt.QFrame(self.parent) outputModelSelectorFrame.setLayout(qt.QHBoxLayout()) self.parent.layout().addWidget(outputModelSelectorFrame) outputModelSelectorLabel = qt.QLabel("Output Model: ", outputModelSelectorFrame) outputModelSelectorLabel.setToolTip("Select the output model") outputModelSelectorFrame.layout().addWidget(outputModelSelectorLabel) outputModelSelector = slicer.qMRMLNodeComboBox( outputModelSelectorFrame) outputModelSelector.nodeTypes = ["vtkMRMLModelNode"] outputModelSelector.selectNodeUponCreation = False outputModelSelector.addEnabled = True outputModelSelector.renameEnabled = True outputModelSelector.removeEnabled = True outputModelSelector.noneEnabled = True outputModelSelector.showHidden = False outputModelSelector.showChildNodeTypes = False outputModelSelector.baseName = "Model" outputModelSelector.selectNodeUponCreation = True outputModelSelector.setMRMLScene(slicer.mrmlScene) outputModelSelectorFrame.layout().addWidget(outputModelSelector) decimationButton = qt.QPushButton("Decimation") decimationButton.checkable = True self.layout.addWidget(decimationButton) decimationFrame = qt.QFrame(self.parent) self.layout.addWidget(decimationFrame) decimationFormLayout = qt.QFormLayout(decimationFrame) reductionFrame, reductionSlider, reductionSpinBox = numericInputFrame( self.parent, "Reduction:", "Tooltip", 0.0, 1.0, 0.05, 2) decimationFormLayout.addWidget(reductionFrame) boundaryDeletionCheckBox = qt.QCheckBox("Boundary deletion") decimationFormLayout.addWidget(boundaryDeletionCheckBox) smoothingButton = qt.QPushButton("Smoothing") smoothingButton.checkable = True self.layout.addWidget(smoothingButton) smoothingFrame = qt.QFrame(self.parent) self.layout.addWidget(smoothingFrame) smoothingFormLayout = qt.QFormLayout(smoothingFrame) smoothingMethodCombo = qt.QComboBox(smoothingFrame) smoothingMethodCombo.addItem("Laplace") smoothingMethodCombo.addItem("Taubin") smoothingFormLayout.addWidget(smoothingMethodCombo) laplaceMethodFrame = qt.QFrame(self.parent) smoothingFormLayout.addWidget(laplaceMethodFrame) laplaceMethodFormLayout = qt.QFormLayout(laplaceMethodFrame) laplaceIterationsFrame, laplaceIterationsSlider, laplaceIterationsSpinBox = numericInputFrame( self.parent, "Iterations:", "Determines the maximum number of smoothing iterations. Higher value allows more smoothing." + " In general, small relaxation factors and large numbers of iterations are more stable than" + " larger relaxation factors and smaller numbers of iterations. ", 0.0, 500.0, 1.0, 0) laplaceMethodFormLayout.addWidget(laplaceIterationsFrame) laplaceRelaxationFrame, laplaceRelaxationSlider, laplaceRelaxationSpinBox = numericInputFrame( self.parent, "Relaxation:", "Specifies how much points may be displaced during each iteration. Higher value results in more smoothing.", 0.0, 1.0, 0.1, 1) laplaceMethodFormLayout.addWidget(laplaceRelaxationFrame) taubinMethodFrame = qt.QFrame(self.parent) smoothingFormLayout.addWidget(taubinMethodFrame) taubinMethodFormLayout = qt.QFormLayout(taubinMethodFrame) taubinIterationsFrame, taubinIterationsSlider, taubinIterationsSpinBox = numericInputFrame( self.parent, "Iterations:", "Determines the maximum number of smoothing iterations. Higher value allows more accurate smoothing." + " Typically 10-20 iterations are enough.", 0.0, 100.0, 1.0, 0) taubinMethodFormLayout.addWidget(taubinIterationsFrame) taubinPassBandFrame, taubinPassBandSlider, taubinPassBandSpinBox = numericInputFrame( self.parent, "Pass Band:", "Number between 0 and 2. Lower values produce more smoothing.", 0.0, 2.0, 0.0001, 4) taubinMethodFormLayout.addWidget(taubinPassBandFrame) boundarySmoothingCheckBox = qt.QCheckBox("Boundary Smoothing") smoothingFormLayout.addWidget(boundarySmoothingCheckBox) normalsButton = qt.QPushButton("Normals") normalsButton.checkable = True self.layout.addWidget(normalsButton) normalsFrame = qt.QFrame(self.parent) self.layout.addWidget(normalsFrame) normalsFormLayout = qt.QFormLayout(normalsFrame) flipNormalsCheckBox = qt.QCheckBox("Flip Normals") normalsFormLayout.addWidget(flipNormalsCheckBox) splittingCheckBox = qt.QCheckBox("Splitting") normalsFormLayout.addWidget(splittingCheckBox) featureAngleFrame, featureAngleSlider, featureAngleSpinBox = numericInputFrame( self.parent, "Feature Angle:", "Tooltip", 0.0, 180.0, 1.0, 0) normalsFormLayout.addWidget(featureAngleFrame) cleanerButton = qt.QPushButton("Cleaner") cleanerButton.checkable = True self.layout.addWidget(cleanerButton) connectivityButton = qt.QPushButton("Connectivity") connectivityButton.checkable = True self.layout.addWidget(connectivityButton) #connectivityFrame = qt.QFrame(self.parent) #self.layout.addWidget(connectivityFrame) #connectivityFormLayout = qt.QFormLayout(connectivityFrame) # TODO: connectivity could be # - largest connected # - threshold connected (discard below point count) # - pick a region interactively # - turn a multiple connected surface into a model hierarchy buttonFrame = qt.QFrame(self.parent) buttonFrame.setLayout(qt.QHBoxLayout()) self.layout.addWidget(buttonFrame) toggleModelsButton = qt.QPushButton("Toggle Models") toggleModelsButton.toolTip = "Show original model." buttonFrame.layout().addWidget(toggleModelsButton) applyButton = qt.QPushButton("Apply") applyButton.toolTip = "Filter surface." buttonFrame.layout().addWidget(applyButton) self.layout.addStretch(1) class state(object): inputModelNode = None outputModelNode = None decimation = False reduction = 0.8 boundaryDeletion = False smoothing = False smoothingMethod = "Laplace" laplaceIterations = 100.0 laplaceRelaxation = 0.5 taubinIterations = 30.0 taubinPassBand = 0.1 boundarySmoothing = True normals = False flipNormals = False splitting = False featureAngle = 30.0 cleaner = False connectivity = False scope_locals = locals() def connect(obj, evt, cmd): def callback(*args): current_locals = scope_locals.copy() current_locals.update({'args': args}) exec cmd in globals(), current_locals updateGUI() obj.connect(evt, callback) def updateGUI(): def button_stylesheet(active): if active: return "background-color: green" else: return "" decimationButton.checked = state.decimation #decimationButton.setStyleSheet(button_stylesheet(state.decimation)) decimationFrame.visible = state.decimation boundaryDeletionCheckBox.checked = state.boundaryDeletion reductionSlider.value = state.reduction reductionSpinBox.value = state.reduction smoothingButton.checked = state.smoothing smoothingFrame.visible = state.smoothing laplaceMethodFrame.visible = state.smoothingMethod == "Laplace" laplaceIterationsSlider.value = state.laplaceIterations laplaceIterationsSpinBox.value = state.laplaceIterations laplaceRelaxationSlider.value = state.laplaceRelaxation laplaceRelaxationSpinBox.value = state.laplaceRelaxation taubinMethodFrame.visible = state.smoothingMethod == "Taubin" taubinIterationsSlider.value = state.taubinIterations taubinIterationsSpinBox.value = state.taubinIterations taubinPassBandSlider.value = state.taubinPassBand taubinPassBandSpinBox.value = state.taubinPassBand boundarySmoothingCheckBox.checked = state.boundarySmoothing normalsButton.checked = state.normals normalsFrame.visible = state.normals flipNormalsCheckBox.checked = state.flipNormals splittingCheckBox.checked = state.splitting featureAngleFrame.visible = state.splitting featureAngleSlider.value = state.featureAngle featureAngleSpinBox.value = state.featureAngle cleanerButton.checked = state.cleaner connectivityButton.checked = state.connectivity toggleModelsButton.enabled = state.inputModelNode is not None and state.outputModelNode is not None applyButton.enabled = state.inputModelNode is not None and state.outputModelNode is not None connect(inputModelSelector, 'currentNodeChanged(vtkMRMLNode*)', 'state.inputModelNode = args[0]') connect(outputModelSelector, 'currentNodeChanged(vtkMRMLNode*)', 'state.outputModelNode = args[0]') def initializeModelNode(node): displayNode = slicer.vtkMRMLModelDisplayNode() storageNode = slicer.vtkMRMLModelStorageNode() displayNode.SetScene(slicer.mrmlScene) storageNode.SetScene(slicer.mrmlScene) slicer.mrmlScene.AddNode(displayNode) slicer.mrmlScene.AddNode(storageNode) node.SetAndObserveDisplayNodeID(displayNode.GetID()) node.SetAndObserveStorageNodeID(storageNode.GetID()) outputModelSelector.connect('nodeAddedByUser(vtkMRMLNode*)', initializeModelNode) connect(decimationButton, 'clicked(bool)', 'state.decimation = args[0]') connect(reductionSlider, 'valueChanged(double)', 'state.reduction = args[0]') connect(reductionSpinBox, 'valueChanged(double)', 'state.reduction = args[0]') connect(boundaryDeletionCheckBox, 'stateChanged(int)', 'state.boundaryDeletion = bool(args[0])') connect(smoothingButton, 'clicked(bool)', 'state.smoothing = args[0]') connect(smoothingMethodCombo, 'currentIndexChanged(QString)', 'state.smoothingMethod = args[0]') connect(laplaceIterationsSlider, 'valueChanged(double)', 'state.laplaceIterations = int(args[0])') connect(laplaceIterationsSpinBox, 'valueChanged(double)', 'state.laplaceIterations = int(args[0])') connect(laplaceRelaxationSlider, 'valueChanged(double)', 'state.laplaceRelaxation = args[0]') connect(laplaceRelaxationSpinBox, 'valueChanged(double)', 'state.laplaceRelaxation = args[0]') connect(taubinIterationsSlider, 'valueChanged(double)', 'state.taubinIterations = int(args[0])') connect(taubinIterationsSpinBox, 'valueChanged(double)', 'state.taubinIterations = int(args[0])') connect(taubinPassBandSlider, 'valueChanged(double)', 'state.taubinPassBand = args[0]') connect(taubinPassBandSpinBox, 'valueChanged(double)', 'state.taubinPassBand = args[0]') connect(boundarySmoothingCheckBox, 'stateChanged(int)', 'state.boundarySmoothing = bool(args[0])') connect(normalsButton, 'clicked(bool)', 'state.normals = args[0]') connect(flipNormalsCheckBox, 'stateChanged(int)', 'state.flipNormals = bool(args[0])') connect(splittingCheckBox, 'stateChanged(int)', 'state.splitting = bool(args[0])') connect(featureAngleSlider, 'valueChanged(double)', 'state.featureAngle = args[0]') connect(featureAngleSpinBox, 'valueChanged(double)', 'state.featureAngle = args[0]') connect(cleanerButton, 'clicked(bool)', 'state.cleaner = args[0]') connect(connectivityButton, 'clicked(bool)', 'state.connectivity = args[0]') def onApply(): updateGUI() applyButton.text = "Working..." applyButton.repaint() slicer.app.processEvents() logic = SurfaceToolboxLogic() result = logic.applyFilters(state) if result: state.inputModelNode.GetModelDisplayNode().VisibilityOff() state.outputModelNode.GetModelDisplayNode().VisibilityOn() else: state.inputModelNode.GetModelDisplayNode().VisibilityOn() state.outputModelNode.GetModelDisplayNode().VisibilityOff() applyButton.text = "Apply" applyButton.connect('clicked()', onApply) def onToggleModels(): updateGUI() if state.inputModelNode.GetModelDisplayNode().GetVisibility(): state.inputModelNode.GetModelDisplayNode().VisibilityOff() state.outputModelNode.GetModelDisplayNode().VisibilityOn() toggleModelsButton.text = "Toggle Models (Output)" else: state.inputModelNode.GetModelDisplayNode().VisibilityOn() state.outputModelNode.GetModelDisplayNode().VisibilityOff() toggleModelsButton.text = "Toggle Models (Input)" toggleModelsButton.connect('clicked()', onToggleModels) updateGUI() self.updateGUI = updateGUI
def setup(self): self.detailsPopup = None self.setDetailsPopup(self.getSavedDICOMDetailsWidgetType()()) # XXX Slicer 4.5 - Remove these. Here only for backward compatibility. self.dicomBrowser = self.detailsPopup.dicomBrowser self.tables = self.detailsPopup.tables layoutManager = slicer.app.layoutManager() if layoutManager is not None: layoutManager.layoutChanged.connect(self.onLayoutChanged) # connect to the 'Show DICOM Browser' button self.showBrowserButton = qt.QPushButton('Show DICOM database browser') self.showBrowserButton.setCheckable(True) self.layout.addWidget(self.showBrowserButton) self.showBrowserButton.setStyleSheet("font:Bold;" "font-size:12px") self.showBrowserButton.connect('clicked()', self.toggleDetailsPopup) self.loadedDataLabel = qt.QLabel("Loaded data") self.loadedDataLabel.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed) self.layout.addWidget(self.loadedDataLabel) font = qt.QFont() font.setBold(True) font.setPointSize(12) self.loadedDataLabel.setFont(font) self.layout.addWidget(self.loadedDataLabel) self.subjectHierarchyTree = slicer.qMRMLSubjectHierarchyTreeView() self.layout.addWidget(self.subjectHierarchyTree) self.subjectHierarchyTree.setMRMLScene(slicer.mrmlScene) self.subjectHierarchyTree.currentItemChanged.connect( self.onCurrentItemChanged) self.subjectHierarchyTree.currentItemModified.connect( self.onCurrentItemModified) self.subjectHierarchyCurrentVisibility = False self.subjectHierarchyTree.setColumnHidden( self.subjectHierarchyTree.model().idColumn, True) self.browserSettingsWidget = ctk.ctkCollapsibleGroupBox() self.browserSettingsWidget.title = "Browser settings" self.layout.addWidget(self.browserSettingsWidget) self.browserSettingsWidget.collapsed = True self.browserSettingsWidget.setLayout(qt.QFormLayout()) self.directoryButton = ctk.ctkDirectoryButton() self.browserSettingsWidget.layout().addRow("Local database:", self.directoryButton) self.directoryButton.directoryChanged.connect( self.onDatabaseDirectoryButtonChanged) self.onDatabaseDirectoryDetailsPopupChanged( self.detailsPopup.dicomBrowser.databaseDirectory) self.tableDensityComboBox = qt.QComboBox() self.browserSettingsWidget.layout().addRow("Table density:", self.tableDensityComboBox) self.tableDensityComboBox.currentIndexChanged.connect( self.onTableDensityChanged) self.updateTableDensityComboBox() self.horizontalCheckBox = qt.QCheckBox() self.horizontalCheckBox.checked = settingsValue( 'DICOM/horizontalTables', 0, converter=int) self.horizontalCheckBox.stateChanged.connect( self.onHorizontalStateChanged) self.browserSettingsWidget.layout().addRow("Horizontal:", self.horizontalCheckBox) self.browserPersistentCheckBox = qt.QCheckBox() self.browserPersistentCheckBox.checked = settingsValue( 'DICOM/BrowserPersistent', False, converter=toBool) self.browserPersistentCheckBox.stateChanged.connect( self.onBrowserPersistentStateChanged) self.browserSettingsWidget.layout().addRow( "Browser persistent:", self.browserPersistentCheckBox) self.additionalSettingsLayout = qt.QHBoxLayout() # # servers # # testing server - not exposed (used for development) self.localFrame = ctk.ctkCollapsibleButton(self.parent) self.localFrame.setLayout(qt.QVBoxLayout()) self.localFrame.setText("Servers") self.layout.addWidget(self.localFrame) self.localFrame.collapsed = True self.toggleServer = qt.QPushButton("Start Testing Server") self.localFrame.layout().addWidget(self.toggleServer) self.toggleServer.connect('clicked()', self.onToggleServer) self.verboseServer = qt.QCheckBox("Verbose") self.localFrame.layout().addWidget(self.verboseServer) # advanced options - not exposed to end users # developers can uncomment these lines to access testing server self.toggleServer.hide() self.verboseServer.hide() # Listener settings = qt.QSettings() self.toggleListener = qt.QPushButton() self.toggleListener.checkable = True if hasattr(slicer, 'dicomListener'): self.toggleListener.text = "Stop Listener" slicer.dicomListener.process.connect( 'stateChanged(QProcess::ProcessState)', self.onListenerStateChanged) else: self.toggleListener.text = "Start Listener" self.localFrame.layout().addWidget(self.toggleListener) self.toggleListener.connect('clicked()', self.onToggleListener) self.runListenerAtStart = qt.QCheckBox( "Start Listener when Slicer Starts") self.localFrame.layout().addWidget(self.runListenerAtStart) self.runListenerAtStart.checked = settingsValue( 'DICOM/RunListenerAtStart', False, converter=toBool) self.runListenerAtStart.connect('clicked()', self.onRunListenerAtStart) # connect to the main window's dicom button mw = slicer.util.mainWindow() if mw: try: action = slicer.util.findChildren(mw, name='LoadDICOMAction')[0] action.connect('triggered()', self.onOpenDetailsPopup) except IndexError: logging.error( 'Could not connect to the main window DICOM button') if hasattr(slicer, 'dicomListener'): slicer.dicomListener.fileToBeAddedCallback = self.onListenerToAddFile slicer.dicomListener.fileAddedCallback = self.onListenerAddedFile slicer.dicomDatabase.connect('databaseChanged()', self.onDatabaseChanged) # the recent activity frame self.activityFrame = ctk.ctkCollapsibleButton(self.parent) self.activityFrame.collapsed = True self.activityFrame.setLayout(qt.QVBoxLayout()) self.activityFrame.setText("Recent DICOM Activity") self.layout.addWidget(self.activityFrame) self.recentActivity = DICOMLib.DICOMRecentActivityWidget( self.activityFrame, detailsPopup=self.detailsPopup) self.activityFrame.layout().addWidget(self.recentActivity) self.requestUpdateRecentActivity()
def createSmall(self): """Make the internals of the widget to display in the Data Probe frame (lower left of slicer main window by default)""" # this method makes SliceView Annotation self.sliceAnnotationsFrame = qt.QFrame(self.frame) self.sliceAnnotationsFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.sliceAnnotationsFrame) sliceAnnotationsLabel = qt.QLabel('Slice Annotations:') self.sliceAnnotationsFrame.layout().addWidget(sliceAnnotationsLabel) # Slice Annotations Settings Button sliceAnnotationsSettings = qt.QPushButton() settingsIcon = qt.QIcon("%s/SlicerAdvancedGear-Small.png" %self.iconsDIR) sliceAnnotationsSettings.setIcon(settingsIcon) self.sliceAnnotationsFrame.layout().addWidget(sliceAnnotationsSettings) self.sliceAnnotations = DataProbeLib.SliceAnnotations() sliceAnnotationsSettings.connect('clicked()', self.sliceAnnotations.openSettingsPopup) self.sliceAnnotationsFrame.layout().addStretch(1) # goto module button self.goToModule = qt.QPushButton('->', self.frame) self.goToModule.setToolTip('Go to the DataProbe module for more information and options') self.frame.layout().addWidget(self.goToModule) self.goToModule.connect("clicked()", self.onGoToModule) # hide this for now - there's not much to see in the module itself self.goToModule.hide() # top row - things about the viewer itself self.viewerFrame = qt.QFrame(self.frame) self.viewerFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.viewerFrame) self.viewerColor = qt.QLabel(self.viewerFrame) self.viewerFrame.layout().addWidget(self.viewerColor) self.viewerName = qt.QLabel(self.viewerFrame) self.viewerFrame.layout().addWidget(self.viewerName) self.viewerRAS = qt.QLabel() self.viewerFrame.layout().addWidget(self.viewerRAS) self.viewerOrient = qt.QLabel() self.viewerFrame.layout().addWidget(self.viewerOrient) self.viewerSpacing = qt.QLabel() self.viewerFrame.layout().addWidget(self.viewerSpacing) self.viewerFrame.layout().addStretch(1) # the grid - things about the layers # this method makes labels self.layerGrid = qt.QFrame(self.frame) self.layerGrid.setLayout(qt.QGridLayout()) self.frame.layout().addWidget(self.layerGrid) layers = ('L', 'F', 'B') self.layerNames = {} self.layerIJKs = {} self.layerValues = {} row = 0 for layer in layers: col = 0 self.layerGrid.layout().addWidget(qt.QLabel(layer), row, col) col += 1 self.layerNames[layer] = qt.QLabel() self.layerGrid.layout().addWidget(self.layerNames[layer], row, col) col += 1 self.layerIJKs[layer] = qt.QLabel() self.layerGrid.layout().addWidget(self.layerIJKs[layer], row, col) col += 1 self.layerValues[layer] = qt.QLabel() self.layerGrid.layout().addWidget(self.layerValues[layer], row, col) self.layerGrid.layout().setColumnStretch(col,100) col += 1 row += 1 # goto module button self.goToModule = qt.QPushButton('->', self.frame) self.goToModule.setToolTip('Go to the DataProbe module for more information and options') self.frame.layout().addWidget(self.goToModule) self.goToModule.connect("clicked()", self.onGoToModule) # hide this for now - there's not much to see in the module itself self.goToModule.hide()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # This module is often used in developer mode, therefore # collapse reload & test section by default. if hasattr(self, "reloadCollapsibleButton"): self.reloadCollapsibleButton.collapsed = True self.dragAndDropEventFilter = DICOMLoadingByDragAndDropEventFilter() globals()['d'] = self self.testingServer = None self.browserWidget = None self.directoryButton = None # Load widget from .ui file (created by Qt Designer) uiWidget = slicer.util.loadUI(self.resourcePath('UI/DICOM.ui')) self.layout.addWidget(uiWidget) self.ui = slicer.util.childWidgetVariables(uiWidget) self.browserWidget = DICOMLib.SlicerDICOMBrowser() self.browserWidget.objectName = 'SlicerDICOMBrowser' slicer.modules.DICOMInstance.setBrowserWidgetInDICOMLayout( self.browserWidget) layoutManager = slicer.app.layoutManager() if layoutManager is not None: layoutManager.layoutChanged.connect(self.onLayoutChanged) viewArrangement = slicer.app.layoutManager().layoutLogic( ).GetLayoutNode().GetViewArrangement() self.ui.showBrowserButton.checked = ( viewArrangement == slicer.vtkMRMLLayoutNode.SlicerLayoutDicomBrowserView) # connect to the 'Show DICOM Browser' button self.ui.showBrowserButton.connect('clicked()', self.toggleBrowserWidget) self.ui.importButton.connect('clicked()', self.importFolder) self.ui.subjectHierarchyTree.setMRMLScene(slicer.mrmlScene) self.ui.subjectHierarchyTree.currentItemChanged.connect( self.onCurrentItemChanged) self.ui.subjectHierarchyTree.currentItemModified.connect( self.onCurrentItemModified) self.subjectHierarchyCurrentVisibility = False self.ui.subjectHierarchyTree.setColumnHidden( self.ui.subjectHierarchyTree.model().idColumn, True) # # DICOM networking # self.ui.networkingFrame.collapsed = True self.ui.queryServerButton.connect('clicked()', self.browserWidget.dicomBrowser, "openQueryDialog()") self.ui.toggleListener.connect('toggled(bool)', self.onToggleListener) settings = qt.QSettings() self.ui.runListenerAtStart.checked = settingsValue( 'DICOM/RunListenerAtStart', False, converter=toBool) self.ui.runListenerAtStart.connect('toggled(bool)', self.onRunListenerAtStart) # Testing server - not exposed (used for development) self.toggleServer = qt.QPushButton("Start Testing Server") self.ui.networkingFrame.layout().addWidget(self.toggleServer) self.toggleServer.connect('clicked()', self.onToggleServer) self.verboseServer = qt.QCheckBox("Verbose") self.ui.networkingFrame.layout().addWidget(self.verboseServer) # advanced options - not exposed to end users # developers can uncomment these lines to access testing server self.toggleServer.hide() self.verboseServer.hide() # # Browser settings # self.ui.browserSettingsFrame.collapsed = True self.updateDatabaseDirectoryFromBrowser( self.browserWidget.dicomBrowser.databaseDirectory) # Synchronize database selection between browser and this widget self.ui.directoryButton.directoryChanged.connect( self.updateDatabaseDirectoryFromWidget) self.browserWidget.dicomBrowser.databaseDirectoryChanged.connect( self.updateDatabaseDirectoryFromBrowser) self.ui.browserAutoHideCheckBox.checked = not settingsValue( 'DICOM/BrowserPersistent', False, converter=toBool) self.ui.browserAutoHideCheckBox.stateChanged.connect( self.onBrowserAutoHideStateChanged) self.ui.repairDatabaseButton.connect('clicked()', self.browserWidget.dicomBrowser, "onRepairAction()") self.ui.clearDatabaseButton.connect('clicked()', self.onClearDatabase) # connect to the main window's dicom button mw = slicer.util.mainWindow() if mw: try: action = slicer.util.findChildren(mw, name='LoadDICOMAction')[0] action.connect('triggered()', self.onOpenBrowserWidget) except IndexError: logging.error( 'Could not connect to the main window DICOM button') self.databaseRefreshRequestTimer = qt.QTimer() self.databaseRefreshRequestTimer.setSingleShot(True) # If not receiving new file for 2 seconds then a database update is triggered. self.databaseRefreshRequestTimer.setInterval(2000) self.databaseRefreshRequestTimer.connect('timeout()', self.requestDatabaseRefresh) # # DICOM Plugins selection widget # self.ui.dicomPluginsFrame.collapsed = True self.pluginSelector = DICOMLib.DICOMPluginSelector( self.ui.dicomPluginsFrame) self.ui.dicomPluginsFrame.layout().addWidget(self.pluginSelector) self.checkBoxByPlugins = [] for pluginClass in slicer.modules.dicomPlugins: self.checkBox = self.pluginSelector.checkBoxByPlugin[pluginClass] self.checkBox.connect('stateChanged(int)', self.onPluginStateChanged) self.checkBoxByPlugins.append(self.checkBox)
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) # # input volume selector # self.hippoSelector = slicer.qMRMLNodeComboBox() self.hippoSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] self.hippoSelector.selectNodeUponCreation = True self.hippoSelector.addEnabled = False self.hippoSelector.removeEnabled = False self.hippoSelector.noneEnabled = False self.hippoSelector.showHidden = False self.hippoSelector.showChildNodeTypes = False self.hippoSelector.setMRMLScene(slicer.mrmlScene) self.hippoSelector.setToolTip("Pick the target object.") parametersFormLayout.addRow("Input Hippocampus Label Volume: ", self.hippoSelector) self.ventSelector = slicer.qMRMLNodeComboBox() self.ventSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] self.ventSelector.selectNodeUponCreation = True self.ventSelector.addEnabled = False self.ventSelector.removeEnabled = False self.ventSelector.noneEnabled = False self.ventSelector.showHidden = False self.ventSelector.showChildNodeTypes = False self.ventSelector.setMRMLScene(slicer.mrmlScene) self.ventSelector.setToolTip("Pick the ventricles object.") parametersFormLayout.addRow("Input Ventricles Label Volume: ", self.ventSelector) self.vesselSelector = slicer.qMRMLNodeComboBox() self.vesselSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] self.vesselSelector.selectNodeUponCreation = True self.vesselSelector.addEnabled = False self.vesselSelector.removeEnabled = False self.vesselSelector.noneEnabled = False self.vesselSelector.showHidden = False self.vesselSelector.showChildNodeTypes = False self.vesselSelector.setMRMLScene(slicer.mrmlScene) self.vesselSelector.setToolTip("Pick the blood vessel object.") parametersFormLayout.addRow("Input Blood Vessels Label Volume: ", self.vesselSelector) self.cortexSelector = slicer.qMRMLNodeComboBox() self.cortexSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] self.cortexSelector.selectNodeUponCreation = True self.cortexSelector.addEnabled = False self.cortexSelector.removeEnabled = False self.cortexSelector.noneEnabled = False self.cortexSelector.showHidden = False self.cortexSelector.showChildNodeTypes = False self.cortexSelector.setMRMLScene(slicer.mrmlScene) self.cortexSelector.setToolTip("Pick the cortex object.") parametersFormLayout.addRow("Input cortex Label Volume: ", self.cortexSelector) # creating the ui dropdowns will let you generalize to other nodes self.inputTargetFiducialSelector = slicer.qMRMLNodeComboBox() self.inputTargetFiducialSelector.nodeTypes = ["vtkMRMLMarkupsFiducialNode"] self.inputTargetFiducialSelector.selectNodeUponCreation = True self.inputTargetFiducialSelector.addEnabled = False self.inputTargetFiducialSelector.removeEnabled = False self.inputTargetFiducialSelector.noneEnabled = False self.inputTargetFiducialSelector.showHidden = False self.inputTargetFiducialSelector.showChildNodeTypes = False self.inputTargetFiducialSelector.setMRMLScene(slicer.mrmlScene) self.inputTargetFiducialSelector.setToolTip("Pick the input fiducials to the algorithm.") parametersFormLayout.addRow("Input Target Fiducials: ", self.inputTargetFiducialSelector) self.inputEntryFiducialSelector = slicer.qMRMLNodeComboBox() self.inputEntryFiducialSelector.nodeTypes = ["vtkMRMLMarkupsFiducialNode"] self.inputEntryFiducialSelector.selectNodeUponCreation = True self.inputEntryFiducialSelector.addEnabled = False self.inputEntryFiducialSelector.removeEnabled = False self.inputEntryFiducialSelector.noneEnabled = False self.inputEntryFiducialSelector.showHidden = False self.inputEntryFiducialSelector.showChildNodeTypes = False self.inputEntryFiducialSelector.setMRMLScene(slicer.mrmlScene) self.inputEntryFiducialSelector.setToolTip("Pick the input fiducials to the algorithm.") parametersFormLayout.addRow("Input Entry Fiducials: ", self.inputEntryFiducialSelector) self.validAngleSlider = ctk.ctkSliderWidget() self.validAngleSlider.singleStep = 1 self.validAngleSlider.minimum = 0 self.validAngleSlider.maximum = 90 self.validAngleSlider.value = 55 self.validAngleSlider.setToolTip("Set angle value for valid incision") parametersFormLayout.addRow("Valid Incision Angle", self.validAngleSlider) self.precisionSlider = ctk.ctkSliderWidget() self.precisionSlider.singleStep = 0.001 self.precisionSlider.minimum = 0.001 self.precisionSlider.maximum = 0.1 self.precisionSlider.value = 0.01 self.precisionSlider.setToolTip("Set precision value for maximising distance to the critical structure") parametersFormLayout.addRow("Precision", self.precisionSlider) self.maximumIncisionLengthSlider = ctk.ctkSliderWidget() self.maximumIncisionLengthSlider.singleStep = 1 self.maximumIncisionLengthSlider.minimum = 0.00 self.maximumIncisionLengthSlider.maximum = 9999999999999 self.maximumIncisionLengthSlider.value = 9999999999999 self.maximumIncisionLengthSlider.setToolTip("Set maximum incision value") parametersFormLayout.addRow("Maximum Incision Length", self.maximumIncisionLengthSlider) # # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.inputEntryFiducialSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.inputTargetFiducialSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelect()
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = SegmentStatisticsLogic() self.grayscaleNode = None self.labelNode = None self.parameterNode = None self.parameterNodeObserver = None # Instantiate and connect widgets ... # # Inputs inputsCollapsibleButton = ctk.ctkCollapsibleButton() inputsCollapsibleButton.text = "Inputs" self.layout.addWidget(inputsCollapsibleButton) inputsFormLayout = qt.QFormLayout(inputsCollapsibleButton) # Segmentation selector self.segmentationSelector = slicer.qMRMLNodeComboBox() self.segmentationSelector.nodeTypes = ["vtkMRMLSegmentationNode"] self.segmentationSelector.addEnabled = False self.segmentationSelector.removeEnabled = True self.segmentationSelector.renameEnabled = True self.segmentationSelector.setMRMLScene(slicer.mrmlScene) self.segmentationSelector.setToolTip( "Pick the segmentation to compute statistics for") inputsFormLayout.addRow("Segmentation:", self.segmentationSelector) # Scalar volume selector self.scalarSelector = slicer.qMRMLNodeComboBox() self.scalarSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.scalarSelector.addEnabled = False self.scalarSelector.removeEnabled = True self.scalarSelector.renameEnabled = True self.scalarSelector.noneEnabled = True self.scalarSelector.showChildNodeTypes = False self.scalarSelector.setMRMLScene(slicer.mrmlScene) self.scalarSelector.setToolTip( "Select the scalar volume for intensity statistics calculations") inputsFormLayout.addRow("Scalar volume:", self.scalarSelector) # Output table selector outputCollapsibleButton = ctk.ctkCollapsibleButton() outputCollapsibleButton.text = "Output" self.layout.addWidget(outputCollapsibleButton) outputFormLayout = qt.QFormLayout(outputCollapsibleButton) self.outputTableSelector = slicer.qMRMLNodeComboBox() self.outputTableSelector.nodeTypes = ["vtkMRMLTableNode"] self.outputTableSelector.addEnabled = True self.outputTableSelector.selectNodeUponCreation = True self.outputTableSelector.renameEnabled = True self.outputTableSelector.removeEnabled = True self.outputTableSelector.noneEnabled = False self.outputTableSelector.setMRMLScene(slicer.mrmlScene) self.outputTableSelector.setToolTip( "Select the table where statistics will be saved into") outputFormLayout.addRow("Output table:", self.outputTableSelector) # Apply Button self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Calculate Statistics." self.applyButton.enabled = False self.parent.layout().addWidget(self.applyButton) # Parameter set parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" #parametersCollapsibleButton.collapsed = True self.layout.addWidget(parametersCollapsibleButton) self.parametersLayout = qt.QFormLayout(parametersCollapsibleButton) # Parameter set selector self.parameterNodeSelector = slicer.qMRMLNodeComboBox() self.parameterNodeSelector.nodeTypes = (("vtkMRMLScriptedModuleNode"), "") self.parameterNodeSelector.addAttribute("vtkMRMLScriptedModuleNode", "ModuleName", "SegmentStatistics") self.parameterNodeSelector.selectNodeUponCreation = True self.parameterNodeSelector.addEnabled = True self.parameterNodeSelector.renameEnabled = True self.parameterNodeSelector.removeEnabled = True self.parameterNodeSelector.noneEnabled = False self.parameterNodeSelector.showHidden = True self.parameterNodeSelector.showChildNodeTypes = False self.parameterNodeSelector.baseName = "SegmentStatistics" self.parameterNodeSelector.setMRMLScene(slicer.mrmlScene) self.parameterNodeSelector.setToolTip("Pick parameter set") self.parametersLayout.addRow("Parameter set: ", self.parameterNodeSelector) # Edit parameter set button to open SegmentStatisticsParameterEditorDialog # Note: we add the plugins' option widgets to the module widget instead of using the editor dialog #self.editParametersButton = qt.QPushButton("Edit Parameter Set") #self.editParametersButton.toolTip = "Editor Statistics Plugin Parameter Set." #self.parametersLayout.addRow(self.editParametersButton) #self.editParametersButton.connect('clicked()', self.onEditParameters) # add caclulator's option widgets self.addPluginOptionWidgets() # Add vertical spacer self.parent.layout().addStretch(1) # connections self.applyButton.connect('clicked()', self.onApply) self.scalarSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onNodeSelectionChanged) self.segmentationSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onNodeSelectionChanged) self.outputTableSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onNodeSelectionChanged) self.parameterNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onNodeSelectionChanged) self.parameterNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onParameterSetSelected) self.parameterNodeSelector.setCurrentNode( self.logic.getParameterNode()) self.onNodeSelectionChanged() self.onParameterSetSelected()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # inputCollapsibleButton = ctk.ctkCollapsibleButton() inputCollapsibleButton.text = "Input Volumes" self.layout.addWidget(inputCollapsibleButton) # Layout within the dummy collapsible button inputFormLayout = qt.QFormLayout(inputCollapsibleButton) loadSpineVolumeButton = qt.QPushButton('Load spine volume') loadSpineVolumeButton.connect('clicked()', self.loadVolume) inputFormLayout.addRow('Load spine volume', loadSpineVolumeButton) loadSegVolumeButton = qt.QPushButton('Load segmentation volume') loadSegVolumeButton.connect('clicked()', self.loadVolume) inputFormLayout.addRow('Load segmentation volume', loadSegVolumeButton) # TODO Add functionality so that if the segmentation is NOT imported as a label map, it is converted to one immediately # # 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("Select the CT spine volume.") inputFormLayout.addRow("Input Volume: ", self.inputSelector) # # output volume selector # self.segmentationSelector = slicer.qMRMLNodeComboBox() self.segmentationSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] self.segmentationSelector.selectNodeUponCreation = True self.segmentationSelector.addEnabled = True self.segmentationSelector.removeEnabled = True self.segmentationSelector.noneEnabled = True self.segmentationSelector.showHidden = False self.segmentationSelector.showChildNodeTypes = False self.segmentationSelector.setMRMLScene(slicer.mrmlScene) self.segmentationSelector.setToolTip( "Select the ground truth segmentation " "(if any exists) to compare with prediction.") inputFormLayout.addRow("Segmentation Volume: ", self.segmentationSelector) # TODO Add a save resampled volume cropCollapsibleButton = ctk.ctkCollapsibleButton() cropCollapsibleButton.text = "Select Vertebrae" self.layout.addWidget(cropCollapsibleButton) # Layout within the dummy collapsible button cropFormLayout = qt.QFormLayout(cropCollapsibleButton) markerTable = slicer.qSlicerSimpleMarkupsWidget() self.markerTableSelector = markerTable.MarkupsFiducialNodeComboBox self.markerTableSelector.selectNodeUponCreation = False self.markerTableSelector.addEnabled = True self.markerTableSelector.removeEnabled = True self.markerTableSelector.noneEnabled = False self.markerTableSelector.renameEnabled = True markerTable.setMRMLScene(slicer.mrmlScene) markerTable.setCurrentNode( slicer.mrmlScene.GetNodeByID( slicer.modules.markups.logic().AddNewFiducialNode())) markerTable.show() cropFormLayout.addWidget(markerTable) # # crop output volume selector # self.cropOutputSelector = slicer.qMRMLNodeComboBox() # self.cropOutputSelector.nodeTypes = ['vtkMRMLScalarVolumeNode'] # self.cropOutputSelector.toolTip = "Crop volumes for vertebrae levels" # self.cropOutputSelector.setMRMLScene(slicer.mrmlScene) # self.cropOutputSelector.renameEnabled = True # self.cropOutputSelector.addEnabled = True # self.cropOutputSelector.noneEnabled = True # self.cropOutputSelector.selectNodeUponCreation = True # self.cropOutputSelector.noneDisplay = 'Define name for cropped volume' # self.cropOutputSelector.removeEnabled = True # self.cropOutputSelector.showHidden = True # # # cropFormLayout.addRow("Output Crop Volume: ", self.cropOutputSelector) # # # # crop button # cropButton = qt.QPushButton("Crop Vertebrae") # cropButton.connect("clicked(bool)", self.onCropButton) # cropFormLayout.addRow("Crop Vertebrae", cropButton) # Segment vertebrae button self.segmentationButton = qt.QPushButton('Segment Vertebrae') self.segmentationButton.toolTip = 'Segment the selected vertebrae' self.segmentationButton.enabled = False # Segmentation button connections self.segmentationButton.connect('clicked(bool)', self.onSegmentButton) self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.markerTableSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.layout.addWidget(self.segmentationButton) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelect()
def setup(self, showPreview=False): """ main window is a frame with widgets from the app widget repacked into it along with slicer-specific extra widgets """ self.setWindowTitle('DICOM Browser') self.setLayout(qt.QVBoxLayout()) self.dicomBrowser.databaseDirectorySelectorVisible = False self.dicomBrowser.toolbarVisible = False self.dicomBrowser.sendActionVisible = True self.dicomBrowser.databaseDirectorySettingsKey = slicer.dicomDatabaseDirectorySettingsKey self.dicomBrowser.dicomTableManager().dynamicTableLayout = False horizontal = self.settings.setValue('DICOM/horizontalTables', 0) self.dicomBrowser.dicomTableManager( ).tableOrientation = qt.Qt.Horizontal if horizontal else qt.Qt.Vertical self.layout().addWidget(self.dicomBrowser) self.userFrame = qt.QWidget() self.preview = qt.QWidget() # # preview related column # self.previewLayout = qt.QVBoxLayout() if showPreview: self.previewLayout.addWidget(self.preview) else: self.preview.hide() # # action related column (interacting with slicer) # self.loadableTableFrame = qt.QWidget() self.loadableTableFrame.setMaximumHeight(200) self.loadableTableLayout = qt.QFormLayout(self.loadableTableFrame) self.layout().addWidget(self.loadableTableFrame) self.loadableTableLayout.addWidget(self.userFrame) self.userFrame.hide() self.loadableTable = DICOMLoadableTable(self.userFrame) self.loadableTable.itemChanged.connect(self.onLoadableTableItemChanged) # # button row for action column # self.actionButtonsFrame = qt.QWidget() self.actionButtonsFrame.setMaximumHeight(40) self.actionButtonsFrame.objectName = 'ActionButtonsFrame' self.layout().addWidget(self.actionButtonsFrame) self.actionButtonLayout = qt.QHBoxLayout() self.actionButtonsFrame.setLayout(self.actionButtonLayout) self.uncheckAllButton = qt.QPushButton('Uncheck All') self.actionButtonLayout.addWidget(self.uncheckAllButton) self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables) self.actionButtonLayout.addStretch(0.05) self.examineButton = qt.QPushButton('Examine') self.examineButton.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed) self.actionButtonLayout.addWidget(self.examineButton) self.examineButton.enabled = False self.examineButton.connect('clicked()', self.examineForLoading) self.loadButton = qt.QPushButton('Load') self.loadButton.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed) self.loadButton.toolTip = 'Load selected items into the scene' self.actionButtonLayout.addWidget(self.loadButton) self.loadButton.connect('clicked()', self.loadCheckedLoadables) self.actionButtonLayout.addStretch(0.05) self.advancedViewButton = qt.QCheckBox('Advanced') self.advancedViewButton.objectName = 'AdvancedViewCheckBox' self.actionButtonLayout.addWidget(self.advancedViewButton) self.advancedViewButton.checked = self.advancedView self.advancedViewButton.toggled.connect(self.onAdvancedViewButton) if self.advancedView: self.loadableTableFrame.visible = True else: self.loadableTableFrame.visible = False self.examineButton.visible = False self.uncheckAllButton.visible = False # # Series selection # self.dicomBrowser.dicomTableManager().connect( 'seriesSelectionChanged(QStringList)', self.onSeriesSelected) # # Plugin selection widget # self.pluginSelector = DICOMLib.DICOMPluginSelector(self) self.loadableTableLayout.addRow(self.pluginSelector, self.loadableTable) self.checkBoxByPlugins = [] for pluginClass in slicer.modules.dicomPlugins: self.checkBox = self.pluginSelector.checkBoxByPlugin[pluginClass] self.checkBox.connect('stateChanged(int)', self.onPluginStateChanged) self.checkBoxByPlugins.append(self.checkBox) self.updateButtonStates()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... self.pbucLogic = PointerBasedUSCalibrationLogic() # Have reference to an instance of the logic # # Tracked ultrasound playback toolbox # self.playToolBox = qt.QToolBox() self.layout.addWidget( self.playToolBox ) # # Real-time playback # self.realTimeFrame = qt.QFrame( self.playToolBox ) self.realTimeLayout = qt.QVBoxLayout( self.realTimeFrame ) self.connectorNodeSelector = slicer.qMRMLNodeComboBox() self.connectorNodeSelector.nodeTypes = [ "vtkMRMLIGTLConnectorNode" ] self.connectorNodeSelector.addEnabled = False self.connectorNodeSelector.removeEnabled = False self.connectorNodeSelector.noneEnabled = False self.connectorNodeSelector.showHidden = False self.connectorNodeSelector.showChildNodeTypes = False self.connectorNodeSelector.setMRMLScene( slicer.mrmlScene ) self.connectorNodeSelector.setToolTip( "Select the connector node for playback." ) self.realTimeLayout.addWidget( self.connectorNodeSelector ) self.freezeButton = qt.QPushButton( "Freeze" ) self.freezeButton.setToolTip( "Freeze the connection." ) self.realTimeLayout.addWidget( self.freezeButton ) # # Recorded sequence playback # self.sequenceFrame = qt.QFrame( self.playToolBox ) self.sequenceLayout = qt.QVBoxLayout( self.sequenceFrame ) self.sequenceBrowserNodeSelector = slicer.qMRMLNodeComboBox() self.sequenceBrowserNodeSelector.nodeTypes = [ "vtkMRMLSequenceBrowserNode" ] self.sequenceBrowserNodeSelector.addEnabled = False self.sequenceBrowserNodeSelector.removeEnabled = False self.sequenceBrowserNodeSelector.noneEnabled = False self.sequenceBrowserNodeSelector.showHidden = False self.sequenceBrowserNodeSelector.showChildNodeTypes = False self.sequenceBrowserNodeSelector.setMRMLScene( slicer.mrmlScene ) self.sequenceBrowserNodeSelector.setToolTip( "Select the sequence browser node for playback." ) self.sequenceLayout.addWidget( self.sequenceBrowserNodeSelector ) self.sequenceBrowserPlayWidget = slicer.qMRMLSequenceBrowserPlayWidget() # TODO: Somehow disable the recording button without changing sequences' recording states self.sequenceBrowserPlayWidget.setMRMLSequenceBrowserNode( self.sequenceBrowserNodeSelector.currentNode() ) self.sequenceLayout.addWidget( self.sequenceBrowserPlayWidget ) self.sequenceBrowserSeekWidget = slicer.qMRMLSequenceBrowserSeekWidget() self.sequenceBrowserSeekWidget.setMRMLSequenceBrowserNode( self.sequenceBrowserNodeSelector.currentNode() ) self.sequenceLayout.addWidget( self.sequenceBrowserSeekWidget ) # Add the playback modes to the tool box self.playToolBox.addItem( self.realTimeFrame, "Real-time" ) self.playToolBox.addItem( self.sequenceFrame, "Sequence" ) # # Points group box # self.pointGroupBox = qt.QGroupBox() self.pointGroupBox.setTitle( "Points" ) self.layout.addWidget( self.pointGroupBox ) # Layout within the group box self.pointGroupBoxLayout = qt.QHBoxLayout( self.pointGroupBox ) # Mark point self.markPointButton = qt.QPushButton( "Mark Point" ) self.markPointButton.setIcon( qt.QIcon( ":/Icons/MarkupsMouseModePlace.png" ) ) self.markPointButton.setToolTip( "Start placing a point on the ultrasound image." ) self.pointGroupBoxLayout.addWidget( self.markPointButton ) # Undo self.undoPointsButton = qt.QPushButton( "" ) self.undoPointsButton.setIcon( qt.QIcon( ":/Icons/Small/SlicerUndo.png" ) ) self.undoPointsButton.setSizePolicy( qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed ) self.undoPointsButton.setToolTip( "Remove the most recently placed point." ) self.pointGroupBoxLayout.addWidget( self.undoPointsButton ) # Reset self.resetPointsButton = qt.QPushButton( "" ) self.resetPointsButton.setIcon( qt.QApplication.style().standardIcon( qt.QStyle.SP_DialogResetButton ) ) self.resetPointsButton.setSizePolicy( qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed ) self.resetPointsButton.setToolTip( "Clear all points." ) self.pointGroupBoxLayout.addWidget( self.resetPointsButton ) # # Result label # self.calibrationResultLabel = qt.QLabel() self.calibrationResultLabel.setText( "No calibration parameters selected." ) self.calibrationResultLabel.setToolTip( "Output from the calibration." ) self.layout.addWidget( self.calibrationResultLabel ) # # Advanced area # self.advancedCollapsibleButton = ctk.ctkCollapsibleButton() self.advancedCollapsibleButton.setText( "Advanced" ) self.advancedCollapsibleButton.collapsed = True self.layout.addWidget( self.advancedCollapsibleButton ) # Layout within the collapsible button self.advancedLayout = qt.QFormLayout( self.advancedCollapsibleButton ) # Mark point self.applyButton = qt.QPushButton( "Apply" ) self.applyButton.setToolTip( "Apply the ImageToProbe transform to the ultrasound image." ) self.advancedLayout.addWidget( self.applyButton ) # # Results area # self.resultsCollapsibleButton = ctk.ctkCollapsibleButton() self.resultsCollapsibleButton.setText( "Results" ) self.resultsCollapsibleButton.collapsed = True self.advancedLayout.addWidget( self.resultsCollapsibleButton ) # Layout within the collapsible button self.resultsLayout = qt.QFormLayout( self.resultsCollapsibleButton ) # Results table self.resultsTable = qt.QTableWidget( self.resultsCollapsibleButton ) self.resultsTable.setColumnCount( self.RESULTS_NUM_INDICES ) self.resultsTable.setHorizontalHeaderLabels( [ "Image Points", "Probe Points", "Error", "Delete" ] ) self.resultsTable.horizontalHeader().setResizeMode( qt.QHeaderView.Stretch ) self.resultsTable.horizontalHeader().setResizeMode( self.RESULTS_DELETE_INDEX, qt.QHeaderView.Fixed ) self.resultsLayout.addRow( self.resultsTable ) # # Parameters area # self.parametersCollapsibleButton = ctk.ctkCollapsibleButton() self.parametersCollapsibleButton.setText( "Parameters" ) self.parametersCollapsibleButton.collapsed = True self.advancedLayout.addWidget( self.parametersCollapsibleButton ) # Layout within the collapsible button self.parametersLayout = qt.QVBoxLayout( self.parametersCollapsibleButton ) # Parameters node self.frwNodeSelector = slicer.qMRMLNodeComboBox() self.frwNodeSelector.nodeTypes = [ "vtkMRMLFiducialRegistrationWizardNode" ] self.frwNodeSelector.addEnabled = True self.frwNodeSelector.removeEnabled = True self.frwNodeSelector.noneEnabled = False self.frwNodeSelector.showHidden = False self.frwNodeSelector.showChildNodeTypes = False self.frwNodeSelector.baseName = "UltrasoundCalibration" self.frwNodeSelector.setMRMLScene( slicer.mrmlScene ) self.frwNodeSelector.setToolTip( "Select the ultrasound calibration parameters node." ) self.parametersLayout.addWidget( self.frwNodeSelector ) # # Input group box # self.inputGroupBox = qt.QGroupBox( self.parametersCollapsibleButton ) self.inputGroupBox.setTitle( "Input" ) self.parametersLayout.addWidget( self.inputGroupBox ) # Layout within the group box self.inputGroupBoxLayout = qt.QFormLayout( self.inputGroupBox ) # US image selector self.usImageNodeSelector = slicer.qMRMLNodeComboBox() self.usImageNodeSelector.nodeTypes = [ "vtkMRMLVolumeNode" ] self.usImageNodeSelector.addEnabled = False self.usImageNodeSelector.removeEnabled = False self.usImageNodeSelector.noneEnabled = True self.usImageNodeSelector.showHidden = False self.usImageNodeSelector.showChildNodeTypes = True self.usImageNodeSelector.setMRMLScene( slicer.mrmlScene ) self.usImageNodeSelector.setToolTip( "Select the ultrasound image node." ) self.inputGroupBoxLayout.addRow( "Ultrasound image ", self.usImageNodeSelector ) # StylusTipToProbe selector self.stylusTipToProbeNodeSelector = slicer.qMRMLNodeComboBox() self.stylusTipToProbeNodeSelector.nodeTypes = [ "vtkMRMLLinearTransformNode" ] self.stylusTipToProbeNodeSelector.addEnabled = False self.stylusTipToProbeNodeSelector.removeEnabled = False self.stylusTipToProbeNodeSelector.noneEnabled = True self.stylusTipToProbeNodeSelector.showHidden = False self.stylusTipToProbeNodeSelector.showChildNodeTypes = True self.stylusTipToProbeNodeSelector.setMRMLScene( slicer.mrmlScene ) self.stylusTipToProbeNodeSelector.setToolTip( "Select the StylusTipToProbe node (parent transforms will be applied)." ) self.inputGroupBoxLayout.addRow( "StylusTipToProbe ", self.stylusTipToProbeNodeSelector ) # # Output group box # self.outputGroupBox = qt.QGroupBox( self.parametersCollapsibleButton ) self.outputGroupBox.setTitle( "Output" ) self.parametersLayout.addWidget( self.outputGroupBox ) # Layout within the group box self.outputGroupBoxLayout = qt.QFormLayout( self.outputGroupBox ) # ImageToProbe selector self.imageToProbeNodeSelector = slicer.qMRMLNodeComboBox() self.imageToProbeNodeSelector.nodeTypes = [ "vtkMRMLLinearTransformNode" ] self.imageToProbeNodeSelector.addEnabled = True self.imageToProbeNodeSelector.removeEnabled = False self.imageToProbeNodeSelector.noneEnabled = True self.imageToProbeNodeSelector.renameEnabled = True self.imageToProbeNodeSelector.showHidden = False self.imageToProbeNodeSelector.showChildNodeTypes = True self.imageToProbeNodeSelector.setMRMLScene( slicer.mrmlScene ) self.imageToProbeNodeSelector.setToolTip( "Select the ImageToProbe output node (stores the result of the calibration)." ) self.outputGroupBoxLayout.addRow( "ImageToProbe ", self.imageToProbeNodeSelector ) # # Set up connections # self.freezeButton.connect( "clicked(bool)", self.onFreezeButtonClicked ) self.sequenceBrowserNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onSequenceBrowserNodeChanged ) self.frwNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onCalibrationNodeChanged ) self.usImageNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onUSImageNodeChanged ) self.stylusTipToProbeNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onStylusTipToProbeNodeChanged ) self.markPointButton.connect( "clicked(bool)", self.onMarkPointButtonClicked ) self.undoPointsButton.connect( "clicked(bool)", self.onUndoPointsButtonClicked ) self.resetPointsButton.connect( "clicked(bool)", self.onResetPointsButtonClicked ) self.imageToProbeNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onImageToProbeNodeChanged ) self.applyButton.connect( "clicked(bool)", self.onApplyOutputTransformToImageClicked ) # # Create a parameters node by default # defaultFRWNode = slicer.vtkMRMLFiducialRegistrationWizardNode() defaultFRWNode.SetName( "UltrasoundCalibration" ) defaultFRWNode.SetScene( slicer.mrmlScene ) slicer.mrmlScene.AddNode( defaultFRWNode ) self.frwNodeSelector.setCurrentNodeID( defaultFRWNode.GetID() ) # Add vertical spacer self.layout.addStretch(1)
def setup(self): ScriptedLoadableModuleWidget.setup(self) #-------------------------------------------------- # For debugging # # Reload and Test area reloadCollapsibleButton = ctk.ctkCollapsibleButton() reloadCollapsibleButton.text = "Reload && Test" self.layout.addWidget(reloadCollapsibleButton) reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) reloadCollapsibleButton.collapsed = True # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "ComputeT2Star Reload" reloadFormLayout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # #-------------------------------------------------- # 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 = ["vtkMRMLLabelMapVolumeNode"] 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) # # output volume selector # self.outputSelector = slicer.qMRMLNodeComboBox() self.outputSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] self.outputSelector.selectNodeUponCreation = True self.outputSelector.addEnabled = True self.outputSelector.removeEnabled = True self.outputSelector.noneEnabled = True self.outputSelector.showHidden = False self.outputSelector.showChildNodeTypes = False self.outputSelector.setMRMLScene( slicer.mrmlScene ) self.outputSelector.setToolTip( "Pick the output to the algorithm." ) parametersFormLayout.addRow("Output Volume: ", self.outputSelector) # # sigma value # self.imageSigmaSliderWidget = ctk.ctkSliderWidget() self.imageSigmaSliderWidget.singleStep = 0.1 self.imageSigmaSliderWidget.minimum = 0.0 self.imageSigmaSliderWidget.maximum = 5.0 self.imageSigmaSliderWidget.value = 1.0 self.imageSigmaSliderWidget.setToolTip("Set sigma value for computing the output image. Voxels that have intensities lower than this value will set to zero.") parametersFormLayout.addRow("Image sigma", self.imageSigmaSliderWidget) # # slice divide # self.sliceDivideSliderWidget = ctk.ctkSliderWidget() self.sliceDivideSliderWidget.singleStep = 1 self.sliceDivideSliderWidget.minimum = 1 self.sliceDivideSliderWidget.maximum = 50 self.sliceDivideSliderWidget.value = 1 self.sliceDivideSliderWidget.setToolTip("Set a number of slices divided from each slice. For example, if the slice thickness of the input volume is 5 mm, and sliceDivide is '2', the slice thickness of the resultant image will be 5/2 = 2.5mm.") parametersFormLayout.addRow("Slice Divide", self.sliceDivideSliderWidget) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelect()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # Set up tabs to split workflow tabsWidget = qt.QTabWidget() curvesTab = qt.QWidget() curvesTabLayout = qt.QFormLayout(curvesTab) fiducialsTab = qt.QWidget() fiducialsTabLayout = qt.QFormLayout(fiducialsTab) batchTab = qt.QWidget() batchTabLayout = qt.QFormLayout(batchTab) tabsWidget.addTab(curvesTab, "Merge Curves") tabsWidget.addTab(fiducialsTab, "Merge Landmark Sets") tabsWidget.addTab(batchTab, "Batch Merge Landmark Sets") self.layout.addWidget(tabsWidget) ################## Curves Tab # # Parameters Area # parametersCurveCollapsibleButton = ctk.ctkCollapsibleButton() parametersCurveCollapsibleButton.text = "Curve Viewer" curvesTabLayout.addRow(parametersCurveCollapsibleButton) # Layout within the dummy collapsible button parametersCurveFormLayout = qt.QFormLayout( parametersCurveCollapsibleButton) # # check box to trigger taking screen shots for later use in tutorials # self.continuousCurvesCheckBox = qt.QCheckBox() self.continuousCurvesCheckBox.checked = 0 self.continuousCurvesCheckBox.setToolTip( "If checked, redundant points will be removed on merging.") parametersCurveFormLayout.addRow("Contiuous curves", self.continuousCurvesCheckBox) # # markups view # self.markupsView = slicer.qMRMLSubjectHierarchyTreeView() self.markupsView.setMRMLScene(slicer.mrmlScene) self.markupsView.setMultiSelection(True) self.markupsView.setAlternatingRowColors(True) self.markupsView.setDragDropMode(qt.QAbstractItemView().DragDrop) self.markupsView.setColumnHidden( self.markupsView.model().transformColumn, True) self.markupsView.sortFilterProxyModel().setNodeTypes( ["vtkMRMLMarkupsCurveNode"]) parametersCurveFormLayout.addRow(self.markupsView) # # Merge Button # self.mergeButton = qt.QPushButton("Merge highlighted nodes") self.mergeButton.toolTip = "Generate a single merged markup file from the selected nodes" self.mergeButton.enabled = False parametersCurveFormLayout.addRow(self.mergeButton) # connections self.mergeButton.connect('clicked(bool)', self.onMergeButton) self.markupsView.connect('currentItemChanged(vtkIdType)', self.updateMergeButton) ################ Landmark Set Tab # # Parameters Area # parametersLMCollapsibleButton = ctk.ctkCollapsibleButton() parametersLMCollapsibleButton.text = "Landmark Viewer" fiducialsTabLayout.addRow(parametersLMCollapsibleButton) # Layout within the dummy collapsible button parametersLMFormLayout = qt.QGridLayout(parametersLMCollapsibleButton) # # markups view # self.markupsFiducialView = slicer.qMRMLSubjectHierarchyTreeView() self.markupsFiducialView.setMRMLScene(slicer.mrmlScene) self.markupsFiducialView.setMultiSelection(True) self.markupsFiducialView.setAlternatingRowColors(True) self.markupsFiducialView.setDragDropMode( qt.QAbstractItemView().DragDrop) self.markupsFiducialView.setColumnHidden( self.markupsView.model().transformColumn, True) self.markupsFiducialView.sortFilterProxyModel().setNodeTypes( ["vtkMRMLMarkupsFiducialNode"]) parametersLMFormLayout.addWidget(self.markupsFiducialView, 0, 0, 1, 3) # # Set landmark type menu # boxLabel = qt.QLabel("Select landmark type description to apply: ") self.LandmarkTypeSelection = qt.QComboBox() self.LandmarkTypeSelection.addItems( ["Select", "Fixed", "Semi", "No description"]) parametersLMFormLayout.addWidget(boxLabel, 1, 0) parametersLMFormLayout.addWidget(self.LandmarkTypeSelection, 1, 1) # # Apply Landmark Type Button # self.ApplyLMButton = qt.QPushButton("Apply to highlighted nodes") self.ApplyLMButton.toolTip = "Apply the selected landmark type to points in the the selected nodes" self.ApplyLMButton.enabled = False parametersLMFormLayout.addWidget(self.ApplyLMButton, 1, 2) # # Merge Button # self.mergeLMButton = qt.QPushButton("Merge highlighted nodes") self.mergeLMButton.toolTip = "Generate a single merged markup file from the selected nodes" self.mergeLMButton.enabled = False parametersLMFormLayout.addWidget(self.mergeLMButton, 2, 0, 1, 3) # connections self.mergeLMButton.connect('clicked(bool)', self.onMergeLMButton) self.ApplyLMButton.connect('clicked(bool)', self.onApplyLMButton) self.markupsFiducialView.connect('currentItemChanged(vtkIdType)', self.updateMergeLMButton) self.LandmarkTypeSelection.connect('currentIndexChanged(int)', self.updateApplyLMButton) ################ Batch Run LM Merge Tab # # Fixed LM Area # fixedBatchCollapsibleButton = ctk.ctkCollapsibleButton() fixedBatchCollapsibleButton.text = "Fixed LM File Selection" batchTabLayout.addRow(fixedBatchCollapsibleButton) # Layout within the dummy collapsible button fixedBatchLayout = qt.QFormLayout(fixedBatchCollapsibleButton) # # Browse Fixed LM Button # self.browseFixedLMButton = qt.QPushButton("Select files...") self.browseFixedLMButton.toolTip = "Select one fixed landmark file for each subject" self.browseFixedLMButton.enabled = True fixedBatchLayout.addRow(self.browseFixedLMButton) # # File viewer box # self.fixedFileTable = qt.QTextEdit() fixedBatchLayout.addRow(self.fixedFileTable) # # Semi LM Area # semiBatchCollapsibleButton = ctk.ctkCollapsibleButton() semiBatchCollapsibleButton.text = "Semi LM File Selection" batchTabLayout.addRow(semiBatchCollapsibleButton) # Layout within the dummy collapsible button semiBatchLayout = qt.QFormLayout(semiBatchCollapsibleButton) # # Browse Fixed LM Button # self.browseSemiLMButton = qt.QPushButton("Select files...") self.browseSemiLMButton.toolTip = "Select one semi-landmark file for each subject, in the same order as the fixed landmarks" self.browseSemiLMButton.enabled = True semiBatchLayout.addRow(self.browseSemiLMButton) # # File viewer box # self.semiFileTable = qt.QTextEdit() semiBatchLayout.addRow(self.semiFileTable) # # Merge LM Area # batchMergeCollapsibleButton = ctk.ctkCollapsibleButton() batchMergeCollapsibleButton.text = "Run merge" batchTabLayout.addRow(batchMergeCollapsibleButton) # Layout within the dummy collapsible button batchMergeLayout = qt.QFormLayout(batchMergeCollapsibleButton) # # Select output landmark directory # self.outputDirectorySelector = ctk.ctkPathLineEdit() self.outputDirectorySelector.filters = ctk.ctkPathLineEdit.Dirs self.outputDirectorySelector.toolTip = "Select the output directory where the merged landmark nodes will be saved" batchMergeLayout.addRow("Select output landmark directory: ", self.outputDirectorySelector) # # Batch Merge Button # self.batchMergeButton = qt.QPushButton( "Merge fixed and semi-landmark nodes") self.batchMergeButton.toolTip = "Generate a single merged markup file from the selected nodes" self.batchMergeButton.enabled = False batchMergeLayout.addRow(self.batchMergeButton) # # Clear Button # self.clearButton = qt.QPushButton("Clear landmark file selections") self.clearButton.toolTip = "Clear the landmark files selected in the viewer boxes" self.clearButton.enabled = False batchMergeLayout.addRow(self.clearButton) # connections self.browseFixedLMButton.connect('clicked(bool)', self.addFixedByBrowsing) self.browseSemiLMButton.connect('clicked(bool)', self.addSemiByBrowsing) self.outputDirectorySelector.connect('validInputChanged(bool)', self.onSelectDirectory) self.batchMergeButton.connect('clicked(bool)', self.onBatchMergeButton) self.clearButton.connect('clicked(bool)', self.onClearButton) # Add vertical spacer self.layout.addStretch(1)
def __init__(self): super().__init__() layout = qt.QGridLayout(self) # set up tree view self.treeView = slicer.qMRMLSubjectHierarchyTreeView( slicer.util.mainWindow()) self.treeView.setMRMLScene(slicer.mrmlScene) self.treeView.contextMenuEnabled = False self.treeView.setEditTriggers(0) # disable double click to edit # add addPixmap = qt.QPixmap( os.path.join( os.path.split(WarpDrive.__file__)[0], 'Resources', 'Icons', 'Add.png')) addIcon = qt.QIcon(addPixmap) self.addButton = qt.QToolButton() self.addButton.setToolButtonStyle(qt.Qt.ToolButtonTextBesideIcon) self.addButton.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Maximum) self.addButton.setIcon(addIcon) self.addButton.setIconSize(addPixmap.rect().size()) self.addButton.setToolTip('Add') # delete deletePixmap = qt.QPixmap( os.path.join( os.path.split(WarpDrive.__file__)[0], 'Resources', 'Icons', 'Delete.png')) deleteIcon = qt.QIcon(deletePixmap) self.deleteButton = qt.QPushButton() self.deleteButton.setIcon(deleteIcon) self.deleteButton.setIconSize(deletePixmap.rect().size()) self.deleteButton.setToolTip('Delete') # rename renamePixmap = qt.QPixmap( os.path.join( os.path.split(WarpDrive.__file__)[0], 'Resources', 'Icons', 'Rename.png')) renameIcon = qt.QIcon(renamePixmap) self.renameButton = qt.QPushButton() self.renameButton.setIcon(renameIcon) self.renameButton.setIconSize(renamePixmap.rect().size()) self.renameButton.setToolTip('Rename') # set up filters #filters = [treeViewSavedWarpFilter(), treeViewAtlasFilter(), treeViewDrawingsFilter(), treeViewSceneFilter()] filters = [ treeViewCorrectionsFiducialsFilter(), treeViewAtlasFilter(), treeViewSegmentationsFilter() ] self.radioButtons = [] for filt, pos in zip(filters, [[0, 0], [0, 2], [0, 4]]): filterRadioButton = qt.QRadioButton(filt.name) filterRadioButton.setToolTip(filt.toolTip) filterRadioButton.clicked.connect( lambda b, f=filt: self.onFilterRadioButtonClicked(f)) layout.addWidget(filterRadioButton, pos[0], pos[1], 1, 2) self.radioButtons.append(filterRadioButton) layout.addWidget(self.addButton, 0, 6, 1, 2) layout.addWidget(self.deleteButton, 0, 8, 1, 1) layout.addWidget(self.renameButton, 0, 9, 1, 1) layout.addWidget(self.treeView, 1, 0, 1, 10) # when adding fixed points while one of them is selected the new one is not set in the correct parent folder # this is overdoing, but fixes the problem self.treeView.model().rowsAboutToBeInserted.connect( lambda: self.treeView.setCurrentItem(0)) # init self.radioButtons[0].animateClick()
def setupClassificationTab(self): self.classificationLayout = qt.QVBoxLayout( self.classificationTabWidget) gridLayoutClass = qt.QGridLayout() ### Input File self.inputClass = qt.QLineEdit("") self.inputClassSelector = qt.QPushButton("Browse") ### Output Directory self.outputDirClass = qt.QLineEdit("") self.outputDirClassSelector = qt.QPushButton("Browse") ### Model Directory self.modelDirClass = qt.QLineEdit("") self.modelDirClassSelector = qt.QPushButton("Browse") ### Summary Directory self.sumDirClass = qt.QLineEdit("") self.sumDirClassSelector = qt.QPushButton("Browse") ### Displacement Field self.dFPathClass = qt.QLineEdit("") self.dFPathClassSelector = qt.QPushButton("Browse") gridLayoutClass.addWidget(qt.QLabel("Input File"), 0, 0) gridLayoutClass.addWidget(self.inputClass, 0, 1) gridLayoutClass.addWidget(self.inputClassSelector, 0, 2) gridLayoutClass.addWidget(qt.QLabel("Output Directory"), 1, 0) gridLayoutClass.addWidget(self.outputDirClass, 1, 1) gridLayoutClass.addWidget(self.outputDirClassSelector, 1, 2) gridLayoutClass.addWidget(qt.QLabel("Model Directory"), 2, 0) gridLayoutClass.addWidget(self.modelDirClass, 2, 1) gridLayoutClass.addWidget(self.modelDirClassSelector, 2, 2) gridLayoutClass.addWidget(qt.QLabel("Summary Directory"), 3, 0) gridLayoutClass.addWidget(self.sumDirClass, 3, 1) gridLayoutClass.addWidget(self.sumDirClassSelector, 3, 2) gridLayoutClass.addWidget(qt.QLabel("Displacement Field"), 4, 0) gridLayoutClass.addWidget(self.dFPathClass, 4, 1) gridLayoutClass.addWidget(self.dFPathClassSelector, 4, 2) gridResClass = qt.QGridLayout() self.classReset = qt.QPushButton("RESET") self.classRun = qt.QPushButton("RUN") gridResClass.addWidget(self.classReset, 0, 0) gridResClass.addWidget(self.classRun, 0, 1) self.classificationLayout.addLayout(gridLayoutClass) self.classificationLayout.addLayout(gridResClass) self.classificationLayout.addStretch(1) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # CONNECTIONS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # self.classReset.connect("clicked(bool)", self.OnClassReset) self.classRun.connect("clicked(bool)", self.OnClassRun) self.inputClassSelector.connect("clicked(bool)", self.OnInputClass) self.outputDirClassSelector.connect("clicked(bool)", self.OnOutputDirClass) self.modelDirClassSelector.connect("clicked(bool)", self.OnModelDirClass) self.sumDirClassSelector.connect("clicked(bool)", self.OnSumDirClass) self.dFPathClassSelector.connect("clicked(bool)", self.OndFClassSelector) self.inputClass.connect("editingFinished()", self.CheckInputClass) self.outputDirClass.connect("editingFinished()", self.CheckOutputDirClass) self.modelDirClass.connect("editingFinished()", self.CheckModelDirClass) self.sumDirClass.connect("editingFinished()", self.CheckSumDirClass) self.dFPathClass.connect("editingFinished()", self.CheckdFClassPath) # self.classificationWidget = widget return
def create(self): super().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 = f'PushButton_QuickRadius_{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)