Пример #1
0
    def updateLandmarkArray(self):
        """Rebuild the list of buttons based on current landmarks"""
        # reset the widget
        if self.landmarkGroupBox:
            self.landmarkGroupBox.setParent(None)
        self.landmarkGroupBox = qt.QGroupBox("Landmarks")
        self.landmarkGroupBox.setLayout(qt.QFormLayout())
        # add the action buttons at the top
        actionButtons = qt.QHBoxLayout()
        # add button - http://www.clipartbest.com/clipart-jTxpEM8Bc
        self.addButton = qt.QPushButton("Add")
        self.addButton.setIcon(
            qt.QIcon(
                os.path.join(
                    os.path.dirname(slicer.modules.landmarkregistration.path),
                    'Resources/Icons/', "icon_Add.png")))
        self.addButton.connect('clicked()', self.addLandmark)
        actionButtons.addWidget(self.addButton)
        self.renameButton = qt.QPushButton("Rename")
        self.renameButton.connect('clicked()', self.renameLandmark)
        self.renameButton.enabled = False
        actionButtons.addWidget(self.renameButton)
        self.landmarkGroupBox.layout().addRow(actionButtons)

        # for now, hide
        self.renameButton.hide()

        # make a button for each current landmark
        self.labels = {}
        landmarks = self.logic.landmarksForVolumes(self.volumeNodes)
        keys = sorted(landmarks.keys())
        for landmarkName in keys:
            row = qt.QWidget()
            rowLayout = qt.QHBoxLayout()
            rowLayout.setMargin(0)

            label = qt.QLabel(landmarkName)
            rowLayout.addWidget(label, 8)

            # active button - https://thenounproject.com/term/crosshair/4434/
            activeButton = qt.QPushButton()
            activeButton.setIcon(
                qt.QIcon(
                    os.path.join(
                        os.path.dirname(
                            slicer.modules.landmarkregistration.path),
                        'Resources/Icons/', "icon_Active.png")))
            activeButton.connect('clicked()',
                                 lambda l=landmarkName: self.pickLandmark(l))
            rowLayout.addWidget(activeButton, 1)

            if landmarkName == self.selectedLandmark:
                label.setStyleSheet("QWidget{font-weight: bold;}")
                activeButton.setEnabled(False)

            # remove button - http://findicons.com/icon/158288/trash_recyclebin_empty_closed_w
            removeButton = qt.QPushButton()
            removeButton.setIcon(
                qt.QIcon(
                    os.path.join(
                        os.path.dirname(
                            slicer.modules.landmarkregistration.path),
                        'Resources/Icons/', "icon_Trash.png")))
            removeButton.connect('clicked()',
                                 lambda l=landmarkName: self.removeLandmark(l))
            rowLayout.addWidget(removeButton, 1)

            row.setLayout(rowLayout)

            self.landmarkGroupBox.layout().addRow(row)
            self.labels[landmarkName] = [label, activeButton]
        self.landmarkArrayHolder.layout().addWidget(self.landmarkGroupBox)

        # observe manipulation of the landmarks
        self.addLandmarkObservers()
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

    #
    # Parameters Area
    #
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Parameters"
    self.layout.addWidget(parametersCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

    #
    # input volume selector
    #
    self.inputSelector = slicer.qMRMLNodeComboBox()
    self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputSelector.selectNodeUponCreation = True
    self.inputSelector.addEnabled = False
    self.inputSelector.removeEnabled = False
    self.inputSelector.noneEnabled = False
    self.inputSelector.showHidden = False
    self.inputSelector.showChildNodeTypes = False
    self.inputSelector.setMRMLScene( slicer.mrmlScene )
    self.inputSelector.setToolTip( "Pick the input to the algorithm." )
    parametersFormLayout.addRow("Input Volume: ", self.inputSelector)

    #
    # output volume selector
    #
    self.outputSelector = slicer.qMRMLNodeComboBox()
    self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.outputSelector.selectNodeUponCreation = True
    self.outputSelector.addEnabled = True
    self.outputSelector.renameEnabled = True
    self.outputSelector.removeEnabled = True
    self.outputSelector.noneEnabled = False
    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)

    #
    # brain mask label selector
    #
    self.brainMaskSelector = slicer.qMRMLNodeComboBox()
    self.brainMaskSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.brainMaskSelector.selectNodeUponCreation = True
    self.brainMaskSelector.addEnabled = True
    self.brainMaskSelector.renameEnabled = True
    self.brainMaskSelector.removeEnabled = True
    self.brainMaskSelector.noneEnabled = True
    self.brainMaskSelector.showHidden = False
    self.brainMaskSelector.showChildNodeTypes = False
    self.brainMaskSelector.setMRMLScene(slicer.mrmlScene)
    self.brainMaskSelector.setToolTip(
      "Output the brain extraction binary mask.")
    parametersFormLayout.addRow("Brain Mask ", self.brainMaskSelector)

    #
    # Apply Button
    #
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the algorithm."
    self.applyButton.enabled = False
    parametersFormLayout.addRow(self.applyButton)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

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

    # Refresh Apply button state
    self.onSelect()
Пример #3
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = SegmentMesherLogic()
        self.logic.logCallback = self.addLog
        self.modelGenerationInProgress = False

        # Instantiate and connect widgets ...

        # Parameter sets
        defaultinputParametersCollapsibleButton = ctk.ctkCollapsibleButton()
        defaultinputParametersCollapsibleButton.text = "Parameter set"
        defaultinputParametersCollapsibleButton.collapsed = True
        self.layout.addWidget(defaultinputParametersCollapsibleButton)
        defaultParametersLayout = qt.QFormLayout(
            defaultinputParametersCollapsibleButton)

        self.parameterNodeSelector = slicer.qMRMLNodeComboBox()
        self.parameterNodeSelector.nodeTypes = ["vtkMRMLScriptedModuleNode"]
        self.parameterNodeSelector.addAttribute("vtkMRMLScriptedModuleNode",
                                                "ModuleName", "SegmentMesher")
        self.parameterNodeSelector.selectNodeUponCreation = True
        self.parameterNodeSelector.addEnabled = True
        self.parameterNodeSelector.renameEnabled = True
        self.parameterNodeSelector.removeEnabled = True
        self.parameterNodeSelector.noneEnabled = False
        self.parameterNodeSelector.showHidden = True
        self.parameterNodeSelector.showChildNodeTypes = False
        self.parameterNodeSelector.baseName = "SegmentMesher"
        self.parameterNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.parameterNodeSelector.setToolTip("Pick parameter set")
        defaultParametersLayout.addRow("Parameter set: ",
                                       self.parameterNodeSelector)

        #
        # Inputs
        #
        inputParametersCollapsibleButton = ctk.ctkCollapsibleButton()
        inputParametersCollapsibleButton.text = "Inputs"
        self.layout.addWidget(inputParametersCollapsibleButton)

        # Layout within the dummy collapsible button
        inputParametersFormLayout = qt.QFormLayout(
            inputParametersCollapsibleButton)

        self.inputModelSelector = slicer.qMRMLNodeComboBox()
        self.inputModelSelector.nodeTypes = ["vtkMRMLSegmentationNode"]
        self.inputModelSelector.selectNodeUponCreation = True
        self.inputModelSelector.addEnabled = False
        self.inputModelSelector.removeEnabled = False
        self.inputModelSelector.noneEnabled = False
        self.inputModelSelector.showHidden = False
        self.inputModelSelector.showChildNodeTypes = False
        self.inputModelSelector.setMRMLScene(slicer.mrmlScene)
        self.inputModelSelector.setToolTip(
            "Volumetric mesh will be generated for all visible segments in this segmentation node."
        )
        inputParametersFormLayout.addRow("Input segmentation: ",
                                         self.inputModelSelector)

        self.methodSelectorComboBox = qt.QComboBox()
        self.methodSelectorComboBox.addItem("Cleaver", METHOD_CLEAVER)
        self.methodSelectorComboBox.addItem("TetGen", METHOD_TETGEN)
        inputParametersFormLayout.addRow("Meshing method: ",
                                         self.methodSelectorComboBox)

        #
        # Outputs
        #
        outputParametersCollapsibleButton = ctk.ctkCollapsibleButton()
        outputParametersCollapsibleButton.text = "Outputs"
        self.layout.addWidget(outputParametersCollapsibleButton)
        outputParametersFormLayout = qt.QFormLayout(
            outputParametersCollapsibleButton)

        #
        # output volume selector
        #
        self.outputModelSelector = slicer.qMRMLNodeComboBox()
        self.outputModelSelector.nodeTypes = ["vtkMRMLModelNode"]
        self.outputModelSelector.selectNodeUponCreation = True
        self.outputModelSelector.addEnabled = True
        self.outputModelSelector.renameEnabled = True
        self.outputModelSelector.removeEnabled = True
        self.outputModelSelector.noneEnabled = False
        self.outputModelSelector.showHidden = False
        self.outputModelSelector.showChildNodeTypes = False
        self.outputModelSelector.setMRMLScene(slicer.mrmlScene)
        self.outputModelSelector.setToolTip("Created volumetric mesh")
        outputParametersFormLayout.addRow("Output model: ",
                                          self.outputModelSelector)

        #
        # Advanced area
        #
        self.advancedCollapsibleButton = ctk.ctkCollapsibleButton()
        self.advancedCollapsibleButton.text = "Advanced"
        self.advancedCollapsibleButton.collapsed = True
        self.layout.addWidget(self.advancedCollapsibleButton)
        advancedFormLayout = qt.QFormLayout(self.advancedCollapsibleButton)

        self.cleaverAdditionalParametersWidget = qt.QLineEdit()
        self.cleaverAdditionalParametersWidget.setToolTip(
            'See description of parameters in module documentation ')
        advancedFormLayout.addRow("Cleaver meshing options:",
                                  self.cleaverAdditionalParametersWidget)
        self.cleaverAdditionalParametersWidget.text = "--scale 0.2 --multiplier 2 --grading 5"

        self.tetGenAdditionalParametersWidget = qt.QLineEdit()
        self.tetGenAdditionalParametersWidget.setToolTip(
            'See description of parameters in module documentation ')
        advancedFormLayout.addRow("TetGen meshing options:",
                                  self.tetGenAdditionalParametersWidget)
        self.tetGenAdditionalParametersWidget.text = ""

        self.showDetailedLogDuringExecutionCheckBox = qt.QCheckBox(" ")
        self.showDetailedLogDuringExecutionCheckBox.checked = False
        self.showDetailedLogDuringExecutionCheckBox.setToolTip(
            "Show detailed log during model generation.")
        advancedFormLayout.addRow("Show detailed log:",
                                  self.showDetailedLogDuringExecutionCheckBox)

        self.keepTemporaryFilesCheckBox = qt.QCheckBox(" ")
        self.keepTemporaryFilesCheckBox.checked = False
        self.keepTemporaryFilesCheckBox.setToolTip(
            "Keep temporary files (inputs, computed outputs, logs) after the model generation is completed."
        )

        self.showTemporaryFilesFolderButton = qt.QPushButton(
            "Show temp folder")
        self.showTemporaryFilesFolderButton.toolTip = "Open the folder where temporary files are stored."
        self.showTemporaryFilesFolderButton.setSizePolicy(
            qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred)

        hbox = qt.QHBoxLayout()
        hbox.addWidget(self.keepTemporaryFilesCheckBox)
        hbox.addWidget(self.showTemporaryFilesFolderButton)
        advancedFormLayout.addRow("Keep temporary files:", hbox)

        customCleaverPath = self.logic.getCustomCleaverPath()
        self.customCleaverPathSelector = ctk.ctkPathLineEdit()
        self.customCleaverPathSelector.setCurrentPath(customCleaverPath)
        self.customCleaverPathSelector.nameFilters = [
            self.logic.cleaverFilename
        ]
        self.customCleaverPathSelector.setSizePolicy(
            qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred)
        self.customCleaverPathSelector.setToolTip(
            "Set cleaver-cli executable path. "
            "If value is empty then cleaver-cli bundled with this extension will be used."
        )
        advancedFormLayout.addRow("Custom Cleaver executable path:",
                                  self.customCleaverPathSelector)

        customTetGenPath = self.logic.getCustomTetGenPath()
        self.customTetGenPathSelector = ctk.ctkPathLineEdit()
        self.customTetGenPathSelector.setCurrentPath(customTetGenPath)
        self.customTetGenPathSelector.nameFilters = [self.logic.tetGenFilename]
        self.customTetGenPathSelector.setSizePolicy(
            qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred)
        self.customTetGenPathSelector.setToolTip(
            "Set tetgen executable path. "
            "If value is empty then tetgen bundled with this extension will be used."
        )
        advancedFormLayout.addRow("Custom TetGen executable path:",
                                  self.customTetGenPathSelector)

        #
        # Display
        #
        displayParametersCollapsibleButton = ctk.ctkCollapsibleButton()
        displayParametersCollapsibleButton.text = "Display"
        displayParametersCollapsibleButton.collapsed = True
        self.layout.addWidget(displayParametersCollapsibleButton)
        displayParametersFormLayout = qt.QFormLayout(
            displayParametersCollapsibleButton)

        self.clipNodeWidget = slicer.qMRMLClipNodeWidget()
        clipNode = slicer.mrmlScene.GetFirstNodeByClass(
            "vtkMRMLClipModelsNode")
        self.clipNodeWidget.setMRMLClipNode(clipNode)
        displayParametersFormLayout.addRow(self.clipNodeWidget)

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = False
        self.layout.addWidget(self.applyButton)

        self.statusLabel = qt.QPlainTextEdit()
        self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
        self.statusLabel.setCenterOnScroll(True)
        self.layout.addWidget(self.statusLabel)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.showTemporaryFilesFolderButton.connect(
            'clicked(bool)', self.onShowTemporaryFilesFolder)
        self.inputModelSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                        self.updateMRMLFromGUI)
        self.outputModelSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                         self.updateMRMLFromGUI)
        self.methodSelectorComboBox.connect("currentIndexChanged(int)",
                                            self.updateMRMLFromGUI)
        # Immediately update deleteTemporaryFiles in the logic to make it possible to decide to
        # keep the temporary file while the model generation is running
        self.keepTemporaryFilesCheckBox.connect(
            "toggled(bool)", self.onKeepTemporaryFilesToggled)

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

        # Refresh Apply button state
        self.updateMRMLFromGUI()
