def setup(self): """ Setup all UI elements and prepare data """ # TODO: following line is only for the purpose of testing self._loadedVolumeNodes = OrderedDict({volume.GetID: volume for volume in slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')}) ScriptedLoadableModuleWidget.setup(self) self._setupPatientWatchBox() self._setupViewSettingGroupBox() self._setupCollapsibleLayoutButton() self._patientAssessmentWidget = AssessmentWidget(forms=self.getSetting("Patient_Assessment_Forms"), title="Patient Level Assessment") self._studyAssessmentWidget = AssessmentWidget(forms=self.getSetting("Study_Assessment_Forms"), title="Study Level Assessment") self._prostateMeasurementsWidget = ProstateWidget() self._findingsWidget = FindingsWidget(maximumNumber=4) self._exportToHTMLButton = UICreationHelpers.createButton("Export to HTML") self.layout.addWidget(self._collapsibleLayoutButton) self._setupCollapsibleMultiVolumeExplorerButton() self.layout.addWidget(self._collapsibleMultiVolumeButton) self.layout.addWidget(self._patientAssessmentWidget) self.layout.addWidget(self._studyAssessmentWidget) self.layout.addWidget(self._prostateMeasurementsWidget) self.layout.addWidget(self._findingsWidget) self.layout.addWidget(self._exportToHTMLButton) self._stepButtonGroup = qt.QButtonGroup() self._stepButtonGroup.addButton(self._patientAssessmentWidget, 1) self._stepButtonGroup.addButton(self._studyAssessmentWidget, 2) self._stepButtonGroup.addButton(self._prostateMeasurementsWidget, 3) self._stepButtonGroup.addButton(self._findingsWidget, 4) self.layout.addStretch(1) self._setupConnections() self.updateGUIFromData()
def __init__(self, parent=None): """ Called when the user opens the module the first time and the widget is initialized. """ ScriptedLoadableModuleWidget.__init__(self, parent) self.logic = None self.subjects = None
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = EPISURGBrowserLogic() self.makeGUI() slicer.episurgBrowser = self self.addObserver(slicer.mrmlScene, slicer.mrmlScene.StartCloseEvent, self.onSceneStartClose)
def __init__(self, parent=None): ScriptedLoadableModuleWidget.__init__(self, parent) VolumeSeriesTypeSceneObserver().refresh() # is a singleton and observes the mrmlScene self.modulePath = os.path.dirname(slicer.util.modulePath(self.moduleName)) SlicerPIRADSConfiguration(self.moduleName, os.path.join(self.modulePath, 'Resources', "default.cfg")) self._loadedVolumeNodes = OrderedDict() self.logic = SlicerPIRADSModuleLogic()
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.testsCollapsibleButton = ctk.ctkCollapsibleButton() self.testsCollapsibleButton.setLayout(qt.QFormLayout()) self.testsCollapsibleButton.text = "Slicer Layout Buttons Tests" self.layout.addWidget(self.testsCollapsibleButton) self.generateButtons()
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.testsCollapsibleButton = ctk.ctkCollapsibleButton() self.testsCollapsibleButton.setLayout(qt.QFormLayout()) self.testsCollapsibleButton.text = "Quantitative Reporting Tests" self.layout.addWidget(self.testsCollapsibleButton) self.generateButtons()
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = ResectorLogic() self.makeGUI() self.onVolumeSelectorModified() slicer.torchio = self import SampleData SampleData.downloadSample('MRHead')
def __init__(self, parent): ScriptedLoadableModuleWidget.__init__(self, parent) global OPENCV2_AVAILABLE try: global cv2 import cv2 OPENCV2_AVAILABLE = True except ImportError: OPENCV2_AVAILABLE = False if not OPENCV2_AVAILABLE: logging.error("OpenCV2 python interface not available.") return self.logic = PinholeCameraRayIntersectionLogic() self.markupsLogic = slicer.modules.markups.logic() self.canSelectFiducials = False self.isManualCapturing = False self.validPinholeCamera = False self.centerFiducialSelectionNode = None self.copyNode = None self.widget = None self.videoCameraIntrinWidget = None self.videoCameraSelector = None self.videoCameraNode = None self.markupsNode = None # Observer tags self.videoCameraObserverTag = None self.videoCameraTransformObserverTag = None self.pointModifiedObserverTag = None self.videoCameraTransformNode = None self.videoCameraTransformStatusLabel = None self.okPixmap = PinholeCameraRayIntersectionWidget.loadPixmap( 'icon_Ok', 20, 20) self.notOkPixmap = PinholeCameraRayIntersectionWidget.loadPixmap( 'icon_NotOk', 20, 20) # Inputs/Outputs self.imageSelector = None self.videoCameraTransformSelector = None # Actions self.captureButton = None self.resetButton = None self.actionContainer = None # Results self.resultsLabel = None self.videoCameraToReference = None self.identity3x3 = vtk.vtkMatrix3x3() self.identity4x4 = vtk.vtkMatrix4x4()
def __init__(self, parent=None): """ Called when the user opens the module the first time and the widget is initialized. """ ScriptedLoadableModuleWidget.__init__(self, parent) VTKObservationMixin.__init__( self) # needed for parameter node observation self.logic = None self.subjects = None
def __init__(self, parent): ScriptedLoadableModuleWidget.__init__(self, parent) slicer.mrmlScene.Clear() self.logic = ResynthLogic() self.logic.installLibraries() self.modelNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelNode') self.modelNode.CreateDefaultDisplayNodes() self.loadBrainMesh() self.makeGUI() slicer.resynth = self
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = TorchIOTransformsLogic() if not self.logic.checkTorchIO(): return self.transforms = [] self.currentTransform = None self.makeGUI() self.onVolumeSelectorModified() slicer.torchio = self self.backgroundNode = None
def setup(self): ScriptedLoadableModuleWidget.setup(self) if not OPENCV2_AVAILABLE: self.layout.addWidget( qt.QLabel( "OpenCV2 python is required and not available. Check installation/configuration of SlicerOpenCV." )) else: # Load the UI From file scriptedModulesPath = eval('slicer.modules.%s.path' % self.moduleName.lower()) scriptedModulesPath = os.path.dirname(scriptedModulesPath) path = os.path.join(scriptedModulesPath, 'Resources', 'UI', 'q' + self.moduleName + 'Widget.ui') self.widget = slicer.util.loadUI(path) self.layout.addWidget(self.widget) # Camera UI layout = PinholeCameraRayIntersectionWidget.get( self.widget, "gridLayout") placeholder = PinholeCameraRayIntersectionWidget.get( self.widget, "placeholder") layout.removeWidget(placeholder) self.videoCameraIntrinWidget = slicer.qMRMLPinholeCameraIntrinsicsWidget( ) self.videoCameraIntrinWidget.setMRMLScene(slicer.mrmlScene) layout.addWidget(self.videoCameraIntrinWidget, 0, 0) # Workaround for videoCamera selector self.videoCameraSelector = self.videoCameraIntrinWidget.children( )[1].children()[1] # Inputs/Outputs self.imageSelector = PinholeCameraRayIntersectionWidget.get( self.widget, "comboBox_ImageSelector") self.videoCameraTransformSelector = PinholeCameraRayIntersectionWidget.get( self.widget, "comboBox_PinholeCameraTransform") self.actionContainer = PinholeCameraRayIntersectionWidget.get( self.widget, "widget_ActionContainer") self.captureButton = PinholeCameraRayIntersectionWidget.get( self.widget, "pushButton_Capture") self.resetButton = PinholeCameraRayIntersectionWidget.get( self.widget, "pushButton_Reset") self.actionContainer = PinholeCameraRayIntersectionWidget.get( self.widget, "widget_ActionContainer") self.resultsLabel = PinholeCameraRayIntersectionWidget.get( self.widget, "label_Results") self.videoCameraTransformStatusLabel = PinholeCameraRayIntersectionWidget.get( self.widget, "label_PinholeCameraTransform_Status") # Disable capture as image processing isn't active yet self.actionContainer.setEnabled(False) # UI file method does not do mrml scene connections, do them manually self.videoCameraIntrinWidget.setMRMLScene(slicer.mrmlScene) self.imageSelector.setMRMLScene(slicer.mrmlScene) self.videoCameraTransformSelector.setMRMLScene(slicer.mrmlScene) # Connections self.videoCameraSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onPinholeCameraSelected) self.imageSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onImageSelected) self.videoCameraTransformSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onPinholeCameraTransformSelected) self.captureButton.connect('clicked(bool)', self.onCapture) self.resetButton.connect('clicked(bool)', self.onReset) # Choose red slice only lm = slicer.app.layoutManager() lm.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView) # Refresh Apply button state self.onSelect()
def __init__(self, parent=None): ScriptedLoadableModuleWidget.__init__(self, parent)
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.tutorials = { "ShapeAnalysisModule": "https://bit.ly/2Fyn97v", # SPHARM-PDM Generator "GroupWiseRegistrationModule": "https://bit.ly/2WsFiun", "RegressionComputation": "https://bit.ly/2uVYche", "ShapeVariationAnalyzer": "https://bit.ly/2HYbHVA", # Population Analysis "SRep": "https://bit.ly/3sTEG3H", "SRepCreator": "https://bit.ly/3sTEG3H", "SRepRefinement": "https://bit.ly/3sTEG3H", } # The anchor associated with each link corresponds to the name of the module to select. # For example, after the user click on the link associated with `href="#DataImporter"`, # the "DataImporter" module is selected. text = """ <br> <u>Workflow quick-reference:</u><br> <br> The drop-down Modules are ordered to follow the basic workflow for choosing and using data. As a quick reference, the basic steps involve:<br> <br> 1. Use the <a href="#DataImporter"><b>Data importer</b></a> module to load your segmentations from FreeSurf, FSL, Autoseg, or a bunch of vtp's<br><br> 2. Use <a href="#ShapePopulationViewer"><b>Shape Population Viewer</b></a> to do a quality check on the imported data<br><br> 3. Use <a href="#ShapeAnalysisModule"><b>SPHARM-PDM Generator</b></a> to do spherical harmonics based analysis<br><br> 4. Use the <a href="#GroupWiseRegistrationModule"><b>Study-specific Shape Analysis</b></a> module.<br><br> 5. Use the <a href="#SkeletalRepresentationVisualizer"><b>S-Rep Shape Analysis</b></a> module to do shape analysis via skeletal representations.<br><br> 6. Use the <a href="#ShapeVariationAnalyzer"><b>Shape Evaluator</b></a> module to compute a mean shape and see how the population varies.<br><br> 7. Use <a href="#RegressionComputation"><b>Shape Regressions</b></a> module to do regression based analysis.<br><br> 8. Use the <a href="#MFSDA"><b>Shape Statistics</b></a> module.<br><br> """ # TEXTEDIT self.HomeTextSection = qt.QTextBrowser() self.HomeTextSection.setHtml(text) self.HomeTextSection.setMinimumHeight(400) self.HomeTextSection.connect('anchorClicked(QUrl)', self.onAnchorClicked) self.layout.addWidget(self.HomeTextSection) # SPACER self.layout.addStretch() # SAMPLE DATA REGISTRATION for json_file in [ 'DataImporterInputData.json', 'MFSDAInputData.json', 'ShapeRegressionInputData.json', 'SPHARM-PDMTestData.json', 'SPHARM-PDMFiducials.json', 'SRepCreatorData.json', 'SVAInputData.json' ]: with open( self.resourcePath('SampleDataDescription/%s' % json_file), 'r') as json_data: source_data = json.load(json_data) if 'iconPath' in source_data: iconPath = self.resourcePath(source_data['iconPath']) else: iconPath = None SampleDataLogic.registerCustomSampleDataSource( category=source_data['category'], sampleName=source_data['sampleName'], uris=source_data['uris'], checksums=source_data.get('checksums', None), fileNames=source_data['fileNames'], nodeNames=None, thumbnailFileName=iconPath, loadFileType=None, customDownloader=self.downloadSampleDataInFolder, ) # HIDE SAMPLE DATA 'BUILTIN' CATEGORY slicer.modules.sampledata.widgetRepresentation().self( ).setCategoryVisible('BuiltIn', False) self.sampleDataModuleTab = None self.sampleDataTabTextEdit = None self.moduleNameToSampleDataCategory = { "DataImporter": "Data Importer", "MFSDA": "Covariate Significance Testing", "ShapeAnalysisModule": "SPHARM-PDM", "RegressionComputation": "Shape Regression", "ShapeVariationAnalyzer": "Population Analysis", "SRepCreator": "Skeletal Representation Creator" } self.sampleDataModuleTab = self.addSampleDataTab() self.updateSampleDataTab("Home") moduleMenu = slicer.util.mainWindow().moduleSelector().modulesMenu() moduleMenu.connect("currentModuleChanged(QString)", self.updateSampleDataTab)
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = EPISURGSegmentLogic() self.makeGUI() slicer.episurgSegment = self
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.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) # # input mesh selector # self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = ["vtkMRMLModelNode"] 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 input model to use as mesh.") parametersFormLayout.addRow("Input Model: ", self.inputSelector) # # Create Problem Button # self.createProblemButton = qt.QPushButton("Create Problem") self.createProblemButton.toolTip = "Create a new FEniCS problem from the selected model." self.createProblemButton.enabled = True parametersFormLayout.addRow(self.createProblemButton) # # displacement value # self.displacementSliderWidget = ctk.ctkSliderWidget() self.displacementSliderWidget.singleStep = 0.1 self.displacementSliderWidget.minimum = -1.0 self.displacementSliderWidget.maximum = 4.0 self.displacementSliderWidget.value = 0.0 self.displacementSliderWidget.setToolTip("Set displacement.") parametersFormLayout.addRow("Displacement", self.displacementSliderWidget) # # rotation angle value # self.rotationAngleSliderWidget = ctk.ctkSliderWidget() self.rotationAngleSliderWidget.singleStep = 1 self.rotationAngleSliderWidget.minimum = -90 self.rotationAngleSliderWidget.maximum = 90 self.rotationAngleSliderWidget.value = 0.0 self.rotationAngleSliderWidget.setToolTip("Set rotation angle.") parametersFormLayout.addRow("Rotation (degrees)", self.rotationAngleSliderWidget) # # body force value # self.bodyForceSliderWidget = ctk.ctkSliderWidget() self.bodyForceSliderWidget.singleStep = 0.1 self.bodyForceSliderWidget.minimum = -10 self.bodyForceSliderWidget.maximum = 10 self.bodyForceSliderWidget.value = 0.0 self.bodyForceSliderWidget.setToolTip("Set body force value.") parametersFormLayout.addRow("Body Force", self.bodyForceSliderWidget) # # traction force value # self.tractionForceSliderWidget = ctk.ctkSliderWidget() self.tractionForceSliderWidget.singleStep = 0.1 self.tractionForceSliderWidget.minimum = -2 self.tractionForceSliderWidget.maximum = 2 self.tractionForceSliderWidget.value = 0.0 self.tractionForceSliderWidget.setToolTip("Set traction force value.") parametersFormLayout.addRow("Traction Force", self.tractionForceSliderWidget) # # Defaults Button # self.defaultsButton = qt.QPushButton("Default parameters") self.defaultsButton.toolTip = "Set default parameters." self.defaultsButton.enabled = True parametersFormLayout.addRow(self.defaultsButton) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # # Squash and Stretch Buttons # self.squashButton = qt.QPushButton("Squash") self.squashButton.toolTip = "Squash" self.squashButton.enabled = False self.stretchButton = qt.QPushButton("Stretch") self.stretchButton.toolTip = "Stretch" self.stretchButton.enabled = False rowLayout = qt.QHBoxLayout() rowLayout.addWidget(self.squashButton) rowLayout.addWidget(self.stretchButton) parametersFormLayout.addRow(rowLayout) # # Rotate Buttons # self.rotateLeftButton = qt.QPushButton("Rotate Left") self.rotateLeftButton.toolTip = "Rotate left." self.rotateLeftButton.enabled = False self.rotateRightButton = qt.QPushButton("Rotate Right") self.rotateRightButton.toolTip = "Rotate right." self.rotateRightButton.enabled = False rowLayout = qt.QHBoxLayout() rowLayout.addWidget(self.rotateLeftButton) rowLayout.addWidget(self.rotateRightButton) parametersFormLayout.addRow(rowLayout) # # Reset Button # self.resetButton = qt.QPushButton("Reset") self.resetButton.toolTip = "Reset the model." self.resetButton.enabled = False parametersFormLayout.addRow(self.resetButton) # connections self.createProblemButton.connect('clicked(bool)', self.onCreateProblemButton) self.applyButton.connect('clicked(bool)', self.onApplyButton) self.defaultsButton.connect('clicked(bool)', self.onDefaultsButton) self.inputSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onSelect) self.squashButton.connect('clicked(bool)', self.onSquashButton) self.stretchButton.connect('clicked(bool)', self.onStretchButton) self.rotateLeftButton.connect('clicked(bool)', self.onRotateLeftButton) self.rotateRightButton.connect('clicked(bool)', self.onRotateRightButton) self.resetButton.connect('clicked(bool)', self.onResetButton) # Add vertical spacer self.layout.addStretch(1) self.onSelect()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # Input file # Text + Button invoking QFileDialog self.inputFileLayout = qt.QHBoxLayout() self.inputFileLabelHeader = qt.QLabel() self.inputFileLabelHeader.text = "Input File: " self.inputFileLabelFile = qt.QLabel() self.inputFileLabelFile.text = "Input header.xml or .m3d" self.inputFileButton = qt.QPushButton() self.inputFileButton.text = "Browse" self.inputFileLayout.addWidget(self.inputFileLabelHeader) self.inputFileLayout.addWidget(self.inputFileLabelFile) self.inputFileLayout.addWidget(self.inputFileButton) self.layout.addLayout(self.inputFileLayout) # # Parameters Area # self.parametersCollapsibleButton = ctk.ctkCollapsibleButton() self.parametersCollapsibleButton.collapsed = True self.parametersCollapsibleButton.text = "Parameters for legacy m3d format" self.layout.addWidget(self.parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(self.parametersCollapsibleButton) # set distance of fold curve from interior points self.distSlider = slicer.qMRMLSliderWidget() self.distSlider.setProperty('maximum', 0.6) self.distSlider.setProperty('minimum', 0.0) self.distSlider.setProperty('singleStep', 0.01) self.distSlider.setToolTip( "Parameter used in transformation from legacy s-rep to new s-rep") parametersFormLayout.addRow("Set distance to expand fold curve", self.distSlider) self.outputFolderLayout = qt.QHBoxLayout() self.outputFolderLabelHeader = qt.QLabel() self.outputFolderLabelHeader.text = "Output folder: " self.outputFolderLabelFile = qt.QLabel() self.outputFolderLabelFile.text = "Folder to save the new xml format" self.outputFolderButton = qt.QPushButton() self.outputFolderButton.text = "Browse" self.outputFolderLayout.addWidget(self.outputFolderLabelHeader) self.outputFolderLayout.addWidget(self.outputFolderLabelFile) self.outputFolderLayout.addWidget(self.outputFolderButton) parametersFormLayout.addRow(self.outputFolderLayout) # # Apply Button # self.applyButton = qt.QPushButton("Visualize s-rep file") self.applyButton.toolTip = "Parse and visualize s-rep." self.layout.addWidget(self.applyButton) # Unused # self.boundarySurfaceRendering = qt.QCheckBox() # self.boundarySurfaceRendering.checked = 0 # self.boundarySurfaceRendering.setToolTip("If checked, set the visibility of the boundary mesh") # self.layout.addWidget(self.boundarySurfaceRendering) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.inputFileButton.connect('clicked(bool)', self.onInputFileButtonClicked) self.outputFolderButton.connect('clicked(bool)', self.onOutputFolderButtonClicked) # Add vertical spacer self.layout.addStretch(1)
def setup(self): ScriptedLoadableModuleWidget.setup(self)