Пример #1
1
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    self.logic = ScreenCaptureLogic()
    self.logic.logCallback = self.addLog
    self.viewNodeType = None
    self.animationMode = None
    self.createdOutputFile = None

    self.snapshotIndex = 0 # this counter is used for determining file names for single-image snapshots
    self.snapshotOutputDir = None
    self.snapshotFileNamePattern = None

    # Instantiate and connect widgets ...

    #
    # Input area
    #
    self.inputCollapsibleButton = ctk.ctkCollapsibleButton()
    self.inputCollapsibleButton.text = "Input"
    self.layout.addWidget(self.inputCollapsibleButton)
    inputFormLayout = qt.QFormLayout(self.inputCollapsibleButton)

    # Input view selector
    self.viewNodeSelector = slicer.qMRMLNodeComboBox()
    self.viewNodeSelector.nodeTypes = ["vtkMRMLSliceNode", "vtkMRMLViewNode"]
    self.viewNodeSelector.addEnabled = False
    self.viewNodeSelector.removeEnabled = False
    self.viewNodeSelector.noneEnabled = False
    self.viewNodeSelector.showHidden = False
    self.viewNodeSelector.showChildNodeTypes = False
    self.viewNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.viewNodeSelector.setToolTip("This slice or 3D view will be updated during capture."
      "Only this view will be captured unless 'Capture of all views' option in output section is enabled." )
    inputFormLayout.addRow("Master view: ", self.viewNodeSelector)

    # Mode
    self.animationModeWidget = qt.QComboBox()
    self.animationModeWidget.setToolTip("Select the property that will be adjusted")
    inputFormLayout.addRow("Animation mode:", self.animationModeWidget)

    # Slice start offset position
    self.sliceStartOffsetSliderLabel = qt.QLabel("Start sweep offset:")
    self.sliceStartOffsetSliderWidget = ctk.ctkSliderWidget()
    self.sliceStartOffsetSliderWidget.singleStep = 30
    self.sliceStartOffsetSliderWidget.minimum = -100
    self.sliceStartOffsetSliderWidget.maximum = 100
    self.sliceStartOffsetSliderWidget.value = 0
    self.sliceStartOffsetSliderWidget.setToolTip("Start slice sweep offset.")
    inputFormLayout.addRow(self.sliceStartOffsetSliderLabel, self.sliceStartOffsetSliderWidget)

    # Slice end offset position
    self.sliceEndOffsetSliderLabel = qt.QLabel("End sweep offset:")
    self.sliceEndOffsetSliderWidget = ctk.ctkSliderWidget()
    self.sliceEndOffsetSliderWidget.singleStep = 5
    self.sliceEndOffsetSliderWidget.minimum = -100
    self.sliceEndOffsetSliderWidget.maximum = 100
    self.sliceEndOffsetSliderWidget.value = 0
    self.sliceEndOffsetSliderWidget.setToolTip("End slice sweep offset.")
    inputFormLayout.addRow(self.sliceEndOffsetSliderLabel, self.sliceEndOffsetSliderWidget)

    # 3D rotation range
    self.rotationSliderLabel = qt.QLabel("Rotation range:")
    self.rotationSliderWidget = ctk.ctkRangeWidget()
    self.rotationSliderWidget.singleStep = 5
    self.rotationSliderWidget.minimum = -180
    self.rotationSliderWidget.maximum = 180
    self.rotationSliderWidget.minimumValue = -180
    self.rotationSliderWidget.maximumValue = 180
    self.rotationSliderWidget.setToolTip("View rotation range, relative to current view orientation.")
    inputFormLayout.addRow(self.rotationSliderLabel, self.rotationSliderWidget)

    # 3D rotation axis
    self.rotationAxisLabel = qt.QLabel("Rotation axis:")
    self.rotationAxisWidget = ctk.ctkRangeWidget()
    self.rotationAxisWidget = qt.QComboBox()
    self.rotationAxisWidget.addItem("Yaw", AXIS_YAW)
    self.rotationAxisWidget.addItem("Pitch", AXIS_PITCH)
    inputFormLayout.addRow(self.rotationAxisLabel, self.rotationAxisWidget)


    # Sequence browser node selector
    self.sequenceBrowserNodeSelectorLabel = qt.QLabel("Sequence:")
    self.sequenceBrowserNodeSelectorWidget = slicer.qMRMLNodeComboBox()
    self.sequenceBrowserNodeSelectorWidget.nodeTypes = ["vtkMRMLSequenceBrowserNode"]
    self.sequenceBrowserNodeSelectorWidget.addEnabled = False
    self.sequenceBrowserNodeSelectorWidget.removeEnabled = False
    self.sequenceBrowserNodeSelectorWidget.noneEnabled = False
    self.sequenceBrowserNodeSelectorWidget.showHidden = False
    self.sequenceBrowserNodeSelectorWidget.setMRMLScene( slicer.mrmlScene )
    self.sequenceBrowserNodeSelectorWidget.setToolTip( "Items defined by this sequence browser will be replayed." )
    inputFormLayout.addRow(self.sequenceBrowserNodeSelectorLabel, self.sequenceBrowserNodeSelectorWidget)

    # Sequence start index
    self.sequenceStartItemIndexLabel = qt.QLabel("Start index:")
    self.sequenceStartItemIndexWidget = ctk.ctkSliderWidget()
    self.sequenceStartItemIndexWidget.minimum = 0
    self.sequenceStartItemIndexWidget.decimals = 0
    self.sequenceStartItemIndexWidget.setToolTip("First item in the sequence to capture.")
    inputFormLayout.addRow(self.sequenceStartItemIndexLabel, self.sequenceStartItemIndexWidget)

    # Sequence end index
    self.sequenceEndItemIndexLabel = qt.QLabel("End index:")
    self.sequenceEndItemIndexWidget = ctk.ctkSliderWidget()
    self.sequenceEndItemIndexWidget.minimum = 0
    self.sequenceEndItemIndexWidget.decimals = 0
    self.sequenceEndItemIndexWidget.setToolTip("Last item in the sequence to capture.")
    inputFormLayout.addRow(self.sequenceEndItemIndexLabel, self.sequenceEndItemIndexWidget)

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

    # Number of steps value
    self.numberOfStepsSliderWidget = ctk.ctkSliderWidget()
    self.numberOfStepsSliderWidget.singleStep = 10
    self.numberOfStepsSliderWidget.minimum = 1
    self.numberOfStepsSliderWidget.maximum = 600
    self.numberOfStepsSliderWidget.value = 31
    self.numberOfStepsSliderWidget.decimals = 0
    self.numberOfStepsSliderWidget.setToolTip("Number of images extracted between start and stop positions.")

    # Single step toggle button
    self.singleStepButton = qt.QToolButton()
    self.singleStepButton.setText("single")
    self.singleStepButton.setCheckable(True)
    self.singleStepButton.toolTip = "Capture a single image of current state only.\n" + \
      "New filename is generated for each captured image (no files are overwritten)."

    hbox = qt.QHBoxLayout()
    hbox.addWidget(self.singleStepButton)
    hbox.addWidget(self.numberOfStepsSliderWidget)
    outputFormLayout.addRow("Number of images:", hbox)

    # Output directory selector
    self.outputDirSelector = ctk.ctkPathLineEdit()
    self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.outputDirSelector.settingKey = 'ScreenCaptureOutputDir'
    outputFormLayout.addRow("Output directory:", self.outputDirSelector)
    if not self.outputDirSelector.currentPath:
      defaultOutputPath = os.path.abspath(os.path.join(slicer.app.defaultScenePath,'SlicerCapture'))
      self.outputDirSelector.setCurrentPath(defaultOutputPath)

    self.captureAllViewsCheckBox = qt.QCheckBox(" ")
    self.captureAllViewsCheckBox.checked = False
    self.captureAllViewsCheckBox.setToolTip("If checked, all views will be captured. If unchecked then only the selected view will be captured.")
    outputFormLayout.addRow("Capture all views:", self.captureAllViewsCheckBox)

    self.videoExportCheckBox = qt.QCheckBox(" ")
    self.videoExportCheckBox.checked = False
    self.videoExportCheckBox.setToolTip("If checked, exported images will be written as a video file."
      " Requires setting of ffmpeg executable path in Advanced section.")

    self.videoFormatWidget = qt.QComboBox()
    self.videoFormatWidget.enabled = False
    self.videoFormatWidget.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Preferred)
    for videoFormatPreset in self.logic.videoFormatPresets:
      self.videoFormatWidget.addItem(videoFormatPreset["name"])

    hbox = qt.QHBoxLayout()
    hbox.addWidget(self.videoExportCheckBox)
    hbox.addWidget(self.videoFormatWidget)
    outputFormLayout.addRow("Video export:", hbox)

    self.videoFileNameWidget = qt.QLineEdit()
    self.videoFileNameWidget.setToolTip("String that defines file name and type.")
    self.videoFileNameWidget.text = "SlicerCapture.avi"
    self.videoFileNameWidget.setEnabled(False)
    outputFormLayout.addRow("Video file name:", self.videoFileNameWidget)

    self.videoLengthSliderWidget = ctk.ctkSliderWidget()
    self.videoLengthSliderWidget.singleStep = 0.1
    self.videoLengthSliderWidget.minimum = 0.1
    self.videoLengthSliderWidget.maximum = 30
    self.videoLengthSliderWidget.value = 5
    self.videoLengthSliderWidget.suffix = "s"
    self.videoLengthSliderWidget.decimals = 1
    self.videoLengthSliderWidget.setToolTip("Length of the exported video in seconds (without backward steps and repeating).")
    self.videoLengthSliderWidget.setEnabled(False)
    outputFormLayout.addRow("Video length:", self.videoLengthSliderWidget)

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

    self.forwardBackwardCheckBox = qt.QCheckBox(" ")
    self.forwardBackwardCheckBox.checked = False
    self.forwardBackwardCheckBox.setToolTip("If checked, image series will be generated playing forward and then backward.")
    advancedFormLayout.addRow("Forward-backward:", self.forwardBackwardCheckBox)

    self.repeatSliderWidget = ctk.ctkSliderWidget()
    self.repeatSliderWidget.decimals = 0
    self.repeatSliderWidget.singleStep = 1
    self.repeatSliderWidget.minimum = 1
    self.repeatSliderWidget.maximum = 50
    self.repeatSliderWidget.value = 1
    self.repeatSliderWidget.setToolTip("Number of times image series are repeated. Useful for making short videos longer for playback in software"
      " that does not support looped playback.")
    advancedFormLayout.addRow("Repeat:", self.repeatSliderWidget)

    ffmpegPath = self.logic.getFfmpegPath()
    self.ffmpegPathSelector = ctk.ctkPathLineEdit()
    self.ffmpegPathSelector.setCurrentPath(ffmpegPath)
    self.ffmpegPathSelector.nameFilters = [self.logic.getFfmpegExecutableFilename()]
    self.ffmpegPathSelector.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred)
    self.ffmpegPathSelector.setToolTip("Set the path to ffmpeg executable. Download from: https://www.ffmpeg.org/")
    advancedFormLayout.addRow("ffmpeg executable:", self.ffmpegPathSelector)

    self.videoExportFfmpegWarning = qt.QLabel('<qt><b><font color="red">Set valid ffmpeg executable path! '+
      '<a href="http://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/Modules/ScreenCapture#Setting_up_ffmpeg">Help...</a></font></b></qt>')
    self.videoExportFfmpegWarning.connect('linkActivated(QString)', self.openURL)
    self.videoExportFfmpegWarning.setVisible(False)
    advancedFormLayout.addRow("", self.videoExportFfmpegWarning)

    self.extraVideoOptionsWidget = qt.QLineEdit()
    self.extraVideoOptionsWidget.setToolTip('Additional video conversion options passed to ffmpeg. Parameters -i (input files), -y'
      +'(overwrite without asking), -r (frame rate), -start_number are specified by the module and therefore'
      +'should not be included in this list.')
    advancedFormLayout.addRow("Video extra options:", self.extraVideoOptionsWidget)

    self.fileNamePatternWidget = qt.QLineEdit()
    self.fileNamePatternWidget.setToolTip(
      "String that defines file name, type, and numbering scheme. Default: image%05d.png.")
    self.fileNamePatternWidget.text = "image_%05d.png"
    advancedFormLayout.addRow("Image file name pattern:", self.fileNamePatternWidget)

    self.maxFramesWidget = qt.QSpinBox()
    self.maxFramesWidget.setRange(1, 9999)
    self.maxFramesWidget.setValue(600)
    self.maxFramesWidget.setToolTip(
      "Maximum number of images to be captured (without backward steps and repeating).")
    advancedFormLayout.addRow("Maximum number of images:", self.maxFramesWidget)

    # Capture button
    self.captureButtonLabelCapture = "Capture"
    self.captureButtonLabelCancel = "Cancel"
    self.captureButton = qt.QPushButton(self.captureButtonLabelCapture)
    self.captureButton.toolTip = "Capture slice sweep to image sequence."
    self.showCreatedOutputFileButton = qt.QPushButton()
    self.showCreatedOutputFileButton.setIcon(qt.QIcon(':Icons/Go.png'))
    self.showCreatedOutputFileButton.setMaximumWidth(60)
    self.showCreatedOutputFileButton.enabled = False
    self.showCreatedOutputFileButton.toolTip = "Show created output file."
    hbox = qt.QHBoxLayout()
    hbox.addWidget(self.captureButton)
    hbox.addWidget(self.showCreatedOutputFileButton)
    self.layout.addLayout(hbox)

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

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

    # connections
    self.captureButton.connect('clicked(bool)', self.onCaptureButton)
    self.showCreatedOutputFileButton.connect('clicked(bool)', self.onShowCreatedOutputFile)
    self.viewNodeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.updateViewOptions)
    self.animationModeWidget.connect("currentIndexChanged(int)", self.updateViewOptions)
    self.sliceStartOffsetSliderWidget.connect('valueChanged(double)', self.setSliceOffset)
    self.sliceEndOffsetSliderWidget.connect('valueChanged(double)', self.setSliceOffset)
    self.sequenceBrowserNodeSelectorWidget.connect("currentNodeChanged(vtkMRMLNode*)", self.updateViewOptions)
    self.sequenceStartItemIndexWidget.connect('valueChanged(double)', self.setSequenceItemIndex)
    self.sequenceEndItemIndexWidget.connect('valueChanged(double)', self.setSequenceItemIndex)
    self.videoExportCheckBox.connect('toggled(bool)', self.fileNamePatternWidget, 'setDisabled(bool)')
    self.videoExportCheckBox.connect('toggled(bool)', self.videoFileNameWidget, 'setEnabled(bool)')
    self.videoExportCheckBox.connect('toggled(bool)', self.videoLengthSliderWidget, 'setEnabled(bool)')
    self.videoExportCheckBox.connect('toggled(bool)', self.videoFormatWidget, 'setEnabled(bool)')
    self.videoFormatWidget.connect("currentIndexChanged(int)", self.updateVideoFormat)
    self.singleStepButton.connect('toggled(bool)', self.numberOfStepsSliderWidget, 'setDisabled(bool)')
    self.maxFramesWidget.connect('valueChanged(int)', self.maxFramesChanged)

    self.updateVideoFormat(0)
    self.updateViewOptions()
Пример #2
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # [TODO]
        # Si potrebbe avere un file di configurazione che contiene eventualmente un path alla colorlut
        # Se non e'vuoto allora lo prendo se no prendo questo di default
        self.lutPath = os.path.join(slicer.app.slicerHome, "share/FreeSurfer/FreeSurferColorLUT20120827.txt")
        print self.lutPath
        # [END TODO]

        self.zonedetectionCB = ctk.ctkCollapsibleButton()
        self.zonedetectionCB.text = "Brain Zone Detection"

        self.layout.addWidget(self.zonedetectionCB)

        self.zoneDetectionLayout = qt.QFormLayout(self.zonedetectionCB)

        ### Select Atlas
        self.atlasInputSelector = slicer.qMRMLNodeComboBox()
        self.atlasInputSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.atlasInputSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap", 0)
        self.atlasInputSelector.selectNodeUponCreation = True
        self.atlasInputSelector.addEnabled = False
        self.atlasInputSelector.removeEnabled = False
        self.atlasInputSelector.noneEnabled = True
        self.atlasInputSelector.showHidden = False
        self.atlasInputSelector.showChildNodeTypes = False
        self.atlasInputSelector.setMRMLScene(slicer.mrmlScene)
        self.atlasInputSelector.setToolTip("Pick the volumetric Atlas.")
        self.zoneDetectionLayout.addRow("Volumetric parcels: ", self.atlasInputSelector)

        self.dialog = qt.QFileDialog()
        self.dialog.setFileMode(qt.QFileDialog.AnyFile)
        self.dialog.setToolTip("Pick the input to the algorithm.")

        self.fidsSelectorZone = slicer.qMRMLNodeComboBox()
        self.fidsSelectorZone.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "")
        self.fidsSelectorZone.selectNodeUponCreation = False
        self.fidsSelectorZone.addEnabled = False
        self.fidsSelectorZone.removeEnabled = False
        self.fidsSelectorZone.noneEnabled = True
        self.fidsSelectorZone.setMRMLScene(slicer.mrmlScene)
        self.fidsSelectorZone.setToolTip("Select a fiducial list")
        self.zoneDetectionLayout.addRow("Fiducial : ", self.fidsSelectorZone)

        self.ROISize = qt.QLineEdit("7")
        self.ROISize.setToolTip("Define side length of cubic region centered in contact centroid")
        self.ROISize.setInputMask("D")

        # Run Zone Detection button
        self.zoneButton = qt.QPushButton("Apply")
        self.zoneButton.toolTip = "Run the algorithm."
        self.zoneButton.enabled = True

        self.zoneDetectionLayout.addRow("Cubic Region Side Length:", self.ROISize)
        self.zoneDetectionLayout.addRow(self.zoneButton)

        # connections
        self.zoneButton.connect("clicked(bool)", self.onZoneButton)
Пример #3
0
    def setup(self):
        # Instantiate and connect widgets ...

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

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

        # fiber
        self.fiberSelector = slicer.qMRMLNodeComboBox(parametersCollapsibleButton)
        self.fiberSelector.nodeTypes = ["vtkMRMLFiberBundleNode"]
        self.fiberSelector.selectNodeUponCreation = False
        self.fiberSelector.addEnabled = False
        self.fiberSelector.removeEnabled = False
        self.fiberSelector.noneEnabled = True
        self.fiberSelector.showHidden = False
        self.fiberSelector.showChildNodeTypes = False
        self.fiberSelector.setMRMLScene(slicer.mrmlScene)
        self.fiberSelector.setToolTip("Pick the fiber bundle to be converted.")
        parametersFormLayout.addRow("Fiber Bundle", self.fiberSelector)

        # label map
        self.labelSelector = slicer.qMRMLNodeComboBox(parametersCollapsibleButton)
        self.labelSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.labelSelector.selectNodeUponCreation = False
        self.labelSelector.addEnabled = False
        self.labelSelector.removeEnabled = False
        self.labelSelector.noneEnabled = True
        self.labelSelector.showHidden = False
        self.labelSelector.showChildNodeTypes = False
        self.labelSelector.setMRMLScene(slicer.mrmlScene)
        self.labelSelector.setToolTip(
            "Pick the target label volume.  Must already exists in order to define sampling grid.  If needed, create one in the Editor module based on template volume."
        )
        parametersFormLayout.addRow("Target LabelMap", self.labelSelector)

        # label value
        self.labelValue = qt.QSpinBox(parametersCollapsibleButton)
        self.labelValue.setToolTip("The numerical value for the rasterized fiber label.")
        self.labelValue.setValue(1)
        parametersFormLayout.addRow("Label Value", self.labelValue)

        # apply
        self.applyButton = qt.QPushButton(parametersCollapsibleButton)
        self.applyButton.text = "Apply"
        parametersFormLayout.addWidget(self.applyButton)

        self.applyButton.connect("clicked()", self.onApply)

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

    # Add margin to the sides
    self.layout.setContentsMargins(4,0,4,0)

    #
    # Parameter Combobox
    #
    self.parameterSelector = slicer.qMRMLNodeComboBox()
    self.parameterLabel = qt.QLabel("Parameter set: ")
    self.parameterSelector.nodeTypes = ["vtkMRMLSegmentEditorNode"]
    self.parameterSelector.removeEnabled = False
    self.parameterSelector.showHidden = True
    self.parameterSelector.setMRMLScene( slicer.mrmlScene )
    self.parameterLayout = qt.QHBoxLayout()
    self.parameterLayout.addWidget(self.parameterLabel)
    self.parameterLayout.addWidget(self.parameterSelector)
    self.layout.addLayout(self.parameterLayout)
    self.parameterSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.parameterNodeChanged)

    #
    # Segment editor widget
    #
    import qSlicerSegmentationsModuleWidgetsPythonQt
    self.editor = qSlicerSegmentationsModuleWidgetsPythonQt.qMRMLSegmentEditorWidget()
    # Set parameter node first so that the automatic selections made when the scene is set are saved
    self.selectParameterNode()
    self.editor.setMRMLScene(slicer.mrmlScene)
    self.layout.addWidget(self.editor)
    
    # Connect observers to scene events
    self.addObserver(slicer.mrmlScene, slicer.mrmlScene.StartCloseEvent, self.onSceneStartClose)
    self.addObserver(slicer.mrmlScene, slicer.mrmlScene.EndCloseEvent, self.onSceneEndClose)
    self.addObserver(slicer.mrmlScene, slicer.mrmlScene.EndImportEvent, self.onSceneEndImport)
Пример #5
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Collapsible button
    self.selectionCollapsibleButton = ctk.ctkCollapsibleButton()
    self.selectionCollapsibleButton.text = "Selection"
    self.layout.addWidget(self.selectionCollapsibleButton)

    # Layout within the collapsible button
    self.formLayout = qt.QFormLayout(self.selectionCollapsibleButton)

    #
    # the volume selectors
    #
    self.inputFrame = qt.QFrame(self.selectionCollapsibleButton)
    self.inputFrame.setLayout(qt.QHBoxLayout())
    self.formLayout.addWidget(self.inputFrame)
    self.inputSelector = qt.QLabel("Input Vector Volume: ", self.inputFrame)
    self.inputFrame.layout().addWidget(self.inputSelector)
    self.inputSelector = slicer.qMRMLNodeComboBox(self.inputFrame)
    self.inputSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
    self.inputSelector.addEnabled = False
    self.inputSelector.removeEnabled = False
    self.inputSelector.setMRMLScene( slicer.mrmlScene )
    self.inputFrame.layout().addWidget(self.inputSelector)

    self.outputFrame = qt.QFrame(self.selectionCollapsibleButton)
    self.outputFrame.setLayout(qt.QHBoxLayout())
    self.formLayout.addWidget(self.outputFrame)
    self.outputSelector = qt.QLabel("Output Scalar Volume: ", self.outputFrame)
    self.outputFrame.layout().addWidget(self.outputSelector)
    self.outputSelector = slicer.qMRMLNodeComboBox(self.outputFrame)
    self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.outputSelector.setMRMLScene( slicer.mrmlScene )
    self.outputSelector.addEnabled = True
    self.outputSelector.renameEnabled = True
    self.outputSelector.baseName = "Scalar Volume"
    self.outputFrame.layout().addWidget(self.outputSelector)

    # Apply button
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run Convert the vector to scalar."
    self.formLayout.addWidget(self.applyButton)
    self.applyButton.connect('clicked(bool)', self.onApply)

    # Add vertical spacer
    self.layout.addStretch(1)
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.layout.addStretch(1)

        #surfaceModel model selector
        self.surfaceModelSelector = slicer.qMRMLNodeComboBox()
        self.surfaceModelSelector.nodeTypes = ["vtkMRMLModelNode"]
        self.surfaceModelSelector.selectNodeUponCreation = True
        self.surfaceModelSelector.addEnabled = False
        self.surfaceModelSelector.removeEnabled = False
        self.surfaceModelSelector.noneEnabled = False
        self.surfaceModelSelector.showHidden = False
        self.surfaceModelSelector.showChildNodeTypes = True
        self.surfaceModelSelector.setMRMLScene( slicer.mrmlScene)
        self.surfaceModelSelector.setToolTip("Load a ")
        self.layout.addWidget(self.addRow("Surface Model: ", self.surfaceModelSelector))
        
        #Centerline model selector (temporarily)
        self.centerlineSelector = slicer.qMRMLNodeComboBox()
        self.centerlineSelector.nodeTypes = ["vtkMRMLModelNode"]
        self.centerlineSelector.selectNodeUponCreation = True
        self.centerlineSelector.addEnabled = True
        self.centerlineSelector.removeEnabled = True
        self.centerlineSelector.noneEnabled = True
        self.centerlineSelector.showHidden = False
        self.centerlineSelector.showChildNodeTypes = False
        self.centerlineSelector.setMRMLScene( slicer.mrmlScene)
        self.centerlineSelector.setToolTip("Set a model node for the output centerline")
        self.layout.addWidget(self.addRow("Centerline Output: ", self.centerlineSelector))

        self.layout.addWidget(qt.QLabel("Some way to set the source and target points will be needed"))
        self.layout.addWidget(qt.QLabel(" "))

        #A button to perform the desired action
        self.applyButton = qt.QPushButton("Run")
        self.applyButton.enabled = False
        self.layout.addWidget(self.addRow("Run: ", self.applyButton))

        self.layout.addStretch(1)

        #Connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.surfaceModelSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
        self.centerlineSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
Пример #7
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 = ["vtkMRMLVectorVolumeNode"]
    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 histogram." )
    parametersFormLayout.addRow("Input Volume: ", self.inputSelector)

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

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

    # Refresh Apply button state
    self.onSelect()
Пример #8
0
 def createComboBox(self, **kwargs):
   combobox = slicer.qMRMLNodeComboBox()
   combobox.addEnabled = False
   combobox.removeEnabled = False
   combobox.noneEnabled = True
   combobox.showHidden = False
   for key, value in kwargs.iteritems():
     if hasattr(combobox, key):
       setattr(combobox, key, value)
     else:
       logging.error("qMRMLNodeComboBox does not have attribute %s" % key)
   combobox.setMRMLScene(slicer.mrmlScene)
   return combobox
Пример #9
0
  def setup(self):
    # Collapsible button
    self.avgvolumesCollapsibleButton = ctk.ctkCollapsibleButton()
    self.avgvolumesCollapsibleButton.text = "Average Scalar Volumes"
    self.layout.addWidget(self.avgvolumesCollapsibleButton)

    # Layout within the averaging collapsible button
    self.avgvolumesFormLayout = qt.QFormLayout(self.avgvolumesCollapsibleButton)

    #
    # the volume selector
    #
    self.inputFrame = qt.QFrame(self.avgvolumesCollapsibleButton)
    self.inputFrame.setLayout(qt.QHBoxLayout())
    self.avgvolumesFormLayout.addWidget(self.inputFrame)
    self.inputSelector = qt.QLabel("Select input nodes: ", self.inputFrame)


    self.inputFrame.layout().addWidget(self.inputSelector)
    self.inputSelector = slicer.qMRMLCheckableNodeComboBox(self.inputFrame)
    self.inputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    self.inputSelector.addEnabled = True
    self.inputSelector.removeEnabled = True
    self.inputSelector.setMRMLScene( slicer.mrmlScene )
    self.inputFrame.layout().addWidget(self.inputSelector)

    self.outputFrame = qt.QFrame(self.avgvolumesCollapsibleButton)
    self.outputFrame.setLayout(qt.QHBoxLayout())
    self.avgvolumesFormLayout.addWidget(self.outputFrame)
    self.outputSelector = qt.QLabel("Select output reference volume ", self.outputFrame)
    self.outputFrame.layout().addWidget(self.outputSelector)
    self.outputSelector = slicer.qMRMLNodeComboBox(self.outputFrame)
    self.outputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    self.outputSelector.setMRMLScene( slicer.mrmlScene )
    self.outputFrame.layout().addWidget(self.outputSelector)


    # Ok button
    okButton = qt.QPushButton("Ok")
    okButton.toolTip = "Average selected volumes"
    self.avgvolumesFormLayout.addWidget(okButton)
    okButton.connect('clicked(bool)', self.onApply)

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

    # Set local var as instance attribute
    self.okButton = okButton
  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)

    #
    # fiducials
    #
    self.Fiducials = slicer.qMRMLNodeComboBox()
    self.Fiducials.nodeTypes = ( ("vtkMRMLMarkupsFiducialNode"), "" )
    self.Fiducials.selectNodeUponCreation = True
    self.Fiducials.addEnabled = False
    self.Fiducials.removeEnabled = False
    self.Fiducials.noneEnabled = False
    self.Fiducials.showHidden = False
    self.Fiducials.showChildNodeTypes = False
    self.Fiducials.setMRMLScene( slicer.mrmlScene )
    self.Fiducials.setToolTip( "Pick the fiducials." )
    parametersFormLayout.addRow("Fiducials: ", self.Fiducials)

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

    # Refresh Apply button state
    self.onSelect()