Пример #4
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)
    slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)
    l = slicer.modules.createmodels.logic()
    self.needleModel = l.CreateNeedle(150, 0.4, 0, False)
    #This code block creates a collapsible button 
    #This defines which type of button you are using 
    self.usContainer = ctk.ctkCollapsibleButton()
    #This is what the button will say 
    self.usContainer.text = "Connection Information"
    #Thiss actually creates that button
    #This creates a variable that describes layout within this collapsible button 
    self.usLayout = qt.QFormLayout(self.usContainer)

    if slicer.mrmlScene.GetNodesByClass("vtkMRMLSequenceNode").GetNumberOfItems() == 0:
      #This is a push button 
      self.connectButton = qt.QPushButton()
      self.connectButton.setDefault(False)
      #This button says connect 
      self.connectButton.text = "Connect"
      #help tooltip that explains the funciton 
      self.connectButton.toolTip = "Connects to Ultrasound"
      #adds the widget to the layout 
      self.usLayout.addWidget(self.connectButton)
    
    # self.normalImageButton = qt.QCheckBox() 
    # self.normalImageButton.text = "Select if performing a 2D Calibration"
    # self.usLayout.addRow(self.normalImageButton)
    
    self.imageSelector = slicer.qMRMLNodeComboBox()
    self.imageSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.imageSelector.selectNodeUponCreation = True
    self.imageSelector.addEnabled = False
    self.imageSelector.removeEnabled = False
    self.imageSelector.noneEnabled = True
    self.imageSelector.showHidden = False
    self.imageSelector.showChildNodeTypes = False
    self.imageSelector.setMRMLScene( slicer.mrmlScene )
    self.imageSelector.setToolTip( "Pick the image to be used." )
    self.usLayout.addRow("US Volume: ", self.imageSelector)
    
        #add combo box for linear transform node 
    self.TransformSelector = slicer.qMRMLNodeComboBox()
    self.TransformSelector.nodeTypes = ["vtkMRMLLinearTransformNode"]
    self.TransformSelector.selectNodeUponCreation = True
    self.TransformSelector.addEnabled = False
    self.TransformSelector.removeEnabled = False
    self.TransformSelector.noneEnabled = True
    self.TransformSelector.showHidden = False
    self.TransformSelector.showChildNodeTypes = False
    self.TransformSelector.setMRMLScene( slicer.mrmlScene )
    self.TransformSelector.setToolTip( "Pick the transform representing the straw line." )
    self.usLayout.addRow("Tip to Probe: ", self.TransformSelector)
    
    self.recordContainer = ctk.ctkCollapsibleButton()
    #This is what the button will say 
    self.recordContainer.text = "Recording Options"
    #Thiss actually creates that button
    #This creates a variable that describes layout within this collapsible button 
    self.recordLayout = qt.QFormLayout(self.recordContainer)
    
    self.RecordButton = qt.QPushButton() 
    self.RecordButton.text = "Start Recording" 
    self.recordLayout.addWidget(self.RecordButton)
    
    self.StopRecordButton = qt.QPushButton() 
    self.StopRecordButton.text = "Stop Recording" 
    self.recordLayout.addWidget(self.StopRecordButton)
    
    self.pathInput = qt.QLineEdit()
    self.pathInput.setPlaceholderText("Enter the path to save files to")
    self.pathText = qt.QLabel("File Path:")
    self.recordLayout.addRow(self.pathText, self.pathInput)
    
    self.SaveRecordButton = qt.QPushButton() 
    self.SaveRecordButton.text = "Save Recording" 
    self.recordLayout.addWidget(self.SaveRecordButton)
    
     # This creates another collapsible button
    self.fiducialContainer = ctk.ctkCollapsibleButton()
    self.fiducialContainer.text = "Registration"

    self.fiducialLayout = qt.QFormLayout(self.fiducialContainer)

    self.freezeButton = qt.QPushButton()
    if slicer.mrmlScene.GetNodesByClass("vtkMRMLSequenceNode").GetNumberOfItems() == 0:
      self.freezeButton.text = "Freeze"
    else:
      self.freezeButton.text = "Place Fiducial"
    self.freezeButton.toolTip = "Freeze the ultrasound image for fiducial placement"
    self.fiducialLayout.addRow(self.freezeButton)
    self.shortcut = qt.QShortcut(qt.QKeySequence('f'), slicer.util.mainWindow())
    
    self.numFidLabel = qt.QLabel()
    self.fiducialLayout.addRow(qt.QLabel("Fiducials collected:"), self.numFidLabel)

    self.transformTable = qt.QTableWidget() 
    self.transTableItem = qt.QTableWidgetItem()
    self.fidError = qt.QLabel()
    self.transformTable.setRowCount(4)
    self.transformTable.setColumnCount(4)
    self.transformTable.horizontalHeader().hide()
    self.transformTable.verticalHeader().hide()
    self.transformTable.setItem(0,0, qt.QTableWidgetItem("1"))
    self.transformTable.setItem(0,1, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(0,2, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(0,3, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(1,0, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(1,1, qt.QTableWidgetItem("1"))
    self.transformTable.setItem(1,2, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(1,3, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(2,0, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(2,1, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(2,2, qt.QTableWidgetItem("1"))
    self.transformTable.setItem(2,3, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(3,0, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(3,1, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(3,2, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(3,3, qt.QTableWidgetItem("1"))
    self.transformTable.setSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.MinimumExpanding)
    self.copyIcon =qt.QIcon(":Icons/Medium/SlicerEditCopy.png")
    self.copyButton = qt.QPushButton()
    self.copyButton.setIcon(self.copyIcon)
    self.copyButton.setMaximumWidth(64)
    self.copyButton.enabled = False 
    if self.numFidLabel >= 2: 
      self.copyButton.enabled = True 
      
    self.fiducialLayout.addRow(qt.QLabel("Image to probe transform:"))
    self.fiducialLayout.addRow(self.transformTable)
    self.fiducialLayout.addRow("Copy:", self.copyButton)
    
    self.validationContainer = ctk.ctkCollapsibleButton()
    self.validationContainer.text = "Validation"
    self.validationLayout = qt.QFormLayout(self.validationContainer)

    self.visualizeButton = qt.QPushButton('Show 3D Scene')
    self.visualizeButton.toolTip = "This button enables the 3D view for visual validation"
    self.validationLayout.addRow(self.visualizeButton)
    
    # Add the containers to the parent
    self.layout.addWidget(self.usContainer)
    if slicer.mrmlScene.GetNodesByClass("vtkMRMLSequenceNode").GetNumberOfItems() == 0:
      self.layout.addWidget(self.recordContainer)
    self.layout.addWidget(self.fiducialContainer)
    self.layout.addWidget(self.validationContainer)
    
    # Add vertical spacer
    self.layout.addStretch(1)
    
    #connections
    if slicer.mrmlScene.GetNodesByClass("vtkMRMLSequenceNode").GetNumberOfItems() == 0:
      self.connectButton.connect('clicked(bool)', self.onConnectButtonClicked)
      self.freezeButton.connect('clicked(bool)', self.onConnectButtonClicked)
      self.shortcut.connect('activated()', self.onConnectButtonClicked)
    else:
      self.shortcut.connect('activated()', self.onFiducialClicked)
      self.freezeButton.connect('clicked(bool)', self.onFiducialClicked)
    self.imageSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onImageChanged)
    self.TransformSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onTransformChanged)
    self.RecordButton.connect('clicked(bool)', self.onRecordButtonClicked)
    self.StopRecordButton.connect('clicked(bool)', self.onStopRecordButtonClicked)
    self.SaveRecordButton.connect('clicked(bool)', self.onSaveRecordButtonClicked)
    self.copyButton.connect('clicked(bool)', self.onCopyButtonClicked)
    self.visualizeButton.connect('clicked(bool)', self.onVisualizeButtonClicked)

    self.StopRecordButton.setEnabled(False)
    self.sceneObserverTag = slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeAddedEvent, self.onNodeAdded)
Пример #5
0
    def setup_atlas_registration_area(self):
        """
        Setup atlas registration area and connect functions.
        """

        atlas_registration_collapsible_button = ctk.ctkCollapsibleButton()
        atlas_registration_collapsible_button.text = "Register Atlas to Scan"
        atlas_registration_collapsible_button.setDisabled(False)
        self.layout.addWidget(atlas_registration_collapsible_button)

        # Layout within the dummy collapsible button
        atlas_registration_form_layout = qt.QFormLayout(
            atlas_registration_collapsible_button)

        self.atlas_fiducials = slicer.qMRMLNodeComboBox()
        self.atlas_fiducials.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
        self.atlas_fiducials.selectNodeUponCreation = True
        self.atlas_fiducials.addEnabled = True
        self.atlas_fiducials.removeEnabled = True
        self.atlas_fiducials.noneEnabled = True
        self.atlas_fiducials.showHidden = True
        self.atlas_fiducials.showChildNodeTypes = True
        self.atlas_fiducials.setMRMLScene(slicer.mrmlScene)
        self.atlas_fiducials.setToolTip("Pick the input to the algorithm.")

        atlas_registration_form_layout.addRow(
            "Atlas AC/PC/Sup1/Sup2 Fiducials", self.atlas_fiducials)

        self.scan_fiducials = slicer.qMRMLNodeComboBox()
        self.scan_fiducials.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
        self.scan_fiducials.selectNodeUponCreation = True
        self.scan_fiducials.addEnabled = True
        self.scan_fiducials.removeEnabled = True
        self.scan_fiducials.noneEnabled = True
        self.scan_fiducials.showHidden = True
        self.scan_fiducials.showChildNodeTypes = True
        self.scan_fiducials.setMRMLScene(slicer.mrmlScene)
        self.scan_fiducials.setToolTip("Pick the input to the algorithm.")

        atlas_registration_form_layout.addRow("Scan AC/PC/Sup1/Sup2 Fiducials",
                                              self.scan_fiducials)

        # atlas volume selector
        #

        self.atlas_volume_selector.nodeTypes = (("vtkMRMLLabelMapVolumeNode"),
                                                "")
        self.atlas_volume_selector.selectNodeUponCreation = False
        self.atlas_volume_selector.addEnabled = False
        self.atlas_volume_selector.removeEnabled = False
        self.atlas_volume_selector.noneEnabled = True
        self.atlas_volume_selector.showHidden = False
        self.atlas_volume_selector.showChildNodeTypes = False
        self.atlas_volume_selector.setMRMLScene(slicer.mrmlScene)
        self.atlas_volume_selector.setToolTip(
            "Pick the input volume for the algorithm.")
        atlas_registration_form_layout.addRow("Atlas Volume: ",
                                              self.atlas_volume_selector)

        #
        # Register Button
        #
        self.atlas_register_button = qt.QPushButton("Register Atlas to Frame")
        self.atlas_register_button.toolTip = "Run the algorithm."
        self.atlas_register_button.enabled = False
        atlas_registration_form_layout.addRow(self.atlas_register_button)

        # Connect Procedures
        self.atlas_fiducials.connect("currentNodeChanged(vtkMRMLNode*)",
                                     self.on_atlas_registration_select)
        self.scan_fiducials.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.on_atlas_registration_select)
        self.atlas_volume_selector.connect("currentNodeChanged(vtkMRMLNode*)",
                                           self.on_atlas_registration_select)
        # Atlas to Frame Registration
        self.atlas_register_button.connect("clicked(bool)",
                                           self.register_ac_pc)
Пример #6
0
    def create(self, registrationState):
        """Make the plugin-specific user interface"""
        super(LocalSimpleITKPlugin, self).create(registrationState)

        # To avoid the overhead of importing SimpleITK during application
        # startup, the import of SimpleITK is delayed until it is needed.
        global sitk
        import SimpleITK as sitk
        global sitkUtils
        import sitkUtils
        print("LocalSimpleITKPlugin.create")

        self.LocalSimpleITKMode = "Small"
        self.VerboseMode = "Quiet"

        #
        # Local Refinment Pane - initially hidden
        # - interface options for linear registration
        #
        localSimpleITKCollapsibleButton = ctk.ctkCollapsibleButton()
        localSimpleITKCollapsibleButton.text = "Local SimpleITK"
        localSimpleITKFormLayout = qt.QFormLayout()
        localSimpleITKCollapsibleButton.setLayout(localSimpleITKFormLayout)
        self.widgets.append(localSimpleITKCollapsibleButton)

        buttonGroup = qt.QButtonGroup()
        self.widgets.append(buttonGroup)
        buttonLayout = qt.QVBoxLayout()
        localSimpleITKModeButtons = {}
        self.LocalSimpleITKModes = ("Small", "Large")
        for mode in self.LocalSimpleITKModes:
            localSimpleITKModeButtons[mode] = qt.QRadioButton()
            localSimpleITKModeButtons[mode].text = mode
            localSimpleITKModeButtons[mode].setToolTip(
                "Run the refinement in a %s local region." % mode.lower())
            buttonLayout.addWidget(localSimpleITKModeButtons[mode])
            buttonGroup.addButton(localSimpleITKModeButtons[mode])
            self.widgets.append(localSimpleITKModeButtons[mode])
            localSimpleITKModeButtons[mode].connect(
                'clicked()', lambda m=mode: self.onLocalSimpleITKMode(m))
        localSimpleITKModeButtons[self.LocalSimpleITKMode].checked = True
        localSimpleITKFormLayout.addRow("Local SimpleITK Mode ", buttonLayout)

        buttonGroup = qt.QButtonGroup()
        self.widgets.append(buttonGroup)
        buttonLayout = qt.QVBoxLayout()
        verboseModeButtons = {}
        self.VerboseModes = ("Quiet", "Verbose", "Full Verbose")
        for mode in self.VerboseModes:
            verboseModeButtons[mode] = qt.QRadioButton()
            verboseModeButtons[mode].text = mode
            verboseModeButtons[mode].setToolTip(
                "Run the refinement in %s mode." % mode.lower())
            buttonLayout.addWidget(verboseModeButtons[mode])
            buttonGroup.addButton(verboseModeButtons[mode])
            self.widgets.append(verboseModeButtons[mode])
            verboseModeButtons[mode].connect(
                'clicked()', lambda m=mode: self.onVerboseMode(m))
        verboseModeButtons[self.VerboseMode].checked = True
        localSimpleITKFormLayout.addRow("Verbose Mode ", buttonLayout)

        self.parent.layout().addWidget(localSimpleITKCollapsibleButton)
Пример #7
0
    def add_widgets(self, instructions):
        if self.processingCollapsibleButton is not None:
            self.processingCollapsibleButton.deleteLater()
        self.processingCollapsibleButton = ctk.ctkCollapsibleButton()
        self.processingCollapsibleButton.text = "Processing"
        self.layout.addWidget(self.processingCollapsibleButton)

        self.processingFormLayout = qt.QFormLayout(
            self.processingCollapsibleButton)

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

        self.widgets = []

        for instruction in instructions:
            if instruction['type'] == 'volume':
                volume = ScalarVolumeWidget(
                    destination=instruction['destination'])
                self.widgets.append(volume)
                self.processingFormLayout.addRow(
                    '{} Volume: '.format(instruction['destination']), volume)

            if instruction['type'] == 'fiducials':
                fiducial = MarkupsFiducialWidget(
                    destination=instruction['destination'])
                self.widgets.append(fiducial)
                self.processingFormLayout.addRow(
                    '{} Fiducials: '.format(instruction['destination']),
                    fiducial)

            if instruction['type'] == 'transform':
                transform = TransformWidget(
                    destination=instruction['destination'])
                self.widgets.append(transform)
                self.processingFormLayout.addRow(
                    '{} Transform: '.format(instruction['destination']),
                    transform)

            if instruction['type'] == 'slider':
                slider = SliderWidget(destination=instruction['destination'],
                                      minimum=instruction['minimum'],
                                      maximum=instruction['maximum'])
                self.widgets.append(slider)
                self.processingFormLayout.addRow(
                    '{} Slider: '.format(instruction['destination']), slider)

            if instruction['type'] == 'checkbox':
                checkbox = CheckboxWidget(
                    destination=instruction['destination'],
                    text=instruction['text'])
                self.widgets.append(checkbox)
                self.processingFormLayout.addRow(
                    '{} Checkbox: '.format(instruction['destination']),
                    checkbox)

            if instruction['type'] == 'radiobutton':
                radiobox = RadioButtonWidget(
                    destination=instruction['destination'],
                    options=instruction['options'])
                self.widgets.append(radiobox)
                self.processingFormLayout.addRow(
                    '{} Options: '.format(instruction['text']), radiobox)

        self.applyButton = add_button('Process',
                                      'Run the algorithm',
                                      enabled=True)

        self.processingFormLayout.addRow(self.applyButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
Пример #8
0
  def setup( self ):
    ScriptedLoadableModuleWidget.setup(self)
        
    #
    # Logic
    #
    self.ptcLogic = PerkTutorCouchDBLogic()
    
    #
    # Save Area
    #
    saveCollapsibleButton = ctk.ctkCollapsibleButton()
    saveCollapsibleButton.text = "Save Session"
    self.layout.addWidget( saveCollapsibleButton )
    # Layout within the collapsible button
    saveFormLayout = qt.QFormLayout( saveCollapsibleButton )

    # User ID input
    self.saveUserIDLineEdit = qt.QLineEdit()
    saveFormLayout.addRow( "User ID", self.saveUserIDLineEdit )

    # Study ID input
    self.saveStudyIDLineEdit = qt.QLineEdit()
    saveFormLayout.addRow("Study ID", self.saveStudyIDLineEdit )

    # Trial ID input
    self.saveTrialIDLineEdit = qt.QLineEdit()
    saveFormLayout.addRow( "Trial ID", self.saveTrialIDLineEdit )

    # skill level selector
    self.saveSkillSelector = qt.QComboBox()
    self.saveSkillSelector.addItems( SKILL_LEVEL_SELECTIONS )
    saveFormLayout.addRow( "Skill level", self.saveSkillSelector )

    # session completed selector
    self.saveSessionCompletionSelector = qt.QComboBox()
    self.saveSessionCompletionSelector.addItems( SESSION_COMPLETION_SELECTIONS )
    saveFormLayout.addRow( "Status", self.saveSessionCompletionSelector )

    # Node to save selector
    self.saveNodeSelector = slicer.qMRMLNodeComboBox()
    self.saveNodeSelector.noneEnabled = True
    self.saveNodeSelector.removeEnabled = False
    self.saveNodeSelector.addEnabled = False
    self.saveNodeSelector.renameEnabled = False
    self.saveNodeSelector.setMRMLScene( slicer.mrmlScene )
    saveFormLayout.addRow( "Data", self.saveNodeSelector )

    # Save Button
    self.saveButton = qt.QPushButton( "Save" )
    self.saveButton.enabled = True
    saveFormLayout.addRow( self.saveButton )
    
    #
    # Search Area
    #
    searchCollapsibleButton = ctk.ctkCollapsibleButton()
    searchCollapsibleButton.text = "Search For Session"
    self.layout.addWidget( searchCollapsibleButton )
    # Layout within the collapsible button
    searchFormLayout = qt.QFormLayout( searchCollapsibleButton )

    # Search user ID field
    self.searchUserIDLineEdit = qt.QLineEdit()
    searchFormLayout.addRow( "User ID", self.searchUserIDLineEdit )

    # Search study ID field
    self.searchStudyIDLineEdit = qt.QLineEdit()
    searchFormLayout.addRow( "Study ID", self.searchStudyIDLineEdit )

    # Search trial ID field
    self.searchTrialIDLineEdit = qt.QLineEdit()
    searchFormLayout.addRow( "Trial ID", self.searchTrialIDLineEdit )

    # Search skill level field
    self.searchSkillSelector = qt.QComboBox()
    self.searchSkillSelector.addItems( ( "", ) + SKILL_LEVEL_SELECTIONS )
    searchFormLayout.addRow( "Skill level", self.searchSkillSelector )

    # Search Button
    self.searchButton = qt.QPushButton( "Search" )
    self.searchButton.enabled = True
    searchFormLayout.addRow( self.searchButton )
    
    #
    # Configuration
    #
    configurationCollapsibleButton = ctk.ctkCollapsibleButton()
    configurationCollapsibleButton.text = "Configuration"
    configurationCollapsibleButton.collapsed = True
    self.layout.addWidget( configurationCollapsibleButton )
    # Layout within the collapsible button
    configurationVBoxLayout = qt.QVBoxLayout( configurationCollapsibleButton )
    
    settings = slicer.app.userSettings()
    
    
    #
    # Database
    #
    databaseCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox()
    databaseCollapsibleGroupBox.setTitle( "Remote Database" )
    databaseCollapsibleGroupBox.collapsed = True
    configurationVBoxLayout.addWidget( databaseCollapsibleGroupBox )
    # Layout within the group box
    databaseFormLayout = qt.QFormLayout( databaseCollapsibleGroupBox )    

    # Database username field
    self.databaseUsernameLineEdit = qt.QLineEdit()
    self.databaseUsernameLineEdit.setText( settings.value( self.moduleName + "/DatabaseUsername" ) )
    databaseFormLayout.addRow( "Username", self.databaseUsernameLineEdit )

    # Database password field
    self.databasePasswordLineEdit = qt.QLineEdit()
    self.databasePasswordLineEdit.setEchoMode( qt.QLineEdit.Password )
    self.databasePasswordLineEdit.setText( settings.value( self.moduleName + "/DatabasePassword" ) )    
    databaseFormLayout.addRow( "Password", self.databasePasswordLineEdit )

    # Remote database address
    self.databaseAddressLineEdit = qt.QLineEdit()
    self.databaseAddressLineEdit.setText( settings.value( self.moduleName + "/DatabaseAddress" ) )
    databaseFormLayout.addRow( "Address", self.databaseAddressLineEdit )
    
    
    #
    # File Server
    #
    fileServerCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox()
    fileServerCollapsibleGroupBox.setTitle( "File Server" )
    fileServerCollapsibleGroupBox.collapsed = True
    configurationVBoxLayout.addWidget( fileServerCollapsibleGroupBox )
    # Layout within the group box
    fileServerFormLayout = qt.QFormLayout( fileServerCollapsibleGroupBox )    

    # File server session field
    self.fileServerSessionLineEdit = qt.QLineEdit()
    self.fileServerSessionLineEdit.setText( settings.value( self.moduleName + "/FileServerSession" ) )
    fileServerFormLayout.addRow( "Session", self.fileServerSessionLineEdit )
    
    # Local storage directory
    self.fileServerLocalDirectoryLineEdit = qt.QLineEdit()
    self.fileServerLocalDirectoryLineEdit.setText( settings.value( self.moduleName + "/FileServerLocalDirectory" ) )
    fileServerFormLayout.addRow( "Local path", self.fileServerLocalDirectoryLineEdit )

    # FTP client
    self.ftpClientDirectoryLineEdit = qt.QLineEdit()
    self.ftpClientDirectoryLineEdit.setText( settings.value( self.moduleName + "/FileServerClient" ) )
    fileServerFormLayout.addRow( "FTP client", self.ftpClientDirectoryLineEdit )
        
    
    # Update Button
    self.updateButton = qt.QPushButton( "Update" )
    self.updateButton.enabled = True
    configurationVBoxLayout.addWidget( self.updateButton )
    
    
    #
    # Stretcher
    #
    self.layout.addStretch( 1 )
    
    #
    # Initialize the remote database from the settings at outset (if the settings are already specified)
    #
    try:
      self.ptcLogic.updateDatabase( PERK_TUTOR_DATABASE_NAME )
    except Exception as e:
      logging.warning( e )
    
    #
    # Connections
    #
    self.saveButton.connect( "clicked(bool)", self.onSaveButton )
    self.searchButton.connect( "clicked(bool)", self.onSearchButton )
    self.updateButton.connect( "clicked(bool)", self.onUpdateButton )
Пример #9
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        self.stage = None
        # 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)

        #Parameters
        self.firstLandMarkSelected = False
        self.secondLandMarkSelected = False
        self.currentVisitingLandMark = 0
        self.passCount = 0

        #
        # input volume selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.inputSelector.selectNodeUponCreation = True
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.noneEnabled = False
        self.inputSelector.showHidden = False
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputSelector.setToolTip("Pick the input to the algorithm.")
        parametersFormLayout.addRow("Input Volume: ", self.inputSelector)

        #
        # 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.imageThresholdSliderWidget = ctk.ctkSliderWidget()
        self.imageThresholdSliderWidget.singleStep = 0.1
        self.imageThresholdSliderWidget.minimum = -100
        self.imageThresholdSliderWidget.maximum = 100
        self.imageThresholdSliderWidget.value = 0.5
        self.imageThresholdSliderWidget.setToolTip(
            "Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero."
        )
        parametersFormLayout.addRow("Image threshold",
                                    self.imageThresholdSliderWidget)

        #
        # 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)

        #
        # Connect to Positioner
        #
        ConnectionWarningLabel = qt.QLabel("Connect to the Stage")
        ConnectionWarningLabel.setWordWrap(True)
        parametersFormLayout.addRow(ConnectionWarningLabel)

        self.connectStageButton = qt.QPushButton("Connect To the Stage")
        self.connectStageButton.toolTip = "Connect to Stage"
        self.connectStageButton.enabled = True
        parametersFormLayout.addRow(self.connectStageButton)

        #
        # input fiducial list selector
        #
        fiducialWarningLabel = qt.QLabel(
            "Note: Parent transforms of fiducials are not used. Fiducials should be defined in the coordinate system that is being registered."
        )
        fiducialWarningLabel.setWordWrap(True)
        parametersFormLayout.addRow(fiducialWarningLabel)

        self.inputFiducialSelector = slicer.qMRMLNodeComboBox()
        self.inputFiducialSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"),
                                                "")
        self.inputFiducialSelector.selectNodeUponCreation = True
        self.inputFiducialSelector.addEnabled = False
        self.inputFiducialSelector.removeEnabled = False
        self.inputFiducialSelector.noneEnabled = False
        self.inputFiducialSelector.showHidden = False
        self.inputFiducialSelector.showChildNodeTypes = False
        self.inputFiducialSelector.setMRMLScene(slicer.mrmlScene)
        self.inputFiducialSelector.setToolTip(
            "Pick the input fiducial list for the algorithm.")
        parametersFormLayout.addRow("Input fiducials: ",
                                    self.inputFiducialSelector)

        #
        # First Landmark Button
        #
        self.set1stLandMarkButton = qt.QPushButton("Reset")
        self.set1stLandMarkButton.toolTip = "Reset"
        self.set1stLandMarkButton.enabled = True
        parametersFormLayout.addRow(self.set1stLandMarkButton)

        self.set2ndLandMarkButton = qt.QPushButton("Done")
        self.set2ndLandMarkButton.toolTip = "Set n-st Landmark"
        self.set2ndLandMarkButton.enabled = False
        parametersFormLayout.addRow(self.set2ndLandMarkButton)

        #
        # Target
        #
        self.targetFiducialSelector = slicer.qMRMLNodeComboBox()
        self.targetFiducialSelector.nodeTypes = ((
            "vtkMRMLMarkupsFiducialNode"), "")
        self.targetFiducialSelector.selectNodeUponCreation = True
        self.targetFiducialSelector.addEnabled = False
        self.targetFiducialSelector.removeEnabled = False
        self.targetFiducialSelector.noneEnabled = False
        self.targetFiducialSelector.showHidden = False
        self.targetFiducialSelector.showChildNodeTypes = False
        self.targetFiducialSelector.setMRMLScene(slicer.mrmlScene)
        self.targetFiducialSelector.setToolTip(
            "Pick the target fiducial list for the algorithm.")
        parametersFormLayout.addRow(
            "Target fiducials: 1st Target, 2ed Entrance",
            self.targetFiducialSelector)

        #
        # Second Landmark Button
        #
        self.applyButton = qt.QPushButton("Cacluate the Target")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = False
        parametersFormLayout.addRow(self.applyButton)

        # connections
        self.set1stLandMarkButton.connect('clicked(bool)',
                                          self.onSet1stLandMarkButton)
        self.set2ndLandMarkButton.connect('clicked(bool)',
                                          self.onSet2ndLandMarkButton)
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.connectStageButton.connect('clicked(bool)',
                                        self.onConnectStageButton)
        self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.onSelect)
        self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onSelect)
        self.inputFiducialSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                           self.onSelect)
        self.targetFiducialSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                            self.onSelect)

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

        # Refresh Apply button state
        self.onSelect()
Пример #10
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.layout.setContentsMargins(6, 6, 6, 6)

        # Init Button
        self.initButton = qt.QPushButton("Initialize")
        self.initButton.toolTip = "Initialize VR system, controllers, and room."
        self.layout.addWidget(self.initButton)

        # Calibration buttons
        self.calibrateGroupBox = qt.QGroupBox("Calibrations")
        self.calibrateGroupBox.enabled = False
        layout = qt.QHBoxLayout(self.calibrateGroupBox)
        layout.setContentsMargins(0, 0, 0, 0)
        self.floorButton = qt.QPushButton("Floor")
        self.floorButton.toolTip = "Calibrate the floor."
        self.faceButton = qt.QPushButton("Face")
        self.faceButton.toolTip = "Calibrate the face."
        layout.addWidget(self.floorButton)
        layout.addWidget(self.faceButton)
        self.layout.addWidget(self.calibrateGroupBox)

        # Inputs Area
        self.inputsGroupBox = qt.QGroupBox("Inputs")
        self.inputsGroupBox.enabled = False
        layout = qt.QFormLayout(self.inputsGroupBox)
        layout.setContentsMargins(0, 0, 0, 0)
        self.participantIdLineEdit = qt.QLineEdit()
        self.participantIdLineEdit.text = "000"
        self.conditionComboBox = qt.QComboBox()
        self.conditionComboBox.addItem("Motion")
        self.conditionComboBox.addItem("No motion")
        self.conditionComboBox.addItem("Replay")
        self.trialNumberSpinBox = qt.QSpinBox()
        self.trialNumberSpinBox.setValue(1)
        self.trialNumberSpinBox.setSingleStep(1)
        self.trialNumberSpinBox.setMinimum(1)
        layout.addRow("Participant ID:", self.participantIdLineEdit)
        layout.addRow("Condition:", self.conditionComboBox)
        layout.addRow("Trial Number:", self.trialNumberSpinBox)
        self.layout.addWidget(self.inputsGroupBox)

        # Sequences loading
        self.sequenceGroupBox = qt.QGroupBox("Target Sequences")
        layout = qt.QHBoxLayout(self.sequenceGroupBox)
        self.motionSequenceButton = qt.QPushButton("Load Motion")
        self.nomotionSequenceButton = qt.QPushButton("Load No-motion")
        self.replaySequenceButton = qt.QPushButton("Load Replay")
        layout.addWidget(self.motionSequenceButton)
        layout.addWidget(self.nomotionSequenceButton)
        layout.addWidget(self.replaySequenceButton)
        self.layout.addWidget(self.sequenceGroupBox)

        # Control UI
        self.controlGroupBox = qt.QGroupBox("Controls")
        layout = qt.QFormLayout(self.controlGroupBox)
        self.showControllerCheckBox = qt.QCheckBox()
        self.showNeedleCheckBox = qt.QCheckBox()
        self.showSphereCheckBox = qt.QCheckBox()
        layout.addRow("Show controller: ", self.showControllerCheckBox)
        layout.addRow("Show needle: ", self.showNeedleCheckBox)
        layout.addRow("Show sphere: ", self.showSphereCheckBox)
        self.layout.addWidget(self.controlGroupBox)

        # Capture related buttons
        widget = qt.QWidget()
        layout = qt.QHBoxLayout(widget)
        layout.setContentsMargins(0, 0, 0, 0)
        self.startButton = qt.QPushButton("Start")
        self.startButton.toolTip = "Start the capture sequence."
        self.startButton.enabled = False
        self.previousButton = qt.QPushButton("Previous")
        self.previousButton.toolTip = "Capture previous point."
        self.previousButton.enabled = False
        self.nextButton = qt.QPushButton("Next")
        self.nextButton.toolTip = "Capture next point."
        self.nextButton.enabled = False
        self.captureButton = qt.QPushButton("Go!")
        self.captureButton.toolTip = "Capture a data point."
        self.captureButton.enabled = False
        self.saveButton = qt.QPushButton("Save")
        self.saveButton.toolTip = "Save the current data set to file."
        self.saveButton.enabled = False
        self.resetButton = qt.QPushButton("Reset")
        self.resetButton.toolTip = "Reset the capture."
        self.resetButton.enabled = False
        layout.addWidget(self.startButton)
        layout.addWidget(self.previousButton)
        layout.addWidget(self.nextButton)
        layout.addWidget(self.captureButton)
        layout.addWidget(self.saveButton)
        layout.addWidget(self.resetButton)
        self.layout.addWidget(widget)

        # Results box
        self.resultGroupBox = qt.QGroupBox("Results")
        layout = qt.QHBoxLayout(self.resultGroupBox)
        self.resultLabel = qt.QLabel("")
        layout.addWidget(self.resultLabel)
        self.layout.addWidget(self.resultGroupBox)

        self.doConnect()

        # Add vertical spacer
        self.layout.addStretch(1)
Пример #11
0
    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)

        # directory selection
        self.inputDirectoryButton = qt.QPushButton("Select a Directory")
        self.inputDirectory = None
        parametersFormLayout.addRow("DICOM Input:", self.inputDirectoryButton)

        # phantom type selection
        self.phantomModelSelector = qt.QGroupBox()

        vbox = qt.QVBoxLayout()
        self.phantom_radios = []
        for name in sorted(phantom_definitions.PHANTOM_CATALOG.keys()):
            rb = qt.QRadioButton(name)
            self.phantom_radios.append(rb)
            vbox.addWidget(rb)
        self.phantomModelSelector.setLayout(vbox)
        parametersFormLayout.addRow("Select phantom model: ",
                                    self.phantomModelSelector)

        #
        # output DWI volume selector
        #
        self.outputDWISelector = slicer.qMRMLNodeComboBox()
        self.outputDWISelector.nodeTypes = [
            "vtkMRMLDiffusionWeightedVolumeNode"
        ]
        self.outputDWISelector.selectNodeUponCreation = True
        self.outputDWISelector.addEnabled = True
        self.outputDWISelector.removeEnabled = True
        self.outputDWISelector.renameEnabled = True
        self.outputDWISelector.noneEnabled = False
        self.outputDWISelector.showHidden = False
        self.outputDWISelector.showChildNodeTypes = False
        self.outputDWISelector.setMRMLScene(slicer.mrmlScene)
        self.outputDWISelector.setToolTip("Pick the output to the algorithm.")
        parametersFormLayout.addRow("Output DWI Volume: ",
                                    self.outputDWISelector)

        #
        # output scalar volume selector
        #
        self.outputSelector = slicer.qMRMLNodeComboBox()
        self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.outputSelector.selectNodeUponCreation = True
        self.outputSelector.addEnabled = True
        self.outputSelector.removeEnabled = True
        self.outputSelector.renameEnabled = True
        self.outputSelector.noneEnabled = False
        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 Scalar Volume: ",
                                    self.outputSelector)

        #
        # output VOI selector
        #
        self.outputVOISelector = slicer.qMRMLNodeComboBox()
        self.outputVOISelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.outputVOISelector.selectNodeUponCreation = True
        self.outputVOISelector.addEnabled = True
        self.outputVOISelector.removeEnabled = True
        self.outputVOISelector.renameEnabled = True
        self.outputVOISelector.noneEnabled = False
        self.outputVOISelector.showHidden = False
        self.outputVOISelector.showChildNodeTypes = False
        self.outputVOISelector.setMRMLScene(slicer.mrmlScene)
        self.outputVOISelector.setToolTip(
            "Pick the output VOI to the algorithm.")
        parametersFormLayout.addRow("Output VOI: ", self.outputVOISelector)

        #
        # 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.inputDirectoryButton.connect('clicked(bool)',
                                          self.onInputDirectory)
        self.phantomModelSelector.connect('clicked(bool)', self.onSelect)
        self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onSelect)
        self.outputDWISelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                       self.onSelect)
        self.outputVOISelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                       self.onSelect)

        # Refresh Apply button state
        self.onSelect()

        # Add space to display feedback from program
        self.statusLabel = qt.QPlainTextEdit()
        self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
        parametersFormLayout.addRow(self.statusLabel)

        # Add vertical spacer
        self.layout.addStretch(1)
