def create(self): super(WandEffectOptions, self).create() self.toleranceFrame = qt.QFrame(self.frame) self.toleranceFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.toleranceFrame) self.widgets.append(self.toleranceFrame) self.toleranceLabel = qt.QLabel("Tolerance:", self.toleranceFrame) self.toleranceLabel.setToolTip("Set the tolerance of the wand in terms of background pixel values") self.toleranceFrame.layout().addWidget(self.toleranceLabel) self.widgets.append(self.toleranceLabel) self.toleranceSpinBox = ctk.ctkDoubleSpinBox(self.toleranceFrame) self.toleranceSpinBox.setToolTip("Set the tolerance of the wand in terms of background pixel values") self.toleranceSpinBox.minimum = 0 self.toleranceSpinBox.maximum = 1000 self.toleranceSpinBox.suffix = "" self.toleranceFrame.layout().addWidget(self.toleranceSpinBox) self.widgets.append(self.toleranceSpinBox) self.maxPixelsFrame = qt.QFrame(self.frame) self.maxPixelsFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.maxPixelsFrame) self.widgets.append(self.maxPixelsFrame) self.maxPixelsLabel = qt.QLabel("Max Pixels per click:", self.maxPixelsFrame) self.maxPixelsLabel.setToolTip("Set the maxPixels for each click") self.maxPixelsFrame.layout().addWidget(self.maxPixelsLabel) self.widgets.append(self.maxPixelsLabel) self.maxPixelsSpinBox = ctk.ctkDoubleSpinBox(self.maxPixelsFrame) self.maxPixelsSpinBox.setToolTip("Set the maxPixels for each click") self.maxPixelsSpinBox.minimum = 1 self.maxPixelsSpinBox.maximum = 100000 self.maxPixelsSpinBox.suffix = "" self.maxPixelsFrame.layout().addWidget(self.maxPixelsSpinBox) self.widgets.append(self.maxPixelsSpinBox) self.fillModeFrame = qt.QFrame(self.frame) self.fillModeFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.fillModeFrame) self.widgets.append(self.fillModeFrame) self.fillModeCheckBox = qt.QCheckBox(self.fillModeFrame) self.fillModeCheckBox.text = "Fill Volume" self.fillModeCheckBox.setToolTip("Fill in 3D when checked, else fill plane") self.fillModeFrame.layout().addWidget(self.fillModeCheckBox) self.widgets.append(self.fillModeCheckBox) HelpButton(self.frame, "Use this tool to label all voxels that are within a tolerance of where you click") # don't connect the signals and slots directly - instead, add these # to the list of connections so that gui callbacks can be cleanly # disabled while the gui is being updated. This allows several gui # elements to be interlinked with signal/slots but still get updated # as a unit to the new value of the mrml node. self.connections.append((self.toleranceSpinBox, "valueChanged(double)", self.onToleranceSpinBoxChanged)) self.connections.append((self.maxPixelsSpinBox, "valueChanged(double)", self.onMaxPixelsSpinBoxChanged)) self.connections.append((self.fillModeCheckBox, "clicked()", self.onFillModeClicked)) # Add vertical spacer self.frame.layout().addStretch(1)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Select landmark file to import # self.inputFileSelector = ctk.ctkPathLineEdit() self.inputFileSelector.setToolTip( "Select landmark file for import" ) parametersFormLayout.addRow("Select file containing landmark names and coordinates to load:", self.inputFileSelector) # # Get header length # self.headerLengthWidget = ctk.ctkDoubleSpinBox() self.headerLengthWidget.value = 2 self.headerLengthWidget.minimum = 0 self.headerLengthWidget.singleStep = 1 self.headerLengthWidget.setToolTip("Input the number of lines in header") parametersFormLayout.addRow("Header length:", self.headerLengthWidget) # # check box to trigger taking screen shots for later use in tutorials # self.enableScreenshotsFlagCheckBox = qt.QCheckBox() self.enableScreenshotsFlagCheckBox.checked = 0 self.enableScreenshotsFlagCheckBox.setToolTip("If checked, take screen shots for tutorials. Use Save Data to write them to disk.") parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.inputFileSelector.connect('validInputChanged(bool)', self.onSelect) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelect()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) self.maximumRunningProcessesSpinBox = ctk.ctkDoubleSpinBox() self.maximumRunningProcessesSpinBox.minimum = 1 self.maximumRunningProcessesSpinBox.decimals = 0 self.maximumRunningProcessesSpinBox.value = self.logic.maximumRunningProcesses parametersFormLayout.addRow("Maximum running processes", self.maximumRunningProcessesSpinBox) processesCollapsibleButton = ctk.ctkCollapsibleButton() processesCollapsibleButton.text = "Processes" self.layout.addWidget(processesCollapsibleButton) processesFormLayout = qt.QFormLayout(processesCollapsibleButton) self.statusLabel = qt.QLabel("No processes running") processesFormLayout.addRow(self.statusLabel) self.processBoxes = {} self.processLabels = {} for processState in self.logic.processStates: processBox = qt.QGroupBox() processBoxLayout = qt.QVBoxLayout(processBox) processBox.setTitle(processState) processesFormLayout.addRow(processBox) processLabel = qt.QLabel(processBox) processLabel.text = "None" processBoxLayout.addWidget(processLabel) self.processBoxes[processState] = processBox self.processLabels[processState] = processLabel self.maximumRunningProcessesSpinBox.connect("valueChanged(double)", self.onMaximumChanged) node = self.logic.getParameterNode() self.nodeObserverTag = node.AddObserver(vtk.vtkCommand.ModifiedEvent, self.onNodeModified) # Add vertical spacer self.layout.addStretch(1)
def default_origin_component(self): """ Create and initialize origin widget. Returns: ctk.ctkDoubleSpinBox(): Initialized origin widget. """ origin_widget = ctk.ctkDoubleSpinBox() origin_widget.singleStep = 0.1 origin_widget.minimum = 50 origin_widget.maximum = 150 origin_widget.value = 100 origin_widget.setToolTip( "Set threshold value for computing the output image. " "Voxels that have intensities lower than this value will set to zero." ) return origin_widget
def gui(self, action, layout): super(CameraRotationAction,self).gui(action, layout) self.referenceSelector = slicer.qMRMLNodeComboBox() self.referenceSelector.nodeTypes = ["vtkMRMLCameraNode"] self.referenceSelector.addEnabled = True self.referenceSelector.renameEnabled = True self.referenceSelector.removeEnabled = False self.referenceSelector.noneEnabled = False self.referenceSelector.selectNodeUponCreation = True self.referenceSelector.showHidden = True self.referenceSelector.showChildNodeTypes = True self.referenceSelector.setMRMLScene( slicer.mrmlScene ) self.referenceSelector.setToolTip( "Pick the reference camera" ) self.referenceSelector.currentNodeID = action['referenceCameraID'] layout.addRow("Reference camera", self.referenceSelector) self.animatedSelector = slicer.qMRMLNodeComboBox() self.animatedSelector.nodeTypes = ["vtkMRMLCameraNode"] self.animatedSelector.addEnabled = True self.animatedSelector.renameEnabled = True self.animatedSelector.removeEnabled = False self.animatedSelector.noneEnabled = False self.animatedSelector.selectNodeUponCreation = True self.animatedSelector.showHidden = True self.animatedSelector.showChildNodeTypes = True self.animatedSelector.setMRMLScene( slicer.mrmlScene ) self.animatedSelector.setToolTip( "Pick the animated camera" ) self.animatedSelector.currentNodeID = action['animatedCameraID'] layout.addRow("Animated camera", self.animatedSelector) self.rate = ctk.ctkDoubleSpinBox() self.rate.suffix = " degreesPerSecond" self.rate.decimals = 2 self.rate.minimum = 0 self.rate.maximum = 1000 self.rate.value = action['degreesPerSecond'] layout.addRow("Rotation rate", self.rate) self.method = qt.QComboBox() for method in self.animationMethods: self.method.addItem(method) self.method.currentText = action['animationMethod'] layout.addRow("Animation method", self.method)
def addAdvancedMenu(self, currentWidgetLayout): # # Advanced menu for single run # advancedCollapsibleButton = ctk.ctkCollapsibleButton() advancedCollapsibleButton.text = "Advanced parameter settings" advancedCollapsibleButton.collapsed = True currentWidgetLayout.addRow(advancedCollapsibleButton) advancedFormLayout = qt.QFormLayout(advancedCollapsibleButton) # Point density label pointDensityCollapsibleButton = ctk.ctkCollapsibleButton() pointDensityCollapsibleButton.text = "Point density" advancedFormLayout.addRow(pointDensityCollapsibleButton) pointDensityFormLayout = qt.QFormLayout(pointDensityCollapsibleButton) # Rigid registration label rigidRegistrationCollapsibleButton = ctk.ctkCollapsibleButton() rigidRegistrationCollapsibleButton.text = "Rigid registration" advancedFormLayout.addRow(rigidRegistrationCollapsibleButton) rigidRegistrationFormLayout = qt.QFormLayout( rigidRegistrationCollapsibleButton) # Point Density slider pointDensity = ctk.ctkSliderWidget() pointDensity.singleStep = 0.1 pointDensity.minimum = 0.1 pointDensity.maximum = 3 pointDensity.value = 1 pointDensity.setToolTip( "Adjust the density of the pointclouds. Larger values increase the number of points, and vice versa." ) pointDensityFormLayout.addRow("Point Density Adjustment: ", pointDensity) # Normal search radius slider normalSearchRadius = ctk.ctkSliderWidget() normalSearchRadius.singleStep = 1 normalSearchRadius.minimum = 2 normalSearchRadius.maximum = 12 normalSearchRadius.value = 2 normalSearchRadius.setToolTip( "Set size of the neighborhood used when computing normals") rigidRegistrationFormLayout.addRow("Normal search radius: ", normalSearchRadius) #FPFH Search Radius slider FPFHSearchRadius = ctk.ctkSliderWidget() FPFHSearchRadius.singleStep = 1 FPFHSearchRadius.minimum = 3 FPFHSearchRadius.maximum = 20 FPFHSearchRadius.value = 5 FPFHSearchRadius.setToolTip( "Set size of the neighborhood used when computing FPFH features") rigidRegistrationFormLayout.addRow("FPFH Search radius: ", FPFHSearchRadius) # Maximum distance threshold slider distanceThreshold = ctk.ctkSliderWidget() distanceThreshold.singleStep = .25 distanceThreshold.minimum = 0.5 distanceThreshold.maximum = 4 distanceThreshold.value = 1.5 distanceThreshold.setToolTip( "Maximum correspondence points-pair distance threshold") rigidRegistrationFormLayout.addRow( "Maximum corresponding point distance: ", distanceThreshold) # Maximum RANSAC iterations slider maxRANSAC = ctk.ctkDoubleSpinBox() maxRANSAC.singleStep = 1 maxRANSAC.setDecimals(0) maxRANSAC.minimum = 1 maxRANSAC.maximum = 500000000 maxRANSAC.value = 4000000 maxRANSAC.setToolTip( "Maximum number of iterations of the RANSAC algorithm") rigidRegistrationFormLayout.addRow("Maximum RANSAC iterations: ", maxRANSAC) # Maximum RANSAC validation steps maxRANSACValidation = ctk.ctkDoubleSpinBox() maxRANSACValidation.singleStep = 1 maxRANSACValidation.setDecimals(0) maxRANSACValidation.minimum = 1 maxRANSACValidation.maximum = 500000000 maxRANSACValidation.value = 500 maxRANSACValidation.setToolTip( "Maximum number of RANSAC validation steps") rigidRegistrationFormLayout.addRow("Maximum RANSAC validation steps: ", maxRANSACValidation) # ICP distance threshold slider ICPDistanceThreshold = ctk.ctkSliderWidget() ICPDistanceThreshold.singleStep = .1 ICPDistanceThreshold.minimum = 0.1 ICPDistanceThreshold.maximum = 2 ICPDistanceThreshold.value = 0.4 ICPDistanceThreshold.setToolTip( "Maximum ICP points-pair distance threshold") rigidRegistrationFormLayout.addRow("Maximum ICP distance: ", ICPDistanceThreshold) return pointDensity, normalSearchRadius, FPFHSearchRadius, distanceThreshold, maxRANSAC, maxRANSACValidation, ICPDistanceThreshold
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) # tracks the modified event observer on the currently # selected sequence browser node self.sequenceBrowserObserverRecord = None self.animatorActionsGUI = None self.logic = AnimatorLogic() # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Animation Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) self.durationBox = ctk.ctkDoubleSpinBox() self.durationBox.suffix = " seconds" self.durationBox.decimals = 1 self.durationBox.minimum = 1 self.durationBox.value = 5 self.durationBox.toolTip = "Duration cannot be changed after animation created" parametersFormLayout.addRow("New animation duration", self.durationBox) # # animation selector # self.animationSelector = slicer.qMRMLNodeComboBox() self.animationSelector.nodeTypes = ["vtkMRMLScriptedModuleNode"] self.animationSelector.setNodeTypeLabel("Animation", "vtkMRMLScriptedModuleNode") self.animationSelector.selectNodeUponCreation = True self.animationSelector.addEnabled = True self.animationSelector.addAttribute("vtkMRMLScriptedModuleNode", "ModuleName", "Animation") self.animationSelector.baseName = "Animation" self.animationSelector.removeEnabled = True self.animationSelector.noneEnabled = True self.animationSelector.showHidden = True self.animationSelector.showChildNodeTypes = False self.animationSelector.setMRMLScene( slicer.mrmlScene ) self.animationSelector.setToolTip( "Pick the animation description." ) parametersFormLayout.addRow("Animation Node: ", self.animationSelector) self.sequencePlay = slicer.qMRMLSequenceBrowserPlayWidget() self.sequencePlay.setMRMLScene(slicer.mrmlScene) self.sequenceSeek = slicer.qMRMLSequenceBrowserSeekWidget() self.sequenceSeek.setMRMLScene(slicer.mrmlScene) parametersFormLayout.addRow(self.sequencePlay) parametersFormLayout.addRow(self.sequenceSeek) self.actionsMenuButton = qt.QPushButton("Add Action") self.actionsMenuButton.enabled = False self.actionsMenu = qt.QMenu() self.actionsMenuButton.setMenu(self.actionsMenu) for actionName in slicer.modules.animatorActionPlugins.keys(): qAction = qt.QAction(actionName, self.actionsMenu) qAction.connect('triggered()', lambda actionName=actionName: self.onAddAction(actionName)) self.actionsMenu.addAction(qAction) parametersFormLayout.addWidget(self.actionsMenuButton) # # Actions Area # self.actionsCollapsibleButton = ctk.ctkCollapsibleButton() self.actionsCollapsibleButton.text = "Actions" self.layout.addWidget(self.actionsCollapsibleButton) # Layout within the dummy collapsible button self.actionsFormLayout = qt.QFormLayout(self.actionsCollapsibleButton) # # Export Area # self.exportCollapsibleButton = ctk.ctkCollapsibleButton() self.exportCollapsibleButton.text = "Export" self.layout.addWidget(self.exportCollapsibleButton) self.exportCollapsibleButton.enabled = False self.exportFormLayout = qt.QFormLayout(self.exportCollapsibleButton) self.sizeSelector = qt.QComboBox() for size in self.sizes.keys(): self.sizeSelector.addItem(size) self.sizeSelector.currentText = self.defaultSize self.exportFormLayout.addRow("Animation size", self.sizeSelector) self.fileFormatSelector = qt.QComboBox() for format in self.fileFormats.keys(): self.fileFormatSelector.addItem(format) self.fileFormatSelector.currentText = self.defaultFileFormat self.exportFormLayout.addRow("Animation format", self.fileFormatSelector) self.outputFileButton = qt.QPushButton("Select a file...") self.exportFormLayout.addRow("Output file", self.outputFileButton) self.exportButton = qt.QPushButton("Export") self.exportButton.enabled = False self.exportFormLayout.addRow("", self.exportButton) # connections self.animationSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.outputFileButton.connect("clicked()", self.selectExportFile) self.exportButton.connect("clicked()", self.onExport) # Add vertical spacer self.layout.addStretch(1)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Select landmark file to import # self.inputFileSelector = ctk.ctkPathLineEdit() self.inputFileSelector.filters = ctk.ctkPathLineEdit().Files self.inputFileSelector.setToolTip("Select landmark file for import") parametersFormLayout.addRow( "Select file containing landmark names and coordinates to load:", self.inputFileSelector) # # output directory selector # self.outputDirectory = ctk.ctkDirectoryButton() self.outputDirectory.directory = slicer.mrmlScene.GetCacheManager( ).GetRemoteCacheDirectory() parametersFormLayout.addRow("Output Directory:", self.outputDirectory) # # Get header length # self.headerLengthWidget = ctk.ctkDoubleSpinBox() self.headerLengthWidget.value = 2 self.headerLengthWidget.minimum = 0 self.headerLengthWidget.singleStep = 1 self.headerLengthWidget.setToolTip( "Input the number of lines in header") parametersFormLayout.addRow("Header length:", self.headerLengthWidget) # # check box to trigger taking screen shots for later use in tutorials # self.loadLandmarkNode = qt.QCheckBox() self.loadLandmarkNode.checked = 0 self.loadLandmarkNode.setToolTip( "After conversion, load landmarks into the scene.") parametersFormLayout.addRow("Load landmarks into scene", self.loadLandmarkNode) # # 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.inputFileSelector.connect('validInputChanged(bool)', 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 ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Select landmark file to import # self.inputDirectory = ctk.ctkPathLineEdit() self.inputDirectory.filters = ctk.ctkPathLineEdit.Dirs self.inputDirectory.setToolTip( "Select directory containing curves to resample") parametersFormLayout.addRow("Input Directory:", self.inputDirectory) # # output directory selector # self.outputDirectory = ctk.ctkPathLineEdit() self.outputDirectory.filters = ctk.ctkPathLineEdit.Dirs self.outputDirectory.currentPath = slicer.app.temporaryPath parametersFormLayout.addRow("Output Directory:", self.outputDirectory) # # Get Resample number # self.ResampleRateWidget = ctk.ctkDoubleSpinBox() self.ResampleRateWidget.value = 50 self.ResampleRateWidget.minimum = 3 self.ResampleRateWidget.maximum = 5000 self.ResampleRateWidget.singleStep = 1 self.ResampleRateWidget.setDecimals(0) self.ResampleRateWidget.setToolTip( "Select the number of points for resampling: ") parametersFormLayout.addRow("Output sample number: ", self.ResampleRateWidget) # # Get open or closed curve option # curveTypeSelector = qt.QHBoxLayout() self.curveTypeOpen = qt.QRadioButton("open") self.curveTypeOpen.setToolTip( "Select option for no interpolation between first and last points") self.curveTypeOpen.setChecked(True) self.curveTypeClosed = qt.QRadioButton("closed") self.curveTypeClosed.setToolTip( "Select option to interpolate between first and last points") curveTypeSelector.addWidget(self.curveTypeOpen) curveTypeSelector.addWidget(self.curveTypeClosed) curveTypeSelector.addStretch() parametersFormLayout.addRow("Curve Type: ", curveTypeSelector) # # check box to trigger taking screen shots for later use in tutorials # self.enableScreenshotsFlagCheckBox = qt.QCheckBox() self.enableScreenshotsFlagCheckBox.checked = 0 self.enableScreenshotsFlagCheckBox.setToolTip( "If checked, take screen shots for tutorials. Use Save Data to write them to disk." ) parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the conversion." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.inputDirectory.connect('validInputChanged(bool)', self.onSelectInput) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelectInput()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... medicalimageButton = ctk.ctkCollapsibleButton() medicalimageButton.text = "Input CT image" self.layout.addWidget(medicalimageButton) medicalimageFormLayout = qt.QFormLayout(medicalimageButton) # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Transducer Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # input volume selector # self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.inputSelector.selectNodeUponCreation = True self.inputSelector.addEnabled = False self.inputSelector.removeEnabled = False self.inputSelector.noneEnabled = False self.inputSelector.showHidden = False self.inputSelector.showChildNodeTypes = False self.inputSelector.setMRMLScene(slicer.mrmlScene) self.inputSelector.setToolTip("Pick the input to the algorithm.") medicalimageFormLayout.addRow("Input CT Volume: ", self.inputSelector) # # output volume selector # self.outputSelector = slicer.qMRMLNodeComboBox() self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] 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) # # threshold value # self.ROC = ctk.ctkSliderWidget() self.ROC.singleStep = 0.1 self.ROC.minimum = 0 self.ROC.maximum = 100 self.ROC.value = 71 parametersFormLayout.addRow("ROC", self.ROC) self.width = ctk.ctkSliderWidget() self.width.singleStep = 0.1 self.width.minimum = 0 self.width.maximum = 100 self.width.value = 71 parametersFormLayout.addRow("Width", self.width) self.freq = ctk.ctkSliderWidget() self.freq.singleStep = 1 self.freq.minimum = 20 self.freq.maximum = 10000 self.freq.value = 200 parametersFormLayout.addRow("kHz", self.freq) self.test = ctk.ctkDoubleSpinBox() self.test.value = 1.0 self.test2 = ctk.ctkDoubleSpinBox() self.test2.value = 2.0 self.test3 = ctk.ctkDoubleSpinBox() self.test3.value = 3.0 self.label1 = qt.QLabel("Test1") self.label1.setFixedWidth(50) rowLayout = qt.QHBoxLayout() rowLayout.addWidget(self.label1) rowLayout.addWidget(self.test) rowLayout.addWidget(self.test2) parametersFormLayout.addRow(rowLayout) #parametersFormLayout.insertRow(2, self.test) # # check box to trigger taking screen shots for later use in tutorials # # # Apply Button # self.applyButton = qt.QPushButton("Run simulation") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = True 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)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # File area # filesCollapsibleButton = ctk.ctkCollapsibleButton() filesCollapsibleButton.text = "Files" filesCollapsibleButton.collapsed = False self.layout.addWidget(filesCollapsibleButton) # Layout within the files collapsible button filesFormLayout = qt.QFormLayout(filesCollapsibleButton) self.fileModel = qt.QStandardItemModel() self.fileTable = qt.QTableView() self.fileTable.horizontalHeader().stretchLastSection = True self.fileTable.horizontalHeader().visible = False self.fileTable.setModel(self.fileModel) filesFormLayout.addRow(self.fileTable) buttonLayout = qt.QHBoxLayout() self.addByBrowsingButton = qt.QPushButton("Browse for files") self.clearFilesButton = qt.QPushButton("Clear files") buttonLayout.addWidget(self.addByBrowsingButton) buttonLayout.addWidget(self.clearFilesButton) filesFormLayout.addRow(buttonLayout) self.propertiesLabel = qt.QLabel() filesFormLayout.addRow(self.propertiesLabel) # # output area # outputCollapsibleButton = ctk.ctkCollapsibleButton() outputCollapsibleButton.text = "Output" outputCollapsibleButton.collapsed = False self.layout.addWidget(outputCollapsibleButton) outputFormLayout = qt.QFormLayout(outputCollapsibleButton) # # output volume selector # self.outputSelector = slicer.qMRMLNodeComboBox() self.outputSelector.nodeTypes = [ "vtkMRMLScalarVolumeNode", ] self.outputSelector.showChildNodeTypes = False self.outputSelector.showHidden = False self.outputSelector.showChildNodeTypes = False self.outputSelector.selectNodeUponCreation = True self.outputSelector.noneEnabled = True self.outputSelector.removeEnabled = True self.outputSelector.renameEnabled = True self.outputSelector.addEnabled = True self.outputSelector.setMRMLScene(slicer.mrmlScene) self.outputSelector.setToolTip( "Pick the output volume to populate or None to autogenerate.") outputFormLayout.addRow("Output Volume: ", self.outputSelector) self.spacing = ctk.ctkCoordinatesWidget() self.spacing.decimals = 8 self.spacing.coordinates = "1,1,1" self.spacing.toolTip = "Set the colunm, row, slice spacing in mm; original spacing not including downsample" outputFormLayout.addRow("Spacing: ", self.spacing) self.downsample = qt.QCheckBox() self.downsample.toolTip = "Reduces data size by half in each dimension by skipping every other pixel and slice (uses about 1/8 memory)" outputFormLayout.addRow("Downsample: ", self.downsample) self.reverse = qt.QCheckBox() self.reverse.toolTip = "Read the images in reverse order" outputFormLayout.addRow("Reverse: ", self.reverse) self.sliceSkip = ctk.ctkDoubleSpinBox() self.sliceSkip.decimals = 0 self.sliceSkip.minimum = 0 self.sliceSkip.toolTip = "Skips the selected number of slices (use, for example, on long thin samples with more slices than in-plane resolution)" outputFormLayout.addRow("Slice skip: ", self.sliceSkip) self.loadButton = qt.QPushButton("Load files") outputFormLayout.addRow(self.loadButton) # # Add by name area # addByNameCollapsibleButton = ctk.ctkCollapsibleButton() addByNameCollapsibleButton.text = "Add files by name" addByNameCollapsibleButton.collapsed = True addByNameFormLayout = qt.QFormLayout(addByNameCollapsibleButton) # Don't enable Add by name for now - let's see if it's actually needed # self.layout.addWidget(addByNameCollapsibleButton) forExample = """ directoryPath = '/Volumes/SSD2T/data/SlicerMorph/Sample_for_steve/1326_Rec' pathFormat = '%s/1326__rec%04d.png' start, end = (50, 621) """ self.archetypePathEdit = ctk.ctkPathLineEdit() addByNameFormLayout.addRow("Archetype file", self.archetypePathEdit) self.archetypeFormat = qt.QLineEdit() addByNameFormLayout.addRow("Name format", self.archetypeFormat) self.indexRange = ctk.ctkRangeWidget() self.indexRange.decimals = 0 self.indexRange.maximum = 0 addByNameFormLayout.addRow("Index range", self.indexRange) self.generateNamesButton = qt.QPushButton("Apply") self.generateNamesButton.toolTip = "Run the algorithm." self.generateNamesButton.enabled = False addByNameFormLayout.addRow(self.generateNamesButton) # connections self.addByBrowsingButton.connect('clicked()', self.addByBrowsing) self.clearFilesButton.connect('clicked()', self.onClearFiles) self.archetypePathEdit.connect('currentPathChanged(QString)', self.validateInput) self.archetypePathEdit.connect('currentPathChanged(QString)', self.updateGUIFromArchetype) self.archetypeFormat.connect('textChanged(QString)', self.validateInput) self.generateNamesButton.connect('clicked()', self.onGenerateNames) # self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.validateInput) # TODO - this is missing self.loadButton.connect('clicked()', self.onLoadButton) # refill last selection self.archetypePathEdit.currentPath = slicer.util.settingsValue( "ImageStacks/lastArchetypePath", "") # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.validateInput()
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.inputDirectory = ctk.ctkPathLineEdit() self.inputDirectory.filters = ctk.ctkPathLineEdit.Dirs self.inputDirectory.setToolTip("Select directory containing volumes") parametersFormLayout.addRow("Input directory: ", self.inputDirectory) # 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) # # Select the extension type # self.extensionOptionGZ = qt.QRadioButton(".nii.gz") self.extensionOptionGZ.setChecked(True) parametersFormLayout.addRow("Select extension type: ", self.extensionOptionGZ) # # set threshold value # self.threshold = ctk.ctkDoubleSpinBox() self.threshold.singleStep = 1 self.threshold.minimum = 0 self.threshold.maximum = 100000 self.threshold.setDecimals(0) self.threshold.value = 500 self.threshold.setToolTip( "Select threshold for segmentation of volume") parametersFormLayout.addRow("Threshold for segmentation:", self.threshold) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Generate VolumeToMeshs." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # # check box to trigger taking screen shots for later use in tutorials # self.enableScreenshotsFlagCheckBox = qt.QCheckBox() self.enableScreenshotsFlagCheckBox.checked = 0 self.enableScreenshotsFlagCheckBox.setToolTip( "If checked, take screen shots for tutorials. Use Save Data to write them to disk." ) parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox) # connections self.inputDirectory.connect('validInputChanged(bool)', self.onSelectInput) self.outputDirectory.connect('validInputChanged(bool)', self.onSelectOutput) 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 landmark directory selector # self.inputLandmarkDirectory = ctk.ctkDirectoryButton() self.inputLandmarkDirectory.directory = qt.QDir.homePath() parametersFormLayout.addRow("Landmark Directory:", self.inputLandmarkDirectory) self.inputLandmarkDirectory.setToolTip( "Select directory containing landmark files") # # input landmark numbers for grid # gridPointsLayout = qt.QGridLayout() self.landmarkGridPoint1 = ctk.ctkDoubleSpinBox() self.landmarkGridPoint1.minimum = 0 self.landmarkGridPoint1.singleStep = 1 self.landmarkGridPoint1.setDecimals(0) self.landmarkGridPoint1.setToolTip( "Input the landmark numbers to create grid") self.landmarkGridPoint2 = ctk.ctkDoubleSpinBox() self.landmarkGridPoint2.minimum = 0 self.landmarkGridPoint2.singleStep = 1 self.landmarkGridPoint2.setDecimals(0) self.landmarkGridPoint2.setToolTip( "Input the landmark numbers to create grid") self.landmarkGridPoint3 = ctk.ctkDoubleSpinBox() self.landmarkGridPoint3.minimum = 0 self.landmarkGridPoint3.singleStep = 1 self.landmarkGridPoint3.setDecimals(0) self.landmarkGridPoint3.setToolTip( "Input the landmark numbers to create grid") self.landmarkGridPoint4 = ctk.ctkDoubleSpinBox() self.landmarkGridPoint4.minimum = 0 self.landmarkGridPoint4.singleStep = 1 self.landmarkGridPoint4.setDecimals(0) self.landmarkGridPoint4.setToolTip( "Input the landmark numbers to create grid") gridPointsLayout.addWidget(self.landmarkGridPoint1, 1, 2) gridPointsLayout.addWidget(self.landmarkGridPoint2, 1, 3) gridPointsLayout.addWidget(self.landmarkGridPoint3, 1, 4) gridPointsLayout.addWidget(self.landmarkGridPoint4, 1, 5) parametersFormLayout.addRow("Semi-landmark grid points:", gridPointsLayout) # # input mesh directory selector # self.inputMeshDirectory = ctk.ctkDirectoryButton() self.inputMeshDirectory.directory = qt.QDir.homePath() parametersFormLayout.addRow("Mesh Directory:", self.inputMeshDirectory) self.inputMeshDirectory.setToolTip( "Select directory containing mesh files") # # output directory selector # self.outputDirectory = ctk.ctkDirectoryButton() self.outputDirectory.directory = qt.QDir.homePath() parametersFormLayout.addRow("Output Directory:", self.outputDirectory) self.inputMeshDirectory.setToolTip( "Select directory for output semi-landmark files") # # check box to trigger taking screen shots for later use in tutorials # self.enableScreenshotsFlagCheckBox = qt.QCheckBox() self.enableScreenshotsFlagCheckBox.checked = 0 self.enableScreenshotsFlagCheckBox.setToolTip( "If checked, take screen shots for tutorials. Use Save Data to write them to disk." ) parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the conversion." self.applyButton.enabled = 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) ################################### # Import node graph json file Area ################################### self.fileCollapsibleButton = ctk.ctkCollapsibleButton() self.fileCollapsibleButton.text = "Import Node Graph Json File" self.layout.addWidget(self.fileCollapsibleButton) self.fileImportFormLayout = qt.QFormLayout(self.fileCollapsibleButton) self.fileImport = ctk.ctkPathLineEdit() self.fileImport.filters = ctk.ctkPathLineEdit.Files self.fileImport.settingKey = 'JsonInputFile' self.fileImport.currentPath = os.path.normpath( os.path.join(os.path.dirname(os.path.realpath(__file__)), './Resources/nodeGraph_3D.json')) self.fileImportFormLayout.addRow("Input Json File:", self.fileImport) self.fileImportButton = qt.QPushButton('Load File') self.fileImportFormLayout.addRow(self.fileImportButton) ################################### # Node Table Area ################################### parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Node Table" self.layout.addWidget(parametersCollapsibleButton) # Layout within the collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Checkbox to see whether or not the input table has a header # self.headerCheckBox = qt.QCheckBox() self.headerCheckBox.checked = 0 self.headerCheckBox.setToolTip( "If checked, it means that the input node table contains a header." ) parametersFormLayout.addRow("Header in Node Table", self.headerCheckBox) # # input table selector # self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = ["vtkMRMLTableNode"] 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( "The input file loaded trough the import Data module should be a one line table (with or without header)." ) parametersFormLayout.addRow("Input Table: ", self.inputSelector) # # Table start column spinBox # self.min_column = 1 self.tableStartSpinBox = qt.QDoubleSpinBox() self.tableStartSpinBox.singleStep = 1 self.tableStartSpinBox.setValue(self.min_column) self.tableStartSpinBox.setDecimals(0) self.tableStartSpinBox.setToolTip( "Set start column, if the first column contains a string of characters(ex: subject name) then this column should be skipped and the start column is thus 1. This should be an integer (int)" ) parametersFormLayout.addRow("Start Column:", self.tableStartSpinBox) ################################### # Region Selector Area ################################### self.nodeselectCollapsibleButton = ctk.ctkCollapsibleButton() self.nodeselectCollapsibleButton.text = "Selection of Node Region" self.layout.addWidget(self.nodeselectCollapsibleButton) # Layout within the collapsible button self.nodeselectFormLayout = qt.QFormLayout( self.nodeselectCollapsibleButton) # Search Box to filter regions to display self.searchLayout = qt.QHBoxLayout() self.nodeselectFormLayout.addRow('Search:', self.searchLayout) self.regionSearchBox = ctk.ctkSearchBox() self.regionSearchBox.placeholderText = "search region" self.regionSearchBox.searchIcon self.searchLayout.addWidget(self.regionSearchBox) self.logic = visuThreeDLogic() self.regionsLayout = qt.QHBoxLayout() self.nodeselectFormLayout.addRow('Regions:', self.regionsLayout) self.regionButtons = ctk.ctkCheckableComboBox() self.regionsLayout.addWidget(self.regionButtons) # Add buttons to select all or no region self.buttonsLayout = qt.QHBoxLayout() self.nodeselectFormLayout.addRow('Select:', self.buttonsLayout) self.calculateAllregionsButton = qt.QPushButton('Select All') self.calculateAllregionsButton.toolTip = 'Select all regions.' self.calculateAllregionsButton.enabled = True self.buttonsLayout.addWidget(self.calculateAllregionsButton) self.calculateAllFilteredregionsButton = qt.QPushButton( 'Select Filtered') self.calculateAllFilteredregionsButton.toolTip = 'Select all filtered regions.' self.calculateAllFilteredregionsButton.enabled = True self.buttonsLayout.addWidget(self.calculateAllFilteredregionsButton) self.deselectButtonsLayout = qt.QHBoxLayout() self.nodeselectFormLayout.addRow('Deselect:', self.deselectButtonsLayout) self.calculateNoregionsButton = qt.QPushButton('Deselect All') self.calculateNoregionsButton.toolTip = 'Deselect all regions.' self.calculateNoregionsButton.enabled = True self.deselectButtonsLayout.addWidget(self.calculateNoregionsButton) self.calculateNoFilteredregionsButton = qt.QPushButton( 'Deselect Filtered') self.calculateNoFilteredregionsButton.toolTip = 'Deselect all filtered regions.' self.calculateNoFilteredregionsButton.enabled = True self.deselectButtonsLayout.addWidget( self.calculateNoFilteredregionsButton) ################################### # Node Size and colorbar thresholding Area ################################### self.colorbarCollapsibleButton = ctk.ctkCollapsibleButton() self.colorbarCollapsibleButton.text = "Node Size and Color Thresholding" self.layout.addWidget(self.colorbarCollapsibleButton) # Layout within the collapsible button self.regioncheckFormLayout = qt.QFormLayout( self.colorbarCollapsibleButton) self.ColorTable = slicer.qMRMLColorTableComboBox() self.ColorTable.nodeTypes = ["vtkMRMLColorTableNode"] self.ColorTable.addEnabled = True self.ColorTable.removeEnabled = True self.ColorTable.noneEnabled = True self.ColorTable.showHidden = True self.ColorTable.setMRMLScene(slicer.mrmlScene) self.regioncheckFormLayout.addRow("Input Color Map: ", self.ColorTable) # # Threshold node value # # default values self.minVal = 0.0 self.maxVal = 1.0 self.nodeThresholdSliderWidget = ctk.ctkRangeWidget() self.nodeThresholdSliderWidget.singleStep = 0.01 self.nodeThresholdSliderWidget.setValues(self.minVal, self.maxVal) self.nodeThresholdSliderWidget.setMaximumValue(self.maxVal) self.nodeThresholdSliderWidget.setMinimumValue(self.minVal) self.nodeThresholdSliderWidget.setRange(self.minVal, self.maxVal) self.nodeThresholdSliderWidget.setMouseTracking(True) self.nodeThresholdSliderWidget.setEnabled(True) self.nodeThresholdSliderWidget.setToolTip( "Set threshold node value for computing the node value.") self.regioncheckFormLayout.addRow("Plot Property Range:", self.nodeThresholdSliderWidget) # # Node size min spinBox # # default value for min size (l: lowest , h: highest) self.minSize_l = 0.0 self.minSize_h = 100.0 self.nodeMinSizeSpinBox = qt.QDoubleSpinBox() self.nodeMinSizeSpinBox.singleStep = 0.01 self.nodeMinSizeSpinBox.setRange(self.minSize_l, self.minSize_h) self.nodeMinSizeSpinBox.setToolTip("Set minimum node size.") self.regioncheckFormLayout.addRow("Min Size:", self.nodeMinSizeSpinBox) # # Node size max spinBox # # default value for max size (l: lowest , h: highest) self.maxSize_l = 0.0 self.maxSize_h = 100.0 self.nodeMaxSizeSpinBox = qt.QDoubleSpinBox() self.nodeMaxSizeSpinBox.singleStep = 0.01 self.nodeMaxSizeSpinBox.setRange(self.maxSize_l, self.maxSize_h) self.nodeMaxSizeSpinBox.setToolTip("Set maximum node size.") self.regioncheckFormLayout.addRow("Max Size:", self.nodeMaxSizeSpinBox) ################################### # Connections line/tube Area ################################### self.lineCollapsibleButton = ctk.ctkCollapsibleButton() self.lineCollapsibleButton.text = "Connection Size and Color Thresholding" self.layout.addWidget(self.lineCollapsibleButton) # Layout within the collapsible button self.lineconnectFormLayout = qt.QFormLayout(self.lineCollapsibleButton) # # input connection matrix selector # self.matrixConnectSelector = slicer.qMRMLNodeComboBox() self.matrixConnectSelector.nodeTypes = ["vtkMRMLTableNode"] self.matrixConnectSelector.selectNodeUponCreation = True self.matrixConnectSelector.addEnabled = False self.matrixConnectSelector.removeEnabled = False self.matrixConnectSelector.noneEnabled = False self.matrixConnectSelector.showHidden = False self.matrixConnectSelector.showChildNodeTypes = False self.matrixConnectSelector.setMRMLScene(slicer.mrmlScene) self.matrixConnectSelector.setToolTip( "Pick the connection matrix input to the algorithm.") self.lineconnectFormLayout.addRow("Input Connection Table: ", self.matrixConnectSelector) # # Checkbox to choose whether or not the connection distribution follows a log scale or else a linear distribution # self.connectionDistCheckBox = qt.QCheckBox() self.connectionDistCheckBox.checked = 0 self.connectionDistCheckBox.setToolTip( "If checked, it means that the connection distribution follows a log scale." ) self.lineconnectFormLayout.addRow("Log Distribution", self.connectionDistCheckBox) self.connectionColorTable = slicer.qMRMLColorTableComboBox() self.connectionColorTable.nodeTypes = ["vtkMRMLColorTableNode"] self.connectionColorTable.addEnabled = True self.connectionColorTable.removeEnabled = True self.connectionColorTable.noneEnabled = True self.connectionColorTable.showHidden = True self.connectionColorTable.setMRMLScene(slicer.mrmlScene) self.lineconnectFormLayout.addRow("Input Color Map: ", self.connectionColorTable) # # Threshold node connection strength # # default values self.logic = visuThreeDLogic() self.min_strength = 0.0 self.max_strength = 1.0 self.connectionThresholdSliderWidget = ctk.ctkRangeWidget() self.connectionThresholdSliderWidget.singleStep = 0.01 self.connectionThresholdSliderWidget.setValues(self.min_strength, self.max_strength) self.connectionThresholdSliderWidget.setMaximumValue(self.max_strength) self.connectionThresholdSliderWidget.setMinimumValue(self.min_strength) self.connectionThresholdSliderWidget.setRange(self.minVal, self.max_strength) self.connectionThresholdSliderWidget.setMouseTracking(True) self.connectionThresholdSliderWidget.setEnabled(True) self.connectionThresholdSliderWidget.setToolTip( "Set threshold node value for computing the node value.") self.lineconnectFormLayout.addRow("Plot Strength Range:", self.connectionThresholdSliderWidget) # # Connection min strength spinBox # # default value for min strength (l: lowest , h: highest) self.minStrength_l = 0.0 self.minStrength_h = 50.0 self.minConnectionSpinBox = qt.QDoubleSpinBox() self.minConnectionSpinBox.singleStep = 0.01 self.minConnectionSpinBox.setRange(self.minStrength_l, self.minStrength_h) self.minConnectionSpinBox.setToolTip( "Set minimum connection strength.") self.lineconnectFormLayout.addRow("Min Strength:", self.minConnectionSpinBox) # # Node size max spinBox # # default value for max size (l: lowest , h: highest) self.maxStrength_l = 0.0 self.maxStrength_h = 100.0 self.maxConnectionSpinBox = qt.QDoubleSpinBox() self.maxConnectionSpinBox.singleStep = 0.01 self.maxConnectionSpinBox.setRange(self.maxStrength_l, self.maxStrength_h) self.maxConnectionSpinBox.setToolTip( "Set maximum connection strength.") self.lineconnectFormLayout.addRow("Max Strenght:", self.maxConnectionSpinBox) ################################### # Advanced Connections scale factors Area ################################### self.scaleCollapsibleButton = ctk.ctkCollapsibleButton() self.scaleCollapsibleButton.text = "Advanced Connection Scale Factors" self.layout.addWidget(self.scaleCollapsibleButton) # Layout within the collapsible button self.scaleconnectFormLayout = qt.QFormLayout( self.scaleCollapsibleButton) #Double SpinBox for default scale factor "f" : #computation of value in matrix by the number of connexions * f factor self.fscaleDoubleSpinBox = ctk.ctkDoubleSpinBox() self.fscaleDoubleSpinBox.setValue(0.000033) self.fscaleDoubleSpinBox.setDecimals(6) self.fscaleDoubleSpinBox.enabled = True self.scaleconnectFormLayout.addWidget(self.fscaleDoubleSpinBox) self.scaleconnectFormLayout.addRow("f Scale:", self.fscaleDoubleSpinBox) #Double SpinBox for log scale factor "C" : self.logScaleDoubleSpinBox = ctk.ctkDoubleSpinBox() self.logScaleDoubleSpinBox.setValue(10) self.logScaleDoubleSpinBox.setDecimals(0.) self.logScaleDoubleSpinBox.enabled = False self.scaleconnectFormLayout.addWidget(self.logScaleDoubleSpinBox) self.scaleconnectFormLayout.addRow("C Log Scale:", self.logScaleDoubleSpinBox) ################################### # Connections ################################### self.coord = [] self.index = [] self.position = [] self.visu = [] self.fileImportButton.connect('clicked(bool)', self.on_node_graph_json_load) self.inputSelector.connect("nodeActivated(vtkMRMLNode*)", self.on_select) self.regionButtons.connect('checkedIndexesChanged()', self.on_regions_checked) self.calculateAllFilteredregionsButton.connect( 'clicked(bool)', self.on_select_all_filtered_regionButtons) self.calculateAllregionsButton.connect( 'clicked(bool)', self.on_select_all_regionButtons) self.calculateNoregionsButton.connect( 'clicked(bool)', self.on_deselect_all_regionButtons) self.calculateNoFilteredregionsButton.connect( 'clicked(bool)', self.on_deselect_all_filtered_regionButtons) self.regionSearchBox.connect("textChanged(QString)", self.on_search) self.ColorTable.connect("currentNodeChanged(vtkMRMLNode*)", self.on_node_color_clicked) self.nodeThresholdSliderWidget.connect("valuesChanged(double, double)", self.sliderbar_changed) self.nodeMinSizeSpinBox.connect("valueChanged(double)", self.min_nodesize_changed) self.nodeMaxSizeSpinBox.connect("valueChanged(double)", self.max_nodesize_changed) self.tableStartSpinBox.connect("valueChanged(double)", self.table_start_changed) self.matrixConnectSelector.connect("nodeActivated(vtkMRMLNode*)", self.on_select_matrix) self.connectionThresholdSliderWidget.connect( "valuesChanged(double, double)", self.sliderbar2_changed) self.maxConnectionSpinBox.connect("valueChanged(double)", self.max_connection_changed) self.connectionColorTable.connect("currentNodeChanged(vtkMRMLNode*)", self.on_connect_color_clicked) self.fscaleDoubleSpinBox.connect("valueChanged(double)", self.on_fscale_changed) self.logScaleDoubleSpinBox.connect("valueChanged(double)", self.on_logscale_changed) # Add vertical spacer self.layout.addStretch(1) self.header = None self.connection_d = None self.value = 'None' self.on_node_graph_json_load()
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) # 3D view set up tab self.meshSelect = slicer.qMRMLNodeComboBox() self.meshSelect.nodeTypes = (("vtkMRMLModelNode"), "") self.meshSelect.selectNodeUponCreation = False self.meshSelect.addEnabled = False self.meshSelect.removeEnabled = False self.meshSelect.noneEnabled = True self.meshSelect.showHidden = False self.meshSelect.setMRMLScene(slicer.mrmlScene) self.meshSelect.connect("currentNodeChanged(vtkMRMLNode*)", self.onMeshSelect) parametersFormLayout.addRow("Model: ", self.meshSelect) self.meshSelect.setToolTip("Select model node for semilandmarking") self.LMSelect = slicer.qMRMLNodeComboBox() self.LMSelect.nodeTypes = (('vtkMRMLMarkupsFiducialNode'), "") self.LMSelect.selectNodeUponCreation = False self.LMSelect.addEnabled = False self.LMSelect.removeEnabled = False self.LMSelect.noneEnabled = True self.LMSelect.showHidden = False self.LMSelect.showChildNodeTypes = False self.LMSelect.setMRMLScene(slicer.mrmlScene) self.LMSelect.connect("currentNodeChanged(vtkMRMLNode*)", self.onLMSelect) parametersFormLayout.addRow("Landmark set: ", self.LMSelect) self.LMSelect.setToolTip( "Select the landmark set that corresponds to the model") # # input landmark numbers for grid # gridPointsLayout = qt.QGridLayout() self.landmarkGridPoint1 = ctk.ctkDoubleSpinBox() self.landmarkGridPoint1.minimum = 0 self.landmarkGridPoint1.singleStep = 1 self.landmarkGridPoint1.setDecimals(0) self.landmarkGridPoint1.setToolTip( "Input the landmark numbers to create grid") self.landmarkGridPoint2 = ctk.ctkDoubleSpinBox() self.landmarkGridPoint2.minimum = 0 self.landmarkGridPoint2.singleStep = 1 self.landmarkGridPoint2.setDecimals(0) self.landmarkGridPoint2.setToolTip( "Input the landmark numbers to create grid") self.landmarkGridPoint3 = ctk.ctkDoubleSpinBox() self.landmarkGridPoint3.minimum = 0 self.landmarkGridPoint3.singleStep = 1 self.landmarkGridPoint3.setDecimals(0) self.landmarkGridPoint3.setToolTip( "Input the landmark numbers to create grid") gridPointsLayout.addWidget(self.landmarkGridPoint1, 1, 2) gridPointsLayout.addWidget(self.landmarkGridPoint2, 1, 3) gridPointsLayout.addWidget(self.landmarkGridPoint3, 1, 4) parametersFormLayout.addRow("Semi-landmark grid points:", gridPointsLayout) # # set number of sample points in each triangle # self.gridSamplingRate = ctk.ctkDoubleSpinBox() self.gridSamplingRate.minimum = 3 self.gridSamplingRate.maximum = 50 self.gridSamplingRate.singleStep = 1 self.gridSamplingRate.setDecimals(0) self.gridSamplingRate.value = 10 self.gridSamplingRate.setToolTip( "Input the landmark numbers to create grid") parametersFormLayout.addRow( "Select number of rows/columns in resampled grid:", self.gridSamplingRate) # # check box to trigger taking screen shots for later use in tutorials # self.enableScreenshotsFlagCheckBox = qt.QCheckBox() self.enableScreenshotsFlagCheckBox.checked = 0 self.enableScreenshotsFlagCheckBox.setToolTip( "If checked, take screen shots for tutorials. Use Save Data to write them to disk." ) parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox) # # Advanced menu # advancedCollapsibleButton = ctk.ctkCollapsibleButton() advancedCollapsibleButton.text = "Advanced" advancedCollapsibleButton.collapsed = True parametersFormLayout.addRow(advancedCollapsibleButton) # Layout within the dummy collapsible button advancedFormLayout = qt.QFormLayout(advancedCollapsibleButton) # # Maximum projection slider # self.projectionDistanceSlider = ctk.ctkSliderWidget() self.projectionDistanceSlider.singleStep = 1 self.projectionDistanceSlider.minimum = 0 self.projectionDistanceSlider.maximum = 100 self.projectionDistanceSlider.value = 25 self.projectionDistanceSlider.setToolTip( "Set maximum projection distance as a percentage of image size") advancedFormLayout.addRow("Set maximum projection distance: ", self.projectionDistanceSlider) # # Normal smoothing slider # self.smoothingSlider = ctk.ctkSliderWidget() self.smoothingSlider.singleStep = 1 self.smoothingSlider.minimum = 0 self.smoothingSlider.maximum = 100 self.smoothingSlider.value = 0 self.smoothingSlider.setToolTip( "Set smothing of normal vectors for projection") advancedFormLayout.addRow("Set smoothing of projection vectors: ", self.smoothingSlider) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Generate semilandmarks." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # # Fiducials view # self.fiducialView = slicer.qMRMLSubjectHierarchyTreeView() self.fiducialView.setMRMLScene(slicer.mrmlScene) self.fiducialView.setMultiSelection(True) self.fiducialView.setAlternatingRowColors(True) self.fiducialView.setDragDropMode(True) self.fiducialView.setColumnHidden( self.fiducialView.model().transformColumn, True) self.fiducialView.sortFilterProxyModel().setNodeTypes( ["vtkMRMLMarkupsFiducialNode"]) parametersFormLayout.addRow(self.fiducialView) # # Apply Button # self.mergeButton = qt.QPushButton("Merge highlighted nodes") self.mergeButton.toolTip = "Generate a single merged landmark file from the selected nodes" self.mergeButton.enabled = False parametersFormLayout.addRow(self.mergeButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.mergeButton.connect('clicked(bool)', self.onMergeButton) self.fiducialView.connect('currentItemChanged(vtkIdType)', self.updateMergeButton) # Add vertical spacer self.layout.addStretch(1)
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 setupOptionsFrame(self): self.operationRadioButtons = [] self.updatingGUIFromMRML = False self.visibleIcon = qt.QIcon(":/Icons/Small/SlicerVisible.png") self.invisibleIcon = qt.QIcon(":/Icons/Small/SlicerInvisible.png") # Fill operation buttons self.fillInsideButton = qt.QRadioButton("Fill inside") self.operationRadioButtons.append(self.fillInsideButton) self.buttonToOperationNameMap[self.fillInsideButton] = 'FILL_INSIDE' self.fillOutsideButton = qt.QRadioButton("Fill outside") self.operationRadioButtons.append(self.fillOutsideButton) self.buttonToOperationNameMap[self.fillOutsideButton] = 'FILL_OUTSIDE' self.binaryMaskFillButton = qt.QRadioButton("Fill inside and outside") self.binaryMaskFillButton.setToolTip("Create a labelmap volume with specified inside and outside fill values.") self.operationRadioButtons.append(self.binaryMaskFillButton) self.buttonToOperationNameMap[self.binaryMaskFillButton] = 'FILL_INSIDE_AND_OUTSIDE' # Operation buttons layout operationLayout = qt.QGridLayout() operationLayout.addWidget(self.fillInsideButton, 0, 0) operationLayout.addWidget(self.fillOutsideButton, 1, 0) operationLayout.addWidget(self.binaryMaskFillButton, 0, 1) self.scriptedEffect.addLabeledOptionsWidget("Operation:", operationLayout) # fill value self.fillValueEdit = ctk.ctkDoubleSpinBox() self.fillValueEdit.setToolTip("Choose the voxel intensity that will be used to fill the masked region.") self.fillValueLabel = qt.QLabel("Fill value: ") # Binary mask fill outside value self.binaryMaskFillOutsideEdit = ctk.ctkDoubleSpinBox() self.binaryMaskFillOutsideEdit.setToolTip("Choose the voxel intensity that will be used to fill outside the mask.") self.fillOutsideLabel = qt.QLabel("Outside fill value: ") # Binary mask fill outside value self.binaryMaskFillInsideEdit = ctk.ctkDoubleSpinBox() self.binaryMaskFillInsideEdit.setToolTip("Choose the voxel intensity that will be used to fill inside the mask.") self.fillInsideLabel = qt.QLabel(" Inside fill value: ") for fillValueEdit in [self.fillValueEdit, self.binaryMaskFillOutsideEdit, self.binaryMaskFillInsideEdit]: fillValueEdit.decimalsOption = ctk.ctkDoubleSpinBox.DecimalsByValue + ctk.ctkDoubleSpinBox.DecimalsByKey + ctk.ctkDoubleSpinBox.InsertDecimals fillValueEdit.minimum = vtk.vtkDoubleArray().GetDataTypeMin(vtk.VTK_DOUBLE) fillValueEdit.maximum = vtk.vtkDoubleArray().GetDataTypeMax(vtk.VTK_DOUBLE) fillValueEdit.connect("valueChanged(double)", self.fillValueChanged) # Fill value layouts fillValueLayout = qt.QFormLayout() fillValueLayout.addRow(self.fillValueLabel, self.fillValueEdit) fillOutsideLayout = qt.QFormLayout() fillOutsideLayout.addRow(self.fillOutsideLabel, self.binaryMaskFillOutsideEdit) fillInsideLayout = qt.QFormLayout() fillInsideLayout.addRow(self.fillInsideLabel, self.binaryMaskFillInsideEdit) binaryMaskFillLayout = qt.QHBoxLayout() binaryMaskFillLayout.addLayout(fillOutsideLayout) binaryMaskFillLayout.addLayout(fillInsideLayout) fillValuesSpinBoxLayout = qt.QFormLayout() fillValuesSpinBoxLayout.addRow(binaryMaskFillLayout) fillValuesSpinBoxLayout.addRow(fillValueLayout) self.scriptedEffect.addOptionsWidget(fillValuesSpinBoxLayout) # input volume selector self.inputVolumeSelector = slicer.qMRMLNodeComboBox() self.inputVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.inputVolumeSelector.selectNodeUponCreation = True self.inputVolumeSelector.addEnabled = True self.inputVolumeSelector.removeEnabled = True self.inputVolumeSelector.noneEnabled = True self.inputVolumeSelector.noneDisplay = "(Source volume)" self.inputVolumeSelector.showHidden = False self.inputVolumeSelector.setMRMLScene(slicer.mrmlScene) self.inputVolumeSelector.setToolTip("Volume to mask. Default is current source volume node.") self.inputVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onInputVolumeChanged) self.inputVisibilityButton = qt.QToolButton() self.inputVisibilityButton.setIcon(self.invisibleIcon) self.inputVisibilityButton.connect('clicked()', self.onInputVisibilityButtonClicked) inputLayout = qt.QHBoxLayout() inputLayout.addWidget(self.inputVisibilityButton) inputLayout.addWidget(self.inputVolumeSelector) self.scriptedEffect.addLabeledOptionsWidget("Input Volume: ", inputLayout) # output volume selector self.outputVolumeSelector = slicer.qMRMLNodeComboBox() self.outputVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode", "vtkMRMLLabelMapVolumeNode"] self.outputVolumeSelector.selectNodeUponCreation = True self.outputVolumeSelector.addEnabled = True self.outputVolumeSelector.removeEnabled = True self.outputVolumeSelector.renameEnabled = True self.outputVolumeSelector.noneEnabled = True self.outputVolumeSelector.noneDisplay = "(Create new Volume)" self.outputVolumeSelector.showHidden = False self.outputVolumeSelector.setMRMLScene(slicer.mrmlScene) self.outputVolumeSelector.setToolTip("Masked output volume. It may be the same as the input volume for cumulative masking.") self.outputVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onOutputVolumeChanged) self.outputVisibilityButton = qt.QToolButton() self.outputVisibilityButton.setIcon(self.invisibleIcon) self.outputVisibilityButton.connect('clicked()', self.onOutputVisibilityButtonClicked) outputLayout = qt.QHBoxLayout() outputLayout.addWidget(self.outputVisibilityButton) outputLayout.addWidget(self.outputVolumeSelector) self.scriptedEffect.addLabeledOptionsWidget("Output Volume: ", outputLayout) # Apply button self.applyButton = qt.QPushButton("Apply") self.applyButton.objectName = self.__class__.__name__ + 'Apply' self.applyButton.setToolTip("Apply segment as volume mask. No undo operation available once applied.") self.scriptedEffect.addOptionsWidget(self.applyButton) self.applyButton.connect('clicked()', self.onApply) for button in self.operationRadioButtons: button.connect('toggled(bool)', lambda toggle, widget=self.buttonToOperationNameMap[button]: self.onOperationSelectionChanged(widget, toggle))
def setup(self): ScriptedLoadableModuleWidget.setup(self) ################################################################### ## ## ## Collapsible part for input/output parameters for Groups CLI ## ## ## ################################################################### self.ioCollapsibleButton = ctk.ctkCollapsibleButton() self.ioCollapsibleButton.text = "IO" self.layout.addWidget(self.ioCollapsibleButton) self.ioQVBox = qt.QVBoxLayout(self.ioCollapsibleButton) # --------------------------------- # # ----- Group Box DIRECTORIES ----- # # --------------------------------- # self.directoryGroupBox = qt.QGroupBox("Groups Dircetories") self.ioQVBox.addWidget(self.directoryGroupBox) self.ioQFormLayout = qt.QFormLayout(self.directoryGroupBox) # Selection of the directory containing the input models (option: --surfaceDir) and option procalign shape self.inputMeshTypeHBox = qt.QVBoxLayout(self.directoryGroupBox) self.inputModelsDirectorySelector = ctk.ctkDirectoryButton() self.inputMeshTypeHBox.addWidget(self.inputModelsDirectorySelector) self.ioQFormLayout.addRow(qt.QLabel("Input Models Directory:"), self.inputMeshTypeHBox) # Selection of the directory which contains each spherical model (option: --sphereDir) self.sphericalModelsDirectorySelector = ctk.ctkDirectoryButton() self.ioQFormLayout.addRow("Spherical Models Directory:", self.sphericalModelsDirectorySelector) # Selection of the output directory for Groups (option: --outputDir) self.outputDirectorySelector = ctk.ctkDirectoryButton() self.ioQFormLayout.addRow(qt.QLabel("Output Directory:"), self.outputDirectorySelector) # CheckBox. If checked, Group Box 'Parameters' will be enabled self.enableRigidAlignmentCB = ctk.ctkCheckBox() self.enableRigidAlignmentCB.setText("Perform Rigid Alignment") self.ioQFormLayout.addRow(self.enableRigidAlignmentCB) # CheckBox. If checked, Group Box 'Parameters' will be enabled self.enableParamCB = ctk.ctkCheckBox() self.enableParamCB.setText("Personalize Groups parameters") self.ioQFormLayout.addRow(self.enableParamCB) # Connections self.inputModelsDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect) self.sphericalModelsDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect) self.outputDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect) self.enableRigidAlignmentCB.connect("stateChanged(int)", self.onCheckBoxRigidAlignment) self.enableParamCB.connect("stateChanged(int)", self.onCheckBoxParam) # Name simplification (string) self.modelsDirectory = str(self.inputModelsDirectorySelector.directory) self.sphericalmodelsDirectory = str(self.sphericalModelsDirectorySelector.directory) self.outputDirectory = str(self.outputDirectorySelector.directory) # ------------------------------------------ # # ----- RigidAlignment Box DIRECTORIES ----- # # ------------------------------------------ # self.rigidalignmentdirectoryGroupBox = qt.QGroupBox("Rigid Alignment Directories") self.ioQVBox.addWidget(self.rigidalignmentdirectoryGroupBox) self.ioQFormLayout = qt.QFormLayout(self.rigidalignmentdirectoryGroupBox) self.rigidalignmentdirectoryGroupBox.setEnabled(False) # Selection of the directory which contains each landmark fcsv file (option: --landmark) self.inputlandmarksfiducialfilesDirectorySelector = ctk.ctkDirectoryButton() self.ioQFormLayout.addRow("Input Landmarks Fiducial Files Directory:", self.inputlandmarksfiducialfilesDirectorySelector) # Selection of the directory which contains common unit sphere file (option: --sphere) self.inputunitspherefileDirectorySelector = ctk.ctkDirectoryButton() self.ioQFormLayout.addRow("Input Unit Sphere File Directory:", self.inputunitspherefileDirectorySelector) # Connections self.inputlandmarksfiducialfilesDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect) self.inputunitspherefileDirectorySelector.connect("directoryChanged(const QString &)", self.onSelect) # Name simplification (string) self.landmarksDirectory = str(self.inputlandmarksfiducialfilesDirectorySelector.directory) self.sphereDirectory = str(self.inputunitspherefileDirectorySelector.directory) # -------------------------------- # # ----- Group Box PARAMETERS ----- # # -------------------------------- # self.parametersGroupBox = qt.QGroupBox("Groups Parameters") self.ioQVBox.addWidget(self.parametersGroupBox) self.paramQFormLayout = qt.QFormLayout(self.parametersGroupBox) self.parametersGroupBox.setEnabled(False) # Selection of the property we want to use self.specifyPropertySelector = ctk.ctkCheckableComboBox() self.specifyPropertySelector.addItems(("Curvedness","Shape_Index")) self.paramQFormLayout.addRow(qt.QLabel("Properties name to use:"), self.specifyPropertySelector) # Weights of each property - Choices on 1 lines self.weightLayout = qt.QVBoxLayout(self.parametersGroupBox) self.weightline1 = qt.QHBoxLayout(self.parametersGroupBox) # Line 1 self.weightLayout.addLayout(self.weightline1) # Fill out first line self.labelCurvedness = qt.QLabel("Curvedness") self.weightline1.addWidget(self.labelCurvedness) self.weightCurvedness = ctk.ctkDoubleSpinBox() self.weightCurvedness.enabled = False self.weightCurvedness.value = 1 self.weightline1.addWidget(self.weightCurvedness) self.labelShape_Index = qt.QLabel(" Shape_Index") self.weightline1.addWidget(self.labelShape_Index) self.weightShape_Index = ctk.ctkDoubleSpinBox() self.weightShape_Index.enabled = False self.weightShape_Index.value = 1 self.weightline1.addWidget(self.weightShape_Index) self.paramQFormLayout.addRow("Weight of each property:", self.weightLayout) # CheckBox. If checked, Landmarks enabled self.enableLandmarks = ctk.ctkCheckBox() self.enableLandmarks.setText("Enable Landmarks") self.paramQFormLayout.addRow(self.enableLandmarks) # Specification of the SPHARM decomposition degree (option: -d) self.degreeSpharm = ctk.ctkSliderWidget() self.degreeSpharm.minimum = 0 self.degreeSpharm.maximum = 50 self.degreeSpharm.value = 5 # initial value self.degreeSpharm.setDecimals(0) self.paramQFormLayout.addRow(qt.QLabel("Degree of SPHARM decomposition:"), self.degreeSpharm) # Maximum iteration (option: --maxIter) self.maxIter = qt.QSpinBox() self.maxIter.minimum = 0 # Check the range authorized self.maxIter.maximum = 100000 self.maxIter.value = 5000 self.paramQFormLayout.addRow("Maximum number of iteration:", self.maxIter) # Name simplification self.property = "" self.propertyValue = "" # Connections self.specifyPropertySelector.connect("checkedIndexesChanged()", self.onSpecifyPropertyChanged) # ------------------------------------------ # # ----- Apply button to launch the CLI ----- # # ------------------------------------------ # self.applyButton = qt.QPushButton("Apply") self.applyButton.enabled = False self.ioQVBox.addWidget(self.applyButton) self.errorLabel = qt.QLabel("Error: Invalide inputs") self.errorLabel.hide() self.errorLabel.setStyleSheet("color: rgb(255, 0, 0);") self.ioQVBox.addWidget(self.errorLabel) # Connections self.applyButton.connect('clicked(bool)', self.onApplyButtonClicked) # ----- Add vertical spacer ----- # self.layout.addStretch(1)
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 create(self): super().create() self.toleranceFrame = qt.QFrame(self.frame) self.toleranceFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.toleranceFrame) self.widgets.append(self.toleranceFrame) self.toleranceLabel = qt.QLabel("Tolerance:", self.toleranceFrame) self.toleranceLabel.setToolTip( "Set the tolerance of the wand in terms of background pixel values" ) self.toleranceFrame.layout().addWidget(self.toleranceLabel) self.widgets.append(self.toleranceLabel) self.toleranceSpinBox = ctk.ctkDoubleSpinBox(self.toleranceFrame) self.toleranceSpinBox.setToolTip( "Set the tolerance of the wand in terms of background pixel values" ) self.toleranceSpinBox.minimum = 0 self.toleranceSpinBox.maximum = 1000 self.toleranceSpinBox.suffix = "" self.toleranceFrame.layout().addWidget(self.toleranceSpinBox) self.widgets.append(self.toleranceSpinBox) self.maxPixelsFrame = qt.QFrame(self.frame) self.maxPixelsFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.maxPixelsFrame) self.widgets.append(self.maxPixelsFrame) self.maxPixelsLabel = qt.QLabel("Max Pixels per click:", self.maxPixelsFrame) self.maxPixelsLabel.setToolTip("Set the maxPixels for each click") self.maxPixelsFrame.layout().addWidget(self.maxPixelsLabel) self.widgets.append(self.maxPixelsLabel) self.maxPixelsSpinBox = ctk.ctkDoubleSpinBox(self.maxPixelsFrame) self.maxPixelsSpinBox.setToolTip("Set the maxPixels for each click") self.maxPixelsSpinBox.minimum = 1 self.maxPixelsSpinBox.maximum = 100000 self.maxPixelsSpinBox.suffix = "" self.maxPixelsFrame.layout().addWidget(self.maxPixelsSpinBox) self.widgets.append(self.maxPixelsSpinBox) self.fillModeFrame = qt.QFrame(self.frame) self.fillModeFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.fillModeFrame) self.widgets.append(self.fillModeFrame) self.fillModeCheckBox = qt.QCheckBox(self.fillModeFrame) self.fillModeCheckBox.text = "Fill Volume" self.fillModeCheckBox.setToolTip( "Fill in 3D when checked, else fill plane") self.fillModeFrame.layout().addWidget(self.fillModeCheckBox) self.widgets.append(self.fillModeCheckBox) HelpButton( self.frame, "Use this tool to label all voxels that are within a tolerance of where you click" ) # don't connect the signals and slots directly - instead, add these # to the list of connections so that gui callbacks can be cleanly # disabled while the gui is being updated. This allows several gui # elements to be interlinked with signal/slots but still get updated # as a unit to the new value of the mrml node. self.connections.append((self.toleranceSpinBox, 'valueChanged(double)', self.onToleranceSpinBoxChanged)) self.connections.append((self.maxPixelsSpinBox, 'valueChanged(double)', self.onMaxPixelsSpinBoxChanged)) self.connections.append( (self.fillModeCheckBox, 'clicked()', self.onFillModeClicked)) # Add vertical spacer self.frame.layout().addStretch(1)