Пример #11
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
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Path collapsible button
        pathCollapsibleButton = ctk.ctkCollapsibleButton()
        pathCollapsibleButton.text = "Path"
        self.layout.addWidget(pathCollapsibleButton)

        # Layout within the path collapsible button
        pathFormLayout = qt.QFormLayout(pathCollapsibleButton)

        # Camera node selector
        cameraNodeSelector = slicer.qMRMLNodeComboBox()
        cameraNodeSelector.objectName = 'cameraNodeSelector'
        cameraNodeSelector.toolTip = "Select a camera that will fly along this path."
        cameraNodeSelector.nodeTypes = ['vtkMRMLCameraNode']
        cameraNodeSelector.noneEnabled = False
        cameraNodeSelector.addEnabled = False
        cameraNodeSelector.removeEnabled = False
        cameraNodeSelector.connect('currentNodeChanged(bool)',
                                   self.enableOrDisableCreateButton)
        cameraNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.setCameraNode)
        pathFormLayout.addRow("Camera:", cameraNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            cameraNodeSelector, 'setMRMLScene(vtkMRMLScene*)')

        # Input fiducials node selector
        inputFiducialsNodeSelector = slicer.qMRMLNodeComboBox()
        inputFiducialsNodeSelector.objectName = 'inputFiducialsNodeSelector'
        inputFiducialsNodeSelector.toolTip = "Select a fiducial list to define control points for the path."
        inputFiducialsNodeSelector.nodeTypes = [
            'vtkMRMLMarkupsFiducialNode', 'vtkMRMLAnnotationHierarchyNode',
            'vtkMRMLFiducialListNode'
        ]
        inputFiducialsNodeSelector.noneEnabled = False
        inputFiducialsNodeSelector.addEnabled = False
        inputFiducialsNodeSelector.removeEnabled = False
        inputFiducialsNodeSelector.connect('currentNodeChanged(bool)',
                                           self.enableOrDisableCreateButton)
        pathFormLayout.addRow("Input Fiducials:", inputFiducialsNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            inputFiducialsNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        # CreatePath button
        createPathButton = qt.QPushButton("Create path")
        createPathButton.toolTip = "Create the path."
        createPathButton.enabled = False
        pathFormLayout.addRow(createPathButton)
        createPathButton.connect('clicked()', self.onCreatePathButtonClicked)

        # Flythrough collapsible button
        flythroughCollapsibleButton = ctk.ctkCollapsibleButton()
        flythroughCollapsibleButton.text = "Flythrough"
        flythroughCollapsibleButton.enabled = False
        self.layout.addWidget(flythroughCollapsibleButton)

        # Layout within the Flythrough collapsible button
        flythroughFormLayout = qt.QFormLayout(flythroughCollapsibleButton)

        # Frame slider
        frameSlider = ctk.ctkSliderWidget()
        frameSlider.connect('valueChanged(double)',
                            self.frameSliderValueChanged)
        frameSlider.decimals = 0
        flythroughFormLayout.addRow("Frame:", frameSlider)

        # Frame skip slider
        frameSkipSlider = ctk.ctkSliderWidget()
        frameSkipSlider.connect('valueChanged(double)',
                                self.frameSkipSliderValueChanged)
        frameSkipSlider.decimals = 0
        frameSkipSlider.minimum = 0
        frameSkipSlider.maximum = 50
        flythroughFormLayout.addRow("Frame skip:", frameSkipSlider)

        # Frame delay slider
        frameDelaySlider = ctk.ctkSliderWidget()
        frameDelaySlider.connect('valueChanged(double)',
                                 self.frameDelaySliderValueChanged)
        frameDelaySlider.decimals = 0
        frameDelaySlider.minimum = 5
        frameDelaySlider.maximum = 100
        frameDelaySlider.suffix = " ms"
        frameDelaySlider.value = 20
        flythroughFormLayout.addRow("Frame delay:", frameDelaySlider)

        # View angle slider
        viewAngleSlider = ctk.ctkSliderWidget()
        viewAngleSlider.connect('valueChanged(double)',
                                self.viewAngleSliderValueChanged)
        viewAngleSlider.decimals = 0
        viewAngleSlider.minimum = 30
        viewAngleSlider.maximum = 180
        flythroughFormLayout.addRow("View Angle:", viewAngleSlider)

        # Play button
        playButton = qt.QPushButton("Play")
        playButton.toolTip = "Fly through path."
        playButton.checkable = True
        flythroughFormLayout.addRow(playButton)
        playButton.connect('toggled(bool)', self.onPlayButtonToggled)

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

        # Set local var as instance attribute
        self.cameraNodeSelector = cameraNodeSelector
        self.inputFiducialsNodeSelector = inputFiducialsNodeSelector
        self.createPathButton = createPathButton
        self.flythroughCollapsibleButton = flythroughCollapsibleButton
        self.frameSlider = frameSlider
        self.viewAngleSlider = viewAngleSlider
        self.playButton = playButton

        cameraNodeSelector.setMRMLScene(slicer.mrmlScene)
        inputFiducialsNodeSelector.setMRMLScene(slicer.mrmlScene)
    def setup(self):
        self.logic = lapdMouseVisualizerLogic()
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        #
        # Parameters Area for Tree
        #
        treeCollapsibleButton = ctk.ctkCollapsibleButton()
        treeCollapsibleButton.text = "Tree structure"
        self.layout.addWidget(treeCollapsibleButton)

        # Layout within the dummy collapsible button
        treeFormLayout = qt.QFormLayout(treeCollapsibleButton)

        # input meta file selector
        self.treeInputSelector = ctk.ctkPathLineEdit()
        self.treeInputSelector.nameFilters = ["Tree structure (*.meta)"]
        self.treeInputSelector.setToolTip(
            "Select the *.meta file containing the tree structure.")
        treeFormLayout.addRow("Input tree file: ", self.treeInputSelector)

        # output model selector
        self.treeOutputSelector = slicer.qMRMLNodeComboBox()
        self.treeOutputSelector.nodeTypes = ["vtkMRMLModelNode"]
        self.treeOutputSelector.selectNodeUponCreation = True
        self.treeOutputSelector.addEnabled = True
        self.treeOutputSelector.removeEnabled = True
        self.treeOutputSelector.renameEnabled = True
        self.treeOutputSelector.noneEnabled = False
        self.treeOutputSelector.showHidden = False
        self.treeOutputSelector.showChildNodeTypes = False
        self.treeOutputSelector.setMRMLScene(slicer.mrmlScene)
        self.treeOutputSelector.setToolTip(
            "Pick the output visualization mesh.")
        treeFormLayout.addRow("Output Model: ", self.treeOutputSelector)

        # apply button
        self.treeApplyButton = qt.QPushButton("Apply")
        self.treeApplyButton.toolTip = "Convert *.meta tree to mesh model"
        self.treeApplyButton.connect('clicked()', self.onTreeApply)
        treeFormLayout.addRow("Convert:", self.treeApplyButton)

        #
        # Parameters Area for Compartment Measurement Tables
        #
        measurementsCollapsibleButton = ctk.ctkCollapsibleButton()
        measurementsCollapsibleButton.text = "Compartment Measurements"
        self.layout.addWidget(measurementsCollapsibleButton)

        # Layout within the dummy collapsible button
        measurementsFormLayout = qt.QFormLayout(measurementsCollapsibleButton)

        # input meta file selector
        self.measurementsInputSelector = ctk.ctkPathLineEdit()
        self.measurementsInputSelector.nameFilters = [
            "Compartment Measurement table (*.csv)"
        ]
        self.measurementsInputSelector.setToolTip(
            "Select the *.csv file containing the compartment measurements.")
        measurementsFormLayout.addRow("Input measurements file: ",
                                      self.measurementsInputSelector)

        # input meta file selector
        self.measurementsInputTableSelector = slicer.qMRMLNodeComboBox()
        self.measurementsInputTableSelector.nodeTypes = ["vtkMRMLTableNode"]
        self.measurementsInputTableSelector.selectNodeUponCreation = True
        self.measurementsInputTableSelector.removeEnabled = True
        self.measurementsInputTableSelector.renameEnabled = True
        self.measurementsInputTableSelector.noneEnabled = True
        self.measurementsInputTableSelector.showHidden = False
        self.measurementsInputTableSelector.showChildNodeTypes = False
        self.measurementsInputTableSelector.setMRMLScene(slicer.mrmlScene)
        self.measurementsInputTableSelector.setToolTip(
            "Select table containing the compartment measurements.")
        measurementsFormLayout.addRow("Input measurements table: ",
                                      self.measurementsInputTableSelector)

        # output model selector
        self.measurementsOutputSelector = slicer.qMRMLNodeComboBox()
        self.measurementsOutputSelector.nodeTypes = ["vtkMRMLModelNode"]
        self.measurementsOutputSelector.selectNodeUponCreation = True
        self.measurementsOutputSelector.addEnabled = True
        self.measurementsOutputSelector.removeEnabled = True
        self.measurementsOutputSelector.renameEnabled = True
        self.measurementsOutputSelector.noneEnabled = False
        self.measurementsOutputSelector.showHidden = False
        self.measurementsOutputSelector.showChildNodeTypes = False
        self.measurementsOutputSelector.setMRMLScene(slicer.mrmlScene)
        self.measurementsOutputSelector.setToolTip(
            "Pick the output visualization mesh.")
        measurementsFormLayout.addRow("Output Model: ",
                                      self.measurementsOutputSelector)

        # apply button
        self.measurementsApplyButton = qt.QPushButton("Apply")
        self.measurementsApplyButton.toolTip = "Convert *.csv compartment measurement tables to mesh model"
        self.measurementsApplyButton.connect('clicked()',
                                             self.onMeasurementsApply)
        measurementsFormLayout.addRow("Convert:", self.measurementsApplyButton)

        self.layout.addStretch(1)
Пример #14
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.items():
                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_()
Пример #15
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        ####################
        # For debugging
        #
        # Reload and Test area
        reloadCollapsibleButton = ctk.ctkCollapsibleButton()
        reloadCollapsibleButton.text = "Reload && Test"
        self.layout.addWidget(reloadCollapsibleButton)
        reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "Reload"
        reloadFormLayout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)
        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # input magnitude volume
        #
        self.magnitudevolume = slicer.qMRMLNodeComboBox()
        self.magnitudevolume.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.magnitudevolume.selectNodeUponCreation = True
        self.magnitudevolume.addEnabled = True
        self.magnitudevolume.removeEnabled = True
        self.magnitudevolume.noneEnabled = True
        self.magnitudevolume.showHidden = False
        self.magnitudevolume.showChildNodeTypes = False
        self.magnitudevolume.setMRMLScene(slicer.mrmlScene)
        self.magnitudevolume.setToolTip("Select the magnitude image")
        parametersFormLayout.addRow("Magnitude Image: ", self.magnitudevolume)

        #
        # input phase volume
        #
        self.phasevolume = slicer.qMRMLNodeComboBox()
        self.phasevolume.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.phasevolume.selectNodeUponCreation = True
        self.phasevolume.addEnabled = True
        self.phasevolume.removeEnabled = True
        self.phasevolume.noneEnabled = True
        self.phasevolume.showHidden = False
        self.phasevolume.showChildNodeTypes = False
        self.phasevolume.setMRMLScene(slicer.mrmlScene)
        self.phasevolume.setToolTip("Select the phase image")
        parametersFormLayout.addRow("Phase Image: ", self.phasevolume)

        #
        # Select which scene view to track
        #
        self.sceneViewButton_red = qt.QRadioButton('Red')
        self.sceneViewButton_yellow = qt.QRadioButton('Yellow')
        self.sceneViewButton_green = qt.QRadioButton('Green')
        self.sceneViewButton_green.checked = 1

        layout = qt.QHBoxLayout(parametersCollapsibleButton)
        layout.addWidget(self.sceneViewButton_red)
        layout.addWidget(self.sceneViewButton_yellow)
        layout.addWidget(self.sceneViewButton_green)
        parametersFormLayout.addRow("Scene view:", layout)

        # Auto slice selecter
        self.autosliceselecterButton = qt.QPushButton("Segment Needle")
        self.autosliceselecterButton.toolTip = "Observe slice from scene viewer"
        self.autosliceselecterButton.enabled = False
        parametersFormLayout.addRow(self.autosliceselecterButton)

        realtimebutton = qt.QHBoxLayout()

        #
        # Start Real-Time Tracking
        #
        self.trackingButton = qt.QPushButton("Start Simulated Tracking")
        self.trackingButton.toolTip = "Observe slice from scene viewer"
        self.trackingButton.enabled = False
        self.trackingButton.clicked.connect(self.SimStartTimer)
        realtimebutton.addWidget(self.trackingButton)

        self.SimTimer = qt.QTimer()
        self.SimTimer.timeout.connect(self.onRealTimeTracking)

        # Stop Real-Time Tracking
        self.stopsequence = qt.QPushButton('Stop Simulated Tracking')
        self.stopsequence.clicked.connect(self.SimStopTimer)
        realtimebutton.addWidget(self.stopsequence)

        parametersFormLayout.addRow("", realtimebutton)

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

        ####################################
        ##                                ##
        ## Scanner Remote Control Protocol##
        ##                                ##
        ####################################

        SRCcollapsibleButton = ctk.ctkCollapsibleButton()
        SRCcollapsibleButton.text = "Scanner Remote Control Protocol"
        self.layout.addWidget(SRCcollapsibleButton)
        SRCFormLayout = qt.QFormLayout(SRCcollapsibleButton)

        realtimebutton = qt.QHBoxLayout()

        # FPS
        self.fpsBox = qt.QDoubleSpinBox()
        self.fpsBox.setSingleStep(0.1)
        self.fpsBox.setMaximum(40)
        self.fpsBox.setMinimum(0.1)
        self.fpsBox.setSuffix(" FPS")
        self.fpsBox.value = 0.5
        SRCFormLayout.addRow("Update Rate:", self.fpsBox)

        # Start SRC Real-Time Tracking
        self.SRCtrackingButton = qt.QPushButton("Start Live Tracking")
        self.SRCtrackingButton.toolTip = "Observe slice from scene viewer"
        self.SRCtrackingButton.enabled = False
        self.SRCtrackingButton.clicked.connect(self.StartTimer)
        realtimebutton.addWidget(self.SRCtrackingButton)

        self.timer = qt.QTimer()
        self.timer.timeout.connect(self.SRCRealTimeTracking)

        # Stop Real-Time Tracking
        self.stopsequence = qt.QPushButton('Stop Live Tracking')
        self.stopsequence.clicked.connect(self.StopTimer)
        realtimebutton.addWidget(self.stopsequence)

        SRCFormLayout.addRow("", realtimebutton)

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

        ######################
        # Advanced Parameters#
        ######################

        advancedCollapsibleButton = ctk.ctkCollapsibleButton()
        advancedCollapsibleButton.text = "Advanced"
        advancedCollapsibleButton.collapsed = 1
        self.layout.addWidget(advancedCollapsibleButton)

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

        #
        # 2D slice value
        #
        self.imageSliceSliderWidget = ctk.ctkSliderWidget()
        self.imageSliceSliderWidget.singleStep = 1
        self.imageSliceSliderWidget.minimum = 0
        self.imageSliceSliderWidget.maximum = 70
        self.imageSliceSliderWidget.value = 1
        self.imageSliceSliderWidget.setToolTip("Select 2D slice")
        advancedFormLayout.addRow("2D Slice ", self.imageSliceSliderWidget)

        #
        # Mask Threshold
        #
        self.maskThresholdWidget = ctk.ctkSliderWidget()
        self.maskThresholdWidget.singleStep = 1
        self.maskThresholdWidget.minimum = 0
        self.maskThresholdWidget.maximum = 100
        self.maskThresholdWidget.value = 20
        self.maskThresholdWidget.setToolTip(
            "Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero."
        )
        advancedFormLayout.addRow("Mask Threshold ", self.maskThresholdWidget)

        #
        # Ridge operator filter
        #
        self.ridgeOperatorWidget = ctk.ctkSliderWidget()
        self.ridgeOperatorWidget.singleStep = 1
        self.ridgeOperatorWidget.minimum = 0
        self.ridgeOperatorWidget.maximum = 100
        self.ridgeOperatorWidget.value = 5
        self.ridgeOperatorWidget.setToolTip(
            "set up meijering filter threshold")
        advancedFormLayout.addRow("Ridge Operator Threshold",
                                  self.ridgeOperatorWidget)

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

        #
        # Manual apply Button
        #
        self.applyButton = qt.QPushButton("Manual")
        self.applyButton.toolTip = "Select slice manually"
        self.applyButton.enabled = False
        advancedFormLayout.addRow(self.applyButton)

        # Refresh Apply button state
        self.onSelect()

        #
        # check box to trigger preview final processed image
        #
        self.enableprocessedimagecheckbox = qt.QCheckBox()
        self.enableprocessedimagecheckbox.checked = 0
        self.enableprocessedimagecheckbox.setToolTip(
            "If checked, take screen shots for tutorials. Use Save Data to write them to disk."
        )
        advancedFormLayout.addRow("Enable Processed Image",
                                  self.enableprocessedimagecheckbox)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.trackingButton.connect('clicked(bool)', self.onRealTimeTracking)
        self.SRCtrackingButton.connect('clicked(bool)',
                                       self.SRCRealTimeTracking)
        self.autosliceselecterButton.connect('clicked(bool)',
                                             self.autosliceselecter)
        self.magnitudevolume.connect("currentNodeChanged(vtkMRMLNode*)",
                                     self.onSelect)
        self.phasevolume.connect("currentNodeChanged(vtkMRMLNode*)",
                                 self.onSelect)
        self.lastMatrix = vtk.vtkMatrix4x4()
        self.timer = qt.QTimer()
        self.timer.timeout.connect(self.SRCRealTimeTracking)
        self.SimTimer = qt.QTimer()
        self.SimTimer.timeout.connect(self.onRealTimeTracking)
Пример #16
0
  def setup(self):

    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

    # Layout within the dummy collapsible button
    inputFormLayout = qt.QFormLayout(inputCollapsibleButton)

   # fixed landmarks (mrml input)
    self.fixedLandmarks = slicer.qMRMLNodeComboBox()
    self.fixedLandmarks.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
    self.fixedLandmarks.selectNodeUponCreation = True
    self.fixedLandmarks.addEnabled = False
    self.fixedLandmarks.removeEnabled = False
    self.fixedLandmarks.noneEnabled = True
    self.fixedLandmarks.showHidden = False
    self.fixedLandmarks.renameEnabled = True
    self.fixedLandmarks.setMRMLScene( slicer.mrmlScene )
    self.fixedLandmarks.setToolTip( "Landmarks on fixed image." )
    inputFormLayout.addRow("Fixed landmarks: ", self.fixedLandmarks)

    # fixed landmarks (directory input)
    self.fixedLandmarksDirectory = ctk.ctkDirectoryButton()
    self.fixedLandmarksDirectory.directory = qt.QDir.homePath()
    inputFormLayout.addRow("", self.fixedLandmarksDirectory)

    # moving landmarks (mrml input)
    self.movingLandmarks = slicer.qMRMLNodeComboBox()
    self.movingLandmarks.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
    self.movingLandmarks.selectNodeUponCreation = True
    self.movingLandmarks.addEnabled = False
    self.movingLandmarks.removeEnabled = False
    self.movingLandmarks.noneEnabled = True
    self.movingLandmarks.showHidden = False
    self.movingLandmarks.showChildNodeTypes = False
    self.movingLandmarks.setMRMLScene( slicer.mrmlScene )
    self.movingLandmarks.setToolTip( "Landmarks on moving image." )
    inputFormLayout.addRow("Moving landmarks: ", self.movingLandmarks)

    self.view = qt.QTableView()
    self.view.sortingEnabled = True
    self.parent.layout().addWidget(self.view)

    # moving landmarks (directory input)
    self.movingLandmarksDirectory = ctk.ctkDirectoryButton()
    self.movingLandmarksDirectory.directory = qt.QDir.homePath()
    inputFormLayout.addRow("", self.movingLandmarksDirectory) 

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

    ### Output Area
    outputCollapsibleButton = ctk.ctkCollapsibleButton()
    outputCollapsibleButton.text = "Output statistics"
    self.layout.addWidget(outputCollapsibleButton)

    # Layout within the dummy collapsible button
    outputFormLayout = qt.QFormLayout(outputCollapsibleButton)

    # output statistics 
    buttonLayout = qt.QHBoxLayout()
    self.averageError = qt.QLineEdit()
    self.averageErrorValue = 1
    self.averageError.setToolTip( "Average landmark separation" )
    buttonLayout.addWidget(self.averageError)
    outputFormLayout.addRow("Average error:", buttonLayout)
     
    buttonLayout = qt.QHBoxLayout()
    self.Variance = qt.QLineEdit()
    self.VarianceValue = 1
    self.Variance.setToolTip( "Variance" )
    buttonLayout.addWidget(self.Variance)
    outputFormLayout.addRow("Variance:", buttonLayout)

    buttonLayout = qt.QHBoxLayout()
    self.stDev = qt.QLineEdit()
    self.stDevValue = 1
    self.stDev.setToolTip( "Standard deviation" )
    buttonLayout.addWidget(self.stDev)
    outputFormLayout.addRow("Standard deviation:", buttonLayout)

    # model and view for stats table
    self.view = qt.QTableView()
    self.view.sortingEnabled = True
    self.parent.layout().addWidget(self.view)

    # connections
    self.fixedLandmarks.connect("currentNodeChanged(vtkMRMLNode*)",  self.onFixedLandmarksSelect)
    self.movingLandmarks.connect("currentNodeChanged(vtkMRMLNode*)", self.onMovingLandmarksSelect)
    self.applyButton.connect('clicked(bool)', self.onMismatchErrorApply)
  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)

    #
    # Segmentation volume selector
    #
    self.segmentationSelector = slicer.qMRMLNodeComboBox()
    self.segmentationSelector.nodeTypes = ["vtkMRMLScalarVolumeNode", "vtkMRMLLabelMapVolumeNode"]
    self.segmentationSelector.selectNodeUponCreation = True
    self.segmentationSelector.addEnabled = False
    self.segmentationSelector.removeEnabled = False
    self.segmentationSelector.noneEnabled = False
    self.segmentationSelector.showHidden = False
    self.segmentationSelector.showChildNodeTypes = False
    self.segmentationSelector.setMRMLScene( slicer.mrmlScene )
    self.segmentationSelector.setToolTip("Choose the segmentation to dilate.")
    parametersFormLayout.addRow("Segmentation: ", self.segmentationSelector)

    #
    # False negative volume selector
    #
    self.falseNegativeSelector = slicer.qMRMLNodeComboBox()
    self.falseNegativeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode", "vtkMRMLLabelMapVolumeNode"]
    self.falseNegativeSelector.selectNodeUponCreation = True
    self.falseNegativeSelector.addEnabled = False
    self.falseNegativeSelector.removeEnabled = False
    self.falseNegativeSelector.noneEnabled = False
    self.falseNegativeSelector.showHidden = False
    self.falseNegativeSelector.showChildNodeTypes = False
    self.falseNegativeSelector.setMRMLScene( slicer.mrmlScene )
    self.falseNegativeSelector.setToolTip("Choose the false negative test line.")
    parametersFormLayout.addRow("False negative line: ", self.falseNegativeSelector)

    #
    # True positive volume selector
    #
    self.truePositiveSelector = slicer.qMRMLNodeComboBox()
    self.truePositiveSelector.nodeTypes = ["vtkMRMLScalarVolumeNode", "vtkMRMLLabelMapVolumeNode"]
    self.truePositiveSelector.selectNodeUponCreation = True
    self.truePositiveSelector.addEnabled = False
    self.truePositiveSelector.removeEnabled = False
    self.truePositiveSelector.noneEnabled = False
    self.truePositiveSelector.showHidden = False
    self.truePositiveSelector.showChildNodeTypes = False
    self.truePositiveSelector.setMRMLScene( slicer.mrmlScene )
    self.truePositiveSelector.setToolTip("Choose the true positive test region.")
    parametersFormLayout.addRow("True positive region: ", self.truePositiveSelector)

    #
    # Dilation value
    #
    self.dilationSliderWidget = ctk.ctkSliderWidget()
    self.dilationSliderWidget.singleStep = 1
    self.dilationSliderWidget.minimum = 0
    self.dilationSliderWidget.maximum = 20
    self.dilationSliderWidget.value = 5
    self.dilationSliderWidget.setToolTip("""Set the value to dilate the segmentation
        line when calculating false negatives with respect to the false negative line.""")
    parametersFormLayout.addRow("Dilation factor", self.dilationSliderWidget)

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

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.segmentationSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.falseNegativeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.truePositiveSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

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

    # Refresh Apply button state
    self.onSelect()
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

    #
    # Parameters Area
    #
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Parameters_test"
    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 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 Volume: ", self.inputSelector2)

    #
    # Ruler selector
    #
    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 to sample along. " )
    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)
    #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()
Пример #19
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 ...
        #

        # 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.layout.addWidget(self.parameterNodeSelector)

        # 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.noneDisplay = "Create new table"
        self.outputTableSelector.setMRMLScene(slicer.mrmlScene)
        self.outputTableSelector.nodeTypes = ["vtkMRMLTableNode"]
        self.outputTableSelector.addEnabled = True
        self.outputTableSelector.selectNodeUponCreation = True
        self.outputTableSelector.renameEnabled = True
        self.outputTableSelector.removeEnabled = True
        self.outputTableSelector.noneEnabled = True
        self.outputTableSelector.setToolTip(
            "Select the table where statistics will be saved into")
        self.outputTableSelector.setCurrentNode(None)

        outputFormLayout.addRow("Output table:", self.outputTableSelector)

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

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

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

        # 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()
Пример #20
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    self.logic = ScreenCaptureLogic()
    self.logic.logCallback = self.addLog

    # Instantiate and connect widgets ...

    #
    # Input area
    #
    inputCollapsibleButton = ctk.ctkCollapsibleButton()
    inputCollapsibleButton.text = "Input"
    self.layout.addWidget(inputCollapsibleButton)
    inputFormLayout = qt.QFormLayout(inputCollapsibleButton)

    # Input view selector
    self.viewNodeSelector = slicer.qMRMLNodeComboBox()
    self.viewNodeSelector.nodeTypes = ["vtkMRMLSliceNode", "vtkMRMLViewNode"]
    self.viewNodeSelector.addEnabled = False
    self.viewNodeSelector.removeEnabled = False
    self.viewNodeSelector.noneEnabled = False
    self.viewNodeSelector.showHidden = False
    self.viewNodeSelector.showChildNodeTypes = False
    self.viewNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.viewNodeSelector.setToolTip( "Contents of this slice or 3D view will be captured." )
    inputFormLayout.addRow("View to capture: ", self.viewNodeSelector)

    #
    # Slice view options area
    #
    self.sliceViewOptionsCollapsibleButton = ctk.ctkCollapsibleButton()
    self.sliceViewOptionsCollapsibleButton.text = "Slice view options"
    self.layout.addWidget(self.sliceViewOptionsCollapsibleButton)
    sliceViewOptionsLayout = qt.QFormLayout(self.sliceViewOptionsCollapsibleButton)

    # Slice mode
    self.sliceModeWidget = qt.QComboBox()
    self.sliceModeWidget.addItem("sweep")
    self.sliceModeWidget.addItem("fade")
    self.sliceModeWidget.setToolTip("Select the property that will be adjusted")
    sliceViewOptionsLayout.addRow("Mode:", self.sliceModeWidget)

    # Start slice offset position
    self.startSliceOffsetSliderLabel = qt.QLabel("Start sweep offset:")
    self.startSliceOffsetSliderWidget = ctk.ctkSliderWidget()
    self.startSliceOffsetSliderWidget.singleStep = 30
    self.startSliceOffsetSliderWidget.minimum = -100
    self.startSliceOffsetSliderWidget.maximum = 100
    self.startSliceOffsetSliderWidget.value = 0
    self.startSliceOffsetSliderWidget.setToolTip("Start slice sweep offset.")
    sliceViewOptionsLayout.addRow(self.startSliceOffsetSliderLabel, self.startSliceOffsetSliderWidget)

    # End slice offset position
    self.endSliceOffsetSliderLabel = qt.QLabel("End sweep offset:")
    self.endSliceOffsetSliderWidget = ctk.ctkSliderWidget()
    self.endSliceOffsetSliderWidget.singleStep = 5
    self.endSliceOffsetSliderWidget.minimum = -100
    self.endSliceOffsetSliderWidget.maximum = 100
    self.endSliceOffsetSliderWidget.value = 0
    self.endSliceOffsetSliderWidget.setToolTip("End slice sweep offset.")
    sliceViewOptionsLayout.addRow(self.endSliceOffsetSliderLabel, self.endSliceOffsetSliderWidget)

    #
    # 3D view options area
    #
    self.threeDViewOptionsCollapsibleButton = ctk.ctkCollapsibleButton()
    self.threeDViewOptionsCollapsibleButton.text = "3D view options"
    self.layout.addWidget(self.threeDViewOptionsCollapsibleButton)
    threeDViewOptionsLayout = qt.QFormLayout(self.threeDViewOptionsCollapsibleButton)

    # Start rotation
    self.startRotationSliderWidget = ctk.ctkSliderWidget()
    self.startRotationSliderWidget.singleStep = 5
    self.startRotationSliderWidget.minimum = 0
    self.startRotationSliderWidget.maximum = 180
    self.startRotationSliderWidget.value = 180
    self.startRotationSliderWidget.setToolTip("Rotation angle for the first image, relative to current orientation.")
    threeDViewOptionsLayout.addRow("Start rotation angle:", self.startRotationSliderWidget)

    # End rotation
    self.endRotationSliderWidget = ctk.ctkSliderWidget()
    self.endRotationSliderWidget.singleStep = 5
    self.endRotationSliderWidget.minimum = 0
    self.endRotationSliderWidget.maximum = 180
    self.endRotationSliderWidget.value = 180
    self.endRotationSliderWidget.setToolTip("Rotation angle for the last image, relative to current orientation.")
    threeDViewOptionsLayout.addRow("End rotation angle:", self.endRotationSliderWidget)

    #
    # Output area
    #
    outputCollapsibleButton = ctk.ctkCollapsibleButton()
    outputCollapsibleButton.text = "Output"
    self.layout.addWidget(outputCollapsibleButton)
    outputFormLayout = qt.QFormLayout(outputCollapsibleButton)
    
    # Number of steps value
    self.numberOfStepsSliderWidget = ctk.ctkSliderWidget()
    self.numberOfStepsSliderWidget.singleStep = 10
    self.numberOfStepsSliderWidget.minimum = 2
    self.numberOfStepsSliderWidget.maximum = 150
    self.numberOfStepsSliderWidget.value = 31
    self.numberOfStepsSliderWidget.decimals = 0
    self.numberOfStepsSliderWidget.setToolTip("Number of images extracted between start and stop positions.")
    outputFormLayout.addRow("Number of images:", self.numberOfStepsSliderWidget)

    # Output directory selector
    self.outputDirSelector = ctk.ctkPathLineEdit()
    self.outputDirSelector.filters = ctk.ctkPathLineEdit.Dirs
    self.outputDirSelector.settingKey = 'ScreenCaptureOutputDir'
    outputFormLayout.addRow("Output directory:", self.outputDirSelector)
    if not self.outputDirSelector.currentPath:
      defaultOutputPath = os.path.abspath(os.path.join(slicer.app.defaultScenePath,'SlicerCapture'))
      self.outputDirSelector.setCurrentPath(defaultOutputPath)

    self.videoExportCheckBox = qt.QCheckBox()
    self.videoExportCheckBox.checked = False
    self.videoExportCheckBox.setToolTip("If checked, exported images will be written as a video file.")
    outputFormLayout.addRow("Video export:", self.videoExportCheckBox)

    self.videoFileNameWidget = qt.QLineEdit()
    self.videoFileNameWidget.setToolTip("String that defines file name, type, and numbering scheme. Default: capture.avi.")
    self.videoFileNameWidget.text = "SlicerCapture.avi"
    self.videoFileNameWidget.setEnabled(False)
    outputFormLayout.addRow("Video file name:", self.videoFileNameWidget)

    self.videoLengthSliderWidget = ctk.ctkSliderWidget()
    self.videoLengthSliderWidget.singleStep = 0.1
    self.videoLengthSliderWidget.minimum = 0.1
    self.videoLengthSliderWidget.maximum = 30
    self.videoLengthSliderWidget.value = 5
    self.videoLengthSliderWidget.decimals = 0
    self.videoLengthSliderWidget.setToolTip("Length of the exported video in seconds.")
    self.videoLengthSliderWidget.setEnabled(False)
    outputFormLayout.addRow("Video length:", self.videoLengthSliderWidget)

    # Capture button
    self.captureButton = qt.QPushButton("Capture")
    self.captureButton.toolTip = "Capture slice sweep to image sequence."
    outputFormLayout.addRow(self.captureButton)
        
    self.statusLabel = qt.QPlainTextEdit()
    self.statusLabel.setTextInteractionFlags(qt.Qt.TextSelectableByMouse)
    self.statusLabel.setCenterOnScroll(True)
    outputFormLayout.addRow(self.statusLabel)

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

    self.fileNamePatternWidget = qt.QLineEdit()
    self.fileNamePatternWidget.setToolTip("String that defines file name, type, and numbering scheme. Default: image%05d.png.")
    self.fileNamePatternWidget.text = "image_%05d.png"
    advancedFormLayout.addRow("Image file name pattern:", self.fileNamePatternWidget)

    ffmpegPath = self.logic.getFfmpegPath()
    self.ffmpegPathSelector = ctk.ctkPathLineEdit()
    self.ffmpegPathSelector.setCurrentPath(ffmpegPath)
    self.ffmpegPathSelector.nameFilters = ['ffmpeg.exe', 'ffmpeg']
    self.ffmpegPathSelector.setMaximumWidth(300)
    self.ffmpegPathSelector.setToolTip("Set the path to ffmpeg executable. Download from: https://www.ffmpeg.org/")
    advancedFormLayout.addRow("ffmpeg executable:", self.ffmpegPathSelector)

    self.extraVideoOptionsWidget = qt.QLineEdit()
    self.extraVideoOptionsWidget.text = "-c:v mpeg4 -qscale:v 5"
    #self.extraVideoOptionsWidget.setToolTip("Additional video conversion options passed to ffmpeg.")
    self.extraVideoOptionsWidget.setToolTip(
        "<html>\n"
        "  <b>Examples:</b>"
        "  <ul>"
        "    <li><b>MPEG4:</b> -c:v mpeg4 -qscale:v 5</li>"
        "    <li><b>H264:</b> -c:v libx264 -preset veryslow -qp 0</li>"
        "  </ul>"
        "</html>")
    advancedFormLayout.addRow("Video extra options:", self.extraVideoOptionsWidget)

    # See encoding options at:
    # https://trac.ffmpeg.org/wiki/Encode/H.264
    # https://trac.ffmpeg.org/wiki/Encode/MPEG-4

    # Add vertical spacer
    self.layout.addStretch(1)
    
    # connections
    self.captureButton.connect('clicked(bool)', self.onCaptureButton)
    self.viewNodeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onViewNodeSelected)
    self.sliceModeWidget.connect("currentIndexChanged(int)", self.onSliceViewModeSelected)
    self.startSliceOffsetSliderWidget.connect('valueChanged(double)', self.setSliceOffset)
    self.endSliceOffsetSliderWidget.connect('valueChanged(double)', self.setSliceOffset)
    self.videoExportCheckBox.connect('toggled(bool)', self.fileNamePatternWidget, 'setDisabled(bool)')
    self.videoExportCheckBox.connect('toggled(bool)', self.videoFileNameWidget, 'setEnabled(bool)')
    self.videoExportCheckBox.connect('toggled(bool)', self.videoLengthSliderWidget, 'setEnabled(bool)')

    self.onViewNodeSelected()