Пример #12
0
 def setup(self):
   self.setLayout(qt.QFormLayout(self))
   self._addDeviceLabel()
   self._addPresetsCombo()
   self._addSliders()
Пример #13
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...
        # Parameters Area
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parametros"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        # input volume selector
        self.baseSelector = slicer.qMRMLNodeComboBox()
        self.baseSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.baseSelector.selectNodeUponCreation = False
        self.baseSelector.addEnabled = False
        self.baseSelector.removeEnabled = False
        self.baseSelector.noneEnabled = False
        self.baseSelector.showHidden = False
        self.baseSelector.showChildNodeTypes = False
        self.baseSelector.setMRMLScene(slicer.mrmlScene)
        self.baseSelector.setToolTip("Volume base para comparacao")
        parametersFormLayout.addRow("Volume Base: ", self.baseSelector)

        # label 1 volume selector
        self.label1Selector = slicer.qMRMLNodeComboBox()
        self.label1Selector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.label1Selector.selectNodeUponCreation = True
        self.label1Selector.addEnabled = False
        self.label1Selector.removeEnabled = False
        self.label1Selector.noneEnabled = True
        self.label1Selector.showHidden = False
        self.label1Selector.showChildNodeTypes = False
        self.label1Selector.setMRMLScene(slicer.mrmlScene)
        parametersFormLayout.addRow("Label Map 1: ", self.label1Selector)

        self.label1Model = qt.QLabel()
        self.label1Model.enabled = False
        parametersFormLayout.addRow("Model:", self.label1Model)

        # label 2 volume selector
        self.label2Selector = slicer.qMRMLNodeComboBox()
        self.label2Selector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.label2Selector.selectNodeUponCreation = True
        self.label2Selector.addEnabled = False
        self.label2Selector.removeEnabled = False
        self.label2Selector.noneEnabled = True
        self.label2Selector.showHidden = False
        self.label2Selector.showChildNodeTypes = False
        self.label2Selector.setMRMLScene(slicer.mrmlScene)
        parametersFormLayout.addRow("Label Map 2: ", self.label2Selector)

        self.label2Model = qt.QLabel()
        self.label2Model.enabled = False
        parametersFormLayout.addRow("Model:", self.label2Model)

        # threshold value
        self.sliderWidget = ctk.ctkSliderWidget()
        self.sliderWidget.singleStep = 0.1
        self.sliderWidget.minimum = 0
        self.sliderWidget.maximum = 1
        self.sliderWidget.value = 0.5
        self.sliderWidget.enabled = False
        parametersFormLayout.addRow("label 2 <-> Label 1", self.sliderWidget)

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

        # connections
        self.sliderWidget.connect("valueChanged(double)", self.onValueChanged)
        self.baseSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                  self.onSelect)
        self.baseSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                  self.transparencyOnSelect)
        self.baseSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                  self.setBackground)
        self.label1Selector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.transparencyOnSelect)
        self.label1Selector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.setLabel1)
        self.label2Selector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.transparencyOnSelect)
        self.label2Selector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.setLabel2)

        # Refresh Apply button state
        self.onSelect()
