Пример #1
0
  def __init__(self, ModuleNodeName):
    VTKObservationMixin.__init__(self)

    self.InputCases = list()
    self.allCaseStartTime = 0

    # Dictionaries
    self.pipeline = {}
    self.completed = {}

    # Status
    self.Node = slicer.vtkMRMLCommandLineModuleNode()
    self.Node.SetStatus(self.Node.Idle)
    self.Node.SetName(ModuleNodeName)
    self.ProgressBar = slicer.qSlicerCLIProgressBar()
    self.ProgressBar.setCommandLineModuleNode(self.Node)
    self.ProgressBar.setNameVisibility(slicer.qSlicerCLIProgressBar.AlwaysVisible)
    self.ErrorMessage = 'Unexpected error'
Пример #2
0
  def __init__(self, pipelineID, CaseInput, interface):

    VTKObservationMixin.__init__(self)

    self.pipelineID = pipelineID
    self.strPipelineID = "_" + str(self.pipelineID)
    self.CaseInput = CaseInput

    # Pipeline computation time
    self.pipelineStartTime = 0
    self.pipelineEndTime = 0

    # Status
    self.StatusModifiedEvent = slicer.vtkMRMLCommandLineModuleNode().StatusModifiedEvent
    self.Node = slicer.vtkMRMLCommandLineModuleNode()
    self.Node.SetStatus(self.Node.Idle)
    self.Node.SetName('Case ' + str(self.pipelineID))
    self.currentCLINode = None
    self.ProgressBar = slicer.qSlicerCLIProgressBar()
    self.ProgressBar.setCommandLineModuleNode(self.Node)
    self.ProgressBar.setNameVisibility(slicer.qSlicerCLIProgressBar.AlwaysVisible)
    self.ErrorMessage = 'Unexpected error'
Пример #3
0
    def __init__(self, pipelineID, CaseInput, interface):

        VTKObservationMixin.__init__(self)

        self.pipelineID = pipelineID
        self.strPipelineID = "_" + str(self.pipelineID)
        self.CaseInput = CaseInput

        # Pipeline computation time
        self.pipelineStartTime = 0
        self.pipelineEndTime = 0

        # Status
        self.StatusModifiedEvent = slicer.vtkMRMLCommandLineModuleNode(
        ).StatusModifiedEvent
        self.Node = slicer.vtkMRMLCommandLineModuleNode()
        self.Node.SetStatus(self.Node.Idle)
        self.Node.SetName('Case ' + str(self.pipelineID))
        self.currentCLINode = None
        self.ProgressBar = slicer.qSlicerCLIProgressBar()
        self.ProgressBar.setCommandLineModuleNode(self.Node)
        self.ProgressBar.setNameVisibility(
            slicer.qSlicerCLIProgressBar.AlwaysVisible)
        self.ErrorMessage = 'Unexpected error'