Пример #21
0
    def setup(self):

        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        ### Input Area
        inputCollapsibleButton = ctk.ctkCollapsibleButton()
        inputCollapsibleButton.text = "Input"
        self.layout.addWidget(inputCollapsibleButton)

        # Layout within the dummy collapsible button
        inputFormLayout = qt.QFormLayout(inputCollapsibleButton)

        # vf image (mrml input)
        self.vfMRMLSelector = slicer.qMRMLNodeComboBox()
        self.vfMRMLSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
        self.vfMRMLSelector.selectNodeUponCreation = True
        self.vfMRMLSelector.addEnabled = False
        self.vfMRMLSelector.removeEnabled = False
        self.vfMRMLSelector.noneEnabled = True
        self.vfMRMLSelector.showHidden = False
        self.vfMRMLSelector.setMRMLScene(slicer.mrmlScene)
        self.vfMRMLSelector.setToolTip("Pick the input to the algorithm.")
        inputFormLayout.addRow("Vector Field image: ", self.vfMRMLSelector)

        # variables
        self.minJacobianValue = 1
        self.maxJacobianValue = 1

        # vf image (directory input)
        self.vfInputDirectory = ctk.ctkDirectoryButton()
        self.vfInputDirectory.directory = qt.QDir.homePath()
        inputFormLayout.addRow("Input Directory:", self.vfInputDirectory)

        # Fixed image (for geometry info)
        self.fixedImage = slicer.qMRMLNodeComboBox()
        self.fixedImage.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.fixedImage.setMRMLScene(slicer.mrmlScene)
        self.fixedImage.selectNodeUponCreation = True
        self.fixedImage.addEnabled = False
        self.fixedImage.renameEnabled = True
        self.fixedImage.noneEnabled = True
        self.fixedImage.setToolTip(
            "Output image of Jacobian matrix.vtkSlicerPlastimatchModuleLogicPython"
        )
        inputFormLayout.addRow("Fixed image (for geometry info): ",
                               self.fixedImage)

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

        ### Output Area
        outputCollapsibleButton = ctk.ctkCollapsibleButton()
        outputCollapsibleButton.text = "Output"
        self.layout.addWidget(outputCollapsibleButton)

        # Layout within the dummy collapsible button
        outputFormLayout = qt.QFormLayout(outputCollapsibleButton)

        # Jacobian image (mrml output)
        self.outputJacobian = slicer.qMRMLNodeComboBox()
        self.outputJacobian.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.outputJacobian.setMRMLScene(slicer.mrmlScene)
        self.outputJacobian.addEnabled = True
        self.outputJacobian.renameEnabled = True
        #self.outputJacobian.layout().addWidget(self.outputSelector)
        self.outputJacobian.setToolTip(
            "Output image of Jacobian matrix.vtkSlicerPlastimatchModuleLogicPython"
        )
        outputFormLayout.addRow("Jacobian image: ", self.outputJacobian)

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

        # output statistics
        buttonLayout = qt.QHBoxLayout()
        self.minJacobian = qt.QLineEdit()
        self.minJacobian.setToolTip("Minimum value of Jacobian matrix")
        buttonLayout.addWidget(self.minJacobian)
        outputFormLayout.addRow("Minimum Jacobian:", buttonLayout)

        buttonLayout = qt.QHBoxLayout()
        self.maxJacobian = qt.QLineEdit()
        self.maxJacobian.setToolTip("Maximum value of Jacobian matrix")
        buttonLayout.addWidget(self.maxJacobian)
        outputFormLayout.addRow("Maximum Jacobian:", buttonLayout)

        # connections
        self.applyButton.connect('clicked(bool)', self.onJacobianApply)
        self.outputJacobian.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onOutputJacobianSelect)
        self.fixedImage.connect("currentNodeChanged(vtkMRMLNode*)",
                                self.onFixedImageSelect)
        self.vfMRMLSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                    self.onvfMRMLSelect)

        # Add vertical spacer
        self.layout.addStretch(1)
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

    # Layout within the dummy collapsible button
    parametersIOLayout = 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 = True
    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. This should be an MRI strutural images with a type listed in the Image Modality option." )
    parametersIOLayout.addRow("Input Volume: ", self.inputSelector)

    #
    # Image Modality
    #
    self.setImageModalityBooleanWidget = ctk.ctkComboBox()
    self.setImageModalityBooleanWidget.addItem("T1")
    self.setImageModalityBooleanWidget.addItem("T2")
    self.setImageModalityBooleanWidget.addItem("PD")
    self.setImageModalityBooleanWidget.setToolTip(
      "MRI strutural image inserted as a input volume.")
    parametersIOLayout.addRow("Image Modality ", self.setImageModalityBooleanWidget)

    #
    # Is brain extracted?
    #
    self.setIsBETWidget = ctk.ctkCheckBox()
    self.setIsBETWidget.setChecked(True)
    self.setIsBETWidget.setToolTip(
      "Is the input data already brain extracted? If not, the ROBEX brain extraction method is used.")
    parametersIOLayout.addRow("Is Brain Extracted?", self.setIsBETWidget)

    #
    # output volume selector
    #
    self.outputSelector = slicer.qMRMLNodeComboBox()
    self.outputSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.outputSelector.selectNodeUponCreation = True
    self.outputSelector.addEnabled = True
    self.outputSelector.removeEnabled = True
    self.outputSelector.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." )
    parametersIOLayout.addRow("Output Volume: ", self.outputSelector)

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

    # Layout within the dummy collapsible button
    parametersTissueLayout = qt.QFormLayout(parametersTissueCollapsibleButton)

    #
    # Separate one tissue?
    #
    self.setSeparateTissueBooleanWidget = ctk.ctkCheckBox()
    self.setSeparateTissueBooleanWidget.setChecked(False)
    self.setSeparateTissueBooleanWidget.setToolTip(
      "Select one tissue type desired to be passed as the output. If checked, the tissue type in Tissue Type option is used.")
    parametersTissueLayout.addRow("Separate One Tissue?", self.setSeparateTissueBooleanWidget)

    #
    # Tissue Type
    #
    self.setTissueTypeWidget = ctk.ctkComboBox()
    self.setTissueTypeWidget.addItem("White Matter")
    self.setTissueTypeWidget.addItem("Gray Matter")
    self.setTissueTypeWidget.addItem("CSF")
    self.setTissueTypeWidget.setToolTip(
      "Tissue type that will be resulted from the brain segmentation.")
    parametersTissueLayout.addRow("Tissue Type ", self.setTissueTypeWidget)


    #
    # Apply AAD filtering
    #
    self.setApplyAADBooleanWidget = ctk.ctkCheckBox()
    self.setApplyAADBooleanWidget.setChecked(True)
    self.setApplyAADBooleanWidget.setToolTip(
      "Apply the AAD filter on the input data. This is recommended since the image noise level may affect the segmentation performance.")
    parametersTissueLayout.addRow("Apply AAD filter", self.setApplyAADBooleanWidget)


    #
    # Apply Bias Correction
    #
    self.setApplyBiasCorrectionBooleanWidget = ctk.ctkCheckBox()
    self.setApplyBiasCorrectionBooleanWidget.setChecked(True)
    self.setApplyBiasCorrectionBooleanWidget.setToolTip(
      "Apply a bias field correction in the input data. This is recommended since the global signal fluctuation provided by magnetic fiel inhomogeneity may affect the segmentation performance.")
    parametersTissueLayout.addRow("Apply Bias Field Correction", self.setApplyBiasCorrectionBooleanWidget)

    #
    # Apply Label Smoothing
    #
    self.setApplyLabelSmoothingBooleanWidget = ctk.ctkCheckBox()
    self.setApplyLabelSmoothingBooleanWidget.setChecked(True)
    self.setApplyLabelSmoothingBooleanWidget.setToolTip(
      "Apply a post processing procedure to reduce the label variability. Here the label smoothing method based on morphological convolution is applied.")
    parametersTissueLayout.addRow("Apply Label Smoothing", self.setApplyLabelSmoothingBooleanWidget)

    #
    # Parameters Area
    #
    parametersSegmentationCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersSegmentationCollapsibleButton.text = "Expert Segmentation Parameters"
    parametersSegmentationCollapsibleButton.collapsed = True
    self.layout.addWidget(parametersSegmentationCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersSegmentationLayout = qt.QFormLayout(parametersSegmentationCollapsibleButton)

    #
    # Segmentation modality
    #
    self.groupBoxRadioButtons = qt.QGroupBox("Segmentation Method")
    RadioButtonLayout = qt.QFormLayout()
    self.groupBoxRadioButtons.setLayout(RadioButtonLayout)
    self.setRadioKMeans = qt.QRadioButton('K-Means')
    self.setRadioKMeans.setToolTip("K-Means algorithm used in the Basic Brain Segmentation module.")
    self.setRadioBLS = qt.QRadioButton('BLS')
    self.setRadioBLS.setChecked(True)
    self.setRadioBLS.setToolTip("Brain Logistic Segmentation (BLS) method.")
    RadioButtonLayout.addRow(self.setRadioKMeans)
    RadioButtonLayout.addRow(self.setRadioBLS)

    parametersSegmentationLayout.addRow(self.groupBoxRadioButtons)

    # #
    # # Tissue Threshold
    # #
    self.setTissueThresholdWidget = ctk.ctkSliderWidget()
    self.setTissueThresholdWidget.singleStep = 0.01
    self.setTissueThresholdWidget.minimum = 0.01
    self.setTissueThresholdWidget.maximum = 0.99
    self.setTissueThresholdWidget.value = 0.50
    self.setTissueThresholdWidget.setToolTip(
      "Regulates the local logistic classification to each brian tissue. The ideal value is 0.50 which does not offer label overlay, however, if you need a rough estimate of partial tissue volume (PTV), one can set it to other threshold (t<0.5 offer a numbered label estimate to PTV and t>0.5 offer a zero mask to PTV). This parameter is only used when BLS segmentation method is called."
      " Example: t=0.50 means that ...")
    parametersSegmentationLayout.addRow("Tissue Threshold", self.setTissueThresholdWidget)

    #
    # Use manual number of bins?
    #
    self.setManualBinsBooleanWidget = ctk.ctkCheckBox()
    self.setManualBinsBooleanWidget.setChecked(False)
    self.setManualBinsBooleanWidget.setToolTip(
      "Set this if you want to regulate the number of bins manually. This parameter is only used when BLS segmentation method is called.")
    parametersSegmentationLayout.addRow("Use Manual Bins", self.setManualBinsBooleanWidget)

    #
    # Number of Bins: manual setting
    #
    self.setNumberOfBinsWidget = ctk.ctkSliderWidget()
    self.setNumberOfBinsWidget.maximum = 255
    self.setNumberOfBinsWidget.minimum = 12
    self.setNumberOfBinsWidget.value = 32
    self.setNumberOfBinsWidget.singleStep = 1
    self.setNumberOfBinsWidget.setToolTip("Select the number of bins that should be used for the image histogram analysis. This parameter is only used when BLS segmentation method is called")
    parametersSegmentationLayout.addRow("Number Of Bins ", self.setNumberOfBinsWidget)


    #
    # Noise Attenuation Parameters Area
    #
    parametersNoiseAttenuationCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersNoiseAttenuationCollapsibleButton.text = "Noise Attenuation Parameters"
    parametersNoiseAttenuationCollapsibleButton.collapsed = True
    self.layout.addWidget(parametersNoiseAttenuationCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersNoiseAttenuationFormLayout = qt.QFormLayout(parametersNoiseAttenuationCollapsibleButton)

    #
    # Filtering Parameters: Condutance
    #
    self.setFilteringCondutanceWidget = ctk.ctkSliderWidget()
    self.setFilteringCondutanceWidget.maximum = 50
    self.setFilteringCondutanceWidget.minimum = 0
    self.setFilteringCondutanceWidget.value = 10
    self.setFilteringCondutanceWidget.singleStep = 1
    self.setFilteringCondutanceWidget.setToolTip("Condutance parameter.")
    parametersNoiseAttenuationFormLayout.addRow("Condutance ", self.setFilteringCondutanceWidget)

    #
    # Filtering Parameters: Number of iterations
    #
    self.setFilteringNumberOfIterationWidget = ctk.ctkSliderWidget()
    self.setFilteringNumberOfIterationWidget.maximum = 50
    self.setFilteringNumberOfIterationWidget.minimum = 1
    self.setFilteringNumberOfIterationWidget.value = 5
    self.setFilteringNumberOfIterationWidget.singleStep = 1
    self.setFilteringNumberOfIterationWidget.setToolTip("Number of iterations parameter.")
    parametersNoiseAttenuationFormLayout.addRow("Number Of Iterations ", self.setFilteringNumberOfIterationWidget)

    #
    # Filtering Parameters: Q value
    #
    self.setFilteringQWidget = ctk.ctkSliderWidget()
    self.setFilteringQWidget.singleStep = 0.01
    self.setFilteringQWidget.minimum = 0.01
    self.setFilteringQWidget.maximum = 1.99
    self.setFilteringQWidget.value = 1.2
    self.setFilteringQWidget.setToolTip("Q value parameter.")
    parametersNoiseAttenuationFormLayout.addRow("Q Value ", self.setFilteringQWidget)

    #
    # Label Refinement Area
    #
    parametersLabelRefinementCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersLabelRefinementCollapsibleButton.text = "Label Refinement Parameters"
    parametersLabelRefinementCollapsibleButton.collapsed = True
    self.layout.addWidget(parametersLabelRefinementCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersLabelRefinementLayout = qt.QFormLayout(parametersLabelRefinementCollapsibleButton)

    #
    # Gaussian Smooth Label Mask
    #
    self.setGaussianLabelQWidget = qt.QDoubleSpinBox()
    self.setGaussianLabelQWidget.setDecimals(3)
    self.setGaussianLabelQWidget.setMaximum(10)
    self.setGaussianLabelQWidget.setMinimum(0.1)
    self.setGaussianLabelQWidget.setSingleStep(0.1)
    self.setGaussianLabelQWidget.setValue(0.2)
    self.setGaussianLabelQWidget.setToolTip("Label smoothing by a gaussian distribution with variance sigma. The units here is given in mm.")
    parametersLabelRefinementLayout.addRow("Gaussian Sigma ", self.setGaussianLabelQWidget)

    #
    # Apply Button
    #
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the algorithm."
    self.applyButton.enabled = False
    parametersIOLayout.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()
Пример #23
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = VisualizationLogic()
        self.watchDog = None
        self.trackedToolTipTransform = None

        # Instantiate and connect widgets ...

        #
        # Parameters Area
        #

        # watch dog stuff

        watchDogCollapsibleButton = ctk.ctkCollapsibleButton()
        watchDogCollapsibleButton.text = "Tracked Instruments"
        watchDogCollapsibleButton.collapsed = True
        self.layout.addWidget(watchDogCollapsibleButton)
        watchDogCollapsibleButton.connect("clicked(bool)",
                                          self.onWatchDogCollapsibleButton)
        watchDogFormLayout = qt.QFormLayout(watchDogCollapsibleButton)

        self.table = qt.QTableWidget()
        self.table.setColumnCount(2)
        header = ['Name', 'Status']
        self.table.setHorizontalHeaderLabels(header)
        watchDogFormLayout.addWidget(self.table)

        visualizationCollapsibleButton = ctk.ctkCollapsibleButton()
        visualizationCollapsibleButton.text = "Visualization Tools"
        visualizationCollapsibleButton.collapsed = True
        self.layout.addWidget(visualizationCollapsibleButton)
        visualizationFormLayout = qt.QFormLayout(
            visualizationCollapsibleButton)

        # input tool model selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ["vtkMRMLModelNode"]
        self.inputSelector.selectNodeUponCreation = False
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.noneEnabled = True
        self.inputSelector.showHidden = False
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.renameEnabled = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputSelector.setToolTip("The currently navigated tool")
        visualizationFormLayout.addRow("Tracking Tool: ", self.inputSelector)
        # connection
        self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.onToolNavigated)

        self.toolViewCheckBox = qt.QCheckBox()
        self.toolViewCheckBox.checked = 0
        self.toolViewCheckBox.setToolTip(
            "If checked, the views will track the tip of the tool selected")
        self.toolViewCheckBox.connect('stateChanged(int)',
                                      self.onToolViewCheckBox)
        visualizationFormLayout.addRow("Attach views to tool tip",
                                       self.toolViewCheckBox)

        self.toolErrorCheckBox = qt.QCheckBox()
        self.toolErrorCheckBox.checked = 0
        self.toolErrorCheckBox.setToolTip("If checked, the show error cone")
        self.toolErrorCheckBox.connect('stateChanged(int)',
                                       self.onToolErrorCheckBox)
        visualizationFormLayout.addRow("Show the Error cone",
                                       self.toolErrorCheckBox)

        #
        self.screenShotButton = qt.QPushButton("Take Screenshot")
        self.screenShotButton.toolTip = "Takes screenshot of the procedure display and saves the image in the ?? folder."
        self.screenShotButton.enabled = True
        visualizationFormLayout.addRow(self.screenShotButton)

        # connections
        self.screenShotButton.connect('clicked(bool)', self.onScreenShotButton)

        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "RFA Generator Parameters"
        parametersCollapsibleButton.collapsed = True
        self.layout.addWidget(parametersCollapsibleButton)

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

        #
        # input time
        self.rfaTime = qt.QSpinBox()
        self.rfaTime.minimum = 0
        self.rfaTime.maximum = 900
        self.rfaTime.suffix = 's'
        self.rfaTime.setValue(900)
        parametersFormLayout.addRow("Input Ablation Time: ", self.rfaTime)

        #
        # output volume selector
        #
        self.rfaPower = qt.QSpinBox()
        self.rfaPower.minimum = -1
        self.rfaPower.maximum = 15
        self.rfaPower.suffix = 'W'
        self.rfaPower.setValue(5)
        parametersFormLayout.addRow("RFA Power: ", self.rfaPower)

        self.ablationButton = qt.QPushButton("Start Ablation")
        self.ablationButton.toolTip = "Ablation timer countdown"
        self.ablationButton.enabled = True
        parametersFormLayout.addRow(self.ablationButton)

        # connections
        self.ablationButton.connect('clicked(bool)', self.onStartAblation)

        self.qLabel = qt.QLabel('')
        self.layout.addWidget(self.qLabel)

        # Add vertical spacer
        self.layout.addStretch(1)
Пример #24
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)
    
    # 3D view set up tab
    self.meshSelect = slicer.qMRMLNodeComboBox()
    self.meshSelect.nodeTypes = ( ("vtkMRMLModelNode"), "" )
    self.meshSelect.selectNodeUponCreation = False
    self.meshSelect.addEnabled = False
    self.meshSelect.removeEnabled = False
    self.meshSelect.noneEnabled = True
    self.meshSelect.showHidden = False
    self.meshSelect.setMRMLScene( slicer.mrmlScene )
    self.meshSelect.connect("currentNodeChanged(vtkMRMLNode*)", self.onMeshSelect)
    parametersFormLayout.addRow("Model: ", self.meshSelect)
    self.meshSelect.setToolTip( "Select model node for semilandmarking" )

    self.LMSelect = slicer.qMRMLNodeComboBox()
    self.LMSelect.nodeTypes = ( ('vtkMRMLMarkupsFiducialNode'), "" )
    self.LMSelect.selectNodeUponCreation = False
    self.LMSelect.addEnabled = False
    self.LMSelect.removeEnabled = False
    self.LMSelect.noneEnabled = True
    self.LMSelect.showHidden = False
    self.LMSelect.showChildNodeTypes = False
    self.LMSelect.setMRMLScene( slicer.mrmlScene )
    self.LMSelect.connect("currentNodeChanged(vtkMRMLNode*)", self.onLMSelect)
    parametersFormLayout.addRow("Landmark set: ", self.LMSelect)
    self.LMSelect.setToolTip( "Select the landmark set that corresponds to the model" )

    #
    # input landmark numbers for grid
    #
    gridPointsLayout= qt.QGridLayout()
    self.landmarkGridPoint1 = ctk.ctkDoubleSpinBox()
    self.landmarkGridPoint1.minimum = 0
    self.landmarkGridPoint1.singleStep = 1
    self.landmarkGridPoint1.setDecimals(0)
    self.landmarkGridPoint1.setToolTip("Input the landmark numbers to create grid")
    
    self.landmarkGridPoint2 = ctk.ctkDoubleSpinBox()
    self.landmarkGridPoint2.minimum = 0
    self.landmarkGridPoint2.singleStep = 1
    self.landmarkGridPoint2.setDecimals(0)
    self.landmarkGridPoint2.setToolTip("Input the landmark numbers to create grid")
    
    self.landmarkGridPoint3 = ctk.ctkDoubleSpinBox()
    self.landmarkGridPoint3.minimum = 0
    self.landmarkGridPoint3.singleStep = 1
    self.landmarkGridPoint3.setDecimals(0)
    self.landmarkGridPoint3.setToolTip("Input the landmark numbers to create grid")
    
    gridPointsLayout.addWidget(self.landmarkGridPoint1,1,2)
    gridPointsLayout.addWidget(self.landmarkGridPoint2,1,3)
    gridPointsLayout.addWidget(self.landmarkGridPoint3,1,4)
    
    parametersFormLayout.addRow("Semi-landmark grid points:", gridPointsLayout)
    
    #
    # set number of sample points in each triangle
    #
    self.gridSamplingRate = ctk.ctkDoubleSpinBox()
    self.gridSamplingRate.minimum = 3
    self.gridSamplingRate.maximum = 50
    self.gridSamplingRate.singleStep = 1
    self.gridSamplingRate.setDecimals(0)
    self.gridSamplingRate.value = 10
    self.gridSamplingRate.setToolTip("Input the landmark numbers to create grid")
    parametersFormLayout.addRow("Select number of rows/columns in resampled grid:", self.gridSamplingRate)

    #
    # check box to trigger taking screen shots for later use in tutorials
    #
    self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
    self.enableScreenshotsFlagCheckBox.checked = 0
    self.enableScreenshotsFlagCheckBox.setToolTip("If checked, take screen shots for tutorials. Use Save Data to write them to disk.")
    parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox)
    
    #
    # Advanced menu
    #
    advancedCollapsibleButton = ctk.ctkCollapsibleButton()
    advancedCollapsibleButton.text = "Advanced"
    advancedCollapsibleButton.collapsed = True
    parametersFormLayout.addRow(advancedCollapsibleButton)
    
    # Layout within the dummy collapsible button
    advancedFormLayout = qt.QFormLayout(advancedCollapsibleButton)
    
    #
    # Maximum projection slider
    #
    self.projectionDistanceSlider = ctk.ctkSliderWidget()
    self.projectionDistanceSlider.singleStep = 1
    self.projectionDistanceSlider.minimum = 0
    self.projectionDistanceSlider.maximum = 100
    self.projectionDistanceSlider.value = 25
    self.projectionDistanceSlider.setToolTip("Set maximum projection distance as a percentage of image size")
    advancedFormLayout.addRow("Set maximum projection distance: ", self.projectionDistanceSlider)
    
    #
    # Normal smoothing slider
    #
    self.smoothingSlider = ctk.ctkSliderWidget()
    self.smoothingSlider.singleStep = 1
    self.smoothingSlider.minimum = 0
    self.smoothingSlider.maximum = 100
    self.smoothingSlider.value = 0
    self.smoothingSlider.setToolTip("Set smothing of normal vectors for projection")
    advancedFormLayout.addRow("Set smoothing of projection vectors: ", self.smoothingSlider)
    
    #
    # Apply Button
    #
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Generate semilandmarks."
    self.applyButton.enabled = False
    parametersFormLayout.addRow(self.applyButton)
    
    #
    # Fiducials view
    #
    self.fiducialView = slicer.qMRMLSubjectHierarchyTreeView()
    self.fiducialView.setMRMLScene(slicer.mrmlScene)
    self.fiducialView.setMultiSelection(True)
    self.fiducialView.setAlternatingRowColors(True)
    self.fiducialView.setDragDropMode(True)
    self.fiducialView.setColumnHidden(self.fiducialView.model().transformColumn, True);
    self.fiducialView.sortFilterProxyModel().setNodeTypes(["vtkMRMLMarkupsFiducialNode"])
    parametersFormLayout.addRow(self.fiducialView)
    
    #
    # Apply Button
    #
    self.mergeButton = qt.QPushButton("Merge highlighted nodes")
    self.mergeButton.toolTip = "Generate a single merged landmark file from the selected nodes"
    self.mergeButton.enabled = False
    parametersFormLayout.addRow(self.mergeButton)
    
    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.mergeButton.connect('clicked(bool)', self.onMergeButton)
    self.fiducialView.connect('currentItemChanged(vtkIdType)', self.updateMergeButton)
    
    # Add vertical spacer
    self.layout.addStretch(1)
Пример #25
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    ########################################################
    ############# Transform Definition Area ################
    ########################################################
    transformsCollapsibleButton = ctk.ctkCollapsibleButton()
    transformsCollapsibleButton.text = "Transform Definition"
    self.layout.addWidget(transformsCollapsibleButton)
    parametersFormLayout = qt.QFormLayout(transformsCollapsibleButton)

    # ApplicatorToTracker transform selector
    self.applicatorToTrackerSelector = slicer.qMRMLNodeComboBox()
    self.applicatorToTrackerSelector.nodeTypes = ( ("vtkMRMLLinearTransformNode"), "" )
    self.applicatorToTrackerSelector.selectNodeUponCreation = True
    self.applicatorToTrackerSelector.addEnabled = False
    self.applicatorToTrackerSelector.removeEnabled = False
    self.applicatorToTrackerSelector.noneEnabled = False
    self.applicatorToTrackerSelector.showHidden = False
    self.applicatorToTrackerSelector.showChildNodeTypes = False
    self.applicatorToTrackerSelector.setMRMLScene( slicer.mrmlScene )
    self.applicatorToTrackerSelector.setToolTip( "Pick the applicatorToTracker transform." )
    parametersFormLayout.addRow("ApplicatorToTracker transform: ", self.applicatorToTrackerSelector)
 
    # LiacToTracker transform selector
    self.liacToTrackerSelector = slicer.qMRMLNodeComboBox()
    self.liacToTrackerSelector.nodeTypes = ( ("vtkMRMLLinearTransformNode"), "" )
    self.liacToTrackerSelector.selectNodeUponCreation = True
    self.liacToTrackerSelector.addEnabled = False
    self.liacToTrackerSelector.removeEnabled = False
    self.liacToTrackerSelector.noneEnabled = False
    self.liacToTrackerSelector.showHidden = False
    self.liacToTrackerSelector.showChildNodeTypes = False
    self.liacToTrackerSelector.setMRMLScene( slicer.mrmlScene )
    self.liacToTrackerSelector.setToolTip( "Pick the LiacToTracker transform." )
    parametersFormLayout.addRow("LiacToTracker transform: ", self.liacToTrackerSelector)

    ########################################################
    ################## Calibration Area ####################
    ########################################################
    calibrationCollapsibleButton = ctk.ctkCollapsibleButton()
    calibrationCollapsibleButton.text = "Calibration"
    self.layout.addWidget(calibrationCollapsibleButton)
    parametersFormLayout = qt.QFormLayout(calibrationCollapsibleButton)

    #
    # Icons retrieval
    #
    sordinaLIACGuidanceModuleDirectoryPath = slicer.modules.sordinaliacguidance.path.replace("SordinaLIACGuidance.py","")
    recordIcon = qt.QIcon(sordinaLIACGuidanceModuleDirectoryPath + '/Resources/Icons/recordIcon.png')
    stopIcon = qt.QIcon(sordinaLIACGuidanceModuleDirectoryPath + '/Resources/Icons/stopIcon.png')
    restartIcon = qt.QIcon(sordinaLIACGuidanceModuleDirectoryPath + '/Resources/Icons/restartIcon.png')
    saveIcon = qt.QIcon(sordinaLIACGuidanceModuleDirectoryPath + '/Resources/Icons/saveIcon.png')    

    #
    # Up-down movement recording
    #
    upDownMovementGroupBox = ctk.ctkCollapsibleGroupBox()
    upDownMovementGroupBox.setTitle("Up-Down Movement")
    upDownMovementGroupBoxFormLayout = qt.QFormLayout(upDownMovementGroupBox)
    parametersFormLayout.addRow(upDownMovementGroupBox)
  
    upDownMovementLayout = qt.QHBoxLayout()
    upDownMovementGroupBoxFormLayout.addRow(upDownMovementLayout)

    self.upDownRecordButton = qt.QPushButton(" Record")
    self.upDownRecordButton.setIcon(recordIcon)
    self.upDownRecordButton.enabled = True
    upDownMovementLayout.addWidget(self.upDownRecordButton)
    # upDownMovementGroupBoxFormLayout.addRow(self.upDownRecordButton)

    self.upDownStopButton = qt.QPushButton(" Stop")
    self.upDownStopButton.setIcon(stopIcon)
    self.upDownStopButton.enabled = False
    upDownMovementLayout.addWidget(self.upDownStopButton)
    # upDownMovementGroupBoxFormLayout.addRow(self.upDownStopButton)

    self.upDownRestartButton = qt.QPushButton(" Restart")
    self.upDownRestartButton.setIcon(restartIcon)
    self.upDownRestartButton.enabled = False
    upDownMovementLayout.addWidget(self.upDownRestartButton)
    # upDownMovementGroupBoxFormLayout.addRow(self.upDownRestartButton)

    #
    # Roll movement recording
    #
    rollMovementGroupBox = ctk.ctkCollapsibleGroupBox()
    rollMovementGroupBox.setTitle("Roll Movement")
    rollMovementGroupBoxFormLayout = qt.QFormLayout(rollMovementGroupBox)
    parametersFormLayout.addRow(rollMovementGroupBox)

    rollMovementLayout = qt.QHBoxLayout()
    rollMovementGroupBoxFormLayout.addRow(rollMovementLayout)
  
    self.rollRecordButton = qt.QPushButton(" Record")
    self.rollRecordButton.setIcon(recordIcon)
    self.rollRecordButton.enabled = True
    rollMovementLayout.addWidget(self.rollRecordButton)
    # rollMovementGroupBoxFormLayout.addRow(self.rollRecordButton)

    self.rollStopButton = qt.QPushButton(" Stop")
    self.rollStopButton.setIcon(stopIcon)
    self.rollStopButton.enabled = False
    rollMovementLayout.addWidget(self.rollStopButton)
    # rollMovementGroupBoxFormLayout.addRow(self.rollStopButton)

    self.rollRestartButton = qt.QPushButton(" Restart")
    self.rollRestartButton.setIcon(restartIcon)
    self.rollRestartButton.enabled = False
    rollMovementLayout.addWidget(self.rollRestartButton)
    # rollMovementGroupBoxFormLayout.addRow(self.rollRestartButton)

    #
    # Save/load calibration file
    #
    self.saveCalibrationButton = qt.QPushButton(" Save Calibration")
    self.saveCalibrationButton.setIcon(saveIcon)
    self.saveCalibrationButton.enabled = True
    self.saveCalibrationButton.adjustSize()
    
    self.loadCalibrationButton = qt.QPushButton(" Load Calibration")
    self.loadCalibrationButton.setIcon(saveIcon)
    self.loadCalibrationButton.enabled = True
    self.loadCalibrationButton.adjustSize()

    self.calibrationErrorLabel = qt.QLabel('Calibration error: - mm')
    self.calibrationErrorLabel.setStyleSheet("QLabel { color : #000000; font: bold}" )
    
    parametersFormLayout.addRow(self.loadCalibrationButton, self.saveCalibrationButton)
    parametersFormLayout.addRow(self.calibrationErrorLabel)  
    
    #########################################################
    #################### Guidance Area ######################
    #########################################################
    guidanceCollapsibleButton = ctk.ctkCollapsibleButton()
    guidanceCollapsibleButton.text = "Guidance"
    self.layout.addWidget(guidanceCollapsibleButton)
    parametersFormLayout = qt.QFormLayout(guidanceCollapsibleButton)

    # Load Models Button
    self.loadModelsButton = qt.QPushButton()
    self.loadModelsButton.toolTip = "Soft tissue visibility."
    self.loadModelsButton.enabled = True
    self.loadModelsButton.text = "Load 3D Models"
    parametersFormLayout.addRow(self.loadModelsButton)

    # connections
    self.applicatorToTrackerSelector.connect('currentNodeChanged(vtkMRMLNode*)',self.onSelect)
    self.liacToTrackerSelector.connect('currentNodeChanged(vtkMRMLNode*)',self.onSelect)
    self.upDownRecordButton.connect('clicked(bool)', self.onUpDownRecordButton)
    self.upDownStopButton.connect('clicked(bool)', self.onUpDownStopButton)
    self.upDownRestartButton.connect('clicked(bool)', self.onUpDownRestartButton)
    self.rollRecordButton.connect('clicked(bool)', self.onRollRecordButton)
    self.rollStopButton.connect('clicked(bool)', self.onRollStopButton)
    self.rollRestartButton.connect('clicked(bool)', self.onRollRestartButton)
    self.loadModelsButton.connect('clicked(bool)', self.onLoadModelsButton)
    
    self.SordinaLIACGuidanceLogic = SordinaLIACGuidanceLogic()  

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

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

    # check if the SlicerVmtk module is installed properly
    # self.__vmtkInstalled = SlicerVmtkCommonLib.Helper.CheckIfVmtkIsInstalled()
    # Helper.Debug("VMTK found: " + self.__vmtkInstalled)

    #
    # the I/O panel
    #

    ioCollapsibleButton = ctk.ctkCollapsibleButton()
    ioCollapsibleButton.text = "Input/Output"
    self.layout.addWidget( ioCollapsibleButton )

    ioFormLayout = qt.QFormLayout( ioCollapsibleButton )

    # inputVolume selector
    self.__inputModelNodeSelector = slicer.qMRMLNodeComboBox()
    self.__inputModelNodeSelector.objectName = 'inputModelNodeSelector'
    self.__inputModelNodeSelector.toolTip = "Select the input model."
    self.__inputModelNodeSelector.nodeTypes = ['vtkMRMLModelNode']
    self.__inputModelNodeSelector.hideChildNodeTypes = ['vtkMRMLAnnotationNode']  # hide all annotation nodes
    self.__inputModelNodeSelector.noneEnabled = False
    self.__inputModelNodeSelector.addEnabled = False
    self.__inputModelNodeSelector.removeEnabled = False
    ioFormLayout.addRow( "Input Model:", self.__inputModelNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__inputModelNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )
    self.__inputModelNodeSelector.connect( 'currentNodeChanged(vtkMRMLNode*)', self.onInputModelChanged )

    # seed selector
    self.__seedFiducialsNodeSelector = slicer.qMRMLNodeComboBox()
    self.__seedFiducialsNodeSelector.objectName = 'seedFiducialsNodeSelector'
    self.__seedFiducialsNodeSelector.toolTip = "Select a fiducial to use as the origin of the Centerline."
    self.__seedFiducialsNodeSelector.nodeTypes = ['vtkMRMLMarkupsFiducialNode']
    self.__seedFiducialsNodeSelector.baseName = "OriginSeed"
    self.__seedFiducialsNodeSelector.noneEnabled = False
    self.__seedFiducialsNodeSelector.addEnabled = False
    self.__seedFiducialsNodeSelector.removeEnabled = False
    ioFormLayout.addRow( "Start Point:", self.__seedFiducialsNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__seedFiducialsNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )
    self.__seedFiducialsNodeSelector.connect( 'currentNodeChanged(vtkMRMLNode*)', self.onSeedChanged )


    self.__ioAdvancedToggle = qt.QCheckBox( "Show Advanced Properties" )
    self.__ioAdvancedToggle.setChecked( False )
    ioFormLayout.addRow( self.__ioAdvancedToggle )

    #
    # I/O advanced panel
    #

    self.__ioAdvancedPanel = qt.QFrame( ioCollapsibleButton )
    self.__ioAdvancedPanel.hide()
    self.__ioAdvancedPanel.setFrameStyle( 6 )
    ioFormLayout.addRow( self.__ioAdvancedPanel )
    self.__ioAdvancedToggle.connect( "clicked()", self.onIOAdvancedToggle )

    ioAdvancedFormLayout = qt.QFormLayout( self.__ioAdvancedPanel )

    # outputModel selector
    self.__outputModelNodeSelector = slicer.qMRMLNodeComboBox()
    self.__outputModelNodeSelector.objectName = 'outputModelNodeSelector'
    self.__outputModelNodeSelector.toolTip = "Select the output model for the Centerlines."
    self.__outputModelNodeSelector.nodeTypes = ['vtkMRMLModelNode']
    self.__outputModelNodeSelector.baseName = "CenterlineComputationModel"
    self.__outputModelNodeSelector.hideChildNodeTypes = ['vtkMRMLAnnotationNode']  # hide all annotation nodes
    self.__outputModelNodeSelector.noneEnabled = False
    self.__outputModelNodeSelector.addEnabled = True
    self.__outputModelNodeSelector.selectNodeUponCreation = True
    self.__outputModelNodeSelector.removeEnabled = True
    ioAdvancedFormLayout.addRow( "Output Centerline Model:", self.__outputModelNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__outputModelNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )

    # voronoiModel selector
    self.__voronoiModelNodeSelector = slicer.qMRMLNodeComboBox()
    self.__voronoiModelNodeSelector.objectName = 'voronoiModelNodeSelector'
    self.__voronoiModelNodeSelector.toolTip = "Select the output model for the Voronoi Diagram."
    self.__voronoiModelNodeSelector.nodeTypes = ['vtkMRMLModelNode']
    self.__voronoiModelNodeSelector.baseName = "VoronoiModel"
    self.__voronoiModelNodeSelector.hideChildNodeTypes = ['vtkMRMLAnnotationNode']  # hide all annotation nodes
    self.__voronoiModelNodeSelector.noneEnabled = False
    self.__voronoiModelNodeSelector.addEnabled = True
    self.__voronoiModelNodeSelector.selectNodeUponCreation = True
    self.__voronoiModelNodeSelector.removeEnabled = True
    ioAdvancedFormLayout.addRow( "Output Voronoi Model:", self.__voronoiModelNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__voronoiModelNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )




    #
    # Reset, preview and apply buttons
    #

    self.__buttonBox = qt.QDialogButtonBox()
    self.__resetButton = self.__buttonBox.addButton( self.__buttonBox.RestoreDefaults )
    self.__resetButton.toolTip = "Click to reset all input elements to default."
    self.__previewButton = self.__buttonBox.addButton( self.__buttonBox.Discard )
    self.__previewButton.setIcon( qt.QIcon() )
    self.__previewButton.text = "Preview.."
    self.__previewButton.toolTip = "Click to refresh the preview."
    self.__startButton = self.__buttonBox.addButton( self.__buttonBox.Apply )
    self.__startButton.setIcon( qt.QIcon() )
    self.__startButton.text = "Start!"
    self.__startButton.enabled = False
    self.__startButton.toolTip = "Click to start the filtering."
    self.layout.addWidget( self.__buttonBox )
    self.__resetButton.connect( "clicked()", self.restoreDefaults )
    self.__previewButton.connect( "clicked()", self.onRefreshButtonClicked )
    self.__startButton.connect( "clicked()", self.onStartButtonClicked )

    self.__inputModelNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.__seedFiducialsNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.__outputModelNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.__voronoiModelNodeSelector.setMRMLScene( slicer.mrmlScene )

    # be ready for events
    self.__updating = 0

    # set default values
    self.restoreDefaults()

    # compress the layout
    self.layout.addStretch( 1 )
Пример #27
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

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

    # Collapsible button
    self.selectionCollapsibleButton = ctk.ctkCollapsibleButton()
    self.selectionCollapsibleButton.text = "Selection"
    self.layout.addWidget(self.selectionCollapsibleButton)

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

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

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

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

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

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

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

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

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

    # conversion widget
    self.conversionMethodWidget.methodSelectorComboBox.connect('currentIndexChanged(int)',
                                        lambda currentIndex:
                                        self.conversionMethodWidget.setGuiBasedOnOptions(
                                          self.conversionMethodWidget.methodSelectorComboBox.itemData(currentIndex),
                                          self.inputVolumeNode())
                                        )
    self.conversionMethodWidget.methodSelectorComboBox.connect('currentIndexChanged(int)', self.updateParameterNodeFromGui)
    self.conversionMethodWidget.componentsComboBox.connect('currentIndexChanged(int)', self.updateParameterNodeFromGui)

    # The parameter node had defaults at creation, propagate them to the GUI.
    self.updateGuiFromMRML()
Пример #28
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()
Пример #29
0
  def setup(self):
    #
    # the grayscale volume selector
    #
    self.grayscaleSelectorFrame = qt.QFrame(self.parent)
    self.grayscaleSelectorFrame.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(self.grayscaleSelectorFrame)

    self.grayscaleSelectorLabel = qt.QLabel("Grayscale Volume: ", self.grayscaleSelectorFrame)
    self.grayscaleSelectorLabel.setToolTip( "Select the grayscale volume (background grayscale scalar volume node) for statistics calculations")
    self.grayscaleSelectorFrame.layout().addWidget(self.grayscaleSelectorLabel)

    self.grayscaleSelector = slicer.qMRMLNodeComboBox(self.grayscaleSelectorFrame)
    self.grayscaleSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.grayscaleSelector.selectNodeUponCreation = False
    self.grayscaleSelector.addEnabled = False
    self.grayscaleSelector.removeEnabled = False
    self.grayscaleSelector.noneEnabled = True
    self.grayscaleSelector.showHidden = False
    self.grayscaleSelector.showChildNodeTypes = False
    self.grayscaleSelector.setMRMLScene( slicer.mrmlScene )
    # TODO: need to add a QLabel
    # self.grayscaleSelector.SetLabelText( "Master Volume:" )
    self.grayscaleSelectorFrame.layout().addWidget(self.grayscaleSelector)

    #
    # the label volume selector
    #
    self.labelSelectorFrame = qt.QFrame()
    self.labelSelectorFrame.setLayout( qt.QHBoxLayout() )
    self.parent.layout().addWidget( self.labelSelectorFrame )

    self.labelSelectorLabel = qt.QLabel()
    self.labelSelectorLabel.setText( "Label Map: " )
    self.labelSelectorFrame.layout().addWidget( self.labelSelectorLabel )

    self.labelSelector = slicer.qMRMLNodeComboBox()
    self.labelSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    # todo addAttribute
    self.labelSelector.selectNodeUponCreation = False
    self.labelSelector.addEnabled = False
    self.labelSelector.noneEnabled = True
    self.labelSelector.removeEnabled = False
    self.labelSelector.showHidden = False
    self.labelSelector.showChildNodeTypes = True
    self.labelSelector.setMRMLScene( slicer.mrmlScene )
    self.labelSelector.setToolTip( "Pick the label map to edit" )
    self.labelSelectorFrame.layout().addWidget( self.labelSelector )

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

    # model and view for stats table
    self.view = qt.QTableView()
    self.view.sortingEnabled = True
    self.parent.layout().addWidget(self.view)

    # Chart button
    self.chartFrame = qt.QFrame()
    self.chartFrame.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(self.chartFrame)
    self.chartButton = qt.QPushButton("Chart")
    self.chartButton.toolTip = "Make a chart from the current statistics."
    self.chartFrame.layout().addWidget(self.chartButton)
    self.chartOption = qt.QComboBox()
    self.chartOption.addItems(self.chartOptions)
    self.chartFrame.layout().addWidget(self.chartOption)
    self.chartIgnoreZero = qt.QCheckBox()
    self.chartIgnoreZero.setText('Ignore Zero')
    self.chartIgnoreZero.checked = False
    self.chartIgnoreZero.setToolTip('Do not include the zero index in the chart to avoid dwarfing other bars')
    self.chartFrame.layout().addWidget(self.chartIgnoreZero)
    self.chartFrame.enabled = False


    # Save button
    self.saveButton = qt.QPushButton("Save")
    self.saveButton.toolTip = "Calculate Statistics."
    self.saveButton.enabled = False
    self.parent.layout().addWidget(self.saveButton)

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

    # connections
    self.applyButton.connect('clicked()', self.onApply)
    self.chartButton.connect('clicked()', self.onChart)
    self.saveButton.connect('clicked()', self.onSave)
    self.grayscaleSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onGrayscaleSelect)
    self.labelSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onLabelSelect)