Пример #14
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        #
        # input/output collapsible area
        #
        inputOutputCollapsibleButton = ctk.ctkCollapsibleButton()
        inputOutputCollapsibleButton.text = "Input/Output"
        self.layout.addWidget(inputOutputCollapsibleButton)

        # Layout within the i/o collapsible button
        ioFormLayout = qt.QFormLayout(inputOutputCollapsibleButton)

        #
        # input volume selector
        #
        self.inputSelector = ctk.ctkPathLineEdit()
        self.inputSelector.filters = ctk.ctkPathLineEdit.Files
        self.inputSelector.setToolTip("Specify the input dwi")
        ioFormLayout.addRow("Input Volume: ", self.inputSelector)

        #
        # input mask selector
        #
        self.maskSelector = ctk.ctkPathLineEdit()
        self.maskSelector.filters = ctk.ctkPathLineEdit.Files
        self.maskSelector.setToolTip("Specify the mask of input dwi")
        ioFormLayout.addRow("Input Volume Mask: ", self.maskSelector)

        #
        # Create Mask
        #
        self.createMaskCheckBox = qt.QCheckBox('Create the mask')
        self.createMaskCheckBox.toolTip = "Check if you don't have a mask or would like to create one"
        self.createMaskCheckBox.enabled = True
        self.createMaskCheckBox.checked = False
        ioFormLayout.addWidget(self.createMaskCheckBox)
        self.createMask = False

        #
        # output directory selector
        #
        self.outputDirSelector = ctk.ctkPathLineEdit()
        self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
        self.outputDirSelector.setToolTip(
            "Specify the output directory, default: same as input dwi directory"
        )
        ioFormLayout.addRow("Output Directory:", self.outputDirSelector)

        #
        # processing collapsible area
        #
        processCollapsibleButton = ctk.ctkCollapsibleButton()
        processCollapsibleButton.text = "Processing"
        self.layout.addWidget(processCollapsibleButton)

        # Layout within the processing collapsible button
        processFormLayout = qt.QFormLayout(processCollapsibleButton)
        processFormLayout.setSpacing(10)

        #
        # Visual Mode
        #
        self.visualMode = qt.QCheckBox('Slicer Visual Mode')
        self.visualMode.toolTip = '''Uncheck for auto processing w/o
                      Slicer visualization and user interaction'''
        self.visualMode.enabled = True
        self.visualMode.checked = True
        processFormLayout.addWidget(self.visualMode)
        self.autoMode = True  # Default initialization, used to trigger Slicer GUI

        #
        # Process Button
        #
        self.applyButton = qt.QPushButton("Process")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = False
        processFormLayout.addRow(self.applyButton)

        #
        # Progress Bar
        #
        self.progressBar = slicer.qSlicerCLIProgressBar()
        self.progressBar.setToolTip("Progress of the algorithm")
        processFormLayout.addWidget(self.progressBar)

        #
        # Decision Labelling
        #
        self.decisionLabel = qt.QLabel("Gradient information")
        self.decisionLabel.setToolTip(
            "Machine learning decision for current gradient on display")
        self.decisionLabel.setStyleSheet("font: bold")
        processFormLayout.addWidget(self.decisionLabel)

        #
        # Summary Labelling
        #
        self.summaryLabel = qt.QLabel("QC summary")
        self.summaryLabel.setToolTip("Quality check summary")
        self.summaryLabel.setStyleSheet("font: bold")
        processFormLayout.addWidget(self.summaryLabel)

        #
        # Reset Result Button
        #
        self.resetResultsButton = qt.QPushButton("Reset Results")
        self.resetResultsButton.toolTip = "Reset to machine learning results."
        self.resetResultsButton.enabled = True
        processFormLayout.addRow(self.resetResultsButton)

        #
        # Decision collapsible area
        #
        processCollapsibleButton = ctk.ctkCollapsibleButton()
        processCollapsibleButton.text = "Decision"
        self.layout.addWidget(processCollapsibleButton)

        # Layout within the processing collapsible button
        decisionFormLayout = qt.QFormLayout(processCollapsibleButton)
        decisionFormLayout.setSpacing(10)
        # -------------------------------------------------------------------------
        qualityPanel = qt.QHBoxLayout()

        #
        # Keep Gradient Button
        #
        self.keepButton = qt.QPushButton("Keep")
        self.keepButton.toolTip = "Keep the current gradient."
        self.keepButton.enabled = True
        qualityPanel.addWidget(self.keepButton)

        #
        # Discard Gradient Button
        #
        self.discardButton = qt.QPushButton("Discard")
        self.discardButton.toolTip = "Discard the current gradient."
        self.discardButton.enabled = True
        self.discardButton.setStyleSheet("background-color: red")
        qualityPanel.addWidget(self.discardButton)

        decisionFormLayout.addRow(qualityPanel)
        # -------------------------------------------------------------------------

        # -------------------------------------------------------------------------
        confidencePanel = qt.QHBoxLayout()

        #
        # Make it sure Button
        #
        self.sureButton = qt.QPushButton("Sure")
        self.sureButton.toolTip = "Make it sure."
        self.sureButton.enabled = True
        confidencePanel.addWidget(self.sureButton)

        # Make it unsure Button
        #
        self.unsureButton = qt.QPushButton("Unsure")
        self.unsureButton.toolTip = "Make it unsure."
        self.unsureButton.enabled = True
        self.unsureButton.setStyleSheet("background-color: yellow")
        confidencePanel.addWidget(self.unsureButton)

        decisionFormLayout.addRow(confidencePanel)
        # -------------------------------------------------------------------------

        #
        # Next Review Button
        #
        self.nextReviewButton = qt.QPushButton("Next Review")
        self.nextReviewButton.toolTip = "Pull up the next gradient for review."
        self.nextReviewButton.enabled = True
        decisionFormLayout.addRow(self.nextReviewButton)

        #
        # Finish collapsible area
        #
        processCollapsibleButton = ctk.ctkCollapsibleButton()
        processCollapsibleButton.text = "Finish"
        self.layout.addWidget(processCollapsibleButton)

        # Layout within the processing collapsible button
        finishFormLayout = qt.QFormLayout(processCollapsibleButton)

        #
        # Save Result Button
        #
        self.saveResultsButton = qt.QPushButton("Save")
        self.saveResultsButton.toolTip = "Save the results."
        self.saveResultsButton.enabled = True
        finishFormLayout.addRow(self.saveResultsButton)

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

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.inputSelector.connect("currentPathChanged(QString)",
                                   self.onSelectInput)
        self.maskSelector.connect("currentPathChanged(QString)",
                                  self.onSelectMask)
        self.outputDirSelector.connect("currentPathChanged(QString)",
                                       self.onSelectOutput)
        self.visualMode.connect('toggled(bool)', self.onVisualMode)
        self.createMaskCheckBox.connect('toggled(bool)', self.withoutMask)
Пример #15
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # parameters area
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Parameters"
    self.layout.addWidget(parametersCollapsibleButton)
    parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

    # transform of interest selector
    self.transformOfInterestSelectorLabel = qt.QLabel()
    self.transformOfInterestSelectorLabel.setText( "Transform of Interest: " )
    self.transformOfInterestSelector = slicer.qMRMLNodeComboBox()
    self.transformOfInterestSelector.nodeTypes = ( ["vtkMRMLTransformNode"] )
    self.transformOfInterestSelector.noneEnabled = False
    self.transformOfInterestSelector.addEnabled = False
    self.transformOfInterestSelector.removeEnabled = True
    self.transformOfInterestSelector.setMRMLScene( slicer.mrmlScene )
    self.transformOfInterestSelector.setToolTip( "Pick transform of interest (e.g., optical tracker)" )
    parametersFormLayout.addRow(self.transformOfInterestSelectorLabel, self.transformOfInterestSelector)

    # num points selector
    self.numPointsSliderWidget = ctk.ctkSliderWidget()
    self.numPointsSliderWidget.singleStep = 1
    self.numPointsSliderWidget.minimum = 10
    self.numPointsSliderWidget.maximum = 300
    self.numPointsSliderWidget.value = 5
    self.numPointsSliderWidget.setToolTip("Set the number of points to monitor the transform for.")
    parametersFormLayout.addRow("Num Points:", self.numPointsSliderWidget)

    # results form
    resultsCollapsibleButton = ctk.ctkCollapsibleButton()
    resultsCollapsibleButton.text = "Median 3DOF positions of most recent trial"
    self.layout.addWidget(resultsCollapsibleButton)
    resultsFormLayout = qt.QFormLayout(resultsCollapsibleButton)

    self.medianPosXLabel = qt.QLabel("Pos x (mm): ")
    self.medianPosXValueLabel = qt.QLabel()

    self.medianPosYLabel = qt.QLabel("Pos y (mm): ")
    self.medianPosYValueLabel = qt.QLabel()

    self.medianPosZLabel = qt.QLabel("Pos z (mm): ")
    self.medianPosZValueLabel = qt.QLabel()

    resultsFormLayout.addRow(self.medianPosXLabel, self.medianPosXValueLabel)
    resultsFormLayout.addRow(self.medianPosYLabel, self.medianPosYValueLabel)
    resultsFormLayout.addRow(self.medianPosZLabel, self.medianPosZValueLabel)

    # write data and results form
    writeDataCollapsibleButton = ctk.ctkCollapsibleButton()
    writeDataCollapsibleButton.text = "Write data from most recent trial to csv"
    self.layout.addWidget(writeDataCollapsibleButton)
    writeDataFormLayout = qt.QFormLayout(writeDataCollapsibleButton)

    # field of view and positions text boxes
    self.fileDirLabel = "Output Dir:"
    self.fileDirTextBox = qt.QLineEdit()
    self.trackerLabel = "Tracker:"
    self.trackerTextBox = qt.QLineEdit()
    self.fovLabel = "FOV Region:"
    self.fovTextBox = qt.QLineEdit()
    self.posLabel = "Position (#):"
    self.posTextBox = qt.QLineEdit()

    writeDataFormLayout.addRow(self.fileDirLabel, self.fileDirTextBox)
    writeDataFormLayout.addRow(self.trackerLabel, self.trackerTextBox)
    writeDataFormLayout.addRow(self.fovLabel, self.fovTextBox)
    writeDataFormLayout.addRow(self.posLabel, self.posTextBox)

    # start button
    self.startButton = qt.QPushButton("Start Sample Collection")
    self.startButton.toolTip = "Collect a sample."
    self.startButton.enabled = True
    self.layout.addWidget(self.startButton)

    # stop button
    self.stopButton = qt.QPushButton("Stop Sample Collection")
    self.stopButton.toolTip = "Collect a sample."
    self.stopButton.enabled = True
    self.layout.addWidget(self.stopButton)

    # start endless button
    self.startEndlessButton = qt.QPushButton("Start Endless Sample Collection")
    self.startEndlessButton.toolTip = "Collect samples until stop button is pressed (or 20,000 samples is reached)."
    self.startEndlessButton.enabled = True
    self.layout.addWidget(self.startEndlessButton)

    # stop endless button
    self.stopEndlessButton = qt.QPushButton("Stop Endless Sample Collection")
    self.stopEndlessButton.toolTip = "Stop collecting endless samples."
    self.stopEndlessButton.enabled = True
    self.layout.addWidget(self.stopEndlessButton)

    # connections
    self.startButton.connect('clicked(bool)', self.onStart)
    self.stopButton.connect('clicked(bool)', self.onStop)
    self.startEndlessButton.connect('clicked(bool)', self.onStartEndless)
    self.stopEndlessButton.connect('clicked(bool)', self.onStopEndless)

    # Add vertical spacer
    self.layout.addStretch(1)