Пример #4
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)
Пример #5
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = CreateMeshLogic()

        # 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 = False
        self.segmentationSelector.renameEnabled = False
        self.segmentationSelector.setMRMLScene(slicer.mrmlScene)
        self.segmentationSelector.setToolTip(
            'Pick the segmentation to compute a mesh from')
        inputsFormLayout.addRow('Segmentation:', self.segmentationSelector)
        # Fiducials selector
        self.fiducialsSelector = slicer.qMRMLNodeComboBox()
        self.fiducialsSelector.nodeTypes = ['vtkMRMLMarkupsFiducialNode']
        self.fiducialsSelector.addEnabled = False
        self.fiducialsSelector.removeEnabled = False
        self.fiducialsSelector.renameEnabled = False
        self.fiducialsSelector.setMRMLScene(slicer.mrmlScene)
        self.fiducialsSelector.setToolTip(
            'Select the fiducials that will define the light sources and detectors position'
        )
        inputsFormLayout.addRow('Fiducials:', self.fiducialsSelector)

        # Outputs
        outputsCollapsibleButton = ctk.ctkCollapsibleButton()
        outputsCollapsibleButton.text = 'Outputs'
        self.layout.addWidget(outputsCollapsibleButton)
        outputsFormLayout = qt.QFormLayout(outputsCollapsibleButton)

        # Mesh directory
        self.meshPathLineEdit = ctk.ctkPathLineEdit()
        self.meshPathLineEdit.filters = ctk.ctkPathLineEdit.Dirs
        self.meshPathLineEdit.currentPath = self.cachedPathFor(
            'CreateMeshOutputPath')
        outputsFormLayout.addRow('Mesh directory:', self.meshPathLineEdit)
        # Mesh name
        self.meshNameField = qt.QLineEdit()
        outputsFormLayout.addRow('Mesh name:', self.meshNameField)

        # Meshing
        meshingCollapsibleButton = ctk.ctkCollapsibleButton()
        meshingCollapsibleButton.text = 'Meshing'
        self.layout.addWidget(meshingCollapsibleButton)
        meshingFormLayout = qt.QFormLayout(meshingCollapsibleButton)

        # Mesh type
        self.meshTypeComboBox = ctk.ctkComboBox()
        for meshType in self.logic.meshTypes:
            self.meshTypeComboBox.addItem(meshType)
        meshingFormLayout.addRow('Mesh type:', self.meshTypeComboBox)
        # Cell size
        self.cellSizeSpinBox = slicer.qMRMLSpinBox()
        self.cellSizeSpinBox.setValue(1.5)
        self.cellSizeSpinBox.setMRMLScene(slicer.mrmlScene)
        meshingFormLayout.addRow('Cell size:', self.cellSizeSpinBox)
        # Cell radius edge
        self.cellRadiusSpinBox = slicer.qMRMLSpinBox()
        self.cellRadiusSpinBox.setValue(3.0)
        self.cellRadiusSpinBox.setMRMLScene(slicer.mrmlScene)
        meshingFormLayout.addRow('Cell radius edge:', self.cellRadiusSpinBox)
        # Facet size
        self.facetSizeSpinBox = slicer.qMRMLSpinBox()
        self.facetSizeSpinBox.setValue(1.5)
        self.facetSizeSpinBox.setMRMLScene(slicer.mrmlScene)
        meshingFormLayout.addRow('Facet size:', self.facetSizeSpinBox)
        # Facet angle
        self.facetAngleSpinBox = slicer.qMRMLSpinBox()
        self.facetAngleSpinBox.setValue(25.0)
        self.facetAngleSpinBox.setMRMLScene(slicer.mrmlScene)
        meshingFormLayout.addRow('Facet angle:', self.facetAngleSpinBox)
        # Facet distance
        self.facetDistanceSpinBox = slicer.qMRMLSpinBox()
        self.facetDistanceSpinBox.setValue(3.0)
        self.facetDistanceSpinBox.setMRMLScene(slicer.mrmlScene)
        meshingFormLayout.addRow('Facet distance:', self.facetDistanceSpinBox)
        # Optimize mesh
        self.optimizeCheckBox = qt.QCheckBox()
        meshingFormLayout.addRow('Optimize mesh:', self.optimizeCheckBox)

        # NIRFAST
        nirfastCollapsibleButton = ctk.ctkCollapsibleButton()
        nirfastCollapsibleButton.text = 'NIRFAST Matlab'
        self.layout.addWidget(nirfastCollapsibleButton)
        nirfastFormLayout = qt.QFormLayout(nirfastCollapsibleButton)

        # NIRFAST-Matlab
        self.nirfastMatlabPathLineEdit = ctk.ctkPathLineEdit()
        self.nirfastMatlabPathLineEdit.filters = ctk.ctkPathLineEdit.Dirs
        self.nirfastMatlabPathLineEdit.currentPath = self.cachedPathFor(
            'NIRFASTMatlabPath')
        nirfastFormLayout.addRow('NIRFAST Matlab:',
                                 self.nirfastMatlabPathLineEdit)

        # Run
        self.runButton = qt.QPushButton()
        self.runButton.setCheckable(True)
        self.setRunning(False)
        self.layout.addWidget(self.runButton)

        # Progress
        self.progressBar = slicer.qSlicerCLIProgressBar()
        self.logic.setProgressBar(self.progressBar)
        self.layout.addWidget(self.progressBar)

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

        # Connections
        self.segmentationSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                          self.onSegmentationNodeChanged)
        self.onSegmentationNodeChanged(self.segmentationSelector.currentNode())
        self.meshPathLineEdit.connect('currentPathChanged(QString)',
                                      self.logic.cacheOutputMeshDir)
        self.nirfastMatlabPathLineEdit.connect(
            'currentPathChanged(QString)', self.logic.cacheNirfastMatlabDir)
        self.runButton.connect('clicked()', self.onRun)
        self.logic.setBusy = self.setRunning
        self.logic.setError = self.showError