Пример #30
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    #
    # Parameter Combobox
    #
    self.parameterSelector = slicer.qMRMLNodeComboBox()
    self.parameterLabel = qt.QLabel("  Parameter set: ")
    self.parameterSelector.nodeTypes = ["vtkMRMLScriptedModuleNode"]
    self.parameterSelector.removeEnabled = False
    self.parameterSelector.showHidden = True
    self.parameterSelector.setMRMLScene( slicer.mrmlScene )
    self.parameterLayout = qt.QHBoxLayout()
    self.parameterLayout.addWidget(self.parameterLabel)
    self.parameterLayout.addWidget(self.parameterSelector)
    self.layout.addLayout(self.parameterLayout)

    #
    # Input Area
    #
    inputCollapsibleButton = ctk.ctkCollapsibleButton()
    inputCollapsibleButton.text = "Input"
    self.layout.addWidget(inputCollapsibleButton)

    # Layout within the dummy collapsible button
    inputFormLayout = qt.QFormLayout(inputCollapsibleButton)

    #
    # Input first DVH selector
    #
    self.dvh1Selector = slicer.qMRMLNodeComboBox()
    self.dvh1Selector.nodeTypes = ["vtkMRMLDoubleArrayNode"]
    self.dvh1Selector.removeEnabled = False
    self.dvh1Selector.setMRMLScene( slicer.mrmlScene )
    inputFormLayout.addRow("DVH 1: ", self.dvh1Selector)

    #
    # Input second DVH selector
    #
    self.dvh2Selector = slicer.qMRMLNodeComboBox()
    self.dvh2Selector.nodeTypes = ["vtkMRMLDoubleArrayNode"]
    self.dvh2Selector.removeEnabled = False
    self.dvh2Selector.setMRMLScene( slicer.mrmlScene )
    inputFormLayout.addRow("DVH 2: ", self.dvh2Selector)

    #
    # Input the dose volume
    #
    self.doseVolumeSelector = slicer.qMRMLNodeComboBox()
    self.doseVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.doseVolumeSelector.addAttribute("vtkMRMLScalarVolumeNode", "DicomRtImport.DoseVolume")
    self.doseVolumeSelector.removeEnabled = False
    self.doseVolumeSelector.setMRMLScene( slicer.mrmlScene )
    inputFormLayout.addRow("Dose Volume: ", self.doseVolumeSelector)

    #
    # Dose volume only check box
    #
    self.showDoseVolumeOnlyCheckbox = qt.QCheckBox("Show dose volume only")
    self.showDoseVolumeOnlyCheckbox.setChecked(2)
    inputFormLayout.addWidget(self.showDoseVolumeOnlyCheckbox)	

    #
    # Volume difference criterion spin box
    #
    self.volumeDifferenceSpinbox = qt.QDoubleSpinBox()
    self.volumeDifferenceSpinbox.setValue(1.0)
    self.volumeDifferenceSpinbox.setDecimals(1)
    self.volumeDifferenceSpinbox.setSingleStep(0.1)
    inputFormLayout.addRow("Volume difference criterion: ", self.volumeDifferenceSpinbox)

    #
    # Dose to agreement criterion spin box
    #
    self.doseToAgreementSpinbox = qt.QDoubleSpinBox()
    self.doseToAgreementSpinbox.setValue(1.0)
    self.doseToAgreementSpinbox.setDecimals(1)
    self.doseToAgreementSpinbox.setSingleStep(0.1)
    inputFormLayout.addRow("Dose to agreement criterion: ", self.doseToAgreementSpinbox)

    #
    # Compute button
    #
    self.computeButton = qt.QPushButton("Compute")
    self.computeButtonLayout = qt.QVBoxLayout()
    self.computeButtonLayout.addStrut(100)
    self.computeButtonLayout.setAlignment(2)
    self.computeButtonLayout.addWidget(self.computeButton)
    self.computeButtonFont = qt.QFont()
    self.computeButtonFont.setBold(True)
    self.computeButton.setFont(self.computeButtonFont)
    inputFormLayout.addRow(self.computeButtonLayout)

    #
    # Output Area
    #
    outputCollapsibleButton = ctk.ctkCollapsibleButton()
    outputCollapsibleButton.text = "Output"
    self.layout.addWidget(outputCollapsibleButton)

    # Layout within the dummy collapsible button
    outputFormLayout = qt.QFormLayout(outputCollapsibleButton)

    self.agreementAcceptanceOutput = qt.QLineEdit()
    self.agreementAcceptanceOutput.setReadOnly(True)
    outputFormLayout.addRow("Agreement acceptance %: ", self.agreementAcceptanceOutput)

    #
    # Visualize Area
    #
    chartCollapsibleButton = ctk.ctkCollapsibleButton()
    chartCollapsibleButton.text = "Visualize"
    self.layout.addWidget(chartCollapsibleButton)

    # Layout within the dummy collapsible button
    chartFormLayout = qt.QFormLayout(chartCollapsibleButton)

    #
    # Input the chart node
    #
    self.chartNodeSelector = slicer.qMRMLNodeComboBox()
    self.chartNodeSelector.nodeTypes = ["vtkMRMLChartNode"]
    self.chartNodeSelector.setMRMLScene( slicer.mrmlScene )
    chartFormLayout.addRow(self.chartNodeSelector)

    self.checkboxList = []
    self.structureList = []

    #
    # Dvh List
    #
    self.dvhTable = qt.QTableWidget();
    chartFormLayout.addWidget(self.dvhTable)


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

    # Connections
    self.parameterSelector.connect('nodeAddedByUser(vtkMRMLNode*)', self.parameterNodeCreated)
    self.parameterSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.updateFromParameter)

    self.showDoseVolumeOnlyCheckbox.connect('stateChanged(int)', self.showDoseVolumesOnlyCheckboxChanged)
    
    self.dvh1Selector.connect("currentNodeChanged(vtkMRMLNode*)", self.dvh1SelectorChanged)
    self.dvh2Selector.connect("currentNodeChanged(vtkMRMLNode*)", self.dvh2SelectorChanged)
    self.doseVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.doseVolumeSelectorChanged)
    
    self.volumeDifferenceSpinbox.connect("valueChanged(double)", self.volumeDifferenceSpinboxChanged)
    self.doseToAgreementSpinbox.connect("valueChanged(double)", self.doseToAgreementSpinboxChanged)

    self.computeButton.connect('clicked(bool)', self.onComputeButton)

    self.chartNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.updateChecksFromChart)

    self.updatingStatus = False

    self.nodeCheck()

    self.updateFromParameter(self.parameterSelector.currentNode())

    self.updateTable()    
    currentChart = self.chartNodeSelector.currentNode()
    if (currentChart != None):
      self.updateChecksFromChart(currentChart)
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        #
        # the I/O panel
        #

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

        # inputVolume selector
        self.inputVolumeNodeSelector = slicer.qMRMLNodeComboBox()
        self.inputVolumeNodeSelector.objectName = 'inputVolumeNodeSelector'
        self.inputVolumeNodeSelector.toolTip = "Select the input volume. This should always be the original image and not a vesselness image, if possible."
        self.inputVolumeNodeSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.inputVolumeNodeSelector.noneEnabled = False
        self.inputVolumeNodeSelector.addEnabled = False
        self.inputVolumeNodeSelector.removeEnabled = False
        inputsFormLayout.addRow("Input Volume:", self.inputVolumeNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.inputVolumeNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')
        self.inputVolumeNodeSelector.connect(
            'currentNodeChanged(vtkMRMLNode*)', self.onInputVolumeChanged)

        # vesselnessVolume selector
        self.vesselnessVolumeNodeSelector = slicer.qMRMLNodeComboBox()
        self.vesselnessVolumeNodeSelector.objectName = 'vesselnessVolumeNodeSelector'
        self.vesselnessVolumeNodeSelector.toolTip = "Select the input vesselness volume."
        self.vesselnessVolumeNodeSelector.nodeTypes = [
            'vtkMRMLScalarVolumeNode'
        ]
        self.vesselnessVolumeNodeSelector.noneEnabled = True
        self.vesselnessVolumeNodeSelector.addEnabled = False
        self.vesselnessVolumeNodeSelector.removeEnabled = False
        inputsFormLayout.addRow("Vesselness Volume:",
                                self.vesselnessVolumeNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.vesselnessVolumeNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')
        self.vesselnessVolumeNodeSelector.connect(
            'currentNodeChanged(vtkMRMLNode*)', self.onVesselnessVolumeChanged)
        self.vesselnessVolumeNodeSelector.setCurrentNode(None)

        # seed selector
        self.seedFiducialsNodeSelector = slicer.qSlicerSimpleMarkupsWidget()
        self.seedFiducialsNodeSelector.objectName = 'seedFiducialsNodeSelector'
        self.seedFiducialsNodeSelector.toolTip = "Select start and end point of the vessel branch. Only the first and last point in the list are used."
        self.seedFiducialsNodeSelector.defaultNodeColor = qt.QColor(
            0, 0, 255)  # blue
        self.seedFiducialsNodeSelector.jumpToSliceEnabled = True
        self.seedFiducialsNodeSelector.markupsPlaceWidget(
        ).placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceMultipleMarkups
        self.seedFiducialsNodeSelector.setNodeBaseName("seeds")
        self.seedFiducialsNodeSelector.markupsSelectorComboBox(
        ).baseName = "Seeds"
        self.seedFiducialsNodeSelector.markupsSelectorComboBox(
        ).noneEnabled = False
        self.seedFiducialsNodeSelector.markupsSelectorComboBox(
        ).removeEnabled = True
        inputsFormLayout.addRow("Seeds:", self.seedFiducialsNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.seedFiducialsNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        # stopper selector
        self.stopperFiducialsNodeSelector = slicer.qSlicerSimpleMarkupsWidget()
        self.stopperFiducialsNodeSelector.objectName = 'stopperFiducialsNodeSelector'
        self.stopperFiducialsNodeSelector.toolTip = "(Optional) Select a hierarchy containing the fiducials to use as Stoppers. Whenever one stopper is reached, the segmentation stops."
        self.stopperFiducialsNodeSelector.defaultNodeColor = qt.QColor(
            0, 0, 255)  # blue
        self.stopperFiducialsNodeSelector.setNodeBaseName("seeds")
        self.stopperFiducialsNodeSelector.tableWidget().hide()
        self.stopperFiducialsNodeSelector.markupsSelectorComboBox(
        ).baseName = "Stoppers"
        self.stopperFiducialsNodeSelector.markupsSelectorComboBox(
        ).noneEnabled = True
        self.stopperFiducialsNodeSelector.markupsSelectorComboBox(
        ).removeEnabled = True
        inputsFormLayout.addRow("Stoppers:", self.stopperFiducialsNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.stopperFiducialsNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        #
        # Outputs
        #

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

        # outputVolume selector
        self.outputVolumeNodeSelector = slicer.qMRMLNodeComboBox()
        self.outputVolumeNodeSelector.toolTip = "Select the output labelmap."
        self.outputVolumeNodeSelector.nodeTypes = ['vtkMRMLLabelMapVolumeNode']
        self.outputVolumeNodeSelector.baseName = "LevelSetSegmentation"
        self.outputVolumeNodeSelector.noneEnabled = False
        self.outputVolumeNodeSelector.addEnabled = True
        self.outputVolumeNodeSelector.selectNodeUponCreation = True
        self.outputVolumeNodeSelector.removeEnabled = True
        outputsFormLayout.addRow("Output Labelmap:",
                                 self.outputVolumeNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.outputVolumeNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        # outputModel selector
        self.outputModelNodeSelector = slicer.qMRMLNodeComboBox()
        self.outputModelNodeSelector.objectName = 'outputModelNodeSelector'
        self.outputModelNodeSelector.toolTip = "Select the output model."
        self.outputModelNodeSelector.nodeTypes = ['vtkMRMLModelNode']
        self.outputModelNodeSelector.hideChildNodeTypes = [
            'vtkMRMLAnnotationNode'
        ]  # hide all annotation nodes
        self.outputModelNodeSelector.baseName = "LevelSetSegmentationModel"
        self.outputModelNodeSelector.noneEnabled = False
        self.outputModelNodeSelector.addEnabled = True
        self.outputModelNodeSelector.selectNodeUponCreation = True
        self.outputModelNodeSelector.removeEnabled = True
        outputsFormLayout.addRow("Output Model:", self.outputModelNodeSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.outputModelNodeSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        #
        # the segmentation panel
        #

        segmentationCollapsibleButton = ctk.ctkCollapsibleButton()
        segmentationCollapsibleButton.text = "Segmentation"
        self.layout.addWidget(segmentationCollapsibleButton)

        segmentationFormLayout = qt.QFormLayout(segmentationCollapsibleButton)

        # Threshold slider
        thresholdLabel = qt.QLabel()
        thresholdLabel.text = "Thresholding" + (' ' * 7)
        thresholdLabel.toolTip = "Choose the intensity range to segment."
        thresholdLabel.setAlignment(4)
        segmentationFormLayout.addRow(thresholdLabel)

        self.thresholdSlider = slicer.qMRMLRangeWidget()
        segmentationFormLayout.addRow(self.thresholdSlider)
        self.thresholdSlider.connect('valuesChanged(double,double)',
                                     self.onThresholdSliderChanged)

        self.segmentationAdvancedToggle = qt.QCheckBox(
            "Show Advanced Segmentation Properties")
        self.segmentationAdvancedToggle.setChecked(False)
        segmentationFormLayout.addRow(self.segmentationAdvancedToggle)

        #
        # segmentation advanced panel
        #

        self.segmentationAdvancedPanel = qt.QFrame(
            segmentationCollapsibleButton)
        self.segmentationAdvancedPanel.hide()
        self.segmentationAdvancedPanel.setFrameStyle(6)
        segmentationFormLayout.addRow(self.segmentationAdvancedPanel)
        self.segmentationAdvancedToggle.connect(
            "clicked()", self.onSegmentationAdvancedToggle)

        segmentationAdvancedFormLayout = qt.QFormLayout(
            self.segmentationAdvancedPanel)

        # inflation slider
        inflationLabel = qt.QLabel()
        inflationLabel.text = "less inflation <-> more inflation" + (' ' * 14)
        inflationLabel.setAlignment(4)
        inflationLabel.toolTip = "Define how fast the segmentation expands."
        segmentationAdvancedFormLayout.addRow(inflationLabel)

        self.inflationSlider = ctk.ctkSliderWidget()
        self.inflationSlider.decimals = 0
        self.inflationSlider.minimum = -100
        self.inflationSlider.maximum = 100
        self.inflationSlider.singleStep = 10
        self.inflationSlider.toolTip = inflationLabel.toolTip
        segmentationAdvancedFormLayout.addRow(self.inflationSlider)

        # curvature slider
        curvatureLabel = qt.QLabel()
        curvatureLabel.text = "less curvature <-> more curvature" + (' ' * 14)
        curvatureLabel.setAlignment(4)
        curvatureLabel.toolTip = "Choose a high curvature to generate a smooth segmentation."
        segmentationAdvancedFormLayout.addRow(curvatureLabel)

        self.curvatureSlider = ctk.ctkSliderWidget()
        self.curvatureSlider.decimals = 0
        self.curvatureSlider.minimum = -100
        self.curvatureSlider.maximum = 100
        self.curvatureSlider.singleStep = 10
        self.curvatureSlider.toolTip = curvatureLabel.toolTip
        segmentationAdvancedFormLayout.addRow(self.curvatureSlider)

        # attraction slider
        attractionLabel = qt.QLabel()
        attractionLabel.text = "less attraction to gradient <-> more attraction to gradient" + (
            ' ' * 14)
        attractionLabel.setAlignment(4)
        attractionLabel.toolTip = "Configure how the segmentation travels towards gradient ridges (vessel lumen wall)."
        segmentationAdvancedFormLayout.addRow(attractionLabel)

        self.attractionSlider = ctk.ctkSliderWidget()
        self.attractionSlider.decimals = 0
        self.attractionSlider.minimum = -100
        self.attractionSlider.maximum = 100
        self.attractionSlider.singleStep = 10
        self.attractionSlider.toolTip = attractionLabel.toolTip
        segmentationAdvancedFormLayout.addRow(self.attractionSlider)

        # iteration spinbox
        self.iterationSpinBox = qt.QSpinBox()
        self.iterationSpinBox.minimum = 0
        self.iterationSpinBox.maximum = 5000
        self.iterationSpinBox.singleStep = 10
        self.iterationSpinBox.toolTip = "Choose the number of evolution iterations."
        segmentationAdvancedFormLayout.addRow((' ' * 100) + "Iterations:",
                                              self.iterationSpinBox)

        #
        # Reset, preview and apply buttons
        #

        self.buttonBox = qt.QDialogButtonBox()
        self.resetButton = self.buttonBox.addButton(
            self.buttonBox.RestoreDefaults)
        self.resetButton.toolTip = "Click to reset all input elements to default."
        self.previewButton = self.buttonBox.addButton(self.buttonBox.Discard)
        self.previewButton.setIcon(qt.QIcon())
        self.previewButton.text = "Preview"
        self.previewButton.toolTip = "Click to refresh the preview."
        self.startButton = self.buttonBox.addButton(self.buttonBox.Apply)
        self.startButton.setIcon(qt.QIcon())
        self.startButton.text = "Start"
        self.startButton.enabled = False
        self.startButton.toolTip = "Click to start the filtering."
        self.layout.addWidget(self.buttonBox)
        self.resetButton.connect("clicked()", self.restoreDefaults)
        self.previewButton.connect("clicked()", self.onPreviewButtonClicked)
        self.startButton.connect("clicked()", self.onStartButtonClicked)

        self.inputVolumeNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.seedFiducialsNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.vesselnessVolumeNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.outputVolumeNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.outputModelNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.stopperFiducialsNodeSelector.setMRMLScene(slicer.mrmlScene)

        # set default values
        self.restoreDefaults()
        self.onInputVolumeChanged()

        # compress the layout
        self.layout.addStretch(1)
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

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

    #
    # input file selectors
    #
    self.inputSelectors = []
    self.nInputs = 5
    times = ["Pre", "Post1", "Post2", "Post3", "Post4"]
    for i in range(self.nInputs):
      inputSelector = slicer.qMRMLNodeComboBox()
      inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
      inputSelector.selectNodeUponCreation = True
      inputSelector.enabled = True
      inputSelector.addEnabled = False
      inputSelector.removeEnabled = False
      inputSelector.noneEnabled = False
      inputSelector.showHidden = False
      inputSelector.showChildNodeTypes = False
      inputSelector.setMRMLScene( slicer.mrmlScene )
      inputSelector.setToolTip( "Pick the inputs to the algorithm." )
      parametersFormLayout.addRow(times[i], inputSelector)
      self.inputSelectors.append(inputSelector)
    
    #
    # mask volume selector
    #
    self.maskSelector = slicer.qMRMLNodeComboBox()
    self.maskSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.maskSelector.selectNodeUponCreation = True
    self.maskSelector.addEnabled = True
    self.maskSelector.removeEnabled = True
    self.maskSelector.noneEnabled = False
    self.maskSelector.showHidden = False
    self.maskSelector.showChildNodeTypes = False
    self.maskSelector.setMRMLScene( slicer.mrmlScene )
    self.maskSelector.setToolTip( "Pick the output to the algorithm." )
    parametersFormLayout.addRow("Mask", self.maskSelector)
            
    #
    # output filename textbox
    #
    self.outputTextbox = qt.QLineEdit("ANNSeg")
    self.outputTextbox.setToolTip( "Pick the output to the algorithm." )
    parametersFormLayout.addRow("Output file basename", self.outputTextbox)
        

    #
    # 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 = True
    parametersFormLayout.addRow(self.applyButton)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)

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

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

    # Init parameter node
    self.parameterNode = SmudgeModuleLogic().getParameterNode()
    self.addObserver(self.parameterNode, vtk.vtkCommand.ModifiedEvent, self.updateGuiFromMRML)


    # Instantiate and connect widgets ...


    #
    # I / O
    #
    self.inputsCollapsibleButton = ctk.ctkCollapsibleButton()
    self.inputsCollapsibleButton.text = "I / O"
    self.layout.addWidget(self.inputsCollapsibleButton)

    # Layout within the dummy collapsible button
    inputsFormLayout = qt.QFormLayout(self.inputsCollapsibleButton)


    #
    # clean up checkbox
    #
    self.cleanUpOnNodeChange = qt.QCheckBox('')
    self.cleanUpOnNodeChange.setChecked(True)
    inputsFormLayout.addRow("Clean Up On Master Change: ", self.cleanUpOnNodeChange)


    #
    # master node selector
    #
    self.masterNodeSelector = slicer.qMRMLNodeComboBox()
    self.masterNodeSelector.nodeTypes = ["vtkMRMLGridTransformNode", "vtkMRMLScalarVolumeNode"]
    self.masterNodeSelector.selectNodeUponCreation = False
    self.masterNodeSelector.addEnabled = False
    self.masterNodeSelector.removeEnabled = False
    self.masterNodeSelector.noneEnabled = True
    self.masterNodeSelector.showHidden = False
    self.masterNodeSelector.showChildNodeTypes = False
    self.masterNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.masterNodeSelector.setToolTip( "Pick the warp to refine or volume to apply warp to." )
    inputsFormLayout.addRow("Master Warp or Volume: ", self.masterNodeSelector)

    #
    # output
    #
    self.hardenOutputPushButton = qt.QPushButton('Harden Current Output Warp on Master')
    self.hardenOutputPushButton.setEnabled(False)
    inputsFormLayout.addRow("Output: ", self.hardenOutputPushButton)

    #
    # Tools Area
    #
    toolsCollapsibleButton = ctk.ctkCollapsibleButton()
    toolsCollapsibleButton.text = "Tools"
    self.layout.addWidget(toolsCollapsibleButton)

    # Layout within the dummy collapsible button
    toolsFormLayout = qt.QFormLayout(toolsCollapsibleButton)

    toolsFrame = qt.QFrame()
    toolsFrame.setLayout(qt.QHBoxLayout())
    toolsFormLayout.addRow(toolsFrame)

    warpEffects = [WarpEffectParameters.NoneEffectParameters(), 
                  WarpEffectParameters.LinearEffectParameters(), 
                  WarpEffectParameters.SmudgeEffectParameters(), 
                  WarpEffectParameters.DrawEffectParameters(),
                  WarpEffectParameters.SmoothEffectParameters()]

    for warpEffectParametersWidget in warpEffects:
      toolsFrame.layout().addWidget(warpEffectParametersWidget.effectButton)
      toolsFormLayout.addRow(warpEffectParametersWidget.parametersFrame)


    #
    # Undo Redo
    #   

    undoRedoGroupBox = qt.QGroupBox('Edit')
    undoRedoGroupBox.setLayout(qt.QHBoxLayout())
    toolsFormLayout.addRow(undoRedoGroupBox)

    undoAllButton =   {'text':'Undo All',  'icon':'UndoAll',   'toolTip':'Undo all user modifications. Fixed points won\'t be deleted.'}
    undoButton =      {'text':'Undo',      'icon':'Undo',      'toolTip':'Undo last operation. In case it was a drawing, corresponding fixed points will be deleted.'}
    redoButton =      {'text':'Redo',      'icon':'Redo',      'toolTip':'Redo'}

    # dont use QToolButton in order to use QPushButton's pressed and release signals
    buttonStyleSheet = "QPushButton { \
                          background-image: url(%s); \
                          font-size: 10px; \
                          text-align: bottom; \
                          border-radius: 3px; \
                          border-style: solid; \
                          border-color: rgb(182, 182, 182); \
                          border-width: 1px; } \
                        QPushButton:disabled { \
                          background-image: url(%s); }\
                        QPushButton:pressed { \
                          background-color: rgb(232, 232, 232); }"

    for b in [undoAllButton, undoButton, redoButton]:
      buttonIconPath = self.resourcePath(os.path.join('Icons', b['icon'] + '%s.png'))
      buttonPixmap = qt.QPixmap(buttonIconPath %'')
      button = qt.QPushButton(b['text'])
      button.setStyleSheet(buttonStyleSheet % (buttonIconPath %'', buttonIconPath %'_disabled'))
      button.setFixedSize(buttonPixmap.rect().size())
      button.setEnabled(False)
      button.setToolTip(b['toolTip'])
      undoRedoGroupBox.layout().addWidget(button)
      b['widget'] = button

    self.undoAllButton = undoAllButton['widget']
    self.undoButton = undoButton['widget']
    self.redoButton = redoButton['widget']


    #
    # Modles Area
    #

    modelsCollapsibleButton = ctk.ctkCollapsibleButton()
    modelsCollapsibleButton.text = "Data Control"
    self.layout.addWidget(modelsCollapsibleButton, 1)

    modelsFormLayout = qt.QGridLayout(modelsCollapsibleButton)    
    modelsFormLayout.addWidget(treeView.WarpDriveTreeView(),0,0)

    self.layout.addStretch(0)

    # connections
    self.hardenOutputPushButton.connect("clicked(bool)", self.onHardenOutputPushButton) 

    self.masterNodeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.exit) # deselect effect
    self.masterNodeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onMasterNodeSelectionChanged)

    self.undoAllButton.connect("clicked(bool)", self.onUndoAllButton)
    self.undoButton.connect("clicked(bool)", self.onUndoButton)
    self.redoButton.connect("clicked(bool)", self.onRedoButton)

    for button in [self.undoAllButton, self.undoButton, self.redoButton]:
      button.connect("pressed()", self.onEditButtonPressed)
      button.connect("released()", self.onEditButtonReleased)
    
    for effect in warpEffects:
      effect.addEditButtonListeners(self)

    self.addObserver(slicer.mrmlScene, slicer.mrmlScene.StartCloseEvent, self.onSceneStartClose)    

    # Refresh
    qt.QApplication.processEvents()

    # check dependencies
    if self.checkExtensionInstall(extensionName = 'SlicerRT'):
      return

    # Lead-DBS call
    if self.updateMRMLFromArgs(): # was called from command line
      self.showSingleModule()
      slicer.util.mainWindow().addToolBar(Toolbar.reducedToolbar())

    self.updateGuiFromMRML()  
  def setup(self):
    self.measurementsLogic = PETLiverUptakeMeasurementQRLogic()

    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

    #
    # Parameters Area
    #
    parametersCollapsibleButton = ctk.ctkCollapsibleButton()
    parametersCollapsibleButton.text = "Liver Uptake Region Segmentation"
    self.layout.addWidget(parametersCollapsibleButton)
    parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)
    #
    # input volume selector
    #
    self.inputSelector = slicer.qMRMLNodeComboBox()
    self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputSelector.addAttribute("vtkMRMLScalarVolumeNode", "DICOM.instanceUIDs", None)
    #self.inputSelector.addAttribute("vtkMRMLScalarVolumeNode", "DICOM.MeasurementUnitsCodeValue", "{SUVbw}g/ml") # ensures that the input is a SUV normalized PET scan
    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( "Input SUVbw normalized DICOM PET volume")
    self.inputSelector.connect("currentNodeChanged(bool)",self.refreshUIElements)
    parametersFormLayout.addRow("Input Volume", self.inputSelector)

    self.segmentationSelector = slicer.qMRMLNodeComboBox()
    self.segmentationSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.segmentationSelector.selectNodeUponCreation = True
    self.segmentationSelector.addEnabled = True
    self.segmentationSelector.removeEnabled = True
    self.segmentationSelector.noneEnabled = False
    self.segmentationSelector.showHidden = False
    self.segmentationSelector.showChildNodeTypes = False
    self.segmentationSelector.setMRMLScene( slicer.mrmlScene )
    self.segmentationSelector.setToolTip( "Output liver reference region volume")
    self.segmentationSelector.connect("currentNodeChanged(bool)",self.refreshUIElements)
    parametersFormLayout.addRow("Output Volume", self.segmentationSelector)

    self.regionSelector = slicer.qMRMLNodeComboBox()
    self.regionSelector.nodeTypes = ["vtkMRMLAnnotationROINode"]
    self.regionSelector.selectNodeUponCreation = True
    self.regionSelector.addEnabled = True
    self.regionSelector.removeEnabled = True
    self.regionSelector.noneEnabled = False
    self.regionSelector.showHidden = False
    self.regionSelector.showChildNodeTypes = False
    self.regionSelector.setMRMLScene( slicer.mrmlScene )
    self.regionSelector.setToolTip( "Search Region")
    self.regionSelector.connect("currentNodeChanged(bool)",self.refreshUIElements)
    parametersFormLayout.addRow("Region", self.regionSelector)

    self.thresholdRangeSlider = ctk.ctkRangeWidget()
    self.thresholdRangeSlider.minimum=0.0
    self.thresholdRangeSlider.maximum=20.0
    self.thresholdRangeSlider.singleStep = 0.1
    self.thresholdRangeSlider.minimumValue = 1.0
    self.thresholdRangeSlider.maximumValue = 10.0
    self.thresholdRangeSlider.connect("minimumValueChanged(double)",self.refreshUIElements)
    self.thresholdRangeSlider.connect("maximumValueChanged(double)",self.refreshUIElements)
    parametersFormLayout.addRow("Thresholds", self.thresholdRangeSlider)

    self.erosionSlider = ctk.ctkSliderWidget()
    self.erosionSlider.minimum=0.0
    self.erosionSlider.maximum=20.0
    self.erosionSlider.singleStep=0.1
    self.erosionSlider.value = 3.0
    self.erosionSlider.connect("valueChanged(double)",self.refreshUIElements)
    parametersFormLayout.addRow("Erosion", self.erosionSlider)

    self.segmentButton = qt.QPushButton("Segment Reference Region")
    self.segmentButton.toolTip = "Segment reference region and measure uptake"
    self.segmentButton.connect('clicked(bool)', self.onSegmentButton)
    parametersFormLayout.addRow("Segment",self.segmentButton)

    # Measurement results
    measurementsCollapsibleButton = ctk.ctkCollapsibleButton()
    measurementsCollapsibleButton.text = "Measurements"
    self.layout.addWidget(measurementsCollapsibleButton)
    parametersFormLayout = qt.QFormLayout(measurementsCollapsibleButton)

    self.meanValueLineEdit = qt.QLineEdit("-")
    self.meanValueLineEdit.setReadOnly(True)
    self.meanValueLineEdit.setToolTip( "Mean value in reference region")
    parametersFormLayout.addRow("Mean",self.meanValueLineEdit)
    self.stdValueLineEdit = qt.QLineEdit("-")
    self.stdValueLineEdit.setReadOnly(True)
    self.stdValueLineEdit.setToolTip( "Standard deviation in reference region")
    parametersFormLayout.addRow("Standard Deviation",self.stdValueLineEdit)
    self.medianValueLineEdit = qt.QLineEdit("-")
    self.medianValueLineEdit.setReadOnly(True)
    self.medianValueLineEdit.setToolTip( "Mean value in reference region")
    parametersFormLayout.addRow("Median",self.medianValueLineEdit)

    # Reporting Section
    dicomReportingCollapsibleButton = ctk.ctkCollapsibleButton()
    dicomReportingCollapsibleButton.text = "DICOM Reporting"
    self.layout.addWidget(dicomReportingCollapsibleButton)
    reportingFormLayout = qt.QFormLayout(dicomReportingCollapsibleButton)

    self.readerValueLineEdit = qt.QLineEdit(getpass.getuser())
    #self.readerValueLineEdit.setReadOnly(True)
    self.readerValueLineEdit.setToolTip( "Name of reader reporting the measurement results")
    reportingFormLayout.addRow("Reader Name",self.readerValueLineEdit)

    self.reportBoxesFrame = qt.QFrame()
    self.reportBoxesFrame.setLayout(qt.QHBoxLayout())
    self.reportBoxesFrame.layout().setSpacing(0)
    self.reportBoxesFrame.layout().setMargin(0)
    self.saveReportButton = qt.QPushButton("Save Report")
    self.saveReportButton.toolTip = "Create partially completed DICOM Structured Report which could be continued at a later time (work in progress)"
    self.saveReportButton.connect('clicked(bool)', self.onSaveReportButtonClicked)
    # note: We don't have the functionality to reload and edit a temporary report, so this option doesn't make sense for us
    #self.reportBoxesFrame.layout().addWidget(self.saveReportButton)
    self.completeReportButton = qt.QPushButton("Complete Report")
    self.completeReportButton.toolTip = "Create the completed DICOM Structured Report and save to database"
    self.completeReportButton.connect('clicked(bool)', self.onCompleteReportButtonClicked)
    self.reportBoxesFrame.layout().addWidget(self.completeReportButton)
    reportingFormLayout.addRow("Report",self.reportBoxesFrame)

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

    self.refreshUIElements()
Пример #35
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = ElastixLogic()
        self.logic.logCallback = self.addLog
        self.registrationInProgress = 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", "Elastix")
        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 = "General Registration (Elastix)"
        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)

        #
        # fixed volume selector
        #
        self.fixedVolumeSelector = slicer.qMRMLNodeComboBox()
        self.fixedVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.fixedVolumeSelector.selectNodeUponCreation = True
        self.fixedVolumeSelector.addEnabled = False
        self.fixedVolumeSelector.removeEnabled = False
        self.fixedVolumeSelector.noneEnabled = False
        self.fixedVolumeSelector.showHidden = False
        self.fixedVolumeSelector.showChildNodeTypes = False
        self.fixedVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.fixedVolumeSelector.setToolTip(
            "The moving volume will be transformed into this image space.")
        inputParametersFormLayout.addRow("Fixed volume: ",
                                         self.fixedVolumeSelector)

        #
        # moving volume selector
        #
        self.movingVolumeSelector = slicer.qMRMLNodeComboBox()
        self.movingVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.movingVolumeSelector.selectNodeUponCreation = True
        self.movingVolumeSelector.addEnabled = False
        self.movingVolumeSelector.removeEnabled = False
        self.movingVolumeSelector.noneEnabled = False
        self.movingVolumeSelector.showHidden = False
        self.movingVolumeSelector.showChildNodeTypes = False
        self.movingVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.movingVolumeSelector.setToolTip(
            "This volume will be transformed into the fixed image space")
        inputParametersFormLayout.addRow("Moving volume: ",
                                         self.movingVolumeSelector)

        self.registrationPresetSelector = qt.QComboBox()
        for preset in self.logic.getRegistrationPresets():
            self.registrationPresetSelector.addItem("{0} ({1})".format(
                preset[RegistrationPresets_Modality],
                preset[RegistrationPresets_Content]))
        inputParametersFormLayout.addRow("Preset: ",
                                         self.registrationPresetSelector)

        #
        # Masking
        #
        maskingParametersCollapsibleButton = ctk.ctkCollapsibleButton()
        maskingParametersCollapsibleButton.text = "Masking"
        maskingParametersCollapsibleButton.collapsed = True
        self.layout.addWidget(maskingParametersCollapsibleButton)

        # Layout within the dummy collapsible button
        maskingParametersFormLayout = qt.QFormLayout(
            maskingParametersCollapsibleButton)

        #
        # fixed volume mask selector
        #
        self.fixedVolumeMaskSelector = slicer.qMRMLNodeComboBox()
        self.fixedVolumeMaskSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.fixedVolumeMaskSelector.addEnabled = False
        self.fixedVolumeMaskSelector.removeEnabled = False
        self.fixedVolumeMaskSelector.noneEnabled = True
        self.fixedVolumeMaskSelector.showHidden = False
        self.fixedVolumeMaskSelector.showChildNodeTypes = False
        self.fixedVolumeMaskSelector.setMRMLScene(slicer.mrmlScene)
        self.fixedVolumeMaskSelector.setToolTip(
            "Areas of the fixed volume where mask label is 0 will be ignored in the registration."
        )
        maskingParametersFormLayout.addRow("Fixed volume mask: ",
                                           self.fixedVolumeMaskSelector)

        #
        # moving volume mask selector
        #
        self.movingVolumeMaskSelector = slicer.qMRMLNodeComboBox()
        self.movingVolumeMaskSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.movingVolumeMaskSelector.selectNodeUponCreation = True
        self.movingVolumeMaskSelector.addEnabled = False
        self.movingVolumeMaskSelector.removeEnabled = False
        self.movingVolumeMaskSelector.noneEnabled = True
        self.movingVolumeMaskSelector.showHidden = False
        self.movingVolumeMaskSelector.showChildNodeTypes = False
        self.movingVolumeMaskSelector.setMRMLScene(slicer.mrmlScene)
        self.movingVolumeMaskSelector.setToolTip(
            "Areas of the moving volume where mask label is 0 will be ignored in the registration"
        )
        maskingParametersFormLayout.addRow("Moving volume mask: ",
                                           self.movingVolumeMaskSelector)

        #
        # Landmarks
        #
        landmarksParametersCollapsibleButton = ctk.ctkCollapsibleButton()
        landmarksParametersCollapsibleButton.text = "Landmark fiducials"
        landmarksParametersCollapsibleButton.collapsed = True
        self.layout.addWidget(landmarksParametersCollapsibleButton)

        # Layout within the dummy collapsible button
        landmarksParametersFormLayout = qt.QFormLayout(
            landmarksParametersCollapsibleButton)

        #
        # fixed volume landmarks selector
        #
        self.fixedVolumeLandmarksSelector = slicer.qMRMLNodeComboBox()
        self.fixedVolumeLandmarksSelector.nodeTypes = [
            "vtkMRMLMarkupsFiducialNode"
        ]
        self.fixedVolumeLandmarksSelector.addEnabled = False
        self.fixedVolumeLandmarksSelector.removeEnabled = False
        self.fixedVolumeLandmarksSelector.noneEnabled = True
        self.fixedVolumeLandmarksSelector.showHidden = False
        self.fixedVolumeLandmarksSelector.showChildNodeTypes = False
        self.fixedVolumeLandmarksSelector.setMRMLScene(slicer.mrmlScene)
        self.fixedVolumeLandmarksSelector.setToolTip(
            "Landmark points of the fixed volume.")
        landmarksParametersFormLayout.addRow(
            "Fixed volume landmark fiducials: ",
            self.fixedVolumeLandmarksSelector)

        #
        # moving volume landmarks selector
        #
        self.movingVolumeLandmarksSelector = slicer.qMRMLNodeComboBox()
        self.movingVolumeLandmarksSelector.nodeTypes = [
            "vtkMRMLMarkupsFiducialNode"
        ]
        self.movingVolumeLandmarksSelector.selectNodeUponCreation = True
        self.movingVolumeLandmarksSelector.addEnabled = False
        self.movingVolumeLandmarksSelector.removeEnabled = False
        self.movingVolumeLandmarksSelector.noneEnabled = True
        self.movingVolumeLandmarksSelector.showHidden = False
        self.movingVolumeLandmarksSelector.showChildNodeTypes = False
        self.movingVolumeLandmarksSelector.setMRMLScene(slicer.mrmlScene)
        self.movingVolumeLandmarksSelector.setToolTip(
            "Landmark points of the moving volume.")
        landmarksParametersFormLayout.addRow(
            "Moving volume landmark fiducials: ",
            self.movingVolumeLandmarksSelector)

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

        # Layout within the dummy collapsible button
        outputParametersFormLayout = qt.QFormLayout(
            outputParametersCollapsibleButton)

        #
        # output volume selector
        #
        self.outputVolumeSelector = slicer.qMRMLNodeComboBox()
        self.outputVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.outputVolumeSelector.selectNodeUponCreation = True
        self.outputVolumeSelector.addEnabled = True
        self.outputVolumeSelector.renameEnabled = True
        self.outputVolumeSelector.removeEnabled = True
        self.outputVolumeSelector.noneEnabled = True
        self.outputVolumeSelector.showHidden = False
        self.outputVolumeSelector.showChildNodeTypes = False
        self.outputVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.outputVolumeSelector.setToolTip(
            "(optional) The moving image warped to the fixed image space. NOTE: You must set at least one output object (transform and/or output volume)"
        )
        outputParametersFormLayout.addRow("Output volume: ",
                                          self.outputVolumeSelector)

        #
        # output transform selector
        #
        self.outputTransformSelector = slicer.qMRMLNodeComboBox()
        self.outputTransformSelector.nodeTypes = ["vtkMRMLTransformNode"]
        self.outputTransformSelector.selectNodeUponCreation = True
        self.outputTransformSelector.addEnabled = True
        self.outputTransformSelector.renameEnabled = True
        self.outputTransformSelector.removeEnabled = True
        self.outputTransformSelector.noneEnabled = True
        self.outputTransformSelector.showHidden = False
        self.outputTransformSelector.showChildNodeTypes = False
        self.outputTransformSelector.setMRMLScene(slicer.mrmlScene)
        self.outputTransformSelector.setToolTip(
            "(optional) Computed displacement field that transform nodes from moving volume space to fixed volume space. NOTE: You must set at least one output object (transform and/or output volume)."
        )
        outputParametersFormLayout.addRow("Output transform: ",
                                          self.outputTransformSelector)

        #
        # 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.showDetailedLogDuringExecutionCheckBox = qt.QCheckBox(" ")
        self.showDetailedLogDuringExecutionCheckBox.checked = False
        self.showDetailedLogDuringExecutionCheckBox.setToolTip(
            "Show detailed log during registration.")
        advancedFormLayout.addRow("Show detailed log during registration:",
                                  self.showDetailedLogDuringExecutionCheckBox)

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

        self.useMovingParentTransformCheckBox = qt.QCheckBox(" ")
        self.useMovingParentTransformCheckBox.checked = False
        self.useMovingParentTransformCheckBox.setToolTip(
            "Initialize Elastix with the transform currently applied to the moving image (Only implemented for linear trasforms)."
        )
        advancedFormLayout.addRow(
            "Use parent transform of moving image for initialization:",
            self.useMovingParentTransformCheckBox)

        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)

        self.showRegistrationParametersDatabaseFolderButton = qt.QPushButton(
            "Show database folder")
        self.showRegistrationParametersDatabaseFolderButton.toolTip = "Open the folder where temporary files are stored."
        self.showRegistrationParametersDatabaseFolderButton.setSizePolicy(
            qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred)
        advancedFormLayout.addRow(
            "Registration presets:",
            self.showRegistrationParametersDatabaseFolderButton)

        customElastixBinDir = self.logic.getCustomElastixBinDir()
        self.customElastixBinDirSelector = ctk.ctkPathLineEdit()
        self.customElastixBinDirSelector.filters = ctk.ctkPathLineEdit.Dirs
        self.customElastixBinDirSelector.setCurrentPath(customElastixBinDir)
        self.customElastixBinDirSelector.setSizePolicy(
            qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred)
        self.customElastixBinDirSelector.setToolTip(
            "Set bin directory of an Elastix installation (where elastix executable is located). "
            "If value is empty then default elastix (bundled with SlicerElastix extension) will be used."
        )
        advancedFormLayout.addRow("Custom Elastix toolbox location:",
                                  self.customElastixBinDirSelector)

        #
        # 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.showRegistrationParametersDatabaseFolderButton.connect(
            'clicked(bool)', self.onShowRegistrationParametersDatabaseFolder)
        self.fixedVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                         self.onSelect)
        self.movingVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                          self.onSelect)
        self.outputVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                          self.onSelect)
        self.outputTransformSelector.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onSelect)
        self.fixedVolumeLandmarksSelector.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onSelect)
        self.movingVolumeLandmarksSelector.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onSelect)
        self.useMovingParentTransformCheckBox.connect('clicked(bool)',
                                                      self.onSelect)
        # Immediately update deleteTemporaryFiles in the logic to make it possible to decide to
        # keep the temporary file while the registration is running
        self.keepTemporaryFilesCheckBox.connect(
            "toggled(bool)", self.onKeepTemporaryFilesToggled)

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

        # Refresh Apply button state
        self.onSelect()
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    #
    # Inputs
    #

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

    # inputVolume selector
    self.inputModelNodeSelector = slicer.qMRMLNodeComboBox()
    self.inputModelNodeSelector.objectName = 'inputModelNodeSelector'
    self.inputModelNodeSelector.toolTip = "Select the input model."
    self.inputModelNodeSelector.nodeTypes = ['vtkMRMLModelNode']
    self.inputModelNodeSelector.hideChildNodeTypes = ['vtkMRMLAnnotationNode']  # hide all annotation nodes
    self.inputModelNodeSelector.noneEnabled = False
    self.inputModelNodeSelector.addEnabled = False
    self.inputModelNodeSelector.removeEnabled = False
    inputsFormLayout.addRow("Vessel tree model:", self.inputModelNodeSelector)
    self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                        self.inputModelNodeSelector, 'setMRMLScene(vtkMRMLScene*)')

    # seed selector
    self.seedFiducialsNodeSelector = slicer.qSlicerSimpleMarkupsWidget()
    self.seedFiducialsNodeSelector.objectName = 'seedFiducialsNodeSelector'
    self.seedFiducialsNodeSelector = slicer.qSlicerSimpleMarkupsWidget()
    self.seedFiducialsNodeSelector.objectName = 'seedFiducialsNodeSelector'
    self.seedFiducialsNodeSelector.toolTip = "Select a fiducial to use as the origin of the Centerline."
    self.seedFiducialsNodeSelector.setNodeBaseName("OriginSeed")
    self.seedFiducialsNodeSelector.defaultNodeColor = qt.QColor(0,255,0)
    self.seedFiducialsNodeSelector.tableWidget().hide()
    self.seedFiducialsNodeSelector.markupsSelectorComboBox().noneEnabled = False
    self.seedFiducialsNodeSelector.markupsPlaceWidget().placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceSingleMarkup
    inputsFormLayout.addRow("Start point:", self.seedFiducialsNodeSelector)
    self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                        self.seedFiducialsNodeSelector, 'setMRMLScene(vtkMRMLScene*)')

    #
    # Outputs
    #

    outputsCollapsibleButton = ctk.ctkCollapsibleButton()
    outputsCollapsibleButton.text = "Outputs"
    self.layout.addWidget(outputsCollapsibleButton)
    outputsFormLayout = qt.QFormLayout(outputsCollapsibleButton)
                        
    # outputModel selector
    self.outputModelNodeSelector = slicer.qMRMLNodeComboBox()
    self.outputModelNodeSelector.objectName = 'outputModelNodeSelector'
    self.outputModelNodeSelector.toolTip = "Select the output model for the Centerlines."
    self.outputModelNodeSelector.nodeTypes = ['vtkMRMLModelNode']
    self.outputModelNodeSelector.baseName = "CenterlineComputationModel"
    self.outputModelNodeSelector.hideChildNodeTypes = ['vtkMRMLAnnotationNode']  # hide all annotation nodes
    self.outputModelNodeSelector.noneEnabled = True
    self.outputModelNodeSelector.noneDisplay = "Create new model"
    self.outputModelNodeSelector.addEnabled = True
    self.outputModelNodeSelector.selectNodeUponCreation = True
    self.outputModelNodeSelector.removeEnabled = True
    outputsFormLayout.addRow("Centerline model:", self.outputModelNodeSelector)
    self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                        self.outputModelNodeSelector, 'setMRMLScene(vtkMRMLScene*)')

    self.outputEndPointsNodeSelector = slicer.qMRMLNodeComboBox()
    self.outputEndPointsNodeSelector.objectName = 'outputEndPointsNodeSelector'
    self.outputEndPointsNodeSelector.toolTip = "Select the output model for the Centerlines."
    self.outputEndPointsNodeSelector.nodeTypes = ['vtkMRMLMarkupsFiducialNode']
    self.outputEndPointsNodeSelector.baseName = "Centerline endpoints"
    self.outputEndPointsNodeSelector.noneEnabled = True
    self.outputEndPointsNodeSelector.noneDisplay = "Create new markups fiducial"
    self.outputEndPointsNodeSelector.addEnabled = True
    self.outputEndPointsNodeSelector.selectNodeUponCreation = True
    self.outputEndPointsNodeSelector.removeEnabled = True
    outputsFormLayout.addRow("Centerline endpoints:", self.outputEndPointsNodeSelector)
    self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                        self.outputEndPointsNodeSelector, 'setMRMLScene(vtkMRMLScene*)')
                        
    # voronoiModel selector
    self.voronoiModelNodeSelector = slicer.qMRMLNodeComboBox()
    self.voronoiModelNodeSelector.objectName = 'voronoiModelNodeSelector'
    self.voronoiModelNodeSelector.toolTip = "Select the output model for the Voronoi Diagram."
    self.voronoiModelNodeSelector.nodeTypes = ['vtkMRMLModelNode']
    self.voronoiModelNodeSelector.baseName = "VoronoiModel"
    self.voronoiModelNodeSelector.hideChildNodeTypes = ['vtkMRMLAnnotationNode']  # hide all annotation nodes
    self.voronoiModelNodeSelector.noneEnabled = True
    self.voronoiModelNodeSelector.addEnabled = True
    self.voronoiModelNodeSelector.selectNodeUponCreation = True
    self.voronoiModelNodeSelector.removeEnabled = True
    outputsFormLayout.addRow("Voronoi Model:", self.voronoiModelNodeSelector)
    self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                        self.voronoiModelNodeSelector, 'setMRMLScene(vtkMRMLScene*)')

    #
    # Reset, preview and apply buttons
    #

    self.buttonBox = qt.QDialogButtonBox()
    self.previewButton = self.buttonBox.addButton(self.buttonBox.Discard)
    self.previewButton.setIcon(qt.QIcon())
    self.previewButton.text = "Preview"
    self.previewButton.toolTip = "Click to refresh the preview."
    self.startButton = self.buttonBox.addButton(self.buttonBox.Apply)
    self.startButton.setIcon(qt.QIcon())
    self.startButton.text = "Start"
    self.startButton.enabled = False
    self.startButton.toolTip = "Click to start the filtering."
    self.layout.addWidget(self.buttonBox)
    self.previewButton.connect("clicked()", self.onPreviewButtonClicked)
    self.startButton.connect("clicked()", self.onStartButtonClicked)

    self.inputModelNodeSelector.setMRMLScene(slicer.mrmlScene)
    self.seedFiducialsNodeSelector.setMRMLScene(slicer.mrmlScene)
    self.outputModelNodeSelector.setMRMLScene(slicer.mrmlScene)
    self.outputEndPointsNodeSelector.setMRMLScene(slicer.mrmlScene)
    self.voronoiModelNodeSelector.setMRMLScene(slicer.mrmlScene)

    # compress the layout
    self.layout.addStretch(1)