Пример #16
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...


    #
    # File area
    #
    filesCollapsibleButton = ctk.ctkCollapsibleButton()
    filesCollapsibleButton.text = "Input files"
    filesCollapsibleButton.collapsed = False
    self.layout.addWidget(filesCollapsibleButton)
    # Layout within the files collapsible button
    filesFormLayout = qt.QFormLayout(filesCollapsibleButton)

    # select one file
    buttonLayout = qt.QHBoxLayout()
    self.archetypeText = qt.QLineEdit()
    buttonLayout.addWidget(self.archetypeText)
    self.addFromArchetype = qt.QPushButton("Browse...")
    buttonLayout.addWidget(self.addFromArchetype)
    self.archetypeStartNumber = 0

    filesFormLayout.addRow("Filename pattern: ", buttonLayout)

    # file list group
    fileListGroupBox = ctk.ctkCollapsibleGroupBox()
    fileListGroupBox.title = "File list"
    fileListLayout = qt.QVBoxLayout()
    fileListGroupBox.setLayout(fileListLayout)
    filesFormLayout.addRow("", fileListGroupBox)

    self.addByBrowsingButton = qt.QPushButton("Select files...")
    fileListLayout.addWidget(self.addByBrowsingButton)

    self.fileTable = qt.QTextBrowser()
    fileListLayout.addWidget(self.fileTable)

    fileListGroupBox.collapsed = True

    # original volume size
    self.originalVolumeSizeLabel = qt.QLabel()
    filesFormLayout.addRow("Size: ", self.originalVolumeSizeLabel)

    # reverse slice order
    self.reverseCheckBox = qt.QCheckBox()
    self.reverseCheckBox.toolTip = "Read the images in reverse order (flips loaded volume along IS axis)"
    filesFormLayout.addRow("Reverse: ", self.reverseCheckBox)

    # original spacing
    self.spacingWidget = slicer.qMRMLCoordinatesWidget()
    self.spacingWidget.setMRMLScene(slicer.mrmlScene)
    self.spacingWidget.decimalsOption  = ctk.ctkDoubleSpinBox.DecimalsByKey | ctk.ctkDoubleSpinBox.DecimalsByShortcuts | ctk.ctkDoubleSpinBox.DecimalsByValue
    self.spacingWidget.minimum = 0.0
    self.spacingWidget.maximum = 1000000000.0
    self.spacingWidget.quantity = "length"
    self.spacingWidget.unitAwareProperties = slicer.qMRMLCoordinatesWidget.Precision | slicer.qMRMLCoordinatesWidget.Prefix | slicer.qMRMLCoordinatesWidget.Scaling | slicer.qMRMLCoordinatesWidget.Suffix
    self.spacingWidget.coordinates = "1,1,1"
    self.spacingWidget.toolTip = "Set the colunm, row, slice spacing; original spacing not including downsample"
    filesFormLayout.addRow("Spacing: ", self.spacingWidget)

    #
    # 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.noneDisplay = "(Create new volume)"
    self.outputSelector.setMRMLScene( slicer.mrmlScene )
    self.outputSelector.setToolTip( "Pick the output volume to populate or None to autogenerate." )
    outputFormLayout.addRow("Output Volume: ", self.outputSelector)

    #
    # output ROI selector
    #
    self.outputROISelector = slicer.qMRMLNodeComboBox()
    self.outputROISelector.nodeTypes = ["vtkMRMLAnnotationROINode", "vtkMRMLMarkupsROINode"]
    self.outputROISelector.showChildNodeTypes = False
    self.outputROISelector.showHidden = False
    self.outputROISelector.showChildNodeTypes = False
    self.outputROISelector.noneEnabled = True
    self.outputROISelector.removeEnabled = True
    self.outputROISelector.renameEnabled = True
    self.outputROISelector.addEnabled = False
    self.outputROISelector.noneDisplay = "(Full volume)"
    self.outputROISelector.setMRMLScene( slicer.mrmlScene )
    self.outputROISelector.setToolTip( "Set the region of the volume that will be loaded")
    outputFormLayout.addRow("Region of interest: ", self.outputROISelector)

    #
    # Quality selector
    #
    qualityLayout = qt.QVBoxLayout()
    self.qualityPreviewRadioButton = qt.QRadioButton("preview")
    self.qualityHalfRadioButton = qt.QRadioButton("half resolution")
    self.qualityFullRadioButton = qt.QRadioButton("full resolution")
    qualityLayout.addWidget(self.qualityPreviewRadioButton)
    qualityLayout.addWidget(self.qualityHalfRadioButton)
    qualityLayout.addWidget(self.qualityFullRadioButton)
    self.qualityPreviewRadioButton.setChecked(True)
    outputFormLayout.addRow("Quality: ", qualityLayout)

    self.sliceSkipSpinBox = qt.QSpinBox()
    self.sliceSkipSpinBox.toolTip = "Skips the selected number of slices between each pair of output volume slices (use, for example, on long thin samples with more slices than in-plane resolution)"
    outputFormLayout.addRow("Slice skip: ", self.sliceSkipSpinBox)

    # output volume size
    self.outputVolumeSizeLabel = qt.QLabel()
    outputFormLayout.addRow("Output size: ", self.outputVolumeSizeLabel)

    # output volume spacing
    self.outputSpacingWidget = slicer.qMRMLCoordinatesWidget()
    self.outputSpacingWidget.setMRMLScene(slicer.mrmlScene)
    self.outputSpacingWidget.readOnly = True
    self.outputSpacingWidget.frame = False
    self.outputSpacingWidget.decimalsOption  = ctk.ctkDoubleSpinBox.DecimalsByKey | ctk.ctkDoubleSpinBox.DecimalsByShortcuts | ctk.ctkDoubleSpinBox.DecimalsByValue
    self.outputSpacingWidget.minimum = 0.0
    self.outputSpacingWidget.maximum = 1000000000.0
    self.outputSpacingWidget.quantity = "length"
    self.outputSpacingWidget.unitAwareProperties = slicer.qMRMLCoordinatesWidget.Precision | slicer.qMRMLCoordinatesWidget.Prefix | slicer.qMRMLCoordinatesWidget.Scaling | slicer.qMRMLCoordinatesWidget.Suffix
    self.outputSpacingWidget.coordinates = "1,1,1"
    self.outputSpacingWidget.toolTip = "Slice spacing of the volume that will be loaded"
    outputFormLayout.addRow("Output spacing: ", self.outputSpacingWidget)

    self.loadButton = qt.QPushButton("Load files")
    self.loadButton.toolTip = "Load files as a 3D volume"
    self.loadButton.enabled = False
    outputFormLayout.addRow(self.loadButton)

    # connections
    self.reverseCheckBox.connect('toggled(bool)', self.updateLogicFromWidget)
    self.sliceSkipSpinBox.connect("valueChanged(int)", self.updateLogicFromWidget)
    self.spacingWidget.connect("coordinatesChanged(double*)", self.updateLogicFromWidget)
    self.qualityPreviewRadioButton.connect("toggled(bool)", lambda toggled, widget=self.qualityPreviewRadioButton: self.onQualityToggled(toggled, widget))
    self.qualityHalfRadioButton.connect("toggled(bool)", lambda toggled, widget=self.qualityHalfRadioButton: self.onQualityToggled(toggled, widget))
    self.qualityFullRadioButton.connect("toggled(bool)", lambda toggled, widget=self.qualityFullRadioButton: self.onQualityToggled(toggled, widget))
    self.outputROISelector.connect("currentNodeChanged(vtkMRMLNode*)", self.setOutputROINode)
    self.addByBrowsingButton.connect('clicked()', self.addByBrowsing)
    self.addFromArchetype.connect('clicked()', self.selectArchetype)
    self.archetypeText.connect('textChanged(const QString &)', self.populateFromArchetype)
    self.loadButton.connect('clicked()', self.onLoadButton)

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

    self.loadButton.enabled = False
Пример #17
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...
        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Input Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # Select base mesh
        #
        self.modelSelector = slicer.qMRMLNodeComboBox()
        self.modelSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        self.modelSelector.selectNodeUponCreation = False
        self.modelSelector.addEnabled = False
        self.modelSelector.removeEnabled = False
        self.modelSelector.noneEnabled = True
        self.modelSelector.showHidden = False
        self.modelSelector.setMRMLScene(slicer.mrmlScene)
        parametersFormLayout.addRow("Base mesh: ", self.modelSelector)

        #
        # Set spacing tolerance
        #
        self.spacingTolerance = ctk.ctkSliderWidget()
        self.spacingTolerance.singleStep = .1
        self.spacingTolerance.minimum = 0
        self.spacingTolerance.maximum = 10
        self.spacingTolerance.value = 4
        self.spacingTolerance.setToolTip(
            "Set tolerance of spacing as a percentage of the image diagonal")
        parametersFormLayout.addRow("Spacing tolerance: ",
                                    self.spacingTolerance)

        #
        # Parameters Area
        #
        templateCollapsibleButton = ctk.ctkCollapsibleButton()
        templateCollapsibleButton.text = "Template Geometry"
        self.layout.addWidget(templateCollapsibleButton)

        # Layout within the dummy collapsible button
        templateFormLayout = qt.QFormLayout(templateCollapsibleButton)

        #
        # Select geometry of template
        #
        self.OriginalType = qt.QRadioButton()
        self.OriginalType.setChecked(True)
        self.EllipseType = qt.QRadioButton()
        self.SphereType = qt.QRadioButton()
        templateFormLayout.addRow("Original Geometry", self.OriginalType)
        templateFormLayout.addRow("Ellipse", self.EllipseType)
        templateFormLayout.addRow("Sphere", self.SphereType)

        #
        # Specify plane of symmetry
        #
        self.planeSelector = slicer.qMRMLNodeComboBox()
        self.planeSelector.nodeTypes = (("vtkMRMLMarkupsPlaneNode"), "")
        self.planeSelector.enabled = True
        self.planeSelector.selectNodeUponCreation = False
        self.planeSelector.addEnabled = False
        self.planeSelector.removeEnabled = False
        self.planeSelector.noneEnabled = True
        self.planeSelector.showHidden = False
        self.planeSelector.setMRMLScene(slicer.mrmlScene)
        templateFormLayout.addRow("Symmetry plane: ", self.planeSelector)

        #
        # Set template scale factor
        #
        self.scaleFactor = ctk.ctkSliderWidget()
        self.scaleFactor.enabled = False
        self.scaleFactor.singleStep = 1
        self.scaleFactor.minimum = 75
        self.scaleFactor.maximum = 150
        self.scaleFactor.value = 110
        self.scaleFactor.setToolTip(
            "Set  template scale factor as a percentage of the image diagonal")
        templateFormLayout.addRow("Template scale factor : ", self.scaleFactor)

        #
        # Set max projection factor
        #
        self.projectionFactor = ctk.ctkSliderWidget()
        self.projectionFactor.enabled = False
        self.projectionFactor.singleStep = 1
        self.projectionFactor.minimum = 1
        self.projectionFactor.maximum = 200
        self.projectionFactor.value = 200
        self.projectionFactor.setToolTip(
            "Set maximum projection as a percentage of the image diagonal")
        templateFormLayout.addRow("Maximum projection factor : ",
                                  self.projectionFactor)

        #
        # Run Area
        #
        samplingCollapsibleButton = ctk.ctkCollapsibleButton()
        samplingCollapsibleButton.text = "Run Sampling"
        self.layout.addWidget(samplingCollapsibleButton)

        # Layout within the dummy collapsible button
        samplingFormLayout = qt.QFormLayout(samplingCollapsibleButton)
        #
        # Get Subsample Rate Button
        #
        self.getPointNumberButton = qt.QPushButton("Get subsample number")
        self.getPointNumberButton.toolTip = "Output the number of points sampled on the template shape."
        self.getPointNumberButton.enabled = False
        samplingFormLayout.addRow(self.getPointNumberButton)

        #
        # Subsample Information
        #
        self.subsampleInfo = qt.QPlainTextEdit()
        self.subsampleInfo.setPlaceholderText("Subsampling information")
        self.subsampleInfo.setReadOnly(True)
        samplingFormLayout.addRow(self.subsampleInfo)

        #
        # Apply sphere button
        #
        self.applySphereButton = qt.QPushButton("Generate template")
        self.applySphereButton.toolTip = "Generate sampled template shape."
        self.applySphereButton.enabled = False
        samplingFormLayout.addRow(self.applySphereButton)

        #
        # Project Points button
        #
        self.projectPointsButton = qt.QPushButton("Project points to surface")
        self.projectPointsButton.toolTip = "Project the points from the sampled template to the model surface."
        self.projectPointsButton.enabled = False
        samplingFormLayout.addRow(self.projectPointsButton)

        #
        # Clean Points button
        #
        self.cleanButton = qt.QPushButton("Enforce spatial sampling rate")
        self.cleanButton.toolTip = "Remove points spaced closer than the user-specified tolerance."
        self.cleanButton.enabled = False
        samplingFormLayout.addRow(self.cleanButton)

        # connections
        self.modelSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.onSelect)
        self.OriginalType.connect('toggled(bool)', self.onToggleModel)
        self.getPointNumberButton.connect('clicked(bool)',
                                          self.onGetPointNumberButton)
        self.applySphereButton.connect('clicked(bool)',
                                       self.onApplySphereButton)
        self.projectPointsButton.connect('clicked(bool)',
                                         self.onProjectPointsButton)
        self.cleanButton.connect('clicked(bool)', self.onCleanButton)

        # Add vertical spacer
        self.layout.addStretch(1)
Пример #18
0
    def setup(self):
        # Instantiate and connect widgets ...
        ScriptedLoadableModuleWidget.setup(self)

        #self.logic = CIP_CalciumScoringLogic()

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # target volume selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.noneEnabled = False
        self.inputSelector.showHidden = False
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.setMRMLScene( slicer.mrmlScene )
        self.inputSelector.setToolTip( "Pick the input to the algorithm." )
        parametersFormLayout.addRow("Target Volume: ", self.inputSelector)
        self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onVolumeChanged)
        self.volumeNode = self.inputSelector.currentNode()
        
        #
        # calcification type
        #