Пример #37
0
    def setup(self):
        self.setLayout(qt.QFormLayout())

        # self.createClosedSegmentsForAlreadyFittedDeviceButton = qt.QPushButton("Create closed segments for already fitted Harmony TCPV valve (temporary?)")
        # #lay.addRow(self.createClosedSegmentsForAlreadyFittedDeviceButton)
        # self.createClosedSegmentsForAlreadyFittedDeviceButton.connect('clicked(bool)', self.onCreateClosedSegmentsForAlreadyFittedHarmonyDevice)

        lay = self.layout()

        self.handlesPerSliceSliderWidget = UIHelper.addSlider(
            {
                "name": "Handles per slice:",
                "info":
                "Controls how many handles are generated for device deformation",
                "value": 8,
                "unit": "",
                "minimum": 4,
                "maximum": 12,
                "singleStep": 2,
                "pageStep": 1,
                "decimals": 0
            }, lay, self.onHandlesSettingsChanged)

        self.handlesSpacingSliderWidget = UIHelper.addSlider(
            {
                "name": "Handles spacing:",
                "info": "Controls distance between handles",
                "value": 5,
                "unit": "mm",
                "minimum": 3,
                "maximum": 15,
                "singleStep": 1,
                "pageStep": 1,
                "decimals": 0
            }, lay, self.onHandlesSettingsChanged)

        # Vessel model selector
        self.vesselModelNodeSelector = slicer.qMRMLNodeComboBox()
        self.vesselModelNodeSelector.nodeTypes = ["vtkMRMLModelNode"]
        self.vesselModelNodeSelector.setNodeTypeLabel("Vessel",
                                                      "vtkMRMLModelNode")
        self.vesselModelNodeSelector.baseName = "Vessel"
        self.vesselModelNodeSelector.selectNodeUponCreation = False
        self.vesselModelNodeSelector.addEnabled = False
        self.vesselModelNodeSelector.removeEnabled = False
        self.vesselModelNodeSelector.noneEnabled = True
        self.vesselModelNodeSelector.showHidden = True
        self.vesselModelNodeSelector.renameEnabled = True
        self.vesselModelNodeSelector.setMRMLScene(slicer.mrmlScene)
        self.vesselModelNodeSelector.setToolTip(
            "select the extracted centerline model to be used for positioning the device"
        )
        lay.addRow("Vessel model node: ", self.vesselModelNodeSelector)
        self.vesselModelNodeSelector.connect(
            "currentNodeChanged(vtkMRMLNode*)",
            self.onVesselModelNodeSelectionChanged)

        # Radio button to choose whether to allow device expansion to fit vessel walls (some devices cannot be expanded beyond their native size, they can only be compressed
        self.allowDeviceExpansionToVesselWallsCheckbox = qt.QCheckBox()
        self.allowDeviceExpansionToVesselWallsCheckbox.setToolTip(
            "Some devices cannot be expanded beyond their native size in the vessel; they can only be compressed."
        )
        self.allowDeviceExpansionToVesselWallsCheckbox.setChecked(False)
        lay.addRow("Allow device to expand to vessel walls",
                   self.allowDeviceExpansionToVesselWallsCheckbox)

        # Button to deform device to vessel walls
        self.deformDeviceToVesselWallsButton = qt.QPushButton(
            "Fit device to vessel wall")
        lay.addRow(self.deformDeviceToVesselWallsButton)
        self.vesselModelNodeSelector.connect(
            'currentNodeChanged(bool)', self.deformDeviceToVesselWallsButton,
            'setEnabled(bool)')

        self.deformDeviceToVesselWallsButton.connect(
            'clicked(bool)', self.onDeformDeviceToVesselWallsClicked)
        self.sliceSelectorSliderWidget = UIHelper.addSlider(
            {
                "name": "Slice:",
                "info": "Jumps to a slice containing handles",
                "value": 0,
                "unit": "",
                "minimum": 0,
                "maximum": 0,
                "singleStep": 1,
                "pageStep": 1,
                "decimals": 0
            }, lay, self.onSliceSelected)

        orthogonalSlicerRotationBox = qt.QHBoxLayout()
        lay.addRow(orthogonalSlicerRotationBox)
        self.previousSliceButton = qt.QPushButton()
        self.previousSliceButton.text = "<"
        self.previousSliceButton.setToolTip(
            "Jump to previous slice. Keyboard shortcut: 'z'")
        orthogonalSlicerRotationBox.addWidget(self.previousSliceButton)
        self.previousSliceButton.connect('clicked(bool)', self.onPreviousSlice)

        self.nextSliceButton = qt.QPushButton()
        self.nextSliceButton.text = ">"
        self.nextSliceButton.setToolTip(
            "Jump to next slice. Keyboard shortcut: 'x'")
        orthogonalSlicerRotationBox.addWidget(self.nextSliceButton)
        self.nextSliceButton.connect('clicked(bool)', self.onNextSlice)
Пример #38
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...
    ####################
    # For debugging
    #
    # Reload and Test area
    reloadCollapsibleButton = ctk.ctkCollapsibleButton()
    reloadCollapsibleButton.text = "Reload && Test"
    self.layout.addWidget(reloadCollapsibleButton)
    reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)
    
    # reload button
    # (use this during development, but remove it when delivering
    #  your module to users)
    self.reloadButton = qt.QPushButton("Reload")
    self.reloadButton.toolTip = "Reload this module."
    self.reloadButton.name = "CurveMaker Reload"
    reloadFormLayout.addWidget(self.reloadButton)
    self.reloadButton.connect('clicked()', self.onReload)
    #
    ####################
    
    #
    # 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)

    # Textbox
    #self.portinput = qt.QFormLayout()
    self.portinput = qt.QLineEdit("/dev/cu.usbmodem14311")
    parametersFormLayout.addRow("Port:", self.portinput)
    # -> on change new port ?

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


    self.session = SliceTrackerSession()

    self.session.addEventObserver(self.session.TargetSelectionEvent, self.onTargetSelectionChanged)
Пример #39
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

    #
    # Parameters Area
    #
    self.frame = qt.QFrame(self.parent)
    self.frame.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(self.frame)
    
    #binfoCollapsibleButton = ctk.ctkCollapsibleButton()
    #binfoCollapsibleButton.text = "LoadBinfo"
    #self.layout.addWidget(binfoCollapsibleButton)

    # Layout within the dummy collapsible button
    #binfoFormLayout = qt.QFormLayout(binfoCollapsibleButton)
    #Load File
    #
    # Load CTX File Button
    #
    self.loadButton = qt.QPushButton("Load Binfo File:")
    self.loadButton.toolTip = "Load binfo file."
    self.loadButton.enabled = True
    self.frame.layout().addWidget(self.loadButton)
    
    # Binfo
    self.selectSegmentation = slicer.qMRMLNodeComboBox()
    self.selectSegmentation.nodeTypes = ( ("vtkMRMLSegmentationNode"),"" )
    #self.selectSegmentation.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 0 )
    self.selectSegmentation.selectNodeUponCreation = True
    self.selectSegmentation.addEnabled = False
    self.selectSegmentation.removeEnabled = True
    self.selectSegmentation.noneEnabled = True
    self.selectSegmentation.showHidden = False
    self.selectSegmentation.showChildNodeTypes = False
    self.selectSegmentation.setMRMLScene( slicer.mrmlScene )
    self.selectSegmentation.setToolTip( "Select segmentation." )
    self.frame.layout().addWidget(self.selectSegmentation)
    #binfoFormLayout.addRow("Volume: ", self.selectVolume)
    #self.binfoListFile = qt.QComboBox()    
    #self.binfoListFile.setToolTip( "Input file" )
    #self.binfoListFile.enabled = False
    #self.frame.layout().addWidget(self.binfoListFile)
    #binfoFormLayout.addRow("Binfo:", self.binfoListFile)
    

    #self.fileName.getOpenFileName(self, tr("Open File"),"",tr("Files (*.*)"));
    
    # Voi list
    self.voiComboBox = qt.QComboBox()
    self.voiComboBox.enabled = False
    self.frame.layout().addWidget(self.voiComboBox)
    #binfoFormLayout.addRow("Select Voi: ", self.voiComboBox)
    
    # Motion state list
    self.motionStateComboBox = qt.QComboBox()
    self.motionStateComboBox.enabled = False
    self.frame.layout().addWidget(self.motionStateComboBox)
    #binfoFormLayout.addRow("Select Motion State: ", self.motionStateComboBox)
    
    self.frame2 = qt.QFrame(self.parent)
    self.frame2.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(self.frame2)
    #
    # Show Button
    #
    self.buttonForm = qt.QGridLayout()
    
    self.show3DButton = qt.QPushButton("Load VOI")
    self.show3DButton.enabled = False
    #self.buttonForm.addWidget(self.show3DButton,0,0)
    self.frame2.layout().addWidget(self.show3DButton)
    
    self.calculateMotionButton = qt.QPushButton("Calculate Motion")
    self.calculateMotionButton.enabled = False
    #self.buttonForm.addWidget(self.calculateMotionButton,0,1)
    self.frame2.layout().addWidget(self.calculateMotionButton)
    #binfoFormLayout.addRow(self.buttonForm)
    #
    # Select dose volume
    #
    self.frame3 = qt.QFrame(self.parent)
    self.frame3.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(self.frame3)
    
    self.selectVolume = slicer.qMRMLNodeComboBox()
    self.selectVolume.nodeTypes = ( ("vtkMRMLScalarVolumeNode"),("vtkMRMLVectorVolumeNode"),"" )
    #self.selectVolume.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 0 )
    self.selectVolume.selectNodeUponCreation = True
    self.selectVolume.addEnabled = False
    self.selectVolume.removeEnabled = True
    self.selectVolume.noneEnabled = True
    self.selectVolume.showHidden = False
    self.selectVolume.showChildNodeTypes = False
    self.selectVolume.setMRMLScene( slicer.mrmlScene )
    self.selectVolume.setToolTip( "Select dose volume." )
    self.frame3.layout().addWidget(self.selectVolume)
    #binfoFormLayout.addRow("Volume: ", self.selectVolume)
    
    self.setDoseColorButton = qt.QPushButton("Set dose color")
    self.setDoseColorButton.toolTip = "Creates default GSI Color table and sets it for input volume."
    self.setDoseColorButton.enabled = True
    self.frame3.layout().addWidget(self.setDoseColorButton)
    

    self.interpolateLabel = qt.QLabel("Interpolate:")
    self.frame3.layout().addWidget(self.interpolateLabel)
    
    self.setInterpolateCheckbox = qt.QCheckBox()
    self.setInterpolateCheckbox.toolTip = "Sets volume interpolation on/off."
    self.setInterpolateCheckbox.enabled = True
    self.frame3.layout().addWidget(self.setInterpolateCheckbox)
    
    self.frame4 = qt.QFrame(self.parent)
    self.frame4.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(self.frame4)
    
    # Input dose value
    # TO DO: add check box to choose between substract origin or change origin
    
    self.doseBoxLabel = qt.QLabel("Dose optimization Value: ", self.frame4)
    self.frame4.layout().addWidget(self.doseBoxLabel)
    #self.doseBoxLabel.setToolTip( "Select the grayscale volume (background grayscale scalar volume node) for statistics calculations")
    #self.grayscaleSelectorFrame.layout().addWidget(self.doseBoxLabel)
    
    self.optDoseBox = qt.QDoubleSpinBox()     
    self.optDoseBox.setToolTip( "The optimization value for dose." )
    self.optDoseBox.setValue(24)
    self.optDoseBox.setRange(0, 1000)
    self.frame4.layout().addWidget(self.optDoseBox)
    #self.optDoseForm.addRow("Dose optimization Value", self.optDoseBox)
    
    self.physDoseLabel = qt.QLabel("Dose in permil:", self.frame4)
    self.optDoseBox.setToolTip( "Check this if doses are evaluated in permil (if you get strange colors, this is probably te case)." )
    self.frame4.layout().addWidget(self.physDoseLabel)
    
    self.pyhsDoseForm = qt.QFormLayout()
    self.pyhsDoseCheckBox = qt.QCheckBox()
    self.pyhsDoseCheckBox.setToolTip("Check if the dose volume is in permil")
    self.frame4.layout().addWidget(self.pyhsDoseCheckBox)
    #self.pyhsDoseForm.addRow("Pyhsical dose: ", self.pyhsDoseCheckBox)
    
    self.overDoseLabel = qt.QLabel("Overdose Off:", self.frame4)
    self.frame4.layout().addWidget(self.overDoseLabel)
    
    self.overDoseOffForm = qt.QFormLayout()
    self.overDoseOffCheckBox = qt.QCheckBox()
    self.overDoseOffCheckBox.setToolTip("Check if you don't want to display overodse.")
    self.frame4.layout().addWidget(self.overDoseOffCheckBox)
    #self.overDoseOffForm.addRow("Overdose Off: ", self.overDoseOffCheckBox)
    
    
    self.frame5 = qt.QFrame(self.parent)
    self.frame5.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(self.frame5)
    #
    # Set dose colormap
    #
    self.setVectorFieldButton = qt.QPushButton("Set TRiP vector field")
    self.setVectorFieldButton.toolTip = "Multiplies vector field values with pixel spacing (historical reason in TRiP)."
    self.setVectorFieldButton.enabled = False
    self.frame5.layout().addWidget(self.setVectorFieldButton)
    
    self.frame6 = qt.QFrame(self.parent)
    self.frame6.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(self.frame6)
    
    self.saveScreenshotButton = qt.QPushButton("Save Screenshot")
    self.saveScreenshotButton.toolTip = "Saves screenshot."
    self.saveScreenshotButton.enabled = True
    self.frame6.layout().addWidget(self.saveScreenshotButton)
    

    
    # connections
    self.show3DButton.connect('clicked(bool)', self.onShow3DButton)
    self.calculateMotionButton.connect('clicked(bool)', self.onCalculateMotionButton)
    self.loadButton.connect('clicked(bool)', self.onLoadButton)
    self.voiComboBox.connect('currentIndexChanged(QString)', self.setMotionStatesFromComboBox)
    self.selectSegmentation.connect("currentNodeChanged(vtkMRMLNode*)", self.setBinfoFile)
    self.setDoseColorButton.connect('clicked(bool)', self.onSetDoseColorButton)
    self.setInterpolateCheckbox.connect('clicked(bool)', self.onSetInterpolateCheckbox)
    self.pyhsDoseCheckBox.connect('clicked(bool)',self.onChangePyhsDoseCheckBox)
    self.selectVolume.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.setVectorFieldButton.connect('clicked(bool)', self.onSetVectorFieldButton)
    self.saveScreenshotButton.connect('clicked(bool)', self.onSaveScreenShotButton)

    # Add vertical spacer
    self.layout.addStretch(1)
    
    # Binfo file:
    #binfo=Binfo()
    self.binfoList = []
    def setup(self):
        self.CsvInputGroupBox = qt.QGroupBox('CSV input for local files')

        CsvInputLayout = qt.QFormLayout(self.CsvInputGroupBox)

        #
        # Input CSV Path
        #
        self.batchTableSelector = slicer.qMRMLNodeComboBox()
        self.batchTableSelector.nodeTypes = ['vtkMRMLTableNode']
        self.batchTableSelector.addEnabled = True
        self.batchTableSelector.selectNodeUponCreation = True
        self.batchTableSelector.renameEnabled = True
        self.batchTableSelector.removeEnabled = True
        self.batchTableSelector.noneEnabled = False
        self.batchTableSelector.setMRMLScene(slicer.mrmlScene)
        self.batchTableSelector.toolTip = 'Select the table representing the cases to process.'
        CsvInputLayout.addRow(self.batchTableSelector)

        self.batchTableView = slicer.qMRMLTableView()
        CsvInputLayout.addRow(self.batchTableView)
        self.batchTableView.show()

        #
        # Parameters Area
        #
        self.parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        self.parametersCollapsibleButton.text = 'Parameters'
        CsvInputLayout.addWidget(self.parametersCollapsibleButton)

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

        #
        # Input parameters GroupBox
        #

        self.inputParametersGroupBox = qt.QGroupBox('Input parameters')
        parametersFormLayout.addRow(self.inputParametersGroupBox)

        inputParametersFormLayout = qt.QFormLayout(
            self.inputParametersGroupBox)

        #
        # Root Path
        #
        self.rootSelector = qt.QLineEdit()
        self.rootSelector.text = 'path'
        self.rootSelector.toolTip = 'Location of the root directory to load from, or the column name specifying said ' \
                                    'directory in the input CSV'
        inputParametersFormLayout.addRow('Root Column', self.rootSelector)

        #
        # Image Path
        #
        self.imageSelector = qt.QLineEdit()
        self.imageSelector.text = 'image'
        self.imageSelector.toolTip = 'Name of the column specifying main image files in input CSV'
        inputParametersFormLayout.addRow('Image Column', self.imageSelector)

        #
        # Mask Path
        #
        self.maskSelector = qt.QLineEdit()
        self.maskSelector.text = 'mask'
        self.maskSelector.toolTip = 'Name of the column specifying main mask files in input CSV'
        inputParametersFormLayout.addRow('Mask Column', self.maskSelector)

        #
        # Additional images
        #
        self.addImsSelector = qt.QLineEdit()
        self.addImsSelector.text = ''
        self.addImsSelector.toolTip = 'Comma separated names of the columns specifying additional image files in input CSV'
        inputParametersFormLayout.addRow('Additional images Column(s)',
                                         self.addImsSelector)

        #
        # Additional masks
        #
        self.addMasksSelector = qt.QLineEdit()
        self.addMasksSelector.text = ''
        self.addMasksSelector.toolTip = 'Comma separated names of the columns specifying additional mask files in input CSV'
        inputParametersFormLayout.addRow('Additional masks Column(s)',
                                         self.addMasksSelector)

        #
        # Connect Event Handlers
        #
        self.batchTableSelector.connect('nodeActivated(vtkMRMLNode*)',
                                        self.onChangeTable)
        self.imageSelector.connect('textEdited(QString)',
                                   self.onChangeImageColumn)

        self.segmentationParametersGroupBox = qt.QGroupBox(
            'Mask interaction parameters')
        parametersFormLayout.addRow(self.segmentationParametersGroupBox)

        segmentationParametersFormLayout = qt.QFormLayout(
            self.segmentationParametersGroupBox)

        #
        # Auto-redirect to SegmentEditor
        #
        self.chkAutoRedirect = qt.QCheckBox()
        self.chkAutoRedirect.checked = False
        self.chkAutoRedirect.toolTip = 'Automatically switch module to "SegmentEditor" when each case is loaded'
        segmentationParametersFormLayout.addRow('Go to Segment Editor',
                                                self.chkAutoRedirect)

        #
        # Save masks
        #
        self.chkSaveMasks = qt.QCheckBox()
        self.chkSaveMasks.checked = False
        self.chkSaveMasks.toolTip = 'save all initially loaded masks when proceeding to next case'
        segmentationParametersFormLayout.addRow('Save loaded masks',
                                                self.chkSaveMasks)

        #
        # Save new masks
        #
        self.chkSaveNewMasks = qt.QCheckBox()
        self.chkSaveNewMasks.checked = True
        self.chkSaveNewMasks.toolTip = 'save all newly generated masks when proceeding to next case'
        segmentationParametersFormLayout.addRow('Save new masks',
                                                self.chkSaveNewMasks)

        return self.CsvInputGroupBox
Пример #41
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)

        #
        # Fisrt input volume selector
        #
        self.inputSelector1 = slicer.qMRMLNodeComboBox()
        self.inputSelector1.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelector1.addAttribute(
            "vtkMRMLScalarVolumeNode", "LabelMap", 0)
        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 Volume", self.inputSelector1)

        #
        # Second input volume selector
        #
        self.inputSelector2 = slicer.qMRMLNodeComboBox()
        self.inputSelector2.nodeTypes = (("vtkMRMLScalarVolumeNode"), "")
        self.inputSelector2.addAttribute(
            "vtkMRMLScalarVolumeNode", "LabelMap", 0)
        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 Volume", self.inputSelector2)
        #
        # 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)

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

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

        # Refresh Apply button state
        self.onSelect()
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        self.registrationInProgress = False
        self.logic = SequenceRegistrationLogic()
        self.logic.logCallback = self.addLog

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

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

        #
        # input volume selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ["vtkMRMLSequenceNode"]
        self.inputSelector.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)
        label = qt.QLabel("Input volume sequence:")
        label.setToolTip("Pick the multivolume sequence as input.")
        self.inputSelector.setToolTip(
            "Pick the multivolume sequence as input.")
        parametersFormLayout.addRow(label, self.inputSelector)

        #
        # output volume selector
        #
        self.outputVolumesSelector = slicer.qMRMLNodeComboBox()
        self.outputVolumesSelector.nodeTypes = ["vtkMRMLSequenceNode"]
        self.outputVolumesSelector.baseName = "OutputVolumes"
        self.outputVolumesSelector.selectNodeUponCreation = True
        self.outputVolumesSelector.addEnabled = True
        self.outputVolumesSelector.removeEnabled = True
        self.outputVolumesSelector.renameEnabled = True
        self.outputVolumesSelector.noneEnabled = True
        self.outputVolumesSelector.showHidden = False
        self.outputVolumesSelector.showChildNodeTypes = False
        self.outputVolumesSelector.setMRMLScene(slicer.mrmlScene)
        label = qt.QLabel("Output volume sequence:")
        label.setToolTip("Pick or create a multivolume sequence as output.")
        self.outputVolumesSelector.setToolTip(
            "Pick or create a multivolume sequence as output.")
        parametersFormLayout.addRow(label, self.outputVolumesSelector)

        #
        # output transform selector
        #
        self.outputTransformSelector = slicer.qMRMLNodeComboBox()
        self.outputTransformSelector.nodeTypes = ["vtkMRMLSequenceNode"]
        self.outputTransformSelector.baseName = "OutputTransforms"
        self.outputTransformSelector.selectNodeUponCreation = True
        self.outputTransformSelector.addEnabled = True
        self.outputTransformSelector.removeEnabled = True
        self.outputTransformSelector.renameEnabled = True
        self.outputTransformSelector.noneEnabled = True
        self.outputTransformSelector.showHidden = False
        self.outputTransformSelector.showChildNodeTypes = False
        self.outputTransformSelector.setMRMLScene(slicer.mrmlScene)
        label = qt.QLabel("Output transform sequence:")
        label.setToolTip(
            "(optional) Computed displacement field that transform nodes from moving volume space to fixed volume space. NOTE: You must set at least one output sequence (transform and/or volume)."
        )
        self.outputTransformSelector.setToolTip(
            "(optional) Computed displacement field that transform nodes from moving volume space to fixed volume space. NOTE: You must set at least one output sequence (transform and/or volume)."
        )
        parametersFormLayout.addRow(label, self.outputTransformSelector)

        self.outputTransformBrowser = None

        #
        # Preset selector
        #
        import Elastix
        label = qt.QLabel("Preset:")
        self.registrationPresetSelector = qt.QComboBox()
        label.setToolTip("Pick preset to register with.")
        self.registrationPresetSelector.setToolTip(
            "Pick preset to register with.")
        for preset in self.logic.elastixLogic.getRegistrationPresets():
            self.registrationPresetSelector.addItem("{0} ({1})".format(
                preset[Elastix.RegistrationPresets_Modality],
                preset[Elastix.RegistrationPresets_Content]))
        parametersFormLayout.addRow(label, self.registrationPresetSelector)

        #
        # Advanced Area
        #
        advancedCollapsibleButton = ctk.ctkCollapsibleButton()
        advancedCollapsibleButton.text = "Advanced"
        advancedCollapsibleButton.collapsed = 1
        self.layout.addWidget(advancedCollapsibleButton)

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

        #
        # fixed frame number value
        #
        self.initialFixedFrame = ctk.ctkSliderWidget()
        self.initialFixedFrame.singleStep = 1
        self.initialFixedFrame.minimum = 0
        self.initialFixedFrame.value = 0
        label = qt.QLabel("Fixed frame at timepoint:")
        label.setToolTip(
            "Set the frame of the input sequence to use as the fixed volume.")
        self.initialFixedFrame.setToolTip(
            "Set the frame of the input sequence to use as the fixed volume.")
        advancedFormLayout.addRow(label, self.initialFixedFrame)

        #
        # Option to show detailed log
        #

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

        #
        # Option to keep temporary files after registration
        #

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

        #
        # Button to open the folder in which temporary files are stored
        #

        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(label, hbox)

        self.showRegistrationParametersDatabaseFolderButton = qt.QPushButton(
            "Show database folder")
        self.showRegistrationParametersDatabaseFolderButton.toolTip = "Open the folder where temporary files are stored."
        self.showRegistrationParametersDatabaseFolderButton.setSizePolicy(
            qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred)
        advancedFormLayout.addRow(
            "Registration presets:",
            self.showRegistrationParametersDatabaseFolderButton)

        customElastixBinDir = self.logic.elastixLogic.getCustomElastixBinDir()
        self.customElastixBinDirSelector = ctk.ctkPathLineEdit()
        self.customElastixBinDirSelector.filters = ctk.ctkPathLineEdit.Dirs
        self.customElastixBinDirSelector.setCurrentPath(customElastixBinDir)
        self.customElastixBinDirSelector.setSizePolicy(
            qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred)
        self.customElastixBinDirSelector.setToolTip(
            "Set bin directory of an Elastix installation (where elastix executable is located). "
            "If value is empty then default elastix (bundled with SlicerElastix extension) will be used."
        )
        advancedFormLayout.addRow("Custom Elastix toolbox location:",
                                  self.customElastixBinDirSelector)

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Register")
        self.applyButton.toolTip = "Start registration."
        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.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.onSelect)
        self.outputVolumesSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                           self.onSelect)
        self.outputTransformSelector.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onSelect)
        self.showTemporaryFilesFolderButton.connect(
            'clicked(bool)', self.onShowTemporaryFilesFolder)
        self.showRegistrationParametersDatabaseFolderButton.connect(
            'clicked(bool)', self.onShowRegistrationParametersDatabaseFolder)
        # Immediately update deleteTemporaryFiles and show detailed logs in the logic to make it possible to decide to
        # update these variables while the registration is running
        self.keepTemporaryFilesCheckBox.connect(
            "toggled(bool)", self.onKeepTemporaryFilesToggled)
        self.showDetailedLogDuringExecutionCheckBox.connect(
            "toggled(bool)", self.onShowLogToggled)

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

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

    self.logic = slicer.vtkSlicerInteractiveUKFLogic()
    self.grayscaleNode = None
    self.labelNode = None
    self.fileName = None
    self.fileDialog = None


    # Instantiate and connect widgets
    #

    self.tabFrame = qt.QTabWidget(self.parent)
    self.tabFrame.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(self.tabFrame)

    self.cliWidget = slicer.modules.ukftractography.createNewWidgetRepresentation()
    self.cliWidget.setMRMLScene(slicer.mrmlScene)

    ######################
    # Customize the widget
    #

    # labels and other anonymous UI elements
    cliw = self.cliWidget
    for name in ["Apply", "AutoRun", "Restore Defaults", "Cancel", "Parameter set:",
                 "Input Label Map", "ROI label to use for seeding",
                 "Signal Parameters (Expert Only)", "Not Used: Debug/Develop Only"]:
      w = slicer.util.findChildren(widget=cliw, text=name)
      if len(w) > 0:
        w = w[0]
        cliw.layout().removeWidget(w)
        w.hide()

    # named selector widgets correspond to CLI argument name
    for name in ["labels", "seedsFile"]:
      with It(slicer.util.findChild(widget=cliw, name=name)) as w:
        cliw.layout().removeWidget(w)
        w.hide()

    with It(slicer.util.findChildren(cliw, text="UKF Tractography", className="ctkCollapsibleButton")[0]) as w:
      with It(slicer.util.findChildren(w, text="IO", className="ctkCollapsibleButton")[0]) as iow:
        w.layout().removeWidget(iow)
        w.parent().layout().addWidget(iow)
        w.parent().layout().removeWidget(w)
        w.parent().layout().addStretch(1)
        w.hide()
        self.ioSelector = iow

    ######################

    # get handles to important selectors
    self.cliSelector = slicer.util.findChild(cliw, "MRMLCommandLineModuleNodeSelector")
    self.cliSelector.hide()
    self.dwiSelector = slicer.util.findChild(cliw, "dwiFile")
    self.fiberBundleSelector = slicer.util.findChild(cliw, "tracts")
    self.maskSelector = slicer.util.findChild(cliw, "maskFile")

    # add Setup widget to tab frame
    self.tabFrame.addTab(self.cliWidget, "Setup")

    # Add "Next" button
    with It(qt.QPushButton(self.parent)) as w:
      w.text = "Next step: Interact"
      w.setStyleSheet("background-color: lightgray")
      self.ioSelector.layout().addItem(
        qt.QSpacerItem(0, 10, qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed))
      self.ioSelector.layout().addWidget(w)
      w.connect('clicked(bool)', lambda: self.tabFrame.setCurrentIndex(1))

    # add Interact widget to tab frame
    self.interactFrame = qt.QFrame(self.parent)
    self.interactFrame.setLayout(qt.QVBoxLayout())
    self.tabFrame.addTab(self.interactFrame, "Interact")

    # selector widget and frame
    self.markupSelectorFrame = qt.QFrame(self.parent)
    self.markupSelectorFrame.setLayout(qt.QVBoxLayout())
    self.parent.layout().addWidget(self.markupSelectorFrame)

    self.markupSelectorLabel = qt.QLabel("Interactive markup node: ", self.markupSelectorFrame)
    self.markupSelectorLabel.setToolTip( "Select the markup node for interactive seeding.")
    self.markupSelectorFrame.layout().addWidget(self.markupSelectorLabel)

    with It(slicer.qMRMLNodeComboBox(self.parent)) as w:
      w.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
      w.selectNodeUponCreation = False
      w.addEnabled = False
      w.removeEnabled = False
      w.noneEnabled = True
      w.showHidden = False
      w.showChildNodeTypes = False
      w.setMRMLScene(slicer.mrmlScene)
      w.connect('currentNodeChanged(bool)', self.markupNodeSelected)

      self.markupSelectorFrame.layout().addWidget(w)
      self.markupSelector = w

    # enable checkbox
    self.enableCBFrame = qt.QFrame(self.markupSelectorFrame)
    self.enableCBFrame.setLayout(qt.QHBoxLayout())

    self.enableSeedingCB = ctk.ctkCheckablePushButton()
    self.enableSeedingCB.text = "Update (check for interactive)"
    self.enableCBFrame.layout().addWidget(self.enableSeedingCB)

    self.markupSelectorFrame.layout().addWidget(self.enableCBFrame)
    self.interactFrame.layout().addWidget(self.markupSelectorFrame)

    self.optsFrame = qt.QFrame(self.parent)
    self.optsFrame.setLayout(qt.QVBoxLayout())
    self.interactFrame.layout().addWidget(self.optsFrame)

    # Move seeding options frame to interactor
    with It(slicer.util.findChildren(cliw, text="Tractography Options")[0]) as w:
      self.tractOpts = w
      cliw.layout().removeWidget(w)
      self.optsFrame.layout().addWidget(w)
      w.collapsed = True

      self.c_seedsPerVoxel = findChild(w, "seedsPerVoxel")
      self.c_seedingThreshold = findChild(w, "seedingThreshold")
      self.c_stoppingFA = findChild(w, "stoppingFA")
      self.c_stoppingThreshold = findChild(w, "stoppingThreshold")

      self.c_numTensor = findChild(w, "numTensor")
      self.c_stepLength = findChild(w, "stepLength")
      self.c_Qm = findChild(w, "Qm")
      self.c_recordLength = findChild(w, "recordLength")
      self.c_recordLength.setValue(2)

      # TODO numThread?
      # TODO maxTract, NMSE

    # Move tensor options frame to interactor
    with It(slicer.util.findChildren(cliw, text="Tensor Model (default)")[0]) as w:
      findChild(w, "recordFA").setChecked(False)
      findChild(w, "recordTrace").setChecked(False)
      findChild(w, "recordFreeWater").setChecked(False)
      findChild(w, "recordTensors").setChecked(False)

      self.c_useFreeWater = findChild(w, "freeWater")
      self.tractTensorOpts = w

      cliw.layout().removeWidget(w)
      self.optsFrame.layout().addWidget(w)
      w.collapsed = True

    # Move NODDI options frame to interactor
    with It(slicer.util.findChildren(cliw, text="NODDI Model")[0]) as w:
      self.noddiOpts = w
      cliw.layout().removeWidget(w)
      self.optsFrame.layout().addWidget(w)
      self.c_noddi = findChild(w, "noddi")

    #
    # Finished customizing
    ######################

    # Event handling
    self.tabFrame.connect('currentChanged(int)', self.onTabChanged)
    self.enableSeedingCB.connect('checkStateChanged(Qt::CheckState)', self.onSeedingCBChanged)
    self.enableSeedingCB.connect('clicked(bool)', self.onSeedingCBClicked)
    self.logic.SetMRMLScene(slicer.mrmlScene)

    # This needs to be last so that all widgets are pushed to top
    self.interactFrame.layout().addStretch(0)
Пример #44
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        ###################################
        # Import node graph json file Area
        ###################################
        self.fileCollapsibleButton = ctk.ctkCollapsibleButton()
        self.fileCollapsibleButton.text = "Import Node Graph Json File"
        self.layout.addWidget(self.fileCollapsibleButton)
        self.fileImportFormLayout = qt.QFormLayout(self.fileCollapsibleButton)

        self.fileImport = ctk.ctkPathLineEdit()
        self.fileImport.filters = ctk.ctkPathLineEdit.Files
        self.fileImport.settingKey = 'JsonInputFile'
        self.fileImport.currentPath = os.path.normpath(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         './Resources/nodeGraph_3D.json'))
        self.fileImportFormLayout.addRow("Input Json File:", self.fileImport)

        self.fileImportButton = qt.QPushButton('Load File')
        self.fileImportFormLayout.addRow(self.fileImportButton)

        ###################################
        # Node Table Area
        ###################################
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Node Table"
        self.layout.addWidget(parametersCollapsibleButton)
        # Layout within the collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # Checkbox to see whether or not the input table has a header
        #
        self.headerCheckBox = qt.QCheckBox()
        self.headerCheckBox.checked = 0
        self.headerCheckBox.setToolTip(
            "If checked, it means that the input node table contains a header."
        )
        parametersFormLayout.addRow("Header in Node Table",
                                    self.headerCheckBox)

        #
        # input table selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ["vtkMRMLTableNode"]
        self.inputSelector.selectNodeUponCreation = True
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.noneEnabled = False
        self.inputSelector.showHidden = False
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputSelector.setToolTip(
            "The input file loaded trough the import Data module should be a one line table (with or without header)."
        )
        parametersFormLayout.addRow("Input Table: ", self.inputSelector)

        #
        # Table start column spinBox
        #
        self.min_column = 1
        self.tableStartSpinBox = qt.QDoubleSpinBox()
        self.tableStartSpinBox.singleStep = 1
        self.tableStartSpinBox.setValue(self.min_column)
        self.tableStartSpinBox.setDecimals(0)
        self.tableStartSpinBox.setToolTip(
            "Set start column, if the first column contains a string of characters(ex: subject name) then this column should be skipped and the start column is thus 1. This should be an integer (int)"
        )
        parametersFormLayout.addRow("Start Column:", self.tableStartSpinBox)

        ###################################
        # Region Selector Area
        ###################################
        self.nodeselectCollapsibleButton = ctk.ctkCollapsibleButton()
        self.nodeselectCollapsibleButton.text = "Selection of Node Region"
        self.layout.addWidget(self.nodeselectCollapsibleButton)
        # Layout within the collapsible button
        self.nodeselectFormLayout = qt.QFormLayout(
            self.nodeselectCollapsibleButton)

        # Search Box to filter regions to display
        self.searchLayout = qt.QHBoxLayout()
        self.nodeselectFormLayout.addRow('Search:', self.searchLayout)
        self.regionSearchBox = ctk.ctkSearchBox()
        self.regionSearchBox.placeholderText = "search region"
        self.regionSearchBox.searchIcon
        self.searchLayout.addWidget(self.regionSearchBox)

        self.logic = visuThreeDLogic()
        self.regionsLayout = qt.QHBoxLayout()
        self.nodeselectFormLayout.addRow('Regions:', self.regionsLayout)
        self.regionButtons = ctk.ctkCheckableComboBox()
        self.regionsLayout.addWidget(self.regionButtons)

        # Add buttons to select all or no region
        self.buttonsLayout = qt.QHBoxLayout()
        self.nodeselectFormLayout.addRow('Select:', self.buttonsLayout)
        self.calculateAllregionsButton = qt.QPushButton('Select All')
        self.calculateAllregionsButton.toolTip = 'Select all regions.'
        self.calculateAllregionsButton.enabled = True
        self.buttonsLayout.addWidget(self.calculateAllregionsButton)
        self.calculateAllFilteredregionsButton = qt.QPushButton(
            'Select Filtered')
        self.calculateAllFilteredregionsButton.toolTip = 'Select all  filtered regions.'
        self.calculateAllFilteredregionsButton.enabled = True
        self.buttonsLayout.addWidget(self.calculateAllFilteredregionsButton)

        self.deselectButtonsLayout = qt.QHBoxLayout()
        self.nodeselectFormLayout.addRow('Deselect:',
                                         self.deselectButtonsLayout)
        self.calculateNoregionsButton = qt.QPushButton('Deselect All')
        self.calculateNoregionsButton.toolTip = 'Deselect all regions.'
        self.calculateNoregionsButton.enabled = True
        self.deselectButtonsLayout.addWidget(self.calculateNoregionsButton)
        self.calculateNoFilteredregionsButton = qt.QPushButton(
            'Deselect Filtered')
        self.calculateNoFilteredregionsButton.toolTip = 'Deselect all filtered regions.'
        self.calculateNoFilteredregionsButton.enabled = True
        self.deselectButtonsLayout.addWidget(
            self.calculateNoFilteredregionsButton)

        ###################################
        # Node Size and colorbar thresholding Area
        ###################################
        self.colorbarCollapsibleButton = ctk.ctkCollapsibleButton()
        self.colorbarCollapsibleButton.text = "Node Size and Color Thresholding"
        self.layout.addWidget(self.colorbarCollapsibleButton)
        # Layout within the collapsible button
        self.regioncheckFormLayout = qt.QFormLayout(
            self.colorbarCollapsibleButton)

        self.ColorTable = slicer.qMRMLColorTableComboBox()
        self.ColorTable.nodeTypes = ["vtkMRMLColorTableNode"]
        self.ColorTable.addEnabled = True
        self.ColorTable.removeEnabled = True
        self.ColorTable.noneEnabled = True
        self.ColorTable.showHidden = True
        self.ColorTable.setMRMLScene(slicer.mrmlScene)
        self.regioncheckFormLayout.addRow("Input Color Map: ", self.ColorTable)

        #
        # Threshold node value
        #
        # default values
        self.minVal = 0.0
        self.maxVal = 1.0
        self.nodeThresholdSliderWidget = ctk.ctkRangeWidget()
        self.nodeThresholdSliderWidget.singleStep = 0.01
        self.nodeThresholdSliderWidget.setValues(self.minVal, self.maxVal)
        self.nodeThresholdSliderWidget.setMaximumValue(self.maxVal)
        self.nodeThresholdSliderWidget.setMinimumValue(self.minVal)
        self.nodeThresholdSliderWidget.setRange(self.minVal, self.maxVal)
        self.nodeThresholdSliderWidget.setMouseTracking(True)
        self.nodeThresholdSliderWidget.setEnabled(True)
        self.nodeThresholdSliderWidget.setToolTip(
            "Set threshold node value for computing the node value.")
        self.regioncheckFormLayout.addRow("Plot Property Range:",
                                          self.nodeThresholdSliderWidget)

        #
        # Node size min spinBox
        #
        # default value for min size (l: lowest , h: highest)
        self.minSize_l = 0.0
        self.minSize_h = 100.0
        self.nodeMinSizeSpinBox = qt.QDoubleSpinBox()
        self.nodeMinSizeSpinBox.singleStep = 0.01
        self.nodeMinSizeSpinBox.setRange(self.minSize_l, self.minSize_h)
        self.nodeMinSizeSpinBox.setToolTip("Set minimum node size.")
        self.regioncheckFormLayout.addRow("Min Size:", self.nodeMinSizeSpinBox)

        #
        # Node size max spinBox
        #
        # default value for max size (l: lowest , h: highest)
        self.maxSize_l = 0.0
        self.maxSize_h = 100.0
        self.nodeMaxSizeSpinBox = qt.QDoubleSpinBox()
        self.nodeMaxSizeSpinBox.singleStep = 0.01
        self.nodeMaxSizeSpinBox.setRange(self.maxSize_l, self.maxSize_h)
        self.nodeMaxSizeSpinBox.setToolTip("Set maximum node size.")
        self.regioncheckFormLayout.addRow("Max Size:", self.nodeMaxSizeSpinBox)

        ###################################
        # Connections line/tube Area
        ###################################
        self.lineCollapsibleButton = ctk.ctkCollapsibleButton()
        self.lineCollapsibleButton.text = "Connection Size and Color Thresholding"
        self.layout.addWidget(self.lineCollapsibleButton)
        # Layout within the collapsible button
        self.lineconnectFormLayout = qt.QFormLayout(self.lineCollapsibleButton)

        #
        # input connection matrix selector
        #
        self.matrixConnectSelector = slicer.qMRMLNodeComboBox()
        self.matrixConnectSelector.nodeTypes = ["vtkMRMLTableNode"]
        self.matrixConnectSelector.selectNodeUponCreation = True
        self.matrixConnectSelector.addEnabled = False
        self.matrixConnectSelector.removeEnabled = False
        self.matrixConnectSelector.noneEnabled = False
        self.matrixConnectSelector.showHidden = False
        self.matrixConnectSelector.showChildNodeTypes = False
        self.matrixConnectSelector.setMRMLScene(slicer.mrmlScene)
        self.matrixConnectSelector.setToolTip(
            "Pick the connection matrix input to the algorithm.")
        self.lineconnectFormLayout.addRow("Input Connection Table: ",
                                          self.matrixConnectSelector)

        #
        # Checkbox to choose whether or not the connection distribution follows a log scale or else a linear distribution
        #
        self.connectionDistCheckBox = qt.QCheckBox()
        self.connectionDistCheckBox.checked = 0
        self.connectionDistCheckBox.setToolTip(
            "If checked, it means that the connection distribution follows a log scale."
        )
        self.lineconnectFormLayout.addRow("Log Distribution",
                                          self.connectionDistCheckBox)

        self.connectionColorTable = slicer.qMRMLColorTableComboBox()
        self.connectionColorTable.nodeTypes = ["vtkMRMLColorTableNode"]
        self.connectionColorTable.addEnabled = True
        self.connectionColorTable.removeEnabled = True
        self.connectionColorTable.noneEnabled = True
        self.connectionColorTable.showHidden = True
        self.connectionColorTable.setMRMLScene(slicer.mrmlScene)
        self.lineconnectFormLayout.addRow("Input Color Map: ",
                                          self.connectionColorTable)

        #
        # Threshold node connection strength
        #
        # default values
        self.logic = visuThreeDLogic()
        self.min_strength = 0.0
        self.max_strength = 1.0
        self.connectionThresholdSliderWidget = ctk.ctkRangeWidget()
        self.connectionThresholdSliderWidget.singleStep = 0.01
        self.connectionThresholdSliderWidget.setValues(self.min_strength,
                                                       self.max_strength)
        self.connectionThresholdSliderWidget.setMaximumValue(self.max_strength)
        self.connectionThresholdSliderWidget.setMinimumValue(self.min_strength)
        self.connectionThresholdSliderWidget.setRange(self.minVal,
                                                      self.max_strength)
        self.connectionThresholdSliderWidget.setMouseTracking(True)
        self.connectionThresholdSliderWidget.setEnabled(True)
        self.connectionThresholdSliderWidget.setToolTip(
            "Set threshold node value for computing the node value.")
        self.lineconnectFormLayout.addRow("Plot Strength Range:",
                                          self.connectionThresholdSliderWidget)

        #
        # Connection min strength spinBox
        #
        # default value for min strength (l: lowest , h: highest)
        self.minStrength_l = 0.0
        self.minStrength_h = 50.0
        self.minConnectionSpinBox = qt.QDoubleSpinBox()
        self.minConnectionSpinBox.singleStep = 0.01
        self.minConnectionSpinBox.setRange(self.minStrength_l,
                                           self.minStrength_h)
        self.minConnectionSpinBox.setToolTip(
            "Set minimum connection strength.")
        self.lineconnectFormLayout.addRow("Min Strength:",
                                          self.minConnectionSpinBox)

        #
        # Node size max spinBox
        #
        # default value for max size (l: lowest , h: highest)
        self.maxStrength_l = 0.0
        self.maxStrength_h = 100.0
        self.maxConnectionSpinBox = qt.QDoubleSpinBox()
        self.maxConnectionSpinBox.singleStep = 0.01
        self.maxConnectionSpinBox.setRange(self.maxStrength_l,
                                           self.maxStrength_h)
        self.maxConnectionSpinBox.setToolTip(
            "Set maximum connection strength.")
        self.lineconnectFormLayout.addRow("Max Strenght:",
                                          self.maxConnectionSpinBox)

        ###################################
        # Advanced Connections scale factors Area
        ###################################
        self.scaleCollapsibleButton = ctk.ctkCollapsibleButton()
        self.scaleCollapsibleButton.text = "Advanced Connection Scale Factors"
        self.layout.addWidget(self.scaleCollapsibleButton)
        # Layout within the collapsible button
        self.scaleconnectFormLayout = qt.QFormLayout(
            self.scaleCollapsibleButton)

        #Double SpinBox for default scale factor "f" :
        #computation of value in matrix by the number of connexions * f factor
        self.fscaleDoubleSpinBox = ctk.ctkDoubleSpinBox()
        self.fscaleDoubleSpinBox.setValue(0.000033)
        self.fscaleDoubleSpinBox.setDecimals(6)
        self.fscaleDoubleSpinBox.enabled = True
        self.scaleconnectFormLayout.addWidget(self.fscaleDoubleSpinBox)
        self.scaleconnectFormLayout.addRow("f Scale:",
                                           self.fscaleDoubleSpinBox)

        #Double SpinBox for log scale factor "C" :
        self.logScaleDoubleSpinBox = ctk.ctkDoubleSpinBox()
        self.logScaleDoubleSpinBox.setValue(10)
        self.logScaleDoubleSpinBox.setDecimals(0.)
        self.logScaleDoubleSpinBox.enabled = False
        self.scaleconnectFormLayout.addWidget(self.logScaleDoubleSpinBox)
        self.scaleconnectFormLayout.addRow("C Log Scale:",
                                           self.logScaleDoubleSpinBox)

        ###################################
        # Connections
        ###################################
        self.coord = []
        self.index = []
        self.position = []
        self.visu = []
        self.fileImportButton.connect('clicked(bool)',
                                      self.on_node_graph_json_load)
        self.inputSelector.connect("nodeActivated(vtkMRMLNode*)",
                                   self.on_select)
        self.regionButtons.connect('checkedIndexesChanged()',
                                   self.on_regions_checked)
        self.calculateAllFilteredregionsButton.connect(
            'clicked(bool)', self.on_select_all_filtered_regionButtons)
        self.calculateAllregionsButton.connect(
            'clicked(bool)', self.on_select_all_regionButtons)
        self.calculateNoregionsButton.connect(
            'clicked(bool)', self.on_deselect_all_regionButtons)
        self.calculateNoFilteredregionsButton.connect(
            'clicked(bool)', self.on_deselect_all_filtered_regionButtons)
        self.regionSearchBox.connect("textChanged(QString)", self.on_search)
        self.ColorTable.connect("currentNodeChanged(vtkMRMLNode*)",
                                self.on_node_color_clicked)
        self.nodeThresholdSliderWidget.connect("valuesChanged(double, double)",
                                               self.sliderbar_changed)
        self.nodeMinSizeSpinBox.connect("valueChanged(double)",
                                        self.min_nodesize_changed)
        self.nodeMaxSizeSpinBox.connect("valueChanged(double)",
                                        self.max_nodesize_changed)
        self.tableStartSpinBox.connect("valueChanged(double)",
                                       self.table_start_changed)
        self.matrixConnectSelector.connect("nodeActivated(vtkMRMLNode*)",
                                           self.on_select_matrix)
        self.connectionThresholdSliderWidget.connect(
            "valuesChanged(double, double)", self.sliderbar2_changed)
        self.maxConnectionSpinBox.connect("valueChanged(double)",
                                          self.max_connection_changed)
        self.connectionColorTable.connect("currentNodeChanged(vtkMRMLNode*)",
                                          self.on_connect_color_clicked)
        self.fscaleDoubleSpinBox.connect("valueChanged(double)",
                                         self.on_fscale_changed)
        self.logScaleDoubleSpinBox.connect("valueChanged(double)",
                                           self.on_logscale_changed)

        # Add vertical spacer
        self.layout.addStretch(1)
        self.header = None
        self.connection_d = None
        self.value = 'None'
        self.on_node_graph_json_load()
Пример #45
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 ...
    #

    # 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.layout.addWidget(self.parameterNodeSelector)

    # 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.noneDisplay = "Create new table"
    self.outputTableSelector.setMRMLScene(slicer.mrmlScene)
    self.outputTableSelector.nodeTypes = ["vtkMRMLTableNode"]
    self.outputTableSelector.addEnabled = True
    self.outputTableSelector.selectNodeUponCreation = True
    self.outputTableSelector.renameEnabled = True
    self.outputTableSelector.removeEnabled = True
    self.outputTableSelector.noneEnabled = True
    self.outputTableSelector.setToolTip("Select the table where statistics will be saved into")
    self.outputTableSelector.setCurrentNode(None)

    outputFormLayout.addRow("Output table:", self.outputTableSelector)

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

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

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

    # 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()
Пример #46
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        # Custom toolbar for applying style
        self.modifyWindowUI()

        #
        # 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()
Пример #47
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        #
        # Parameters Area
        #
        parameterCollapsibleButton = ctk.ctkCollapsibleButton()
        parameterCollapsibleButton.text = 'Parameters'
        self.layout.addWidget(parameterCollapsibleButton)

        # Layout with the collapsible button
        parameterFormLayout = qt.QFormLayout(parameterCollapsibleButton)

        #
        # Input volume selector
        #
        self.volumeSelector = slicer.qMRMLNodeComboBox()
        self.volumeSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.volumeSelector.noneEnabled = False
        self.volumeSelector.selectNodeUponCreation = True

        self.volumeSelector.setMRMLScene(slicer.mrmlScene)
        self.volumeSelector.setToolTip("Select input volume")
        parameterFormLayout.addRow("Input Volume: ", self.volumeSelector)

        #
        # Ruler selector
        #
        self.rulerSelector = slicer.qMRMLNodeComboBox()
        self.rulerSelector.nodeTypes = ("vtkMRMLAnnotationRulerNode", "")
        self.rulerSelector.noneEnabled = False
        self.rulerSelector.selectNodeUponCreation = True

        self.rulerSelector.setMRMLScene(slicer.mrmlScene)
        self.rulerSelector.setToolTip("Pick the ruler to make a sphere")
        parameterFormLayout.addRow("Ruler: ", self.rulerSelector)

        #
        # Show/Hide sphere ChechBox
        #
        self.showCheckBox = qt.QCheckBox("Show/Hide Sphere")
        # self.showCheckBox.setToolTip("Show or hide the sphere")
        self.showCheckBox.toolTip = "Show or hide the sphere"

        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Generate a sphere according to the sphere"
        self.applyButton.enabled = True

        # parameterFormLayout.addWidget(self.applyButton)
        # parameterFormLayout.addRow("A test label:", self.applyButton)
        parameterFormLayout.addRow(self.showCheckBox, self.applyButton)

        #
        # Results
        #
        self.currentCenterLabel = qt.QLabel()
        self.currentCenterLabel.setText("Current Centre: ")
        self.currentCenterCoord = qt.QLabel()
        parameterFormLayout.addRow(
            self.currentCenterLabel, self.currentCenterCoord)

        self.currentRadiusLabel = qt.QLabel()
        self.currentRadiusLabel.setText("Current Radius: ")
        self.currentRadiusLength = qt.QLabel()
        parameterFormLayout.addRow(
            self.currentRadiusLabel, self.currentRadiusLength)

        #
        # Connections
        #
        self.showCheckBox.connect('toggled(bool)', self.onShowCheckBoxToggled)
        self.applyButton.connect('clicked()', self.onApplyButtonClicked)
        self.volumeSelector.connect(
            'currentNodeChanged(vtkMRMLNode*)', self.onSelect)

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

        # Refresh applyButton state
        self.onSelect()
Пример #48
0
    def setup(self):
        # Instantiate and connect widgets ...

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

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

        # fiber
        self.fiberSelector = slicer.qMRMLNodeComboBox(
            parametersCollapsibleButton)
        self.fiberSelector.nodeTypes = ["vtkMRMLFiberBundleNode"]
        self.fiberSelector.selectNodeUponCreation = False
        self.fiberSelector.addEnabled = False
        self.fiberSelector.removeEnabled = False
        self.fiberSelector.noneEnabled = True
        self.fiberSelector.showHidden = False
        self.fiberSelector.showChildNodeTypes = False
        self.fiberSelector.setMRMLScene(slicer.mrmlScene)
        self.fiberSelector.setToolTip("Pick the fiber bundle to be converted.")
        parametersFormLayout.addRow("Fiber Bundle", self.fiberSelector)

        # label map
        self.labelSelector = slicer.qMRMLNodeComboBox(
            parametersCollapsibleButton)
        self.labelSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
        self.labelSelector.selectNodeUponCreation = False
        self.labelSelector.addEnabled = False
        self.labelSelector.removeEnabled = False
        self.labelSelector.noneEnabled = True
        self.labelSelector.showHidden = False
        self.labelSelector.showChildNodeTypes = False
        self.labelSelector.setMRMLScene(slicer.mrmlScene)
        self.labelSelector.setToolTip(
            "Pick the target label volume.  Must already exists in order to define sampling grid.  If needed, create one in the Editor module based on template volume."
        )
        parametersFormLayout.addRow("Target LabelMap", self.labelSelector)

        # label value
        self.labelValue = qt.QSpinBox(parametersCollapsibleButton)
        self.labelValue.setToolTip(
            "The numerical value for the rasterized fiber label.")
        self.labelValue.setValue(1)
        parametersFormLayout.addRow("Label Value", self.labelValue)

        # apply
        self.applyButton = qt.QPushButton(parametersCollapsibleButton)
        self.applyButton.text = "Apply"
        parametersFormLayout.addWidget(self.applyButton)

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

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

        self.samplingDistance = ctk.ctkDoubleSpinBox()
        self.samplingDistance.minimum = 0.01
        self.samplingDistance.maximum = 5.0
        self.samplingDistance.decimals = 2
        self.samplingDistance.singleStep = 0.1
        self.samplingDistance.value = 0.1
        self.samplingDistance.decimalsOption = (
            ctk.ctkDoubleSpinBox.ReplaceDecimals
            | ctk.ctkDoubleSpinBox.DecimalsByKey)
        advancedFormLayout.addRow("Sampling distance (mm)",
                                  self.samplingDistance)

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

        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        ### Input Area
        inputCollapsibleButton = ctk.ctkCollapsibleButton()
        inputCollapsibleButton.text = "Input"
        self.layout.addWidget(inputCollapsibleButton)

        # Layout within the dummy collapsible button
        inputFormLayout = qt.QFormLayout(inputCollapsibleButton)

        # vf image (mrml input)
        self.vfMRMLSelector = slicer.qMRMLNodeComboBox()
        self.vfMRMLSelector.nodeTypes = ["vtkMRMLVectorVolumeNode"]
        self.vfMRMLSelector.selectNodeUponCreation = True
        self.vfMRMLSelector.addEnabled = False
        self.vfMRMLSelector.removeEnabled = False
        self.vfMRMLSelector.noneEnabled = True
        self.vfMRMLSelector.showHidden = False
        self.vfMRMLSelector.setMRMLScene(slicer.mrmlScene)
        self.vfMRMLSelector.setToolTip("Pick the input to the algorithm.")
        inputFormLayout.addRow("Vector Field image: ", self.vfMRMLSelector)

        # variables
        self.minJacobianValue = 1
        self.maxJacobianValue = 1

        # vf image (directory input)
        self.vfInputDirectory = ctk.ctkDirectoryButton()
        self.vfInputDirectory.directory = qt.QDir.homePath()
        inputFormLayout.addRow("Input Directory:", self.vfInputDirectory)

        # Fixed image (for geometry info)
        self.fixedImage = slicer.qMRMLNodeComboBox()
        self.fixedImage.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.fixedImage.setMRMLScene(slicer.mrmlScene)
        self.fixedImage.selectNodeUponCreation = True
        self.fixedImage.addEnabled = False
        self.fixedImage.renameEnabled = True
        self.fixedImage.noneEnabled = True
        self.fixedImage.setToolTip("Output image of Jacobian matrix.vtkSlicerPlastimatchModuleLogicPython")
        inputFormLayout.addRow("Fixed image (for geometry info): ", self.fixedImage)

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

        ### Output Area
        outputCollapsibleButton = ctk.ctkCollapsibleButton()
        outputCollapsibleButton.text = "Output"
        self.layout.addWidget(outputCollapsibleButton)

        # Layout within the dummy collapsible button
        outputFormLayout = qt.QFormLayout(outputCollapsibleButton)

        # Jacobian image (mrml output)
        self.outputJacobian = slicer.qMRMLNodeComboBox()
        self.outputJacobian.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.outputJacobian.setMRMLScene(slicer.mrmlScene)
        self.outputJacobian.addEnabled = True
        self.outputJacobian.renameEnabled = True
        # self.outputJacobian.layout().addWidget(self.outputSelector)
        self.outputJacobian.setToolTip("Output image of Jacobian matrix.vtkSlicerPlastimatchModuleLogicPython")
        outputFormLayout.addRow("Jacobian image: ", self.outputJacobian)

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

        # output statistics
        buttonLayout = qt.QHBoxLayout()
        self.minJacobian = qt.QLineEdit()
        self.minJacobian.setToolTip("Minimum value of Jacobian matrix")
        buttonLayout.addWidget(self.minJacobian)
        outputFormLayout.addRow("Minimum Jacobian:", buttonLayout)

        buttonLayout = qt.QHBoxLayout()
        self.maxJacobian = qt.QLineEdit()
        self.maxJacobian.setToolTip("Maximum value of Jacobian matrix")
        buttonLayout.addWidget(self.maxJacobian)
        outputFormLayout.addRow("Maximum Jacobian:", buttonLayout)

        # connections
        self.applyButton.connect("clicked(bool)", self.onJacobianApply)
        self.outputJacobian.connect("currentNodeChanged(vtkMRMLNode*)", self.onOutputJacobianSelect)
        self.fixedImage.connect("currentNodeChanged(vtkMRMLNode*)", self.onFixedImageSelect)
        self.vfMRMLSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onvfMRMLSelect)

        # Add vertical spacer
        self.layout.addStretch(1)
Пример #50
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 fiberbundle selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ["vtkMRMLFiberBundleNode"]
        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 Fiberbundle: ", self.inputSelector)

        #
        # Output fiberbundle selector
        #
        self.outputSelector = slicer.qMRMLNodeComboBox()
        self.outputSelector.nodeTypes = ["vtkMRMLFiberBundleNode"]
        self.outputSelector.selectNodeUponCreation = True
        self.outputSelector.addEnabled = True
        self.outputSelector.removeEnabled = True
        self.outputSelector.renameEnabled = 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 Fiberbundle: ",
                                    self.outputSelector)

        #
        # 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()