#        self.calcificationTypeBox = qt.QComboBox()
#        self.calcificationTypeBox.addItem("Heart")
#        self.calcificationTypeBox.addItem("Aorta")
#        parametersFormLayout.addRow("Region", self.calcificationTypeBox)
#        self.calcificationTypeBox.connect("currentIndexChanged(int)", self.onTypeChanged)

        self.ThresholdRange = ctk.ctkRangeWidget()
        self.ThresholdRange.minimum = 0
        self.ThresholdRange.maximum = 2000
        self.ThresholdRange.setMinimumValue(self.ThresholdMin)
        self.ThresholdRange.setMaximumValue(self.ThresholdMax)
        self.ThresholdRange.connect("minimumValueChanged(double)", self.onThresholdMinChanged)
        self.ThresholdRange.connect("maximumValueChanged(double)", self.onThresholdMaxChanged)
        parametersFormLayout.addRow("Threshold Value", self.ThresholdRange)
        self.ThresholdRange.setMinimumValue(self.ThresholdMin)
        self.ThresholdRange.setMaximumValue(self.ThresholdMax)

        self.LesionSizeRange= ctk.ctkRangeWidget()
        self.LesionSizeRange.minimum = 0.5
        self.LesionSizeRange.maximum = 1000
        self.LesionSizeRange.setMinimumValue(self.MinimumLesionSize)
        self.LesionSizeRange.setMaximumValue(self.MaximumLesionSize)
        self.LesionSizeRange.connect("minimumValueChanged(double)", self.onMinSizeChanged)
        self.LesionSizeRange.connect("maximumValueChanged(double)", self.onMaxSizeChanged)
        parametersFormLayout.addRow("Lesion Size (mm^3)", self.LesionSizeRange)
        self.LesionSizeRange.setMinimumValue(self.MinimumLesionSize)
        self.LesionSizeRange.setMaximumValue(self.MaximumLesionSize)

        self.scoreField=dict()
        for sr in self.summary_reports:
          self.scoreField[sr] = qt.QLineEdit()
          self.scoreField[sr].setText(0)
          parametersFormLayout.addRow("Total "+sr, self.scoreField[sr])
        
        
        #
        # Update button and Select Table
        #
        
        self.updateButton = qt.QPushButton("Update")
        self.updateButton.toolTip = "Update calcium score computation"
        self.updateButton.enabled = True
        self.updateButton.setFixedSize(100, 50)
        #parametersFormLayout.addRow("", self.updateButton)
        
        self.updateButton.connect('clicked()', self.onUpdate)
        
        #
        # Select table
        #
        self.selectLabels = qt.QTableWidget()
        #self.selectLabels.horizontalHeader().hide()
        self.selectLabels.verticalHeader().hide()
        self.selectLabels.setColumnCount(6)
        self.selectLabels.itemClicked.connect(self.handleItemClicked)
        
        #Add row with columns name
        col_names=["","Agatston Score","Mass Score","Volume (mm^3)","Mean HU","Max HU"]
        self.selectLabels.setHorizontalHeaderLabels(col_names)
        
        parametersFormLayout.addRow(self.updateButton, self.selectLabels)


        #
        # Save Widget Area
        #

        #self.saveCollapsibleButton = ctk.ctkCollapsibleButton()
        #self.saveCollapsibleButton.text = "Saving"
        #self.layout.addWidget(self.saveCollapsibleButton)

        self.reportsWidget = CaseReportsWidget(self.moduleName, self.columnsDict, parentWidget=self.parent)
        self.reportsWidget.setup()
        self.reportsWidget.showPrintButton(False)
        
        self.reportsWidget.addObservable(self.reportsWidget.EVENT_SAVE_BUTTON_CLICKED, self.onSaveReport)

        #
        # ROI Area
        #
        self.roiCollapsibleButton = ctk.ctkCollapsibleButton()
        self.roiCollapsibleButton.text = "ROI"
        self.roiCollapsibleButton.setChecked(False)
        self.layout.addWidget(self.roiCollapsibleButton)

        # Layout within the dummy collapsible button
        roiFormLayout = qt.QFormLayout(self.roiCollapsibleButton)

        #
        # ROI
        #
        self.ROIWidget = slicer.qMRMLAnnotationROIWidget()
        self.roiNode = slicer.vtkMRMLAnnotationROINode()
        slicer.mrmlScene.AddNode(self.roiNode)
        self.ROIWidget.setMRMLAnnotationROINode(self.roiNode)
        roiFormLayout.addRow("", self.ROIWidget)
        #self.roiNode.AddObserver("ModifiedEvent", self.onROIChangedEvent, 1)

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

        # Add temp nodes
        self.croppedNode=slicer.vtkMRMLScalarVolumeNode()
        self.croppedNode.SetHideFromEditors(1)
        slicer.mrmlScene.AddNode(self.croppedNode)
        self.labelsNode=slicer.vtkMRMLLabelMapVolumeNode()
        slicer.mrmlScene.AddNode(self.labelsNode)
        
        if self.inputSelector.currentNode():
            self.onVolumeChanged(self.inputSelector.currentNode())