Пример #51
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

    #
    # 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 volume for geometry viewing." )

    #
    # Algorithm segmentation volume selector
    #
    self.algorithmSegmentation = slicer.qMRMLNodeComboBox()
    self.algorithmSegmentation.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.algorithmSegmentation.selectNodeUponCreation = True
    self.algorithmSegmentation.addEnabled = False
    self.algorithmSegmentation.removeEnabled = False
    self.algorithmSegmentation.noneEnabled = False
    self.algorithmSegmentation.showHidden = False
    self.algorithmSegmentation.showChildNodeTypes = False
    self.algorithmSegmentation.setMRMLScene( slicer.mrmlScene )
    self.algorithmSegmentation.setToolTip( "Pick the algorithm segmentation to evaluate." )

    #
    # Volumes group box
    #
    self.inputVolumesLayout = qt.QFormLayout()
    self.inputVolumesLayout.addRow("Input volume: ", self.inputSelector)
    self.inputVolumesLayout.addRow("Algorithm segmentation: ", self.algorithmSegmentation)
    self.volumesGroupBox = qt.QGroupBox()
    self.volumesGroupBox.setTitle("Volumes")
    self.volumesGroupBox.setLayout(self.inputVolumesLayout)
    inputsFormLayout.addWidget(self.volumesGroupBox)

    #
    # Configuration file selector
    #
    fileLayout = qt.QHBoxLayout()
    self.configFile = qt.QLineEdit()
    self.configFile.setReadOnly(True)
    self.configFileButton = qt.QPushButton()
    self.configFileButton.setText("Select File")
    fileLayout.addWidget(self.configFile)
    fileLayout.addWidget(self.configFileButton)

    #
    # Manual segmentations directory
    #
    directoryLayout = qt.QHBoxLayout()
    self.directory = qt.QLineEdit()
    self.directory.setReadOnly(True)
    self.directoryButton = qt.QPushButton()
    self.directoryButton.setText("Select Directory")
    directoryLayout.addWidget(self.directory)
    directoryLayout.addWidget(self.directoryButton)

    #
    # Paths group box
    #
    self.inputFilePathsLayout = qt.QFormLayout()
    self.inputFilePathsLayout.addRow("PLUS configuration file: ", fileLayout)
    self.inputFilePathsLayout.addRow("Manual segmentations directory: ", directoryLayout)
    self.pathsGroupBox = qt.QGroupBox()
    self.pathsGroupBox.setTitle("Paths")
    self.pathsGroupBox.setLayout(self.inputFilePathsLayout)
    inputsFormLayout.addWidget(self.pathsGroupBox)

    #
    # False negative distance value
    #
    self.falseNegativeDistance = qt.QSpinBox()
    self.falseNegativeDistance.setMinimum(0)
    self.falseNegativeDistance.setSuffix(" mm")

    #
    # Parameters group box
    #
    self.inputParametersLayout = qt.QFormLayout()
    self.inputParametersLayout.addRow("False negative distance: ", self.falseNegativeDistance)
    self.parametersGroupBox = qt.QGroupBox()
    self.parametersGroupBox.setTitle("Parameters")
    self.parametersGroupBox.setLayout(self.inputParametersLayout)
    inputsFormLayout.addWidget(self.parametersGroupBox)

    #
    # OUTPUT VOLUMES Area
    #
    outputsCollapsibleButton = ctk.ctkCollapsibleButton()
    outputsCollapsibleButton.text = "Outputs"
    self.layout.addWidget(outputsCollapsibleButton)
    outputsFormLayout = qt.QVBoxLayout(outputsCollapsibleButton)

    #
    # Merged manual segmentations
    #
    self.mergedManualSegmentations = slicer.qMRMLNodeComboBox()
    self.mergedManualSegmentations.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.mergedManualSegmentations.selectNodeUponCreation = True
    self.mergedManualSegmentations.addEnabled = True
    self.mergedManualSegmentations.renameEnabled = True
    self.mergedManualSegmentations.removeEnabled = True
    self.mergedManualSegmentations.noneEnabled = False
    self.mergedManualSegmentations.showHidden = False
    self.mergedManualSegmentations.showChildNodeTypes = False
    self.mergedManualSegmentations.setMRMLScene( slicer.mrmlScene )
    self.mergedManualSegmentations.setToolTip( "Pick the label map for the merged manual segmentations." )

    #
    # Scanline label map
    #
    self.scanlines = slicer.qMRMLNodeComboBox()
    self.scanlines.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.scanlines.selectNodeUponCreation = True
    self.scanlines.addEnabled = True
    self.scanlines.renameEnabled = True
    self.scanlines.removeEnabled = True
    self.scanlines.noneEnabled = False
    self.scanlines.showHidden = False
    self.scanlines.showChildNodeTypes = False
    self.scanlines.setMRMLScene( slicer.mrmlScene )
    self.scanlines.setToolTip( "Pick the label map for displaying the input volumes scanlines." )

    #
    # Output segmentation label map
    #
    self.outputSegmentation = slicer.qMRMLNodeComboBox()
    self.outputSegmentation.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.outputSegmentation.selectNodeUponCreation = True
    self.outputSegmentation.addEnabled = True
    self.outputSegmentation.renameEnabled = True
    self.outputSegmentation.removeEnabled = True
    self.outputSegmentation.noneEnabled = False
    self.outputSegmentation.showHidden = False
    self.outputSegmentation.showChildNodeTypes = False
    self.outputSegmentation.setMRMLScene( slicer.mrmlScene )
    self.outputSegmentation.setToolTip( "Pick the label map for the output segmentation." )

    #
    # Volumes group box
    #
    self.outputVolumesLayout = qt.QFormLayout()
    self.outputVolumesLayout.addRow("Summed manaual segmentations: ", self.mergedManualSegmentations)
    self.outputVolumesLayout.addRow("Scanlines: ", self.scanlines)
    self.outputVolumesLayout.addRow("Output segmentation: ", self.outputSegmentation)
    self.outputVolumesGroupBox = qt.QGroupBox()
    self.outputVolumesGroupBox.setTitle("Volumes")
    self.outputVolumesGroupBox.setLayout(self.outputVolumesLayout)
    outputsFormLayout.addWidget(self.outputVolumesGroupBox)

    #
    # True positive metric
    #
    self.truePositiveMetric = qt.QLineEdit()
    self.truePositiveMetric.setReadOnly(True)

    #
    # False positive metric
    #
    self.falsePositiveMetric = qt.QLineEdit()
    self.falsePositiveMetric.setReadOnly(True)

    #
    # False negative metric
    #
    self.falseNegativeMetric = qt.QLineEdit()
    self.falseNegativeMetric.setReadOnly(True)

    #
    # Output metric group box
    #
    self.outputMetricsLayout = qt.QFormLayout()
    self.outputMetricsLayout.addRow("True positive percentage: ", self.truePositiveMetric)
    self.outputMetricsLayout.addRow("False positive percentage: ", self.falsePositiveMetric)
    self.outputMetricsLayout.addRow("False negative percentage: ", self.falseNegativeMetric)
    self.outputMetricsGroupBox = qt.QGroupBox()
    self.outputMetricsGroupBox.setTitle("Metrics")
    self.outputMetricsGroupBox.setLayout(self.outputMetricsLayout)
    outputsFormLayout.addWidget(self.outputMetricsGroupBox)

    #
    # FUNCTIONS Area
    #
    functionsCollapsibleButton = ctk.ctkCollapsibleButton()
    functionsCollapsibleButton.text = "Functions"
    self.layout.addWidget(functionsCollapsibleButton)
    functionsFormLayout = qt.QVBoxLayout(functionsCollapsibleButton)

    # Button for generating scanlines from PLUS config file
    self.createScanlinesButton = qt.QPushButton("Create Scanlines")
    self.createScanlinesButton.toolTip = "Create scanlines from PLUS configuration file"
    self.createScanlinesButton.enabled = False

    # Button for combining manual segmentations into one volume
    self.createMergedManualSegmentationButton = qt.QPushButton("Merge Manual Segmentations")
    self.createMergedManualSegmentationButton.toolTip = "Combine manual segmentations into one volume"
    self.createMergedManualSegmentationButton.enabled = False

    # Button for computing metrics of a segmentation
    self.computeMetricsButton = qt.QPushButton("Compute Metrics")
    self.computeMetricsButton.toolTip = "Compute the true positive and false negative metrics of a segmentation"
    self.computeMetricsButton.enabled = False

    # Add buttongs to functions section
    functionsFormLayout.addWidget(self.createScanlinesButton)
    functionsFormLayout.addWidget(self.createMergedManualSegmentationButton)
    functionsFormLayout.addWidget(self.computeMetricsButton)

    # Connections

    # *** Input/output volumes and parameters ***
    # Ultrasound volume
    self.inputSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onInputSelect)
    # Algorithm segmentation
    self.algorithmSegmentation.connect('currentNodeChanged(vtkMRMLNode*)', self.onAlgorithmSegmentationSelect)
    # PLUS config file
    self.configFile.connect('textChanged(QString)',self.onConfigFileSelect)
    # Manual segmentations directory
    self.directory.connect('textChanged(QString)',self.createMergedManualSegmentationsEnableCheck)
    # Summed manual segmentations
    self.mergedManualSegmentations.connect("currentNodeChanged(vtkMRMLNode*)", self.createMergedManualSegmentationsEnableCheck)
    # Scanlines
    self.scanlines.connect('currentNodeChanged(vtkMRMLNode*)', self.createScanlinesEnableCheck)
    # Output segmentation
    self.outputSegmentation.connect('currentNodeChanged(vtkMRMLNode*)', self.computeMetricsEnableCheck)

    # *** Buttons for selecting config file / manual segmentation directory ***
    # Manaul segmentation directory button
    self.directoryButton.connect('clicked(bool)', self.selectDirectory)
    # Ultrasound config file button
    self.configFileButton.connect('clicked(bool)', self.selectFile)

    # *** Function buttons ***
    # Sum manual segmentations
    self.createMergedManualSegmentationButton.connect('clicked(bool)', self.onCreateMergedManualSegmentationButton)
    # Create scanlines
    self.createScanlinesButton.connect('clicked(bool)', self.onCreateScanlinesButton)
    # Compute metrics
    self.computeMetricsButton.connect('clicked(bool)', self.onComputeMetricsButton)

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

    # Refresh Apply button state
    self.onInputSelect()
Пример #52
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)
        #version = qt.QLabel(TITLE + ' - version 2')
        #parametersFormLayout.addRow(version)

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

        #
        # Remember template ROIs.
        # To delete items, edit $HOME/.config/NA-MIC/Slicer.ini @[ctkPathLineEdit]
        #

        self.ROITemplateSelector = ctk.ctkPathLineEdit()
        self.ROITemplateSelector.filters = ctk.ctkPathLineEdit.Files
        self.ROITemplateSelector.settingKey = 'ROITemplateFile'
        self.ROITemplateSelector.nameFilters = ['ROI files (*.acsv)']
        self.ROITemplateSelector.retrieveHistory()
        parametersFormLayout.addRow("ROI template:", self.ROITemplateSelector)
        self.saveROIButton = qt.QPushButton("Remember selected ROI")
        parametersFormLayout.addRow(self.saveROIButton)

        #
        # We want to go to Volume Rendering after cropping
        #
        self.gotoVRButton = qt.QPushButton("Go to Volume Rendering")
        self.gotoVRButton.enabled = False
        parametersFormLayout.addRow(self.gotoVRButton)

        #
        # 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)
        self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.onSelect)
        self.gotoVRButton.connect('clicked(bool)', self.onGoToVR)
        # https://github.com/SlicerIGT/SlicerIGT/blob/master/Guidelet/GuideletLib/Guidelet.py
        #self.ROITemplateSelector.connect('currentPathChanged(QString)', self.onPathChanged)
        self.saveROIButton.connect('clicked(bool)', self.onSaveROI)

        # Add vertical spacer
        self.layout.addStretch(1)
Пример #53
0
  def create(self):
    """create the segmentation helper box"""

    #
    # Master Frame
    #
    self.masterFrame = qt.QFrame(self.parent)
    self.masterFrame.setLayout(qt.QVBoxLayout())
    self.parent.layout().addWidget(self.masterFrame)

    #
    # the master volume selector
    #
    self.masterSelectorFrame = qt.QFrame(self.parent)
    self.masterSelectorFrame.objectName = 'MasterVolumeFrame'
    self.masterSelectorFrame.setLayout(qt.QHBoxLayout())
    self.masterFrame.layout().addWidget(self.masterSelectorFrame)

    self.masterSelectorLabel = qt.QLabel("Master Volume: ", self.masterSelectorFrame)
    self.masterSelectorLabel.setToolTip( "Select the master volume (background grayscale scalar volume node)")
    self.masterSelectorFrame.layout().addWidget(self.masterSelectorLabel)

    self.masterSelector = slicer.qMRMLNodeComboBox(self.masterSelectorFrame)
    self.masterSelector.objectName = 'MasterVolumeNodeSelector'
    # TODO
    self.masterSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.masterSelector.selectNodeUponCreation = False
    self.masterSelector.addEnabled = False
    self.masterSelector.removeEnabled = False
    self.masterSelector.noneEnabled = True
    self.masterSelector.showHidden = False
    self.masterSelector.showChildNodeTypes = False
    self.masterSelector.setMRMLScene( slicer.mrmlScene )
    # TODO: need to add a QLabel
    # self.masterSelector.SetLabelText( "Master Volume:" )
    self.masterSelector.setToolTip( "Pick the master structural volume to define the segmentation.  A label volume with the with \"%s\" appended to the name will be created if it doesn't already exist." % self.mergeVolumePostfix)
    self.masterSelectorFrame.layout().addWidget(self.masterSelector)


    #
    # merge label name and set button
    #
    self.mergeSelectorFrame = qt.QFrame(self.masterFrame)
    self.mergeSelectorFrame.objectName = 'MergeVolumeFrame'
    self.mergeSelectorFrame.setLayout(qt.QHBoxLayout())
    self.masterFrame.layout().addWidget(self.mergeSelectorFrame)

    mergeNameToolTip = "Composite label map containing the merged structures (be aware that merge operations will overwrite any edits applied to this volume)"
    self.mergeNameLabel = qt.QLabel("Merge Volume: ", self.mergeSelectorFrame)
    self.mergeNameLabel.setToolTip( mergeNameToolTip )
    self.mergeSelectorFrame.layout().addWidget(self.mergeNameLabel)

    self.mergeSelector = slicer.qMRMLNodeComboBox(self.mergeSelectorFrame)
    self.mergeSelector.objectName = 'MergeVolumeNodeSelector'
    self.mergeSelector.setToolTip( mergeNameToolTip )
    self.mergeSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.mergeSelector.addEnabled = False
    self.mergeSelector.removeEnabled = False
    self.mergeSelector.noneEnabled = False
    self.mergeSelector.showHidden = False
    self.mergeSelector.showChildNodeTypes = False
    self.mergeSelector.setMRMLScene( slicer.mrmlScene )
    self.mergeSelectorFrame.layout().addWidget(self.mergeSelector)

    self.newMergeVolumeAction = qt.QAction("Create new LabelMapVolume", self.mergeSelector)
    self.newMergeVolumeAction.connect("triggered()", self.newMerge)
    self.mergeSelector.addMenuAction(self.newMergeVolumeAction)

    #
    # Structures Frame
    #
    self.structuresFrame = ctk.ctkCollapsibleGroupBox(self.masterFrame)
    self.structuresFrame.objectName = 'PerStructureVolumesFrame'
    self.structuresFrame.title = "Per-Structure Volumes"
    self.structuresFrame.collapsed = True
    self.structuresFrame.setLayout(qt.QVBoxLayout())
    self.masterFrame.layout().addWidget(self.structuresFrame)

    self.structureListWidget = LabelStructureListWidget()
    self.structureListWidget.mergeVolumePostfix = self.mergeVolumePostfix
    self.structuresFrame.layout().addWidget(self.structureListWidget)

    #
    # signals, slots, and observers
    #

    # signals/slots on qt widgets are automatically when
    # this class destructs, but observers of the scene must be explicitly
    # removed in the destuctor

    # node selected
    self.masterSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.mergeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onMergeSelect)

    # so buttons will initially be disabled
    self.master = None
    self.structureListWidget.updateStructures()
Пример #54
0
  def create(self,registrationState):
    """Make the plugin-specific user interface"""
    super(PlmRegisterPlugin,self).create(registrationState)

    self.registrationState = registrationState

    ## Set up GUI ##

    # Main collapsible bar
    self.collapsibleButton = ctk.ctkCollapsibleButton()
    self.collapsibleButton.text = "Plastimatch Registration"
    plmRegisterFormLayout = qt.QFormLayout()
    self.collapsibleButton.setLayout(plmRegisterFormLayout)
    self.widgets.append(self.collapsibleButton)

    # Cost function
    buttonLayout = qt.QHBoxLayout()
    self.costFunctionButtons = {}
    self.costFunctions = ("MSE", "MI")
    for cost in self.costFunctions:
      self.costFunctionButtons[cost] = qt.QRadioButton()
      self.costFunctionButtons[cost].text = cost
      self.costFunctionButtons[cost].setToolTip(
        "Register using %s cost function." % cost)
      buttonLayout.addWidget(self.costFunctionButtons[cost])
    self.costFunctionButtons[self.costFunction].checked = True
    plmRegisterFormLayout.addRow("Cost function:", buttonLayout)

    # Pre-alignment
    buttonLayout = qt.QHBoxLayout()
    self.prealignmentComboBox = qt.QComboBox()
    self.prealignmentComboBox.insertItem (1, "None")
    self.prealignmentComboBox.insertItem (2, "Local")
    self.prealignmentComboBox.insertItem (3, "Global")
    self.prealignmentComboBox.setToolTip(
      "Pre-alignment method\nEither none, global, or local")
    buttonLayout.addWidget(self.prealignmentComboBox)
    plmRegisterFormLayout.addRow("Pre-alignment:", buttonLayout)

    # Number of stages
    buttonLayout = qt.QHBoxLayout()
    self.numstagesComboBox = qt.QComboBox()
    self.numstagesComboBox.insertItem (1, "1")
    self.numstagesComboBox.insertItem (2, "2")
    self.numstagesComboBox.insertItem (3, "3")
    self.numstagesComboBox.setToolTip("Choose number of stages\nUse more stages for slower, more precise registration.")
    buttonLayout.addWidget(self.numstagesComboBox)
    plmRegisterFormLayout.addRow("B-Spline stages:", buttonLayout)

    # Output transform
    self.outputTransformComboBox = slicer.qMRMLNodeComboBox()
    self.outputTransformComboBox.nodeTypes = ["vtkMRMLGridTransformNode"]
    self.outputTransformComboBox.selectNodeUponCreation = True
    self.outputTransformComboBox.addEnabled = True
    self.outputTransformComboBox.removeEnabled = True
    self.outputTransformComboBox.noneEnabled = True
    self.outputTransformComboBox.showHidden = False
    self.outputTransformComboBox.showChildNodeTypes = False
    self.outputTransformComboBox.setMRMLScene( slicer.mrmlScene )
    plmRegisterFormLayout.addRow("Output transform:",
                                 self.outputTransformComboBox)

    # Apply button
    self.applyButton = qt.QPushButton("Click to start registration!")
    self.applyButton.setStyleSheet("background-color: #FFFF99")
    self.applyButton.connect('clicked(bool)', self.onApply)
    plmRegisterFormLayout.addWidget(self.applyButton)

    # Stop button
    self.stopButton = qt.QPushButton("Click to stop registration!")
    self.stopButton.setStyleSheet("background-color: #FF3232")
    self.stopButton.connect('clicked(bool)', self.onStop)
    plmRegisterFormLayout.addWidget(self.stopButton)

    # Status label
    self.statusLabel = qt.QLabel("")
    plmRegisterFormLayout.addWidget(self.statusLabel)

    # Stage 1
    self.stage1Box = qt.QGroupBox("Stage 1")
    self.stage1Box.setLayout(qt.QFormLayout())

    # Iterations
    buttonLayout = qt.QHBoxLayout()
    self.stage1_iterationsLineEdit = qt.QLineEdit()
    self.stage1_iterationsLineEdit.setText('40')
    self.stage1_iterationsLineEdit.setToolTip( "Maximum number of iterations" ) 
    self.stage1_iterationsLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_iterationsLineEdit)
    self.stage1Box.layout().addRow("Iterations:", buttonLayout)

    # Subsampling rate
    buttonLayout = qt.QHBoxLayout()
    self.stage1_subsamplingLineEdit = qt.QLineEdit()
    self.stage1_subsamplingLineEdit.setText('4 4 2')
    self.stage1_subsamplingLineEdit.setToolTip( "Subsampling rate" ) 
    self.stage1_subsamplingLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_subsamplingLineEdit)
    self.stage1Box.layout().addRow("Subsampling rate (vox):", buttonLayout)

    # Grid spacing
    buttonLayout = qt.QHBoxLayout()
    self.stage1_gridSpacingLineEdit = qt.QLineEdit()
    self.stage1_gridSpacingLineEdit.setText('100')
    self.stage1_gridSpacingLineEdit.setToolTip( "Set B-spline grid spacing" )
    self.stage1_gridSpacingLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_gridSpacingLineEdit)
    self.stage1Box.layout().addRow("Grid size (mm):", buttonLayout)

    # Regularization
    buttonLayout = qt.QHBoxLayout()
    self.stage1_regularizationLineEdit = qt.QLineEdit()
    self.stage1_regularizationLineEdit.setText('0.1')
    self.stage1_regularizationLineEdit.setToolTip(
      "Set Regularization penalty term")
    self.stage1_regularizationLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_regularizationLineEdit)
    self.stage1Box.layout().addRow("Regularization:", buttonLayout)

    # Landmark penalty
    buttonLayout = qt.QHBoxLayout()
    self.stage1_landmarkPenaltyLineEdit = qt.QLineEdit()
    self.stage1_landmarkPenaltyLineEdit.setText('10')
    self.stage1_landmarkPenaltyLineEdit.setToolTip(
      "Set landmark distance penalty term")
    self.stage1_landmarkPenaltyLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_landmarkPenaltyLineEdit)
    self.stage1Box.layout().addRow("Landmark penalty:", buttonLayout)

    plmRegisterFormLayout.addRow(self.stage1Box)

    # Stage 2
    self.stage2Box = qt.QGroupBox("Stage 2")
    self.stage2Box.setLayout(qt.QFormLayout())

    # Iterations
    buttonLayout = qt.QHBoxLayout()
    self.stage2_iterationsLineEdit = qt.QLineEdit()
    self.stage2_iterationsLineEdit.setText('20')
    self.stage2_iterationsLineEdit.setToolTip( "Maximum number of iterations" ) 
    self.stage2_iterationsLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_iterationsLineEdit)
    self.stage2Box.layout().addRow("Iterations:", buttonLayout)

    # Subsampling rate
    buttonLayout = qt.QHBoxLayout()
    self.stage2_subsamplingLineEdit = qt.QLineEdit()
    self.stage2_subsamplingLineEdit.setText('2 2 1')
    self.stage2_subsamplingLineEdit.setToolTip( "Subsampling rate" ) 
    self.stage2_subsamplingLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_subsamplingLineEdit)
    self.stage2Box.layout().addRow("Subsampling rate (vox):", buttonLayout)

    # Grid spacing
    buttonLayout = qt.QHBoxLayout()
    self.stage2_gridSpacingLineEdit = qt.QLineEdit()
    self.stage2_gridSpacingLineEdit.setText('50')
    self.stage2_gridSpacingLineEdit.setToolTip( "Set B-spline grid spacing" )
    self.stage2_gridSpacingLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_gridSpacingLineEdit)
    self.stage2Box.layout().addRow("Grid size (mm):", buttonLayout)

    # Regularization
    buttonLayout = qt.QHBoxLayout()
    self.stage2_regularizationLineEdit = qt.QLineEdit()
    self.stage2_regularizationLineEdit.setText('0.1')
    self.stage2_regularizationLineEdit.setToolTip(
      "Set Regularization penalty term")
    self.stage2_regularizationLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_regularizationLineEdit)
    self.stage2Box.layout().addRow("Regularization:", buttonLayout)

    # Landmark penalty
    buttonLayout = qt.QHBoxLayout()
    self.stage2_landmarkPenaltyLineEdit = qt.QLineEdit()
    self.stage2_landmarkPenaltyLineEdit.setText('10')
    self.stage2_landmarkPenaltyLineEdit.setToolTip(
      "Set landmark distance penalty term")
    self.stage2_landmarkPenaltyLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_landmarkPenaltyLineEdit)
    self.stage2Box.layout().addRow("Landmark penalty:", buttonLayout)

    plmRegisterFormLayout.addRow(self.stage2Box)

    # Stage 3
    self.stage3Box = qt.QGroupBox("Stage 3")
    self.stage3Box.setLayout(qt.QFormLayout())

    # Iterations
    buttonLayout = qt.QHBoxLayout()
    self.stage3_iterationsLineEdit = qt.QLineEdit()
    self.stage3_iterationsLineEdit.setText('10')
    self.stage3_iterationsLineEdit.setToolTip( "Maximum number of iterations" ) 
    self.stage3_iterationsLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_iterationsLineEdit)
    self.stage3Box.layout().addRow("Iterations:", buttonLayout)

    # Subsampling rate
    buttonLayout = qt.QHBoxLayout()
    self.stage3_subsamplingLineEdit = qt.QLineEdit()
    self.stage3_subsamplingLineEdit.setText('1 1 1')
    self.stage3_subsamplingLineEdit.setToolTip( "Subsampling rate" ) 
    self.stage3_subsamplingLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_subsamplingLineEdit)
    self.stage3Box.layout().addRow("Subsampling rate (vox):", buttonLayout)

    # Grid spacing
    buttonLayout = qt.QHBoxLayout()
    self.stage3_gridSpacingLineEdit = qt.QLineEdit()
    self.stage3_gridSpacingLineEdit.setText('30')
    self.stage3_gridSpacingLineEdit.setToolTip( "Set B-spline grid spacing" )
    self.stage3_gridSpacingLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_gridSpacingLineEdit)
    self.stage3Box.layout().addRow("Grid size (mm):", buttonLayout)

    # Regularization
    buttonLayout = qt.QHBoxLayout()
    self.stage3_regularizationLineEdit = qt.QLineEdit()
    self.stage3_regularizationLineEdit.setText('0.1')
    self.stage3_regularizationLineEdit.setToolTip(
      "Set Regularization penalty term")
    self.stage3_regularizationLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_regularizationLineEdit)
    self.stage3Box.layout().addRow("Regularization:", buttonLayout)

    # Landmark penalty
    buttonLayout = qt.QHBoxLayout()
    self.stage3_landmarkPenaltyLineEdit = qt.QLineEdit()
    self.stage3_landmarkPenaltyLineEdit.setText('10')
    self.stage3_landmarkPenaltyLineEdit.setToolTip(
      "Set landmark distance penalty term")
    self.stage3_landmarkPenaltyLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_landmarkPenaltyLineEdit)
    self.stage3Box.layout().addRow("Landmark penalty:", buttonLayout)

    plmRegisterFormLayout.addRow(self.stage3Box)

    # Add UI elements to parent layout
    self.parent.layout().addWidget(self.collapsibleButton)
Пример #55
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

    inputModelSelectorFrame = qt.QFrame(self.parent)
    inputModelSelectorFrame.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(inputModelSelectorFrame)

    inputModelSelectorLabel = qt.QLabel("Input Model: ", inputModelSelectorFrame)
    inputModelSelectorLabel.setToolTip( "Select the input model")
    inputModelSelectorFrame.layout().addWidget(inputModelSelectorLabel)

    inputModelSelector = slicer.qMRMLNodeComboBox(inputModelSelectorFrame)
    inputModelSelector.nodeTypes = ["vtkMRMLModelNode"]
    inputModelSelector.selectNodeUponCreation = False
    inputModelSelector.addEnabled = False
    inputModelSelector.removeEnabled = False
    inputModelSelector.noneEnabled = True
    inputModelSelector.showHidden = False
    inputModelSelector.showChildNodeTypes = False
    inputModelSelector.setMRMLScene( slicer.mrmlScene )
    inputModelSelectorFrame.layout().addWidget(inputModelSelector)

    outputModelSelectorFrame = qt.QFrame(self.parent)
    outputModelSelectorFrame.setLayout(qt.QHBoxLayout())
    self.parent.layout().addWidget(outputModelSelectorFrame)

    outputModelSelectorLabel = qt.QLabel("Output Model: ", outputModelSelectorFrame)
    outputModelSelectorLabel.setToolTip( "Select the output model")
    outputModelSelectorFrame.layout().addWidget(outputModelSelectorLabel)

    outputModelSelector = slicer.qMRMLNodeComboBox(outputModelSelectorFrame)
    outputModelSelector.nodeTypes = ["vtkMRMLModelNode"]
    outputModelSelector.selectNodeUponCreation = False
    outputModelSelector.addEnabled = True
    outputModelSelector.renameEnabled = True
    outputModelSelector.removeEnabled = True
    outputModelSelector.noneEnabled = True
    outputModelSelector.showHidden = False
    outputModelSelector.showChildNodeTypes = False
    outputModelSelector.baseName = "Model"
    outputModelSelector.selectNodeUponCreation = True
    outputModelSelector.setMRMLScene( slicer.mrmlScene )
    outputModelSelectorFrame.layout().addWidget(outputModelSelector)

    decimationButton = qt.QPushButton("Decimation")
    decimationButton.checkable = True
    self.layout.addWidget(decimationButton)
    decimationFrame = qt.QFrame(self.parent)
    self.layout.addWidget(decimationFrame)
    decimationFormLayout = qt.QFormLayout(decimationFrame)

    reductionFrame, reductionSlider, reductionSpinBox = numericInputFrame(self.parent,"Reduction:","Tooltip",0.0,1.0,0.05,2)
    decimationFormLayout.addWidget(reductionFrame)

    boundaryDeletionCheckBox = qt.QCheckBox("Boundary deletion")
    decimationFormLayout.addWidget(boundaryDeletionCheckBox)

    smoothingButton = qt.QPushButton("Smoothing")
    smoothingButton.checkable = True
    self.layout.addWidget(smoothingButton)
    smoothingFrame = qt.QFrame(self.parent)
    self.layout.addWidget(smoothingFrame)
    smoothingFormLayout = qt.QFormLayout(smoothingFrame)

    smoothingMethodCombo = qt.QComboBox(smoothingFrame)
    smoothingMethodCombo.addItem("Laplace")
    smoothingMethodCombo.addItem("Taubin")
    smoothingFormLayout.addWidget(smoothingMethodCombo)

    laplaceMethodFrame = qt.QFrame(self.parent)
    smoothingFormLayout.addWidget(laplaceMethodFrame)
    laplaceMethodFormLayout = qt.QFormLayout(laplaceMethodFrame)

    laplaceIterationsFrame, laplaceIterationsSlider, laplaceIterationsSpinBox = numericInputFrame(self.parent,"Iterations:","Tooltip",0.0,500.0,1.0,0)
    laplaceMethodFormLayout.addWidget(laplaceIterationsFrame)

    laplaceRelaxationFrame, laplaceRelaxationSlider, laplaceRelaxationSpinBox = numericInputFrame(self.parent,"Relaxation:","Tooltip",0.0,1.0,0.1,1)
    laplaceMethodFormLayout.addWidget(laplaceRelaxationFrame)

    taubinMethodFrame = qt.QFrame(self.parent)
    smoothingFormLayout.addWidget(taubinMethodFrame)
    taubinMethodFormLayout = qt.QFormLayout(taubinMethodFrame)

    taubinIterationsFrame, taubinIterationsSlider, taubinIterationsSpinBox = numericInputFrame(self.parent,"Iterations:","Tooltip",0.0,100.0,1.0,0)
    taubinMethodFormLayout.addWidget(taubinIterationsFrame)

    taubinPassBandFrame, taubinPassBandSlider, taubinPassBandSpinBox = numericInputFrame(self.parent,"Pass Band:","Tooltip",0.0,1.0,0.01,2)
    taubinMethodFormLayout.addWidget(taubinPassBandFrame)

    boundarySmoothingCheckBox = qt.QCheckBox("Boundary Smoothing")
    smoothingFormLayout.addWidget(boundarySmoothingCheckBox)

    normalsButton = qt.QPushButton("Normals")
    normalsButton.checkable = True
    self.layout.addWidget(normalsButton)
    normalsFrame = qt.QFrame(self.parent)
    self.layout.addWidget(normalsFrame)
    normalsFormLayout = qt.QFormLayout(normalsFrame)

    flipNormalsCheckBox = qt.QCheckBox("Flip Normals")
    normalsFormLayout.addWidget(flipNormalsCheckBox)

    splittingCheckBox = qt.QCheckBox("Splitting")
    normalsFormLayout.addWidget(splittingCheckBox)

    featureAngleFrame, featureAngleSlider, featureAngleSpinBox = numericInputFrame(self.parent,"Feature Angle:","Tooltip",0.0,180.0,1.0,0)
    normalsFormLayout.addWidget(featureAngleFrame)

    cleanerButton = qt.QPushButton("Cleaner")
    cleanerButton.checkable = True
    self.layout.addWidget(cleanerButton)

    connectivityButton = qt.QPushButton("Connectivity")
    connectivityButton.checkable = True
    self.layout.addWidget(connectivityButton)
    #connectivityFrame = qt.QFrame(self.parent)
    #self.layout.addWidget(connectivityFrame)
    #connectivityFormLayout = qt.QFormLayout(connectivityFrame)

    # TODO: connectivity could be
    # - largest connected
    # - threshold connected (discard below point count)
    # - pick a region interactively
    # - turn a multiple connected surface into a model hierarchy

    buttonFrame = qt.QFrame(self.parent)
    buttonFrame.setLayout(qt.QHBoxLayout())
    self.layout.addWidget(buttonFrame)

    toggleModelsButton = qt.QPushButton("Toggle Models")
    toggleModelsButton.toolTip = "Show original model."
    buttonFrame.layout().addWidget(toggleModelsButton)

    applyButton = qt.QPushButton("Apply")
    applyButton.toolTip = "Filter surface."
    buttonFrame.layout().addWidget(applyButton)

    self.layout.addStretch(1)

    class state(object):
      inputModelNode = None
      outputModelNode = None
      decimation = False
      reduction = 0.8
      boundaryDeletion = False
      smoothing = False
      smoothingMethod = "Laplace"
      laplaceIterations = 100.0
      laplaceRelaxation = 0.5
      taubinIterations = 30.0
      taubinPassBand = 0.1
      boundarySmoothing = True
      normals = False
      flipNormals = False
      splitting = False
      featureAngle = 30.0
      cleaner = False
      connectivity = False

    scope_locals = locals()
    def connect(obj, evt, cmd):
      def callback(*args):
        current_locals = scope_locals.copy()
        current_locals.update({'args':args})
        exec cmd in globals(), current_locals
        updateGUI()
      obj.connect(evt,callback)

    def updateGUI():

      def button_stylesheet(active):
        if active:
          return "background-color: green"
        else:
          return ""

      decimationButton.checked = state.decimation
      #decimationButton.setStyleSheet(button_stylesheet(state.decimation))
      decimationFrame.visible = state.decimation
      boundaryDeletionCheckBox.checked = state.boundaryDeletion
      reductionSlider.value = state.reduction
      reductionSpinBox.value = state.reduction

      smoothingButton.checked = state.smoothing
      smoothingFrame.visible = state.smoothing
      laplaceMethodFrame.visible = state.smoothingMethod == "Laplace"
      laplaceIterationsSlider.value = state.laplaceIterations
      laplaceIterationsSpinBox.value = state.laplaceIterations
      laplaceRelaxationSlider.value = state.laplaceRelaxation
      laplaceRelaxationSpinBox.value = state.laplaceRelaxation
      taubinMethodFrame.visible = state.smoothingMethod == "Taubin"
      taubinIterationsSlider.value = state.taubinIterations
      taubinIterationsSpinBox.value = state.taubinIterations
      taubinPassBandSlider.value = state.taubinPassBand
      taubinPassBandSpinBox.value = state.taubinPassBand
      boundarySmoothingCheckBox.checked = state.boundarySmoothing

      normalsButton.checked = state.normals
      normalsFrame.visible = state.normals
      flipNormalsCheckBox.checked = state.flipNormals
      splittingCheckBox.checked = state.splitting
      featureAngleFrame.visible = state.splitting
      featureAngleSlider.value = state.featureAngle
      featureAngleSpinBox.value = state.featureAngle

      cleanerButton.checked = state.cleaner

      connectivityButton.checked = state.connectivity

      toggleModelsButton.enabled = state.inputModelNode is not None and state.outputModelNode is not None
      applyButton.enabled = state.inputModelNode is not None and state.outputModelNode is not None


    connect(inputModelSelector,'currentNodeChanged(vtkMRMLNode*)','state.inputModelNode = args[0]')
    connect(outputModelSelector,'currentNodeChanged(vtkMRMLNode*)','state.outputModelNode = args[0]')

    def initializeModelNode(node):
      displayNode = slicer.vtkMRMLModelDisplayNode()
      storageNode = slicer.vtkMRMLModelStorageNode()
      displayNode.SetScene(slicer.mrmlScene)
      storageNode.SetScene(slicer.mrmlScene)
      slicer.mrmlScene.AddNode(displayNode)
      slicer.mrmlScene.AddNode(storageNode)
      node.SetAndObserveDisplayNodeID(displayNode.GetID())
      node.SetAndObserveStorageNodeID(storageNode.GetID())

    outputModelSelector.connect('nodeAddedByUser(vtkMRMLNode*)',initializeModelNode)

    connect(decimationButton, 'clicked(bool)', 'state.decimation = args[0]')
    connect(reductionSlider, 'valueChanged(double)', 'state.reduction = args[0]')
    connect(reductionSpinBox, 'valueChanged(double)', 'state.reduction = args[0]')
    connect(boundaryDeletionCheckBox, 'stateChanged(int)', 'state.boundaryDeletion = bool(args[0])')

    connect(smoothingButton, 'clicked(bool)', 'state.smoothing = args[0]')
    connect(smoothingMethodCombo, 'currentIndexChanged(QString)', 'state.smoothingMethod = args[0]')

    connect(laplaceIterationsSlider, 'valueChanged(double)', 'state.laplaceIterations = int(args[0])')
    connect(laplaceIterationsSpinBox, 'valueChanged(double)', 'state.laplaceIterations = int(args[0])')
    connect(laplaceRelaxationSlider, 'valueChanged(double)', 'state.laplaceRelaxation = args[0]')
    connect(laplaceRelaxationSpinBox, 'valueChanged(double)', 'state.laplaceRelaxation = args[0]')

    connect(taubinIterationsSlider, 'valueChanged(double)', 'state.taubinIterations = int(args[0])')
    connect(taubinIterationsSpinBox, 'valueChanged(double)', 'state.taubinIterations = int(args[0])')
    connect(taubinPassBandSlider, 'valueChanged(double)', 'state.taubinPassBand = args[0]')
    connect(taubinPassBandSpinBox, 'valueChanged(double)', 'state.taubinPassBand = args[0]')

    connect(boundarySmoothingCheckBox, 'stateChanged(int)', 'state.boundarySmoothing = bool(args[0])')

    connect(normalsButton, 'clicked(bool)', 'state.normals = args[0]')

    connect(flipNormalsCheckBox, 'stateChanged(int)', 'state.flipNormals = bool(args[0])')
    connect(splittingCheckBox, 'stateChanged(int)', 'state.splitting = bool(args[0])')
    connect(featureAngleSlider, 'valueChanged(double)', 'state.featureAngle = args[0]')
    connect(featureAngleSpinBox, 'valueChanged(double)', 'state.featureAngle = args[0]')

    connect(cleanerButton, 'clicked(bool)', 'state.cleaner = args[0]')
    connect(connectivityButton, 'clicked(bool)', 'state.connectivity = args[0]')

    def onApply():
      updateGUI()
      applyButton.text = "Working..."
      applyButton.repaint()
      slicer.app.processEvents()
      logic = SurfaceToolboxLogic()
      result = logic.applyFilters(state)
      if result:
        state.inputModelNode.GetModelDisplayNode().VisibilityOff()
        state.outputModelNode.GetModelDisplayNode().VisibilityOn()
      else:
        state.inputModelNode.GetModelDisplayNode().VisibilityOn()
        state.outputModelNode.GetModelDisplayNode().VisibilityOff()
      applyButton.text = "Apply"

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

    def onToggleModels():
      updateGUI()
      if state.inputModelNode.GetModelDisplayNode().GetVisibility():
        state.inputModelNode.GetModelDisplayNode().VisibilityOff()
        state.outputModelNode.GetModelDisplayNode().VisibilityOn()
        toggleModelsButton.text = "Toggle Models (Output)"
      else:
        state.inputModelNode.GetModelDisplayNode().VisibilityOn()
        state.outputModelNode.GetModelDisplayNode().VisibilityOff()
        toggleModelsButton.text = "Toggle Models (Input)"

    toggleModelsButton.connect('clicked()', onToggleModels)

    updateGUI()

    self.updateGUI = updateGUI