Пример #19
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

    #
    # Parameters Area
    #
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Parameters"
    self.layout.addWidget(parametersCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

    #
    # input volume selector
    #
    self.inputSelector = slicer.qMRMLNodeComboBox()
    self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputSelector.selectNodeUponCreation = True
    self.inputSelector.addEnabled = False
    self.inputSelector.removeEnabled = False
    self.inputSelector.noneEnabled = False
    self.inputSelector.showHidden = False
    self.inputSelector.showChildNodeTypes = False
    self.inputSelector.setMRMLScene( slicer.mrmlScene )
    self.inputSelector.setToolTip( "Pick the input to the algorithm." )
    parametersFormLayout.addRow("Input Volume: ", self.inputSelector)

    #
    # 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.imageThresholdSliderWidget = ctk.ctkSliderWidget()
    self.imageThresholdSliderWidget.singleStep = 0.1
    self.imageThresholdSliderWidget.minimum = -100
    self.imageThresholdSliderWidget.maximum = 100
    self.imageThresholdSliderWidget.value = 0.5
    self.imageThresholdSliderWidget.setToolTip("Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero.")
    parametersFormLayout.addRow("Image threshold", self.imageThresholdSliderWidget)

    #
    # 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.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

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

    # Refresh Apply button state
    self.onSelect()
Пример #20
0
    def setup(self):
        """This is called one time when the module GUI is initialized
        """
        ScriptedLoadableModuleWidget.setup(self)

        # Create objects that can be used anywhere in the module. Example: in most cases there should be just one
        # object of the logic class
        self._initLogic_()
        self.currentVolumeLoaded = None
        self.blockNodeEvents = False

        ##########
        # Volume selection
        self.volumeSelectionCollapsibleButton = ctk.ctkCollapsibleButton()
        self.volumeSelectionCollapsibleButton.text = "Volume selection"
        self.layout.addWidget(self.volumeSelectionCollapsibleButton)
        self.volumeSelectionLayout = qt.QFormLayout(
            self.volumeSelectionCollapsibleButton)

        # Node selector
        # volumeLabel = qt.QLabel("Active volume: ")
        # volumeLabel.setStyleSheet("margin-left:5px")
        # self.mainLayout.addWidget(volumeLabel, 0, 0)
        self.volumeSelector = slicer.qMRMLNodeComboBox()
        self.volumeSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.volumeSelector.selectNodeUponCreation = True
        self.volumeSelector.autoFillBackground = True
        self.volumeSelector.addEnabled = False
        self.volumeSelector.noneEnabled = False
        self.volumeSelector.removeEnabled = False
        self.volumeSelector.showHidden = False
        self.volumeSelector.showChildNodeTypes = False
        self.volumeSelector.setMRMLScene(slicer.mrmlScene)
        # self.volumeSelector.setFixedWidth(250)
        # self.volumeSelector.setStyleSheet("margin: 15px 0")
        # self.volumeSelector.selectNodeUponCreation = False
        #self.volumeSelectionLayout.addWidget(self.volumeSelector, 0, 1, 1, 3)
        self.volumeSelectionLayout.addRow("Active volume:",
                                          self.volumeSelector)
        self.volumeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                    self.__onCurrentNodeChanged__)

        ##########
        # Main area
        self.mainAreaCollapsibleButton = ctk.ctkCollapsibleButton()
        self.mainAreaCollapsibleButton.text = "Main area"
        self.layout.addWidget(self.mainAreaCollapsibleButton,
                              SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.mainLayout = qt.QGridLayout(self.mainAreaCollapsibleButton)

        # Radio buttons frame. This will be filled by every child module
        self.radioButtonsFrame = qt.QFrame()
        self.mainLayout.addWidget(self.radioButtonsFrame, 2, 0, 1, 3,
                                  SlicerUtil.ALIGNMENT_VERTICAL_TOP)

        # Load caselist button
        self.loadButton = ctk.ctkPushButton()
        self.loadButton.text = "Load fiducials file"
        self.loadButton.setIcon(
            qt.QIcon("{0}/open_file.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.loadButton.setIconSize(qt.QSize(20, 20))
        self.loadButton.setFixedWidth(135)
        self.mainLayout.addWidget(self.loadButton, 3, 0)
        self.loadButton.connect('clicked()', self.openFiducialsFile)

        # Remove fiducial button
        self.removeLastFiducialButton = ctk.ctkPushButton()
        self.removeLastFiducialButton.text = "Remove last fiducial"
        self.removeLastFiducialButton.toolTip = "Remove the last fiducial added"
        self.removeLastFiducialButton.setIcon(
            qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.removeLastFiducialButton.setIconSize(qt.QSize(20, 20))
        self.removeLastFiducialButton.setFixedWidth(200)
        self.mainLayout.addWidget(self.removeLastFiducialButton, 3, 1)
        self.removeLastFiducialButton.connect(
            'clicked()', self.__onRemoveLastFiducialButtonClicked__)

        # Save results button
        self.saveResultsButton = ctk.ctkPushButton()
        self.saveResultsButton.setText("Save markups")
        self.saveResultsButton.toolTip = "Save the markups in the specified directory"
        self.saveResultsButton.setIcon(
            qt.QIcon("{0}/Save.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.saveResultsButton.setIconSize(qt.QSize(20, 20))
        self.saveResultsButton.setFixedWidth(135)
        self.mainLayout.addWidget(self.saveResultsButton, 4, 0)
        self.saveResultsButton.connect('clicked()',
                                       self.__onSaveResultsButtonClicked__)

        # Save results directory button
        defaultPath = os.path.join(
            SlicerUtil.getSettingsDataFolder(self.moduleName),
            "results")  # Assign a default path for the results
        path = SlicerUtil.settingGetOrSetDefault(self.moduleName,
                                                 "SaveResultsDirectory",
                                                 defaultPath)
        self.saveResultsDirectoryButton = ctk.ctkDirectoryButton()
        self.saveResultsDirectoryButton.directory = path
        self.saveResultsDirectoryButton.setMaximumWidth(375)
        self.mainLayout.addWidget(self.saveResultsDirectoryButton, 4, 1, 1, 2)
        self.saveResultsDirectoryButton.connect(
            "directoryChanged (QString)",
            self.__onSaveResultsDirectoryChanged__)

        #####
        # Case navigator
        self.caseNavigatorWidget = None
        if SlicerUtil.isSlicerACILLoaded():
            caseNavigatorAreaCollapsibleButton = ctk.ctkCollapsibleButton()
            caseNavigatorAreaCollapsibleButton.text = "Case navigator"
            self.layout.addWidget(caseNavigatorAreaCollapsibleButton, 0x0020)
            # caseNavigatorLayout = qt.QVBoxLayout(caseNavigatorAreaCollapsibleButton)

            # Add a case list navigator
            from ACIL.ui import CaseNavigatorWidget
            self.caseNavigatorWidget = CaseNavigatorWidget(
                self.moduleName, caseNavigatorAreaCollapsibleButton)
            for key, value in self.additionalFileTypes.iteritems():
                self.caseNavigatorWidget.additionalFileTypes[key] = value
            self.caseNavigatorWidget.setup()
            # Listen for the event of loading a new labelmap
            # self.caseNavigatorWidget.addObservable(self.caseNavigatorWidget.EVENT_LABELMAP_LOADED, self.__onNewILDClassificationLabelmapLoaded__)
            self.caseNavigatorWidget.addObservable(
                self.caseNavigatorWidget.EVENT_BUNDLE_CASE_FINISHED,
                self._onFinishCaseBundleLoad_)

        self.layout.addStretch()

        # Extra Connections
        self._createSceneObservers_()
Пример #21
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.predictionUrl = ''
        self.interfaceUrl = ''
        self.clearToSendMsg = False
        # Instantiate and connect widgets ...

        #
        # LOGO area
        #
        logoCollapsibleButton = collapsible_button('Info')

        self.layout.addWidget(logoCollapsibleButton)
        self.logolayout = qt.QFormLayout(logoCollapsibleButton)

        self.logolabel, _ = \
          add_image(os.path.join(os.path.split(os.path.realpath(__file__))[0], "Resources/Icons/TOMAAT_INFO.png"))

        self.logolayout.addRow(self.logolabel)

        #
        # Direct Connection area
        #
        directConnectionCollapsibleButton = collapsible_button(
            'Direct Connection')
        self.layout.addWidget(directConnectionCollapsibleButton)
        self.directConnectionLayout = qt.QFormLayout(
            directConnectionCollapsibleButton)

        self.urlBoxDirectConnection = add_textbox("http://localhost:9000")

        self.urlBoxButton = add_button(text='Confirm',
                                       tooltip_text='Confirm entry',
                                       click_function=self.select_from_textbox,
                                       enabled=True)

        self.directConnectionLayout.addRow("Server URL: ",
                                           self.urlBoxDirectConnection)

        self.directConnectionLayout.addRow(self.urlBoxButton)

        directConnectionCollapsibleButton.collapsed = True

        #
        # Managed Connection area
        #
        managedConenctionCollapsibleButton = collapsible_button(
            'Public Server List')
        self.layout.addWidget(managedConenctionCollapsibleButton)

        self.managedConnectionLayout = qt.QFormLayout(
            managedConenctionCollapsibleButton)

        self.urlBoxManagedConnection = add_textbox(
            "http://tomaat.cloud:8001/discover")

        self.managedConnectionLayout.addRow("Discovery Server URL: ",
                                            self.urlBoxManagedConnection)

        self.serviceTree = qt.QTreeWidget()
        self.serviceTree.setHeaderLabel('Available services')
        self.serviceTree.itemSelectionChanged.connect(self.select_from_tree)

        self.discoverServicesButton = add_button(
            "Discover Services",
            "Discover available segmentation services on the net.",
            self.onDiscoverButton, True)

        self.serviceDescription = add_label('')

        self.managedConnectionLayout.addRow(self.discoverServicesButton)

        self.managedConnectionLayout.addRow(self.serviceTree)

        self.managedConnectionLayout.addRow(self.serviceDescription)

        self.processingCollapsibleButton = None
Пример #22
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # input volume selector
        #
        with It(slicer.qMRMLNodeComboBox()) as w:
            self.inputSelector = w
            w.nodeTypes = ["vtkMRMLFiberBundleNode"]
            w.selectNodeUponCreation = True
            w.addEnabled = False
            w.removeEnabled = False
            w.noneEnabled = False
            w.showHidden = False
            w.showChildNodeTypes = False
            w.setMRMLScene(slicer.mrmlScene)
            w.setToolTip("Pick the fiber bundle to export.")
            parametersFormLayout.addRow("Input FiberBundleNode: ",
                                        self.inputSelector)

        #
        # tube radius controller
        #
        with It(ctk.ctkSliderWidget()) as w:
            self.radiusSelector = w
            w.minimum = 0.1
            w.maximum = 20.0
            w.singleStep = 0.1
            w.setToolTip("Select radius for output tubes")
            parametersFormLayout.addRow("Tube radius: ", self.radiusSelector)

        with It(ctk.ctkSliderWidget()) as w:
            self.numSidesSelector = w
            w.value = 6
            w.decimals = 0
            w.minimum = 3
            w.maximum = 20
            w.singleStep = 1
            w.pageStep = 1
            w.setToolTip(
                "Select number of sides for output tube: higher number will look nicer, but will take more memory and time to export."
            )
            parametersFormLayout.addRow("Number of sides: ",
                                        self.numSidesSelector)

        #
        # use native scalar range
        #
        with It(qt.QCheckBox()) as w:
            self.nativeRangeCheckbox = w
            w.checked = True
            w.setToolTip(
                "Checked: set the scalar range of the exported color table to match the scalar range of the selected node. Otherwise, the range will be set to [0,1]."
            )
            parametersFormLayout.addRow("Restrict scalar range", w)

        #
        # output file selector, export button, and status frame
        #
        with It(ctk.ctkPathLineEdit()) as w:
            self.outputFileSelector = w
            # make a file-only, save dialog
            w.filters = ctk.ctkPathLineEdit.Files | ctk.ctkPathLineEdit.Writable
            w.connect('currentPathChanged(const QString&)', self.reset)
            parametersFormLayout.addRow("Output File: ",
                                        self.outputFileSelector)

        with It(qt.QPushButton("Export")) as w:
            self.exportButton = w
            w.toolTip = "Run Export"
            w.styleSheet = "background: lightgray"
            w.connect('clicked(bool)', self.onExport)
            parametersFormLayout.addRow("", w)

        with It(qt.QStatusBar()) as w:
            self.statusLabel = w
            w.setToolTip("CLI status")
            w.styleSheet = "background: lightgray"
            parametersFormLayout.addRow("Status: ", w)

        # Add vertical spacer
        self.layout.addStretch(1)
Пример #23
0
    def setup_registration_area(self):
        """
        Setup image registration area and connect functions.
        """

        registration_collapsible_button = ctk.ctkCollapsibleButton()
        registration_collapsible_button.text = "Register Image to Frame"
        registration_collapsible_button.setDisabled(False)
        registration_collapsible_button.collapsed = False
        self.layout.addWidget(registration_collapsible_button)

        # Layout within the dummy collapsible button
        registration_form_layout = qt.QFormLayout(
            registration_collapsible_button)

        #
        # input fiducial list selector
        #

        fiducial_warning_label = qt.QLabel(
            "Note: Parent transforms of fiducials are not used. "
            "Fiducials should be defined in the coordinate system "
            "that is being registered.")
        fiducial_warning_label.setWordWrap(True)
        registration_form_layout.addRow(fiducial_warning_label)

        self.input_fiducial_selector = slicer.qMRMLNodeComboBox()
        self.input_fiducial_selector.nodeTypes = ((
            "vtkMRMLMarkupsFiducialNode"), "")
        self.input_fiducial_selector.selectNodeUponCreation = False
        self.input_fiducial_selector.addEnabled = False
        self.input_fiducial_selector.removeEnabled = False
        self.input_fiducial_selector.noneEnabled = True
        self.input_fiducial_selector.showHidden = False
        self.input_fiducial_selector.showChildNodeTypes = False
        self.input_fiducial_selector.setMRMLScene(slicer.mrmlScene)
        self.input_fiducial_selector.setToolTip(
            "Pick the input fiducial list for the algorithm.")
        registration_form_layout.addRow("Input fiducials: ",
                                        self.input_fiducial_selector)

        #
        # input volume selector
        #
        self.input_volume_selector = slicer.qMRMLNodeComboBox()
        self.input_volume_selector.nodeTypes = (("vtkMRMLScalarVolumeNode"),
                                                "")
        self.input_volume_selector.selectNodeUponCreation = False
        self.input_volume_selector.addEnabled = False
        self.input_volume_selector.removeEnabled = False
        self.input_volume_selector.noneEnabled = True
        self.input_volume_selector.showHidden = False
        self.input_volume_selector.showChildNodeTypes = False
        self.input_volume_selector.setMRMLScene(slicer.mrmlScene)
        self.input_volume_selector.setToolTip(
            "Pick the input volume for the algorithm.")
        registration_form_layout.addRow("Input Volume: ",
                                        self.input_volume_selector)

        # Register Button
        self.apply_reg_button = qt.QPushButton("Apply")
        self.apply_reg_button.toolTip = "Run the algorithm."
        self.apply_reg_button.enabled = False
        registration_form_layout.addRow(self.apply_reg_button)

        # Connect Procedures
        # Image to Frame Registration
        self.apply_reg_button.connect("clicked(bool)", self.onapply_reg_button)
        self.input_volume_selector.connect("currentNodeChanged(vtkMRMLNode*)",
                                           self.on_registration_select)
        self.input_fiducial_selector.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.on_registration_select)
    def setup(self):

        #->> TODO could also specify with Qt Designer instead in future (QtUiTools)

        # IO COLLAPSIBLE BUTTON
        ioCollapsibleButton = ctk.ctkCollapsibleButton()
        ioCollapsibleButton.text = "IO"
        self.layout.addWidget(ioCollapsibleButton)

        # Layout within the io collapsible button
        ioFormLayout = qt.QFormLayout(ioCollapsibleButton)

        # inputVolume node selector 1
        inputNodeSelector1 = slicer.qMRMLNodeComboBox()
        inputNodeSelector1.objectName = 'inputNodeSelector1'
        inputNodeSelector1.toolTip = "Select the 1st input volume to be segmented."
        inputNodeSelector1.nodeTypes = ['vtkMRMLScalarVolumeNode']
        inputNodeSelector1.noneEnabled = False
        inputNodeSelector1.addEnabled = False
        inputNodeSelector1.removeEnabled = False
        inputNodeSelector1.editEnabled = True
        inputNodeSelector1.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.setInputNode1)
        ioFormLayout.addRow("Input Volume 1:", inputNodeSelector1)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            inputNodeSelector1, 'setMRMLScene(vtkMRMLScene*)')
        self.inputNodeSelector1 = inputNodeSelector1

        #->> TODO for all parameters, provide slots to set them, and use internal values to eventually pass them into the PDF segmenter - for using the interactive PDF segmenter somewhere else, ex in editor module

        # inputVolume node selector 2
        inputNodeSelector2 = slicer.qMRMLNodeComboBox()
        inputNodeSelector2.objectName = 'inputNodeSelector2'
        inputNodeSelector2.toolTip = "Select the 2nd input volume to be segmented."
        inputNodeSelector2.nodeTypes = ['vtkMRMLScalarVolumeNode']
        inputNodeSelector2.noneEnabled = True
        inputNodeSelector2.addEnabled = False
        inputNodeSelector2.removeEnabled = False
        inputNodeSelector2.editEnabled = True
        inputNodeSelector2.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.setInputNode2)
        ioFormLayout.addRow("Input Volume 2 (optional):", inputNodeSelector2)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            inputNodeSelector2, 'setMRMLScene(vtkMRMLScene*)')
        self.inputNodeSelector2 = inputNodeSelector2

        # inputVolume node selector 3
        inputNodeSelector3 = slicer.qMRMLNodeComboBox()
        inputNodeSelector3.objectName = 'inputNodeSelector3'
        inputNodeSelector3.toolTip = "Select the 3rd input volume to be segmented."
        inputNodeSelector3.nodeTypes = ['vtkMRMLScalarVolumeNode']
        inputNodeSelector3.noneEnabled = True
        inputNodeSelector3.addEnabled = False
        inputNodeSelector3.removeEnabled = False
        inputNodeSelector3.editEnabled = True
        inputNodeSelector3.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.setInputNode3)
        ioFormLayout.addRow("Input Volume 3 (optional):", inputNodeSelector3)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            inputNodeSelector3, 'setMRMLScene(vtkMRMLScene*)')
        self.inputNodeSelector3 = inputNodeSelector3

        # outputVolume node selector
        outputNodeSelector = slicer.qMRMLNodeComboBox()
        outputNodeSelector.objectName = 'outputNodeSelector'
        outputNodeSelector.toolTip = "Select the output volume to be segmented."
        outputNodeSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        outputNodeSelector.noneEnabled = False
        outputNodeSelector.addEnabled = True
        outputNodeSelector.removeEnabled = False
        outputNodeSelector.editEnabled = True
        outputNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.setOutputNode)
        ioFormLayout.addRow("Output Volume:", outputNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            outputNodeSelector, 'setMRMLScene(vtkMRMLScene*)')
        self.outputNodeSelector = outputNodeSelector

        # LABEL MAP COLLAPSIBLE BUTTON

        labelMapCollapsibleButton = ctk.ctkCollapsibleButton()
        labelMapCollapsibleButton.text = "Label Maps"
        self.layout.addWidget(labelMapCollapsibleButton)

        # Layout within the labelMap collapsible button
        labelMapFormLayout = qt.QFormLayout(labelMapCollapsibleButton)

        # labelMap node selector
        labelMapNodeSelector = slicer.qMRMLNodeComboBox()
        labelMapNodeSelector.objectName = 'labelMapNodeSelector'
        labelMapNodeSelector.toolTip = "Select the label map roughly outlining the structure to be segmented and its background."
        labelMapNodeSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        labelMapNodeSelector.addAttribute("vtkMRMLScalarVolumeNode",
                                          "LabelMap", True)
        labelMapNodeSelector.noneEnabled = False
        labelMapNodeSelector.addEnabled = True
        labelMapNodeSelector.removeEnabled = False
        labelMapNodeSelector.editEnabled = True
        labelMapNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                     self.setLabelMapNode)
        labelMapFormLayout.addRow("Label Map:", labelMapNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            labelMapNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')
        self.labelMapNodeSelector = labelMapNodeSelector

        # Create frame editor widget
        editorFrame = qt.QFrame()
        editorFrame.setLayout(qt.QVBoxLayout())
        palette = editorFrame.palette
        bgColor = 240
        palette.setColor(qt.QPalette.Background,
                         qt.QColor(bgColor, bgColor, bgColor))
        editorFrame.setPalette(palette)
        editorFrame.setAutoFillBackground(True)
        labelMapFormLayout.addRow(editorFrame)
        self.editorFrame = editorFrame

        # initialize editor widget: using parent frame, embedded is true and list of effects
        self.editorWidget = __main__.EditorWidget(
            parent=self.editorFrame,
            embedded=True,
            suppliedEffects=self.editorEffects,
            showVolumesFrame=False)

        # voidLabel selector
        # The voidLabel selector selects which label corresponds to the void label
        # All other labels in the label map will be extracted and set to object labels
        voidLabelSpinBox = qt.QSpinBox()
        voidLabelSpinBox.objectName = 'voidLabelSpinBox'
        voidLabelSpinBox.toolTip = "Value that represents nothing in the label map.  All other labels represent objects."
        voidLabelSpinBox.setMinimum(0)
        voidLabelSpinBox.setMaximum(255)  # temporary value to start
        voidLabelSpinBox.enabled = False
        labelMapFormLayout.addRow("Void Id:", voidLabelSpinBox)
        self.voidLabelSpinBox = voidLabelSpinBox

        #->> TODO: later on, would like a label combo box that shows only those labels
        # that are included in the label map
        # The following code starts in that direction, but does not work

        # BEGIN hacking
        ##  voidLabelSelector = slicer.qMRMLLabelComboBox()
        ##  voidLabelSelector.maximumColorCount = 256 #->> TODO
        ##  labelMapFormLayout.addRow("Void Label:", voidLabelSelector)
        ##  self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
        ##                      voidLabelSelector, 'setMRMLScene(vtkMRMLScene*)')
        ##  # create a new vtkMRMLColorTableNode to hold the labels in the label map
        ##  colorLogic = slicer.vtkSlicerColorLogic()
        ##  defaultID = colorLogic.GetDefaultEditorColorNodeID()
        ##  defaultNode = slicer.mrmlScene.GetNodeByID(defaultID)
        ##  if defaultNode:
        ##    # create the node based on the default editor color node
        ##    self.labelsColorNode = slicer.vtkMRMLColorTableNode()
        ##    self.labelsColorNode.Copy(defaultNode)
        ##    # substitute in a new lookup table that we will manipulate
        ##    lookupTable = vtk.vtkLookupTable()
        ##    lookupTable.DeepCopy(defaultNode.GetLookupTable())
        ##    defaultLookupTable = defaultNode.GetLookupTable()
        ##    list = [3,5,7,9]
        ##    lookupTable.SetNumberOfTableValues(len(list))
        ##    for i in range(0, len(list)):
        ##      orig = []
        ##      defaultLookupTable.GetTableValue(list[i], orig)
        ##      lookupTable.SetTableValue(i, defaultNode.GetLookupTable().
        ##    self.labelsColorNode.SetLookupTable(lookupTable)
        ##    # set the new color node to the selector
        ##    # voidLabelSelector.setMRMLColorNode(self.labelsColorNode)
        ##    print "lut:", self.labelsColorNode.GetLookupTable()
        ## self.voidLabelSelector = voidLabelSelector
        # END hacking

        #->> TODO: another alternative is to use an EditColor - but it is heavily coupled
        # to the editor logic, using an editor parameter node that ties it with the editor
        # widget's EditColor
        # Create a frame to give the EditColor a suitable parent
        ## voidLabelFrame = qt.QFrame()
        ## voidLabelFrame.setLayout(qt.QHBoxLayout())
        ## voidLabelFrame.toolTip = "Value that represents nothing in the label map.  All labels not equal to the void id represent objects."
        ## voidLabelSelector = EditorLib.EditColor(parent=voidLabelFrame)
        ## labelMapFormLayout.addRow("Void Id", voidLabelFrame)
        ## self.voidLabelSelector = voidLabelSelector

        # SEGMENTATION PARAMETERS COLLAPSIBLE BUTTON
        segmentationCollapsibleButton = ctk.ctkCollapsibleButton()
        segmentationCollapsibleButton.text = "Segmentation Parameters"
        self.layout.addWidget(segmentationCollapsibleButton)

        # Layout within the parameters collapsible button
        segmentationFormLayout = qt.QFormLayout(segmentationCollapsibleButton)

        # segmentation "goal" buttons
        self.goalButtonList = []
        goalButtonGroup = qt.QButtonGroup()
        goalGroupBox = qt.QGroupBox()
        goalGroupBox.objectName = 'goalGroupBox'
        goalGroupBox.toolTip = "Select what the goal segmentation looks like"
        goalGroupBoxLayout = qt.QHBoxLayout()

        for i in range(0, len(self.goalButtonTexts)):
            button = qt.QToolButton()
            button.setText(self.goalButtonTexts[i])
            button.setCheckable(True)
            goalButtonGroup.addButton(button, i)
            goalGroupBoxLayout.addWidget(button)
            self.goalButtonList.append(button)

        self.goalButtonList[self.goalButtonDefault].setChecked(True)

        goalButtonGroup.setExclusive(True)
        goalButtonGroup.connect('buttonClicked(int)',
                                self.setGoalSegmentationType)
        goalGroupBox.setLayout(goalGroupBoxLayout)
        goalGroupBox.setFlat(True)

        segmentationFormLayout.addRow("Goal Segmentation:", goalGroupBox)
        self.goalButtonGroup = goalButtonGroup

        # ADVANCED PARAMETERS COLLAPSIBLE BUTTON
        advancedCollapsibleButton = ctk.ctkCollapsibleButton()
        advancedCollapsibleButton.text = "Advanced Parameters"
        self.layout.addWidget(advancedCollapsibleButton)

        # Layout within the parameters collapsible button
        advancedFormLayout = qt.QFormLayout(advancedCollapsibleButton)

        # Erosion radius spin box
        erosionSpinBox = qt.QSpinBox()
        erosionSpinBox.objectName = 'erosionSpinBox'
        erosionSpinBox.toolTip = "Set the erosion radius."
        erosionSpinBox.setMinimum(0)
        erosionSpinBox.connect('valueChanged(int)', self.setErosionRadius)
        advancedFormLayout.addRow("Erosion Radius:", erosionSpinBox)
        self.erosionSpinBox = erosionSpinBox

        # Hole fill iterations spin box
        holeFillSpinBox = qt.QSpinBox()
        holeFillSpinBox.objectName = 'holeFillSpinBox'
        holeFillSpinBox.toolTip = "Set the number of hole filling iterations."
        holeFillSpinBox.setMinimum(0)
        holeFillSpinBox.connect('valueChanged(int)',
                                self.setHoleFillIterations)
        advancedFormLayout.addRow("Hole Fill Iterations:", holeFillSpinBox)
        self.holeFillSpinBox = holeFillSpinBox

        # falsePositiveRatio spin box
        falsePositiveRatioSpinBox = qt.QDoubleSpinBox()
        falsePositiveRatioSpinBox.objectName = 'falsePositiveRatioSpinBox'
        falsePositiveRatioSpinBox.toolTip = "Relative Cost of False Positive vs. false negative."
        falsePositiveRatioSpinBox.setMinimum(0.0)
        falsePositiveRatioSpinBox.setValue(1.0)  # Default
        falsePositiveRatioSpinBox.setSingleStep(0.1)
        advancedFormLayout.addRow("False Positive Ratio:",
                                  falsePositiveRatioSpinBox)
        self.falsePositiveRatioSpinBox = falsePositiveRatioSpinBox

        # probabilitySmoothingStandardDeviation spin box
        probabilitySmoothingStdDevSpinBox = qt.QDoubleSpinBox()
        probabilitySmoothingStdDevSpinBox.objectName = 'probabilitySmoothingStdDevSpinBox'
        probabilitySmoothingStdDevSpinBox.toolTip = "Standard deviation of blur applied to probability images prior to computing maximum likelihood of each class at each pixel."
        probabilitySmoothingStdDevSpinBox.setMinimum(0.0)
        probabilitySmoothingStdDevSpinBox.setValue(3.0)  # Default
        probabilitySmoothingStdDevSpinBox.setSingleStep(0.1)
        advancedFormLayout.addRow("Probability Smoothing Standard Deviation:",
                                  probabilitySmoothingStdDevSpinBox)
        self.probabilitySmoothingStdDevSpinBox = probabilitySmoothingStdDevSpinBox

        # draft check box
        draftCheckBox = qt.QCheckBox()
        draftCheckBox.objectName = 'draftCheckBox'
        draftCheckBox.toolTip = "Generate draft results?"
        advancedFormLayout.addRow("Draft Mode:", draftCheckBox)
        self.draftCheckBox = draftCheckBox

        # reclassifyObjectMask check box
        reclassifyObjectMaskCheckBox = qt.QCheckBox()
        reclassifyObjectMaskCheckBox.objectName = 'reclassifyObjectMaskCheckBox'
        reclassifyObjectMaskCheckBox.toolTip = "Perform classification on voxels within the object mask?"
        reclassifyObjectMaskCheckBox.setChecked(True)
        advancedFormLayout.addRow("Reclassify Object Mask:",
                                  reclassifyObjectMaskCheckBox)
        self.reclassifyObjectMaskCheckBox = reclassifyObjectMaskCheckBox

        # reclassifyNotObjectMask check box
        reclassifyNotObjectMaskCheckBox = qt.QCheckBox()
        reclassifyNotObjectMaskCheckBox.objectName = 'reclassifyNotObjectMaskCheckBox'
        reclassifyNotObjectMaskCheckBox.toolTip = "Perform classification on all non-void voxels?"
        reclassifyNotObjectMaskCheckBox.setChecked(True)
        advancedFormLayout.addRow("Reclassify Not Object Mask:",
                                  reclassifyNotObjectMaskCheckBox)
        self.reclassifyNotObjectMaskCheckBox = reclassifyNotObjectMaskCheckBox

        # SEGMENTATION BUTTON
        segmentCollapsibleButton = ctk.ctkCollapsibleButton()
        segmentCollapsibleButton.text = "Run Segmentation"
        self.layout.addWidget(segmentCollapsibleButton)

        # Layout within the parameters collapsible button
        segmentFormLayout = qt.QFormLayout(segmentCollapsibleButton)

        # segmentation button
        segmentationButton = qt.QPushButton("Segment")
        segmentationButton.toolTip = "Perform PDF Segmentation."
        segmentFormLayout.addRow(segmentationButton)
        segmentationButton.connect('clicked()',
                                   self.onSegmentationButtonClicked)

        # Now that we've created all UI elements, apply the default goal segmentation type
        self.setGoalSegmentationType(self.goalButtonDefault)
Пример #25
0
    def setup_targeting_area(self):
        """
        Setup target and trajectory area and connect functions.
        """
        parameters_collapsible_button = ctk.ctkCollapsibleButton()
        parameters_collapsible_button.text = "Target and Trajectory"
        self.layout.addWidget(parameters_collapsible_button)

        # Layout within the dummy collapsible button
        parameters_form_layout = qt.QFormLayout(parameters_collapsible_button)

        # input model selector
        self.input_selector = slicer.qMRMLNodeComboBox()
        self.input_selector.nodeTypes = ["vtkMRMLModelNode"]
        self.input_selector.selectNodeUponCreation = False
        self.input_selector.addEnabled = False
        self.input_selector.removeEnabled = False
        self.input_selector.noneEnabled = False
        self.input_selector.showHidden = False
        self.input_selector.showChildNodeTypes = False
        self.input_selector.setMRMLScene(slicer.mrmlScene)
        self.input_selector.setToolTip("Pick the Electrode to Target")
        parameters_form_layout.addRow("Target Electrode: ",
                                      self.input_selector)

        # Arc Angle value
        self.arc_angle_widget = self.default_angle_component()
        parameters_form_layout.addRow("Arc", self.arc_angle_widget)

        # Collar Angle value
        self.collar_angle_widget = ctk.ctkSliderWidget()
        self.collar_angle_widget.singleStep = 0.1
        self.collar_angle_widget.minimum = 0
        self.collar_angle_widget.maximum = 180
        self.collar_angle_widget.value = 90
        self.collar_angle_widget.setToolTip("Set Collar angle of approach.")
        parameters_form_layout.addRow("Collar", self.collar_angle_widget)

        # X-origin
        self.x_origin_widget = self.default_origin_component()
        parameters_form_layout.addRow("X0", self.x_origin_widget)

        # Y-origin
        self.y_origin_widget = self.default_origin_component()
        parameters_form_layout.addRow("Y0", self.y_origin_widget)

        # Z-origin
        self.z_origin_widget = self.default_origin_component()
        parameters_form_layout.addRow("Z0", self.z_origin_widget)

        # Apply Button
        self.new_electrode_button = qt.QPushButton("New Electrode")
        self.new_electrode_button.toolTip = "Generate New Electrode"
        self.new_electrode_button.enabled = False
        parameters_form_layout.addRow(self.new_electrode_button)

        # Connect Procedures
        # Target and Trajectory
        self.new_electrode_button.connect("clicked(bool)", self.new_electrode)
        self.input_selector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.on_electrode_select)

        self.arc_angle_widget.connect("valueChanged(double)", self.on_changes)
        self.collar_angle_widget.connect("valueChanged(double)",
                                         self.on_changes)

        self.x_origin_widget.connect("valueChanged(double)", self.on_changes)
        self.y_origin_widget.connect("valueChanged(double)", self.on_changes)
        self.z_origin_widget.connect("valueChanged(double)", self.on_changes)
Пример #26
0
    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 Morphologika landmark file for conversion")
        parametersFormLayout.addRow(
            "Select file containing landmark names and coordinates to load:",
            self.inputFileSelector)

        #
        # output directory selector
        #
        self.outputDirectory = ctk.ctkDirectoryButton()
        self.outputDirectory.directory = qt.QDir.homePath()
        parametersFormLayout.addRow("Output Directory:", self.outputDirectory)

        #
        # 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.inputFileSelector.connect('validInputChanged(bool)',
                                       self.onSelectInput)

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

        # Refresh Apply button state
        self.onSelectInput()
Пример #27
0
  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)

    #
    # first input volume selector
    #
    self.inputSelector1 = slicer.qMRMLNodeComboBox()
    self.inputSelector1.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputSelector1.selectNodeUponCreation = True
    self.inputSelector1.addEnabled = False
    self.inputSelector1.removeEnabled = False
    self.inputSelector1.noneEnabled = False
    self.inputSelector1.showHidden = False
    self.inputSelector1.showChildNodeTypes = False
    self.inputSelector1.setMRMLScene( slicer.mrmlScene )
    self.inputSelector1.setToolTip( "Pick the first input." )
    parametersFormLayout.addRow(" First input Volume: ", self.inputSelector1)
	
	#
    # second input volume selector
    #
    self.inputSelector2 = slicer.qMRMLNodeComboBox()
    self.inputSelector2.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputSelector2.selectNodeUponCreation = True
    self.inputSelector2.addEnabled = False
    self.inputSelector2.removeEnabled = False
    self.inputSelector2.noneEnabled = False
    self.inputSelector2.showHidden = False
    self.inputSelector2.showChildNodeTypes = False
    self.inputSelector2.setMRMLScene( slicer.mrmlScene )
    self.inputSelector2.setToolTip( "Pick the second input." )
    parametersFormLayout.addRow(" Second input Volume: ", self.inputSelector2)
	


    self.rulerSelector = slicer.qMRMLNodeComboBox()
    self.rulerSelector.nodeTypes = ["vtkMRMLAnnotationRulerNode"]
    self.rulerSelector.selectNodeUponCreation = True
    self.rulerSelector.addEnabled = False
    self.rulerSelector.removeEnabled = False
    self.rulerSelector.noneEnabled = False
    self.rulerSelector.showHidden = False
    self.rulerSelector.showChildNodeTypes = False
    self.rulerSelector.setMRMLScene( slicer.mrmlScene )
    self.rulerSelector.setToolTip( "Pick the ruler." )
    parametersFormLayout.addRow("Ruler: ", self.rulerSelector)


    #
    # Apply Button
    #
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the algorithm."
    self.applyButton.enabled = True
    parametersFormLayout.addRow(self.applyButton)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    
    # Add vertical spacer
    self.layout.addStretch(1)
Пример #28
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    self.logic = SegmentStatisticsLogic()
    self.grayscaleNode = None
    self.labelNode = None
    self.parameterNode = None
    self.parameterNodeObserver = None

    # Instantiate and connect widgets ...
    #

    # Inputs
    inputsCollapsibleButton = ctk.ctkCollapsibleButton()
    inputsCollapsibleButton.text = "Inputs"
    self.layout.addWidget(inputsCollapsibleButton)
    inputsFormLayout = qt.QFormLayout(inputsCollapsibleButton)

    # Segmentation selector
    self.segmentationSelector = slicer.qMRMLNodeComboBox()
    self.segmentationSelector.nodeTypes = ["vtkMRMLSegmentationNode"]
    self.segmentationSelector.addEnabled = False
    self.segmentationSelector.removeEnabled = True
    self.segmentationSelector.renameEnabled = True
    self.segmentationSelector.setMRMLScene( slicer.mrmlScene )
    self.segmentationSelector.setToolTip( "Pick the segmentation to compute statistics for" )
    inputsFormLayout.addRow("Segmentation:", self.segmentationSelector)

    # Scalar volume selector
    self.scalarSelector = slicer.qMRMLNodeComboBox()
    self.scalarSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.scalarSelector.addEnabled = False
    self.scalarSelector.removeEnabled = True
    self.scalarSelector.renameEnabled = True
    self.scalarSelector.noneEnabled = True
    self.scalarSelector.showChildNodeTypes = False
    self.scalarSelector.setMRMLScene( slicer.mrmlScene )
    self.scalarSelector.setToolTip( "Select the scalar volume for intensity statistics calculations")
    inputsFormLayout.addRow("Scalar volume:", self.scalarSelector)

    # Output table selector
    outputCollapsibleButton = ctk.ctkCollapsibleButton()
    outputCollapsibleButton.text = "Output"
    self.layout.addWidget(outputCollapsibleButton)
    outputFormLayout = qt.QFormLayout(outputCollapsibleButton)

    self.outputTableSelector = slicer.qMRMLNodeComboBox()
    self.outputTableSelector.nodeTypes = ["vtkMRMLTableNode"]
    self.outputTableSelector.addEnabled = True
    self.outputTableSelector.selectNodeUponCreation = True
    self.outputTableSelector.renameEnabled = True
    self.outputTableSelector.removeEnabled = True
    self.outputTableSelector.noneEnabled = False
    self.outputTableSelector.setMRMLScene( slicer.mrmlScene )
    self.outputTableSelector.setToolTip( "Select the table where statistics will be saved into")
    outputFormLayout.addRow("Output table:", self.outputTableSelector)

    # Apply Button
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Calculate Statistics."
    self.applyButton.enabled = False
    self.parent.layout().addWidget(self.applyButton)

    # Parameter set
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Parameters"
    #parametersCollapsibleButton.collapsed = True
    self.layout.addWidget(parametersCollapsibleButton)
    self.parametersLayout = qt.QFormLayout(parametersCollapsibleButton)

    # Parameter set selector
    self.parameterNodeSelector = slicer.qMRMLNodeComboBox()
    self.parameterNodeSelector.nodeTypes = ( ("vtkMRMLScriptedModuleNode"), "" )
    self.parameterNodeSelector.addAttribute( "vtkMRMLScriptedModuleNode", "ModuleName", "SegmentStatistics" )
    self.parameterNodeSelector.selectNodeUponCreation = True
    self.parameterNodeSelector.addEnabled = True
    self.parameterNodeSelector.renameEnabled = True
    self.parameterNodeSelector.removeEnabled = True
    self.parameterNodeSelector.noneEnabled = False
    self.parameterNodeSelector.showHidden = True
    self.parameterNodeSelector.showChildNodeTypes = False
    self.parameterNodeSelector.baseName = "SegmentStatistics"
    self.parameterNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.parameterNodeSelector.setToolTip( "Pick parameter set" )
    self.parametersLayout.addRow("Parameter set: ", self.parameterNodeSelector)

    # Edit parameter set button to open SegmentStatisticsParameterEditorDialog
    # Note: we add the plugins' option widgets to the module widget instead of using the editor dialog
    #self.editParametersButton = qt.QPushButton("Edit Parameter Set")
    #self.editParametersButton.toolTip = "Editor Statistics Plugin Parameter Set."
    #self.parametersLayout.addRow(self.editParametersButton)
    #self.editParametersButton.connect('clicked()', self.onEditParameters)
    # add caclulator's option widgets
    self.addPluginOptionWidgets()

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

    # connections
    self.applyButton.connect('clicked()', self.onApply)
    self.scalarSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onNodeSelectionChanged)
    self.segmentationSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onNodeSelectionChanged)
    self.outputTableSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onNodeSelectionChanged)
    self.parameterNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onNodeSelectionChanged)
    self.parameterNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onParameterSetSelected)

    self.parameterNodeSelector.setCurrentNode(self.logic.getParameterNode())
    self.onNodeSelectionChanged()
    self.onParameterSetSelected()
Пример #29
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = VectorToScalarVolumeLogic()
        # This will use createParameterNode with the provided default options
        self.setParameterNode(self.logic.getParameterNode())

        self.parameterSetSelectionCollapsibleButton = ctk.ctkCollapsibleButton(
        )
        self.parameterSetSelectionCollapsibleButton.text = "Parameter set"
        self.layout.addWidget(self.parameterSetSelectionCollapsibleButton)

        # Layout within the "Selection" collapsible button
        parameterSetSelectionFormLayout = qt.QFormLayout(
            self.parameterSetSelectionCollapsibleButton)

        # Parameter set selector (inspired by SegmentStatistics.py)
        self.parameterNodeSelector = slicer.qMRMLNodeComboBox()
        self.parameterNodeSelector.nodeTypes = (("vtkMRMLScriptedModuleNode"),
                                                "")
        self.parameterNodeSelector.addAttribute("vtkMRMLScriptedModuleNode",
                                                "ModuleName",
                                                "VectorToScalarVolume")
        self.parameterNodeSelector.selectNodeUponCreation = True
        self.parameterNodeSelector.addEnabled = True
        self.parameterNodeSelector.renameEnabled = True
        self.parameterNodeSelector.removeEnabled = True
        self.parameterNodeSelector.noneEnabled = False
        self.parameterNodeSelector.showHidden = True
        self.parameterNodeSelector.showChildNodeTypes = False
        self.parameterNodeSelector.baseName = "VectorToScalarVolume"
        self.parameterNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.parameterNodeSelector.toolTip = "Pick parameter set"
        parameterSetSelectionFormLayout.addRow("Parameter set: ",
                                               self.parameterNodeSelector)

        # Parameters
        self.selectionCollapsibleButton = ctk.ctkCollapsibleButton()
        self.selectionCollapsibleButton.text = "Conversion settings"
        self.layout.addWidget(self.selectionCollapsibleButton)

        # Layout within the "Selection" collapsible button
        parametersFormLayout = qt.QFormLayout(self.selectionCollapsibleButton)

        #
        # the volume selectors
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        parametersFormLayout.addRow("Input Vector Volume: ",
                                    self.inputSelector)

        self.outputSelector = slicer.qMRMLNodeComboBox()
        self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.outputSelector.hideChildNodeTypes = ["vtkMRMLVectorVolumeNode"]
        self.outputSelector.setMRMLScene(slicer.mrmlScene)
        self.outputSelector.addEnabled = True
        self.outputSelector.renameEnabled = True
        self.outputSelector.baseName = "Scalar Volume"
        parametersFormLayout.addRow("Output Scalar Volume: ",
                                    self.outputSelector)

        #
        # Options to extract single components
        #
        self.conversionMethodWidget = VectorToScalarVolumeConversionMethodWidget(
        )
        parametersFormLayout.addRow("Conversion Method: ",
                                    self.conversionMethodWidget)
        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Run Convert the vector to scalar."
        parametersFormLayout.addRow(self.applyButton)

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

        # Connections
        self.parameterNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                           self.setParameterNode)
        self.parameterNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                           self.updateGuiFromMRML)

        # updateParameterNodeFromGui
        self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.updateParameterNodeFromGui)
        self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.updateParameterNodeFromGui)

        self.applyButton.connect('clicked(bool)', self.onApply)

        # conversion widget
        self.conversionMethodWidget.methodSelectorComboBox.connect(
            'currentIndexChanged(int)', self.updateParameterNodeFromGui)
        self.conversionMethodWidget.componentsComboBox.connect(
            'currentIndexChanged(int)', self.updateParameterNodeFromGui)

        # The parameter node had defaults at creation, propagate them to the GUI.
        self.updateGuiFromMRML()
Пример #30
0
    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)