Пример #56
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # tracks the modified event observer on the currently
        # selected sequence browser node
        self.sequenceBrowserObserverRecord = None

        self.animatorActionsGUI = None

        self.logic = AnimatorLogic()

        # Instantiate and connect widgets ...

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

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

        self.durationBox = ctk.ctkDoubleSpinBox()
        self.durationBox.suffix = " seconds"
        self.durationBox.decimals = 1
        self.durationBox.minimum = 1
        self.durationBox.value = 5
        self.durationBox.toolTip = "Duration cannot be changed after animation created"
        parametersFormLayout.addRow("New animation duration", self.durationBox)

        #
        # input volume selector
        #
        self.animationSelector = slicer.qMRMLNodeComboBox()
        self.animationSelector.nodeTypes = ["vtkMRMLScriptedModuleNode"]
        self.animationSelector.setNodeTypeLabel("Animation",
                                                "vtkMRMLScriptedModuleNode")
        self.animationSelector.selectNodeUponCreation = True
        self.animationSelector.addEnabled = True
        self.animationSelector.addAttribute("vtkMRMLScriptedModuleNode",
                                            "ModuleName", "Animation")
        self.animationSelector.baseName = "Animation"
        self.animationSelector.removeEnabled = True
        self.animationSelector.noneEnabled = True
        self.animationSelector.showHidden = True
        self.animationSelector.showChildNodeTypes = False
        self.animationSelector.setMRMLScene(slicer.mrmlScene)
        self.animationSelector.setToolTip("Pick the animation description.")
        parametersFormLayout.addRow("Animation Node: ", self.animationSelector)

        self.sequencePlay = slicer.qMRMLSequenceBrowserPlayWidget()
        self.sequencePlay.setMRMLScene(slicer.mrmlScene)
        self.sequenceSeek = slicer.qMRMLSequenceBrowserSeekWidget()
        self.sequenceSeek.setMRMLScene(slicer.mrmlScene)

        parametersFormLayout.addRow(self.sequencePlay)
        parametersFormLayout.addRow(self.sequenceSeek)

        self.actionsMenuButton = qt.QPushButton("Add Action")
        self.actionsMenuButton.enabled = False
        self.actionsMenu = qt.QMenu()
        self.actionsMenuButton.setMenu(self.actionsMenu)
        for actionName in slicer.modules.animatorActionPlugins.keys():
            qAction = qt.QAction(actionName, self.actionsMenu)
            qAction.connect(
                'triggered()',
                lambda actionName=actionName: self.onAddAction(actionName))
            self.actionsMenu.addAction(qAction)
        parametersFormLayout.addWidget(self.actionsMenuButton)

        #
        # Actions Area
        #
        self.actionsCollapsibleButton = ctk.ctkCollapsibleButton()
        self.actionsCollapsibleButton.text = "Actions"
        self.layout.addWidget(self.actionsCollapsibleButton)

        # Layout within the dummy collapsible button
        self.actionsFormLayout = qt.QFormLayout(self.actionsCollapsibleButton)

        #
        # Export Area
        #
        self.exportCollapsibleButton = ctk.ctkCollapsibleButton()
        self.exportCollapsibleButton.text = "Export"
        self.layout.addWidget(self.exportCollapsibleButton)
        self.exportCollapsibleButton.enabled = False
        self.exportFormLayout = qt.QFormLayout(self.exportCollapsibleButton)

        self.sizeSelector = qt.QComboBox()
        for size in self.sizes.keys():
            self.sizeSelector.addItem(size)
        self.sizeSelector.currentText = self.defaultSize
        self.exportFormLayout.addRow("Animation size", self.sizeSelector)

        self.fileFormatSelector = qt.QComboBox()
        for format in self.fileFormats.keys():
            self.fileFormatSelector.addItem(format)
        self.fileFormatSelector.currentText = self.defaultFileFormat
        self.exportFormLayout.addRow("Animation format",
                                     self.fileFormatSelector)

        self.outputFileButton = qt.QPushButton("Select a file...")
        self.exportFormLayout.addRow("Output file", self.outputFileButton)

        self.exportButton = qt.QPushButton("Export")
        self.exportButton.enabled = False
        self.exportFormLayout.addRow("", self.exportButton)

        # connections
        self.animationSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                       self.onSelect)
        self.outputFileButton.connect("clicked()", self.selectExportFile)
        self.exportButton.connect("clicked()", self.onExport)

        # Add vertical spacer
        self.layout.addStretch(1)
Пример #57
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 = ["vtkMRMLSequenceNode"]
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.noneEnabled = False
        self.inputSelector.showHidden = False
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputSelector.setToolTip(
            "Pick a sequence node of volumes that will be cropped and resampled."
        )
        parametersFormLayout.addRow("Input volume sequence: ",
                                    self.inputSelector)

        #
        # output volume selector
        #
        self.outputSelector = slicer.qMRMLNodeComboBox()
        self.outputSelector.nodeTypes = ["vtkMRMLSequenceNode"]
        self.outputSelector.selectNodeUponCreation = True
        self.outputSelector.addEnabled = True
        self.outputSelector.removeEnabled = True
        self.outputSelector.noneEnabled = True
        self.outputSelector.noneDisplay = "(Overwrite input)"
        self.outputSelector.showHidden = False
        self.outputSelector.showChildNodeTypes = False
        self.outputSelector.setMRMLScene(slicer.mrmlScene)
        self.outputSelector.setToolTip(
            "Pick a sequence node where the cropped and resampled volumes will be stored."
        )
        parametersFormLayout.addRow("Output volume sequence: ",
                                    self.outputSelector)

        #
        # Crop parameters selector
        #
        self.cropParametersSelector = slicer.qMRMLNodeComboBox()
        self.cropParametersSelector.nodeTypes = [
            "vtkMRMLCropVolumeParametersNode"
        ]
        self.cropParametersSelector.selectNodeUponCreation = True
        self.cropParametersSelector.addEnabled = True
        self.cropParametersSelector.removeEnabled = True
        self.cropParametersSelector.renameEnabled = True
        self.cropParametersSelector.noneEnabled = False
        self.cropParametersSelector.showHidden = True
        self.cropParametersSelector.showChildNodeTypes = False
        self.cropParametersSelector.setMRMLScene(slicer.mrmlScene)
        self.cropParametersSelector.setToolTip(
            "Select a crop volumes parameters.")

        self.editCropParametersButton = qt.QPushButton()
        self.editCropParametersButton.setIcon(qt.QIcon(':Icons/Go.png'))
        #self.editCropParametersButton.setMaximumWidth(60)
        self.editCropParametersButton.enabled = True
        self.editCropParametersButton.toolTip = "Go to Crop Volume module to edit cropping parameters."
        hbox = qt.QHBoxLayout()
        hbox.addWidget(self.cropParametersSelector)
        hbox.addWidget(self.editCropParametersButton)
        parametersFormLayout.addRow("Crop volume settings: ", hbox)

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

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

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

        # Refresh Apply button state
        self.onSelect()
Пример #58
0
  def create(self,registrationState):
    """Make the plugin-specific user interface"""
    super(PlmRegisterPlugin,self).create(registrationState)

    self.registrationState = registrationState

    ## Set up GUI ##

    # Main collapsible bar
    self.collapsibleButton = ctk.ctkCollapsibleButton()
    self.collapsibleButton.text = "Plastimatch Registration"
    plmRegisterFormLayout = qt.QFormLayout()
    self.collapsibleButton.setLayout(plmRegisterFormLayout)
    self.widgets.append(self.collapsibleButton)

    # Cost function
    buttonLayout = qt.QHBoxLayout()
    self.costFunctionButtons = {}
    self.costFunctions = ("MSE", "MI")
    for cost in self.costFunctions:
      self.costFunctionButtons[cost] = qt.QRadioButton()
      self.costFunctionButtons[cost].text = cost
      self.costFunctionButtons[cost].setToolTip("Register using %s cost function." % cost)
      buttonLayout.addWidget(self.costFunctionButtons[cost])
    self.costFunctionButtons[self.costFunction].checked = True
    plmRegisterFormLayout.addRow("Cost function:", buttonLayout)

    # Pre-alignment
    buttonLayout = qt.QHBoxLayout()
    self.prealignmentComboBox = qt.QComboBox()
    self.prealignmentComboBox.insertItem (1, "None")
    self.prealignmentComboBox.insertItem (2, "Local")
    self.prealignmentComboBox.insertItem (3, "Global")
    self.prealignmentComboBox.setToolTip("Pre-alignment method\nEither none, global, or local")
    buttonLayout.addWidget(self.prealignmentComboBox)
    plmRegisterFormLayout.addRow("Pre-alignment:", buttonLayout)

    # Number of stages
    buttonLayout = qt.QHBoxLayout()
    self.numstagesComboBox = qt.QComboBox()
    self.numstagesComboBox.insertItem (1, "1")
    self.numstagesComboBox.insertItem (2, "2")
    self.numstagesComboBox.insertItem (3, "3")
    self.numstagesComboBox.setToolTip("Choose number of stages\nUse more stages for slower, more precise registration.")
    buttonLayout.addWidget(self.numstagesComboBox)
    plmRegisterFormLayout.addRow("B-Spline stages:", buttonLayout)

    # Output transform
    self.outputTransformComboBox = slicer.qMRMLNodeComboBox()
    self.outputTransformComboBox.nodeTypes = ["vtkMRMLGridTransformNode"]
    self.outputTransformComboBox.selectNodeUponCreation = True
    self.outputTransformComboBox.addEnabled = True
    self.outputTransformComboBox.removeEnabled = True
    self.outputTransformComboBox.noneEnabled = True
    self.outputTransformComboBox.showHidden = False
    self.outputTransformComboBox.showChildNodeTypes = False
    self.outputTransformComboBox.setMRMLScene( slicer.mrmlScene )
    plmRegisterFormLayout.addRow("Output transform:",
                                 self.outputTransformComboBox)

    # Apply button
    self.applyButton = qt.QPushButton("Click to start registration!")
    self.applyButton.setStyleSheet("background-color: #FFFF99")
    self.applyButton.connect('clicked(bool)', self.onApply)
    plmRegisterFormLayout.addWidget(self.applyButton)

    # Stop button
    self.stopButton = qt.QPushButton("Click to stop registration!")
    self.stopButton.setStyleSheet("background-color: #FF3232")
    self.stopButton.connect('clicked(bool)', self.onStop)
    plmRegisterFormLayout.addWidget(self.stopButton)

    # Status label
    self.statusLabel = qt.QLabel("")
    plmRegisterFormLayout.addWidget(self.statusLabel)

    # Stage 1
    self.stage1Box = qt.QGroupBox("Stage 1")
    self.stage1Box.setLayout(qt.QFormLayout())

    # Iterations
    buttonLayout = qt.QHBoxLayout()
    self.stage1_iterationsLineEdit = qt.QLineEdit()
    self.stage1_iterationsLineEdit.setText('40')
    self.stage1_iterationsLineEdit.setToolTip( "Maximum number of iterations" )
    self.stage1_iterationsLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_iterationsLineEdit)
    self.stage1Box.layout().addRow("Iterations:", buttonLayout)

    # Subsampling rate
    buttonLayout = qt.QHBoxLayout()
    self.stage1_subsamplingLineEdit = qt.QLineEdit()
    self.stage1_subsamplingLineEdit.setText('4 4 2')
    self.stage1_subsamplingLineEdit.setToolTip( "Subsampling rate" )
    self.stage1_subsamplingLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_subsamplingLineEdit)
    self.stage1Box.layout().addRow("Subsampling rate (vox):", buttonLayout)

    # Grid spacing
    buttonLayout = qt.QHBoxLayout()
    self.stage1_gridSpacingLineEdit = qt.QLineEdit()
    self.stage1_gridSpacingLineEdit.setText('100')
    self.stage1_gridSpacingLineEdit.setToolTip( "Set B-spline grid spacing" )
    self.stage1_gridSpacingLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_gridSpacingLineEdit)
    self.stage1Box.layout().addRow("Grid size (mm):", buttonLayout)

    # Regularization
    buttonLayout = qt.QHBoxLayout()
    self.stage1_regularizationLineEdit = qt.QLineEdit()
    self.stage1_regularizationLineEdit.setText('0.1')
    self.stage1_regularizationLineEdit.setToolTip("Set Regularization penalty term")
    self.stage1_regularizationLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_regularizationLineEdit)
    self.stage1Box.layout().addRow("Regularization:", buttonLayout)

    # Landmark penalty
    buttonLayout = qt.QHBoxLayout()
    self.stage1_landmarkPenaltyLineEdit = qt.QLineEdit()
    self.stage1_landmarkPenaltyLineEdit.setText('10')
    self.stage1_landmarkPenaltyLineEdit.setToolTip("Set landmark distance penalty term")
    self.stage1_landmarkPenaltyLineEdit.connect('textChanged(QString)', self.parameterStage1IsChanged)
    buttonLayout.addWidget(self.stage1_landmarkPenaltyLineEdit)
    self.stage1Box.layout().addRow("Landmark penalty:", buttonLayout)

    plmRegisterFormLayout.addRow(self.stage1Box)

    # Stage 2
    self.stage2Box = qt.QGroupBox("Stage 2")
    self.stage2Box.setLayout(qt.QFormLayout())

    # Iterations
    buttonLayout = qt.QHBoxLayout()
    self.stage2_iterationsLineEdit = qt.QLineEdit()
    self.stage2_iterationsLineEdit.setText('20')
    self.stage2_iterationsLineEdit.setToolTip( "Maximum number of iterations" )
    self.stage2_iterationsLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_iterationsLineEdit)
    self.stage2Box.layout().addRow("Iterations:", buttonLayout)

    # Subsampling rate
    buttonLayout = qt.QHBoxLayout()
    self.stage2_subsamplingLineEdit = qt.QLineEdit()
    self.stage2_subsamplingLineEdit.setText('2 2 1')
    self.stage2_subsamplingLineEdit.setToolTip( "Subsampling rate" )
    self.stage2_subsamplingLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_subsamplingLineEdit)
    self.stage2Box.layout().addRow("Subsampling rate (vox):", buttonLayout)

    # Grid spacing
    buttonLayout = qt.QHBoxLayout()
    self.stage2_gridSpacingLineEdit = qt.QLineEdit()
    self.stage2_gridSpacingLineEdit.setText('50')
    self.stage2_gridSpacingLineEdit.setToolTip( "Set B-spline grid spacing" )
    self.stage2_gridSpacingLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_gridSpacingLineEdit)
    self.stage2Box.layout().addRow("Grid size (mm):", buttonLayout)

    # Regularization
    buttonLayout = qt.QHBoxLayout()
    self.stage2_regularizationLineEdit = qt.QLineEdit()
    self.stage2_regularizationLineEdit.setText('0.1')
    self.stage2_regularizationLineEdit.setToolTip("Set Regularization penalty term")
    self.stage2_regularizationLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_regularizationLineEdit)
    self.stage2Box.layout().addRow("Regularization:", buttonLayout)

    # Landmark penalty
    buttonLayout = qt.QHBoxLayout()
    self.stage2_landmarkPenaltyLineEdit = qt.QLineEdit()
    self.stage2_landmarkPenaltyLineEdit.setText('10')
    self.stage2_landmarkPenaltyLineEdit.setToolTip("Set landmark distance penalty term")
    self.stage2_landmarkPenaltyLineEdit.connect('textChanged(QString)', self.parameterStage2IsChanged)
    buttonLayout.addWidget(self.stage2_landmarkPenaltyLineEdit)
    self.stage2Box.layout().addRow("Landmark penalty:", buttonLayout)

    plmRegisterFormLayout.addRow(self.stage2Box)

    # Stage 3
    self.stage3Box = qt.QGroupBox("Stage 3")
    self.stage3Box.setLayout(qt.QFormLayout())

    # Iterations
    buttonLayout = qt.QHBoxLayout()
    self.stage3_iterationsLineEdit = qt.QLineEdit()
    self.stage3_iterationsLineEdit.setText('10')
    self.stage3_iterationsLineEdit.setToolTip( "Maximum number of iterations" )
    self.stage3_iterationsLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_iterationsLineEdit)
    self.stage3Box.layout().addRow("Iterations:", buttonLayout)

    # Subsampling rate
    buttonLayout = qt.QHBoxLayout()
    self.stage3_subsamplingLineEdit = qt.QLineEdit()
    self.stage3_subsamplingLineEdit.setText('1 1 1')
    self.stage3_subsamplingLineEdit.setToolTip( "Subsampling rate" )
    self.stage3_subsamplingLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_subsamplingLineEdit)
    self.stage3Box.layout().addRow("Subsampling rate (vox):", buttonLayout)

    # Grid spacing
    buttonLayout = qt.QHBoxLayout()
    self.stage3_gridSpacingLineEdit = qt.QLineEdit()
    self.stage3_gridSpacingLineEdit.setText('30')
    self.stage3_gridSpacingLineEdit.setToolTip( "Set B-spline grid spacing" )
    self.stage3_gridSpacingLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_gridSpacingLineEdit)
    self.stage3Box.layout().addRow("Grid size (mm):", buttonLayout)

    # Regularization
    buttonLayout = qt.QHBoxLayout()
    self.stage3_regularizationLineEdit = qt.QLineEdit()
    self.stage3_regularizationLineEdit.setText('0.1')
    self.stage3_regularizationLineEdit.setToolTip("Set Regularization penalty term")
    self.stage3_regularizationLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_regularizationLineEdit)
    self.stage3Box.layout().addRow("Regularization:", buttonLayout)

    # Landmark penalty
    buttonLayout = qt.QHBoxLayout()
    self.stage3_landmarkPenaltyLineEdit = qt.QLineEdit()
    self.stage3_landmarkPenaltyLineEdit.setText('10')
    self.stage3_landmarkPenaltyLineEdit.setToolTip("Set landmark distance penalty term")
    self.stage3_landmarkPenaltyLineEdit.connect('textChanged(QString)', self.parameterStage3IsChanged)
    buttonLayout.addWidget(self.stage3_landmarkPenaltyLineEdit)
    self.stage3Box.layout().addRow("Landmark penalty:", buttonLayout)

    plmRegisterFormLayout.addRow(self.stage3Box)

    # Add UI elements to parent layout
    self.parent.layout().addWidget(self.collapsibleButton)
Пример #59
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # check if the SlicerVmtk module is installed properly
    # self.__vmtkInstalled = SlicerVmtkCommonLib.Helper.CheckIfVmtkIsInstalled()
    # Helper.Debug("VMTK found: " + self.__vmtkInstalled)

    #
    # the I/O panel
    #

    ioCollapsibleButton = ctk.ctkCollapsibleButton()
    ioCollapsibleButton.text = "Input/Output"
    self.layout.addWidget( ioCollapsibleButton )

    ioFormLayout = qt.QFormLayout( ioCollapsibleButton )

    # inputVolume selector
    self.__inputVolumeNodeSelector = slicer.qMRMLNodeComboBox()
    self.__inputVolumeNodeSelector.objectName = 'inputVolumeNodeSelector'
    self.__inputVolumeNodeSelector.toolTip = "Select the input volume. This should always be the original image and not a vesselness image, if possible."
    self.__inputVolumeNodeSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
    self.__inputVolumeNodeSelector.noneEnabled = False
    self.__inputVolumeNodeSelector.addEnabled = False
    self.__inputVolumeNodeSelector.removeEnabled = False
    ioFormLayout.addRow( "Input Volume:", self.__inputVolumeNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__inputVolumeNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )
    self.__inputVolumeNodeSelector.connect( 'currentNodeChanged(vtkMRMLNode*)', self.onInputVolumeChanged )
    self.__inputVolumeNodeSelector.connect( 'nodeActivated(vtkMRMLNode*)', self.onInputVolumeChanged )

    # seed selector
    self.__seedFiducialsNodeSelector = slicer.qMRMLNodeComboBox()
    self.__seedFiducialsNodeSelector.objectName = 'seedFiducialsNodeSelector'
    self.__seedFiducialsNodeSelector.toolTip = "Select a hierarchy containing the fiducials to use as Seeds."
    self.__seedFiducialsNodeSelector.nodeTypes = ['vtkMRMLMarkupsFiducialNode']
    self.__seedFiducialsNodeSelector.baseName = "Seeds"
    self.__seedFiducialsNodeSelector.noneEnabled = False
    self.__seedFiducialsNodeSelector.addEnabled = False
    self.__seedFiducialsNodeSelector.removeEnabled = False
    ioFormLayout.addRow( "Seeds:", self.__seedFiducialsNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__seedFiducialsNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )

    self.__ioAdvancedToggle = qt.QCheckBox( "Show Advanced I/O Properties" )
    self.__ioAdvancedToggle.setChecked( False )
    ioFormLayout.addRow( self.__ioAdvancedToggle )

    #
    # I/O advanced panel
    #

    self.__ioAdvancedPanel = qt.QFrame( ioCollapsibleButton )
    self.__ioAdvancedPanel.hide()
    self.__ioAdvancedPanel.setFrameStyle( 6 )
    ioFormLayout.addRow( self.__ioAdvancedPanel )
    self.__ioAdvancedToggle.connect( "clicked()", self.onIOAdvancedToggle )

    ioAdvancedFormLayout = qt.QFormLayout( self.__ioAdvancedPanel )

    # inputVolume selector
    self.__vesselnessVolumeNodeSelector = slicer.qMRMLNodeComboBox()
    self.__vesselnessVolumeNodeSelector.objectName = 'vesselnessVolumeNodeSelector'
    self.__vesselnessVolumeNodeSelector.toolTip = "Select the input vesselness volume. This is optional input."
    self.__vesselnessVolumeNodeSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
    self.__vesselnessVolumeNodeSelector.noneEnabled = True
    self.__vesselnessVolumeNodeSelector.addEnabled = False
    self.__vesselnessVolumeNodeSelector.removeEnabled = False
    ioAdvancedFormLayout.addRow( "Vesselness Volume:", self.__vesselnessVolumeNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__vesselnessVolumeNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )
    self.__vesselnessVolumeNodeSelector.setCurrentNode( None )

    # stopper selector
    self.__stopperFiducialsNodeSelector = slicer.qMRMLNodeComboBox()
    self.__stopperFiducialsNodeSelector.objectName = 'stopperFiducialsNodeSelector'
    self.__stopperFiducialsNodeSelector.toolTip = "Select a hierarchy containing the fiducials to use as Stoppers. Whenever one stopper is reached, the segmentation stops."
    self.__stopperFiducialsNodeSelector.nodeTypes = ['vtkMRMLMarkupsFiducialNode']
    self.__stopperFiducialsNodeSelector.baseName = "Stoppers"
    self.__stopperFiducialsNodeSelector.noneEnabled = False
    self.__stopperFiducialsNodeSelector.addEnabled = True
    self.__stopperFiducialsNodeSelector.removeEnabled = False
    ioAdvancedFormLayout.addRow( "Stoppers:", self.__stopperFiducialsNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__stopperFiducialsNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )

    # outputVolume selector
    self.__outputVolumeNodeSelector = slicer.qMRMLNodeComboBox()
    self.__outputVolumeNodeSelector.toolTip = "Select the output labelmap."
    self.__outputVolumeNodeSelector.nodeTypes = ['vtkMRMLLabelMapVolumeNode']
    self.__outputVolumeNodeSelector.baseName = "LevelSetSegmentation"
    self.__outputVolumeNodeSelector.noneEnabled = False
    self.__outputVolumeNodeSelector.addEnabled = True
    self.__outputVolumeNodeSelector.selectNodeUponCreation = True
    self.__outputVolumeNodeSelector.removeEnabled = True
    ioAdvancedFormLayout.addRow( "Output Labelmap:", self.__outputVolumeNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__outputVolumeNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )

    # outputModel selector
    self.__outputModelNodeSelector = slicer.qMRMLNodeComboBox()
    self.__outputModelNodeSelector.objectName = 'outputModelNodeSelector'
    self.__outputModelNodeSelector.toolTip = "Select the output model."
    self.__outputModelNodeSelector.nodeTypes = ['vtkMRMLModelNode']
    self.__outputModelNodeSelector.baseName = "LevelSetSegmentationModel"
    self.__outputModelNodeSelector.hideChildNodeTypes = ['vtkMRMLMarkupsFiducialNode']# hide all annotation nodes
    self.__outputModelNodeSelector.noneEnabled = False
    self.__outputModelNodeSelector.addEnabled = True
    self.__outputModelNodeSelector.selectNodeUponCreation = True
    self.__outputModelNodeSelector.removeEnabled = True
    ioAdvancedFormLayout.addRow( "Output Model:", self.__outputModelNodeSelector )
    self.parent.connect( 'mrmlSceneChanged(vtkMRMLScene*)',
                        self.__outputModelNodeSelector, 'setMRMLScene(vtkMRMLScene*)' )


    #
    # the segmentation panel
    #

    segmentationCollapsibleButton = ctk.ctkCollapsibleButton()
    segmentationCollapsibleButton.text = "Segmentation"
    self.layout.addWidget( segmentationCollapsibleButton )

    segmentationFormLayout = qt.QFormLayout( segmentationCollapsibleButton )

    # Threshold slider
    thresholdLabel = qt.QLabel()
    thresholdLabel.text = "Thresholding" + SlicerVmtkCommonLib.Helper.CreateSpace( 7 )
    thresholdLabel.toolTip = "Choose the intensity range to segment."
    thresholdLabel.setAlignment( 4 )
    segmentationFormLayout.addRow( thresholdLabel )

    self.__thresholdSlider = slicer.qMRMLRangeWidget()
    segmentationFormLayout.addRow( self.__thresholdSlider )
    self.__thresholdSlider.connect( 'valuesChanged(double,double)', self.onThresholdSliderChanged )

    self.__segmentationAdvancedToggle = qt.QCheckBox( "Show Advanced Segmentation Properties" )
    self.__segmentationAdvancedToggle.setChecked( False )
    segmentationFormLayout.addRow( self.__segmentationAdvancedToggle )

    #
    # segmentation advanced panel
    #

    self.__segmentationAdvancedPanel = qt.QFrame( segmentationCollapsibleButton )
    self.__segmentationAdvancedPanel.hide()
    self.__segmentationAdvancedPanel.setFrameStyle( 6 )
    segmentationFormLayout.addRow( self.__segmentationAdvancedPanel )
    self.__segmentationAdvancedToggle.connect( "clicked()", self.onSegmentationAdvancedToggle )

    segmentationAdvancedFormLayout = qt.QFormLayout( self.__segmentationAdvancedPanel )

    # inflation slider
    inflationLabel = qt.QLabel()
    inflationLabel.text = "less inflation <-> more inflation" + SlicerVmtkCommonLib.Helper.CreateSpace( 14 )
    inflationLabel.setAlignment( 4 )
    inflationLabel.toolTip = "Define how fast the segmentation expands."
    segmentationAdvancedFormLayout.addRow( inflationLabel )

    self.__inflationSlider = ctk.ctkSliderWidget()
    self.__inflationSlider.decimals = 0
    self.__inflationSlider.minimum = -100
    self.__inflationSlider.maximum = 100
    self.__inflationSlider.singleStep = 10
    self.__inflationSlider.toolTip = inflationLabel.toolTip
    segmentationAdvancedFormLayout.addRow( self.__inflationSlider )

    # curvature slider
    curvatureLabel = qt.QLabel()
    curvatureLabel.text = "less curvature <-> more curvature" + SlicerVmtkCommonLib.Helper.CreateSpace( 14 )
    curvatureLabel.setAlignment( 4 )
    curvatureLabel.toolTip = "Choose a high curvature to generate a smooth segmentation."
    segmentationAdvancedFormLayout.addRow( curvatureLabel )

    self.__curvatureSlider = ctk.ctkSliderWidget()
    self.__curvatureSlider.decimals = 0
    self.__curvatureSlider.minimum = -100
    self.__curvatureSlider.maximum = 100
    self.__curvatureSlider.singleStep = 10
    self.__curvatureSlider.toolTip = curvatureLabel.toolTip
    segmentationAdvancedFormLayout.addRow( self.__curvatureSlider )

    # attraction slider
    attractionLabel = qt.QLabel()
    attractionLabel.text = "less attraction to gradient <-> more attraction to gradient" + SlicerVmtkCommonLib.Helper.CreateSpace( 14 )
    attractionLabel.setAlignment( 4 )
    attractionLabel.toolTip = "Configure how the segmentation travels towards gradient ridges (vessel lumen wall)."
    segmentationAdvancedFormLayout.addRow( attractionLabel )

    self.__attractionSlider = ctk.ctkSliderWidget()
    self.__attractionSlider.decimals = 0
    self.__attractionSlider.minimum = -100
    self.__attractionSlider.maximum = 100
    self.__attractionSlider.singleStep = 10
    self.__attractionSlider.toolTip = attractionLabel.toolTip
    segmentationAdvancedFormLayout.addRow( self.__attractionSlider )

    # iteration spinbox
    self.__iterationSpinBox = qt.QSpinBox()
    self.__iterationSpinBox.minimum = 0
    self.__iterationSpinBox.maximum = 5000
    self.__iterationSpinBox.singleStep = 10
    self.__iterationSpinBox.toolTip = "Choose the number of evolution iterations."
    segmentationAdvancedFormLayout.addRow( SlicerVmtkCommonLib.Helper.CreateSpace( 100 ) + "Iterations:", self.__iterationSpinBox )

    #
    # Reset, preview and apply buttons
    #

    self.__buttonBox = qt.QDialogButtonBox()
    self.__resetButton = self.__buttonBox.addButton( self.__buttonBox.RestoreDefaults )
    self.__resetButton.toolTip = "Click to reset all input elements to default."
    self.__previewButton = self.__buttonBox.addButton( self.__buttonBox.Discard )
    self.__previewButton.setIcon( qt.QIcon() )
    self.__previewButton.text = "Preview.."
    self.__previewButton.toolTip = "Click to refresh the preview."
    self.__startButton = self.__buttonBox.addButton( self.__buttonBox.Apply )
    self.__startButton.setIcon( qt.QIcon() )
    self.__startButton.text = "Start!"
    self.__startButton.enabled = False
    self.__startButton.toolTip = "Click to start the filtering."
    self.layout.addWidget( self.__buttonBox )
    self.__resetButton.connect( "clicked()", self.restoreDefaults )
    self.__previewButton.connect( "clicked()", self.onRefreshButtonClicked )
    self.__startButton.connect( "clicked()", self.onStartButtonClicked )

    self.__inputVolumeNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.__seedFiducialsNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.__vesselnessVolumeNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.__outputVolumeNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.__outputModelNodeSelector.setMRMLScene( slicer.mrmlScene )
    self.__stopperFiducialsNodeSelector.setMRMLScene( slicer.mrmlScene )

    # be ready for events
    self.__updating = 0

    # set default values
    self.restoreDefaults()

    # compress the layout
    self.layout.addStretch( 1 )
Пример #60
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...
        medicalimageButton = ctk.ctkCollapsibleButton()
        medicalimageButton.text = "Input CT image"
        self.layout.addWidget(medicalimageButton)

        medicalimageFormLayout = qt.QFormLayout(medicalimageButton)

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

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

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

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

        #
        # threshold value
        #
        self.ROC = ctk.ctkSliderWidget()
        self.ROC.singleStep = 0.1
        self.ROC.minimum = 0
        self.ROC.maximum = 100
        self.ROC.value = 71
        parametersFormLayout.addRow("ROC", self.ROC)

        self.width = ctk.ctkSliderWidget()
        self.width.singleStep = 0.1
        self.width.minimum = 0
        self.width.maximum = 100
        self.width.value = 71
        parametersFormLayout.addRow("Width", self.width)

        self.freq = ctk.ctkSliderWidget()
        self.freq.singleStep = 1
        self.freq.minimum = 20
        self.freq.maximum = 10000
        self.freq.value = 200
        parametersFormLayout.addRow("kHz", self.freq)

        self.test = ctk.ctkDoubleSpinBox()
        self.test.value = 1.0

        self.test2 = ctk.ctkDoubleSpinBox()
        self.test2.value = 2.0

        self.test3 = ctk.ctkDoubleSpinBox()
        self.test3.value = 3.0

        self.label1 = qt.QLabel("Test1")
        self.label1.setFixedWidth(50)

        rowLayout = qt.QHBoxLayout()
        rowLayout.addWidget(self.label1)
        rowLayout.addWidget(self.test)
        rowLayout.addWidget(self.test2)

        parametersFormLayout.addRow(rowLayout)

        #parametersFormLayout.insertRow(2, self.test)

        #
        # check box to trigger taking screen shots for later use in tutorials
        #
        #
        # Apply Button
        #
        self.applyButton = qt.QPushButton("Run simulation")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = True
        parametersFormLayout.addRow(self.applyButton)

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

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