示例#1
0
  def __init__(self):

    self.popupGeometry = qt.QRect()
    settings = qt.QSettings()
    if settings.contains('DICOM/headerPopup.geometry'):
      self.popupGeometry = settings.value('DICOM/headerPopup.geometry')
    self.popupPositioned = False
    self.window = ctk.ctkDICOMObjectListWidget()
    self.window.setWindowTitle('DICOM File Metadata')

    self.layout = qt.QGridLayout()
    self.window.setLayout(self.layout)
    def setup(self):
        # Instantiate and connect widgets ...

        #PARCHEE"
        w = qt.QWidget()
        layout = qt.QGridLayout()
        w.setLayout(layout)
        self.layout.addWidget(w)
        w.show()
        self.layout = layout

        # INPUT MENU
        self.inputFrame = ctk.ctkCollapsibleButton()
        self.inputFrame.text = "Input"
        self.inputFrame.collapsed = 0
        inputFrameLayout = qt.QFormLayout(self.inputFrame)
        self.layout.addWidget(self.inputFrame)

        #Descubriendo que seria esto#
        self.__mvNode = None

        #Entrada multivolume
        label = qt.QLabel('Input multivolume')
        self.mvSelector = slicer.qMRMLNodeComboBox()
        self.mvSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.mvSelector.setMRMLScene(slicer.mrmlScene)
        self.mvSelector.addEnabled = 0
        self.mvSelector.noneEnabled = 1
        inputFrameLayout.addRow(label, self.mvSelector)

        #Entrada frame a mostrar
        label = qt.QLabel('Frame a mostrar')
        self.__veInitial = qt.QDoubleSpinBox()
        self.__veInitial.value = 0
        inputFrameLayout.addRow(label, self.__veInitial)

        ###PARTE HELLO WORLD## BUTTON DE ACTIVACION

        # Collapsible button
        sampleCollapsibleButton = ctk.ctkCollapsibleButton()
        sampleCollapsibleButton.text = "A collapsible button"
        self.layout.addWidget(sampleCollapsibleButton)

        # Layout within the sample collapsible button
        sampleFormLayout = qt.QFormLayout(sampleCollapsibleButton)
        helloWorldButton = qt.QPushButton("Hello World")
        helloWorldButton.toolTip = "Print 'Hello World' in standard output."
        sampleFormLayout.addWidget(helloWorldButton)
        helloWorldButton.connect('clicked(bool)',
                                 self.onHelloWorldButtonClicked)

        # Set local var as instance attribute
        self.helloWorldButton = helloWorldButton
    def __init__(self, parent):
        layout = qt.QGridLayout(parent)

        self.pathList = slicer.qSlicerDirectoryListView()
        layout.addWidget(self.pathList, 0, 0, 3, 1)

        self.addPathButton = qt.QToolButton()
        self.addPathButton.icon = qt.QIcon.fromTheme("list-add")
        self.addPathButton.text = "Add"
        layout.addWidget(self.addPathButton, 0, 1)

        self.removePathButton = qt.QToolButton()
        self.removePathButton.icon = qt.QIcon.fromTheme("list-remove")
        self.removePathButton.text = "Remove"
        layout.addWidget(self.removePathButton, 1, 1)
示例#4
0
    def __init__(self,
                 parent,
                 logic,
                 configurationName='Default',
                 sliceletDockWidgetPosition=qt.Qt.LeftDockWidgetArea):
        logging.debug('Guidelet.__init__')
        self.sliceletDockWidgetPosition = sliceletDockWidgetPosition
        self.parent = parent
        self.logic = logic
        self.configurationName = configurationName
        self.parameterNodeObserver = None
        self.parameterNode = self.logic.getParameterNode()
        self.layoutManager = slicer.app.layoutManager()
        self.layoutNameToIdMap = {}
        self.layoutNameToSelectCallbackMap = {}
        self.defaultLayoutName = self.VIEW_ULTRASOUND

        self.logic.updateParameterNodeFromSettings(self.parameterNode,
                                                   self.configurationName)
        self.setAndObserveParameterNode(self.parameterNode)

        self.ultrasound = self.getUltrasoundClass()
        self.fitUltrasoundImageToViewOnConnect = True
        self.setupConnectorNode()

        self.sliceletDockWidget = qt.QDockWidget(self.parent)
        self.mainWindow = slicer.util.mainWindow()
        self.sliceletDockWidget.setParent(self.mainWindow)
        self.mainWindow.addDockWidget(self.sliceletDockWidgetPosition,
                                      self.sliceletDockWidget)
        self.sliceletPanel = qt.QFrame(self.sliceletDockWidget)
        self.sliceletPanelLayout = qt.QVBoxLayout(self.sliceletPanel)
        self.sliceletDockWidget.setWidget(self.sliceletPanel)

        self.topPanelLayout = qt.QGridLayout(self.sliceletPanel)
        self.sliceletPanelLayout.addLayout(self.topPanelLayout)
        self.setupTopPanel()

        self.setupFeaturePanelList()
        self.setupAdvancedPanel()
        self.setupAdditionalPanel()

        self.addConnectorObservers()
        self.setupConnections()

        self.sliceletDockWidget.setStyleSheet(self.loadStyleSheet())
示例#5
0
    def __init__(self, MODULE = None):
        """ Init function.
        """

        super(XnatViewer, self).__init__(self)
        self.MODULE = MODULE

        

        #--------------------
        # Make label to display when no search
        # results are found.
        #--------------------       
        self.noSearchResultsFound = qt.QLabel("<i>No results found.</i>", self)
        self.noSearchResultsFound.setStyleSheet('color: gray; margin-left: 150px; text-align: center')


        
        #--------------------
        # Make a stackedLayout and stackedWidget
        # of the XnatView and the 'noSearchResultsFound'
        # label.  We create a 'stackedWidget' because we need
        # a widget to feed into the viewerLayout, which is a 
        # QGridLayout. We then set the index to the XnatView --
        # the XnatView will call 'setNoResultsWidgetVisible'
        # if there are no search results.
        #--------------------          
        self.stackedLayout = qt.QStackedLayout(self)
        self.stackedLayout.addWidget(self.noSearchResultsFound)
        self.stackedLayout.addWidget(self.MODULE.XnatView)
        self.stackedLayout.setCurrentIndex(1)
        self.stackedLayout.setStackingMode(1)
        self.stackedWidget = qt.QWidget(self)
        self.stackedWidget.setLayout(self.stackedLayout)


        
        #--------------------
        # Make main layout.
        #-------------------- 
        self.viewerLayout = qt.QGridLayout()  
        self.viewerLayout.addWidget(self.MODULE.XnatSearchBar, 0, 0, 1, 1)        
        self.viewerLayout.addWidget(self.stackedWidget, 2, 0)
        self.viewerLayout.addLayout(self.MODULE.XnatButtons.loadSaveButtonLayout, 2, 1)
        self.setLayout(self.viewerLayout)
示例#6
0
def makeLoginLayout(LoginMenu):
    """ As stated.
    """

    #--------------------
    # Username/Password Row
    #--------------------
    credentialsRow = qt.QHBoxLayout()
    credentialsRow.addWidget(LoginMenu.manageHostsButton)
    credentialsRow.addWidget(LoginMenu.hostDropdown)
    credentialsRow.addSpacing(20)
    credentialsRow.addWidget(LoginMenu.usernameLine)
    credentialsRow.addWidget(LoginMenu.passwordLine)
    credentialsRow.addWidget(LoginMenu.loginButton)

    #--------------------
    # Everything related to logging in.
    #--------------------
    loginLayout = qt.QGridLayout()
    loginLayout.addLayout(credentialsRow, 0, 2)

    return loginLayout
示例#7
0
    def __init__(self, MODULE=None):
        """ Init function.
        """

        #--------------------
        # Call parent init.
        #--------------------
        super(XnatNodeDetails, self).__init__()

        self.MODULE = MODULE

        #self.settingsButton = self.MODULE.utils.makeSettingsButton(self.MODULE.XnatDetailsSettings)

        self.textEdit = qt.QTextEdit(self)

        self.currFont = self.MODULE.GLOBALS.LABEL_FONT
        self.textEdit.setFont(self.currFont)
        self.textEdit.setReadOnly(True)

        self._layout = qt.QGridLayout()
        self._layout.setContentsMargins(0, 0, 0, 0)

        #--------------------
        # Call parent init.
        #--------------------
        self.numColumns = 2

        self.textEdit.setStyleSheet(
            'border: none; padding: 0px; margin-left: 0px; margin-right: 0px')

        #--------------------
        # NOTE: fixes a scaling error that occurs with the scroll
        # bar.  Have yet to pinpoint why this happens.
        #--------------------
        self.textEdit.verticalScrollBar().setStyleSheet('width: 15px;')

        self._layout.addWidget(self.textEdit, 0, 0)

        self.setLayout(self._layout)
 def setupFieldsSection(self):
     self.fieldsCollapsibleButton = ctk.ctkCollapsibleButton()
     self.fieldsCollapsibleButton.objectName = "ReferencePoints"
     self.fieldsCollapsibleButton.text = "Reference points"
     self.fieldsCollapsibleButton.setToolTip(
         "Mark reference points in 2D or 3D views.\nHold down Shift key while moving the mouse pointer to synchronize mouse pointer in all views."
     )
     self.layout.addWidget(self.fieldsCollapsibleButton)
     self.fieldsCollapsibleButton.connect(
         'toggled(bool)', lambda toggle: self.onWorkflowStepChanged(
             self.fieldsCollapsibleButton, toggle))
     fieldsFormLayout = qt.QFormLayout(self.fieldsCollapsibleButton)
     self.inputFieldsCommentLabel = qt.QLabel()
     self.wordWrap = True
     self.inputFieldsCommentLabel.enabled = False  # make it gray
     self.inputFieldsCommentLabel.hide()
     fieldsFormLayout.addRow(self.inputFieldsCommentLabel)
     # Input field editor widgets be inserted into this frame
     self.fieldsWidgetsFrame = qt.QFrame()
     self.fieldsWidgetsFrame.setFrameShape(qt.QFrame.NoFrame)
     self.fieldsWidgetsGridLayout = qt.QGridLayout(self.fieldsWidgetsFrame)
     self.fieldsWidgetsGridLayout.setContentsMargins(0, 0, 0, 0)
     fieldsFormLayout.addRow(self.fieldsWidgetsFrame)
示例#9
0
    def setup(self):

        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.onVCMRMLSceneChanged)

        w = qt.QWidget()
        layout = qt.QGridLayout()
        w.setLayout(layout)
        self.layout.addWidget(w)
        w.show()
        self.layout = layout

        # create frames
        self.inputFrame = ctk.ctkCollapsibleButton()
        self.inputFrame.text = "Input"
        self.inputFrame.collapsed = 0
        inputFrameLayout = qt.QFormLayout(self.inputFrame)
        self.layout.addWidget(self.inputFrame)

        self.ctrlFrame = ctk.ctkCollapsibleButton()
        self.ctrlFrame.text = "Frame control"
        self.ctrlFrame.collapsed = 0
        ctrlFrameLayout = qt.QGridLayout(self.ctrlFrame)
        self.layout.addWidget(self.ctrlFrame)

        self.plotFrame = ctk.ctkCollapsibleButton()
        self.plotFrame.text = "Plotting"
        self.plotFrame.collapsed = 0
        plotFrameLayout = qt.QGridLayout(self.plotFrame)
        self.layout.addWidget(self.plotFrame)

        self.plotSettingsFrame = ctk.ctkCollapsibleButton()
        self.plotSettingsFrame.text = "Settings"
        self.plotSettingsFrame.collapsed = 1
        plotSettingsFrameLayout = qt.QGridLayout(self.plotSettingsFrame)
        plotFrameLayout.addWidget(self.plotSettingsFrame, 0, 1)

        label = qt.QLabel('Input multivolume')
        self.__mvSelector = slicer.qMRMLNodeComboBox()
        self.__mvSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.__mvSelector.setMRMLScene(slicer.mrmlScene)
        self.__mvSelector.connect('mrmlSceneChanged(vtkMRMLScene*)',
                                  self.onVCMRMLSceneChanged)
        self.__mvSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                  self.onInputChanged)
        self.__mvSelector.addEnabled = 0

        inputFrameLayout.addRow(label, self.__mvSelector)

        label = qt.QLabel('Input secondary multivolume')
        self.fgSelector = slicer.qMRMLNodeComboBox()
        self.fgSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.fgSelector.setMRMLScene(slicer.mrmlScene)
        self.fgSelector.addEnabled = 0
        self.fgSelector.noneEnabled = 1
        self.fgSelector.toolTip = "Secondary multivolume will be used for the secondary \
      plot in interactive charting. As an example, this can be used to overlay the \
      curve obtained by fitting a model to the data"

        inputFrameLayout.addRow(label, self.fgSelector)

        # TODO: initialize the slider based on the contents of the labels array
        # slider to scroll over metadata stored in the vector container being explored
        self.__mdSlider = ctk.ctkSliderWidget()

        label = qt.QLabel('Current frame number')

        # "play" control
        self.playButton = qt.QPushButton('Play')
        self.playButton.toolTip = 'Iterate over multivolume frames'
        self.playButton.checkable = True

        ctrlFrameLayout.addWidget(label, 0, 0)
        ctrlFrameLayout.addWidget(self.__mdSlider, 0, 1)
        ctrlFrameLayout.addWidget(self.playButton, 0, 2)

        self.playButton.connect('toggled(bool)', self.onPlayButtonToggled)

        self.__mdSlider.connect('valueChanged(double)', self.onSliderChanged)

        label = qt.QLabel('Current frame copy')

        self.__vfSelector = slicer.qMRMLNodeComboBox()
        self.__vfSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.__vfSelector.setMRMLScene(slicer.mrmlScene)
        self.__vfSelector.connect('mrmlSceneChanged(vtkMRMLScene*)',
                                  self.onVFMRMLSceneChanged)
        self.__vfSelector.addEnabled = 1
        self.__vfSelector.enabled = 0
        # do not show "children" of vtkMRMLScalarVolumeNode
        self.__vfSelector.hideChildNodeTypes = ["vtkMRMLDiffusionWeightedVolumeNode", \
            "vtkMRMLDiffusionTensorVolumeNode", "vtkMRMLVectorVolumeNode"]

        self.extractFrame = False
        self.extractButton = qt.QPushButton('Enable current frame copying')
        self.extractButton.checkable = True
        self.extractButton.connect('toggled(bool)', self.onExtractFrameToggled)

        ctrlFrameLayout.addWidget(label, 1, 0)
        ctrlFrameLayout.addWidget(self.__vfSelector, 1, 1, 1, 2)
        ctrlFrameLayout.addWidget(self.extractButton, 2, 0, 1, 3)

        # initialize slice observers (from DataProbe.py)
        # keep list of pairs: [observee,tag] so they can be removed easily
        self.styleObserverTags = []
        # keep a map of interactor styles to sliceWidgets so we can easily get sliceLogic
        self.sliceWidgetsPerStyle = {}
        self.refreshObservers()

        # label map for probing
        label = qt.QLabel('Probed label volume')
        self.__fSelector = slicer.qMRMLNodeComboBox()
        self.__fSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.__fSelector.addAttribute('vtkMRMLScalarVolumeNode', 'LabelMap',
                                      '1')
        self.__fSelector.toolTip = 'Label map to be probed'
        self.__fSelector.setMRMLScene(slicer.mrmlScene)
        self.__fSelector.addEnabled = 0
        self.chartButton = qt.QPushButton('Chart')
        self.chartButton.checkable = False
        self.chartButton.connect('clicked()', self.onChartRequested)
        plotSettingsFrameLayout.addWidget(label, 0, 0)
        plotSettingsFrameLayout.addWidget(self.__fSelector, 0, 1)
        plotSettingsFrameLayout.addWidget(self.chartButton, 0, 2)

        self.iCharting = qt.QPushButton()
        self.iCharting.text = 'Enable interactive charting'
        self.iCharting.checkable = True

        plotSettingsFrameLayout.addWidget(self.iCharting, 1, 0, 1, 3)
        self.iCharting.setChecked(True)
        self.iCharting.connect('toggled(bool)',
                               self.onInteractiveChartingChanged)

        groupLabel = qt.QLabel('Interactive plotting mode:')
        self.iChartingMode = qt.QButtonGroup()
        self.iChartingIntensity = qt.QRadioButton('Signal intensity')
        #self.iChartingIntensity.tooltip = 'Plot range adjusted dynamically to the range over the time course for the selected pixel'
        self.iChartingIntensityFixedAxes = qt.QRadioButton(
            'Fixed range intensity')
        #self.iChartingIntensityFixedAxes.tooltip = "If checked, the extent of the vertical axis of the plot will be fixed to the range of the intensities in the input MultiVolume"
        self.iChartingPercent = qt.QRadioButton('Percent change')
        #self.iChartingPercent.tooltip = 'Percent change relative to the average of the first N frames (parameter set below)'
        self.iChartingIntensity.setChecked(1)

        self.groupWidget = qt.QWidget()
        self.groupLayout = qt.QFormLayout(self.groupWidget)
        self.groupLayout.addRow(groupLabel)
        self.groupLayout.addRow(self.iChartingIntensity)
        self.groupLayout.addRow(self.iChartingIntensityFixedAxes)
        self.groupLayout.addRow(self.iChartingPercent)

        self.baselineFrames = qt.QSpinBox()
        self.baselineFrames.minimum = 1
        label = qt.QLabel('Number of frames for baseline calculation')
        self.groupLayout.addRow(label, self.baselineFrames)

        self.xLogScaleCheckBox = qt.QCheckBox()
        self.xLogScaleCheckBox.setChecked(0)
        label = qt.QLabel('Use log scale for X axis')
        self.groupLayout.addRow(self.xLogScaleCheckBox, label)
        self.xLogScaleCheckBox.connect('stateChanged(int)',
                                       self.onXLogScaleRequested)

        self.yLogScaleCheckBox = qt.QCheckBox()
        self.yLogScaleCheckBox.setChecked(0)
        label = qt.QLabel('Use log scale for Y axis')
        self.groupLayout.addRow(self.yLogScaleCheckBox, label)
        self.yLogScaleCheckBox.connect('stateChanged(int)',
                                       self.onYLogScaleRequested)

        plotSettingsFrameLayout.addWidget(self.groupWidget, 2, 0)

        # add chart container widget
        self.__chartView = ctk.ctkVTKChartView(w)
        plotFrameLayout.addWidget(self.__chartView, 3, 0, 1, 3)

        self.__chart = self.__chartView.chart()
        self.__chartTable = vtk.vtkTable()
        self.__xArray = vtk.vtkFloatArray()
        self.__yArray = vtk.vtkFloatArray()
        # will crash if there is no name
        self.__xArray.SetName('')
        self.__yArray.SetName('signal intensity')
        self.__chartTable.AddColumn(self.__xArray)
        self.__chartTable.AddColumn(self.__yArray)
示例#10
0
    def setup(self):
        # Instantiate and connect widgets ...

        w = qt.QWidget()
        layout = qt.QGridLayout()
        w.setLayout(layout)
        self.layout.addWidget(w)
        w.show()
        #self.layout = layout

        if self.isDeveloperMode:
            #
            # 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 = "SequenceLabelStatistics Reload"
            reloadFormLayout.addWidget(self.reloadButton)
            self.reloadButton.connect('clicked()', self.onReload)

            # reload and test button
            # (use this during development, but remove it when delivering
            #  your module to users)
            self.reloadAndTestButton = qt.QPushButton("Reload and Test")
            self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
            reloadFormLayout.addWidget(self.reloadAndTestButton)
            self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

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

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

        #
        # the grayscale volume selector
        #
        self.grayscaleSelector = slicer.qMRMLNodeComboBox()
        self.grayscaleSelector.nodeTypes = (("vtkMRMLSequenceNode"), "")
        self.grayscaleSelector.selectNodeUponCreation = False
        self.grayscaleSelector.addEnabled = False
        self.grayscaleSelector.removeEnabled = False
        self.grayscaleSelector.noneEnabled = False
        self.grayscaleSelector.showHidden = False
        self.grayscaleSelector.showChildNodeTypes = False
        self.grayscaleSelector.setMRMLScene(slicer.mrmlScene)
        self.grayscaleSelector.setToolTip(
            "Select the grayscale volume (background grayscale scalar volume node) for statistics calculations."
        )
        # TODO: need to add a QLabel
        # self.grayscaleSelector.SetLabelText( "Master Volume:" )
        parametersFormLayout.addRow("Grayscale Volume Sequence: ",
                                    self.grayscaleSelector)

        #
        # the label volume selector
        #
        self.labelSelector = slicer.qMRMLNodeComboBox()
        self.labelSelector.nodeTypes = ("vtkMRMLSequenceNode",
                                        "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 = False
        self.labelSelector.setMRMLScene(slicer.mrmlScene)
        self.labelSelector.setToolTip("Pick the label map to edit")
        parametersFormLayout.addRow("Labelmap/Sequence: ", self.labelSelector)

        # Apply button
        self.applyButton = qt.QPushButton("Apply")
        self.applyButton.toolTip = "Calculate Statistics."
        self.applyButton.enabled = False
        parametersFormLayout.addRow(self.applyButton)

        # model and view for stats table
        self.view = qt.QTableView()
        self.view.sortingEnabled = True
        parametersFormLayout.addRow(self.view)

        # Chart button
        self.chartFrame = qt.QFrame()
        self.chartFrame.setLayout(qt.QHBoxLayout())
        parametersFormLayout.addRow(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
        parametersFormLayout.addRow(self.saveButton)

        # Add vertical spacer
        self.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)

        # Set initial state
        self.grayscaleNode = self.grayscaleSelector.currentNode()
        self.labelNode = self.labelSelector.currentNode()
        self.applyButton.enabled = bool(self.grayscaleNode) and bool(
            self.labelNode)
示例#11
0
    def setup(self):
        for cervicalVertebrae in range(
                1, self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE + 1):
            self.verterbraeNames.append("C" + str(cervicalVertebrae))

        for thoracicVertebrae in range(
                1, self.CONST_NUMBER_OF_THORACIC_VERTERBRAE + 1):
            self.verterbraeNames.append("T" + str(thoracicVertebrae))

        for lumbarVertebrae in range(
                1, self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE + 1):
            self.verterbraeNames.append("L" + str(lumbarVertebrae))

        self.superiorAnglesList = [
            None
        ] * self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE * self.CONST_NUMBER_OF_THORACIC_VERTERBRAE * self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE
        self.inferiorAnglesList = [
            None
        ] * self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE * self.CONST_NUMBER_OF_THORACIC_VERTERBRAE * self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE

        # Instantiate and connect widgets
        #
        # Brief Explanation Text
        instructionsCollapsibleButton = ctk.ctkCollapsibleButton()
        instructionsCollapsibleButton.text = "Instructions"
        self.layout.addWidget(instructionsCollapsibleButton)

        instructionsLayout = qt.QVBoxLayout(instructionsCollapsibleButton)

        self.namingInstructions = ctk.ctkFittedTextBrowser()
        self.namingInstructions.setReadOnly(True)
        self.namingInstructions.setPlainText(
            "C - Cervical, T - Thoracic, L - Lumbar\ns - Superior, i - Inferior\nName ruler annotations like so: T1-s, T1-i, T2-s, etc."
        )
        instructionsLayout.addWidget(self.namingInstructions)

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

        # Layout
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        # Input Selector
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = (("vtkMRMLAnnotationHierarchyNode"), "")
        self.inputSelector.selectNodeUponCreation = True
        self.inputSelector.addEnabled = True
        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.")
        parametersFormLayout.addRow("Input Rulers: ", self.inputSelector)

        self.projectionPlaneBox = qt.QComboBox()
        self.projectionPlaneBox.addItems(["Coronal", "Axial", "Sagittal"])
        parametersFormLayout.addRow("Projection Plane: ",
                                    self.projectionPlaneBox)

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

        # Layout
        outputVerticalLayout = qt.QGridLayout(outputCollapsibleButton)

        # Calculate Button
        self.calculateButton = qt.QPushButton("Start Calculating")
        outputVerticalLayout.addWidget(self.calculateButton, 0, 0, 1, 5)

        # Save Button
        self.saveButton = qt.QPushButton("Save as CSV")
        outputVerticalLayout.addWidget(self.saveButton, 1, 0, 1, 5)

        # Angle Table
        horizontalHeaders = [
            "Vertebrae", "Superior Angles (degrees)",
            "Inferior Angles (degrees)"
        ]

        self.angleTable = qt.QTableWidget(
            self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE +
            self.CONST_NUMBER_OF_THORACIC_VERTERBRAE +
            self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE, 3)
        self.angleTable.sortingEnabled = False
        self.angleTable.setEditTriggers(0)
        self.angleTable.setMinimumHeight(
            self.angleTable.verticalHeader().length() + 25)
        self.angleTable.horizontalHeader().setResizeMode(
            qt.QHeaderView.Stretch)
        self.angleTable.setSizePolicy(qt.QSizePolicy.MinimumExpanding,
                                      qt.QSizePolicy.Preferred)
        outputVerticalLayout.addWidget(self.angleTable, 2, 0, 1, 5)

        self.angleTable.setHorizontalHeaderLabels(horizontalHeaders)

        self.labelReferences = []
        self.superiorAngleReferences = []
        self.inferiorAngleReferences = []
        for verterbraeIndex, verterbraeName in enumerate(self.verterbraeNames):
            vertebraeLabel = qt.QTableWidgetItem(verterbraeName)
            self.labelReferences.append(vertebraeLabel)
            self.angleTable.setItem(verterbraeIndex, 0, vertebraeLabel)

            superiorAngleItem = qt.QTableWidgetItem("")
            self.superiorAngleReferences.append(superiorAngleItem)
            self.angleTable.setItem(verterbraeIndex, 1, superiorAngleItem)

            inferiorAngleItem = qt.QTableWidgetItem("")
            self.inferiorAngleReferences.append(inferiorAngleItem)
            self.angleTable.setItem(verterbraeIndex, 2, inferiorAngleItem)

        # connections
        self.calculateButton.connect('clicked(bool)', self.onCalculateButton)
        self.saveButton.connect('clicked(bool)', self.onSaveButton)
        self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.onSelect)

        self.layout.addStretch(1)
示例#12
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.logic = CIP_PAARatioLogic()

        #
        # Create all the widgets. Example Area
        mainAreaCollapsibleButton = ctk.ctkCollapsibleButton()
        mainAreaCollapsibleButton.text = "Main parameters"
        self.layout.addWidget(mainAreaCollapsibleButton)
        self.mainAreaLayout = qt.QGridLayout(mainAreaCollapsibleButton)

        self.label = qt.QLabel("Select the volume")
        self.label.setStyleSheet("margin:10px 0 20px 7px")
        self.mainAreaLayout.addWidget(self.label, 0, 0)

        self.volumeSelector = slicer.qMRMLNodeComboBox()
        self.volumeSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        # DEPRECATED. Now there is a new vtkMRMLLabelMapNode
        #self.volumeSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", "0" )  # No labelmaps
        self.volumeSelector.selectNodeUponCreation = True
        self.volumeSelector.autoFillBackground = True
        self.volumeSelector.addEnabled = True
        self.volumeSelector.noneEnabled = False
        self.volumeSelector.removeEnabled = False
        self.volumeSelector.showHidden = False
        self.volumeSelector.showChildNodeTypes = False
        self.volumeSelector.setMRMLScene(slicer.mrmlScene)
        self.volumeSelector.setStyleSheet(
            "margin:0px 0 0px 0; padding:2px 0 2px 5px")
        self.mainAreaLayout.addWidget(self.volumeSelector, 0, 1)

        # self.label2 = qt.QLabel("Select the slice")
        # self.label2.setStyleSheet("margin:0px 0 20px 7px; padding-top:20px")
        # self.mainAreaLayout.addWidget(self.label2, 1, 0)

        self.placeDefaultRulersButton = ctk.ctkPushButton()
        self.placeDefaultRulersButton.text = "Place default rulers"
        # self.placeDefaultRulersSliceButton.toolTip = "Navigate to the best estimated slice to place the rulers"
        self.placeDefaultRulersButton.setIcon(
            qt.QIcon("{0}/next.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.placeDefaultRulersButton.setIconSize(qt.QSize(20, 20))
        self.placeDefaultRulersButton.setStyleSheet("font-weight: bold;")
        # self.placeDefaultRulersButton.setFixedWidth(140)
        self.mainAreaLayout.addWidget(self.placeDefaultRulersButton, 1, 1)

        ### Structure Selector
        self.structuresGroupbox = qt.QGroupBox("Select the structure")
        self.groupboxLayout = qt.QVBoxLayout()
        self.structuresGroupbox.setLayout(self.groupboxLayout)
        self.mainAreaLayout.addWidget(self.structuresGroupbox, 2, 0)

        self.structuresButtonGroup = qt.QButtonGroup()
        # btn = qt.QRadioButton("None")
        # btn.visible = False
        # self.structuresButtonGroup.addButton(btn)
        # self.groupboxLayout.addWidget(btn)

        btn = qt.QRadioButton("Both")
        btn.checked = True
        self.structuresButtonGroup.addButton(btn, 0)
        self.groupboxLayout.addWidget(btn)

        btn = qt.QRadioButton("Pulmonary Arterial")
        self.structuresButtonGroup.addButton(btn, 1)
        self.groupboxLayout.addWidget(btn)

        btn = qt.QRadioButton("Aorta")
        self.structuresButtonGroup.addButton(btn, 2)
        self.groupboxLayout.addWidget(btn)

        ### Buttons toolbox
        self.buttonsToolboxFrame = qt.QFrame()
        self.buttonsToolboxLayout = qt.QGridLayout()
        self.buttonsToolboxFrame.setLayout(self.buttonsToolboxLayout)
        self.mainAreaLayout.addWidget(self.buttonsToolboxFrame, 2, 1)

        self.placeRulersButton = ctk.ctkPushButton()
        self.placeRulersButton.text = "Place ruler/s"
        self.placeRulersButton.toolTip = "Place the ruler/s for the selected structure/s in the current slice"
        self.placeRulersButton.setIcon(
            qt.QIcon("{0}/ruler.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.placeRulersButton.setIconSize(qt.QSize(20, 20))
        self.placeRulersButton.setFixedWidth(105)
        self.placeRulersButton.setStyleSheet("font-weight:bold")
        self.buttonsToolboxLayout.addWidget(self.placeRulersButton, 0, 0)

        self.moveUpButton = ctk.ctkPushButton()
        self.moveUpButton.text = "Move up"
        self.moveUpButton.toolTip = "Move the selected ruler/s one slice up"
        self.moveUpButton.setIcon(
            qt.QIcon("{0}/move_up.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.moveUpButton.setIconSize(qt.QSize(20, 20))
        self.moveUpButton.setFixedWidth(95)
        self.buttonsToolboxLayout.addWidget(self.moveUpButton, 0, 1)

        self.moveDownButton = ctk.ctkPushButton()
        self.moveDownButton.text = "Move down"
        self.moveDownButton.toolTip = "Move the selected ruler/s one slice down"
        self.moveDownButton.setIcon(
            qt.QIcon("{0}/move_down.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.moveDownButton.setIconSize(qt.QSize(20, 20))
        self.moveDownButton.setFixedWidth(95)
        self.buttonsToolboxLayout.addWidget(self.moveDownButton, 0, 2)

        self.removeButton = ctk.ctkPushButton()
        self.removeButton.text = "Remove ALL rulers"
        self.removeButton.toolTip = "Remove all the rulers for this volume"
        self.removeButton.setIcon(
            qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.removeButton.setIconSize(qt.QSize(20, 20))
        self.buttonsToolboxLayout.addWidget(self.removeButton, 1, 1, 1, 2, 2)

        ### Textboxes
        self.textboxesFrame = qt.QFrame()
        self.textboxesLayout = qt.QFormLayout()
        self.textboxesFrame.setLayout(self.textboxesLayout)
        self.textboxesFrame.setFixedWidth(190)
        self.mainAreaLayout.addWidget(self.textboxesFrame, 3, 0)

        self.paTextBox = qt.QLineEdit()
        self.paTextBox.setReadOnly(True)
        self.textboxesLayout.addRow("PA (mm):  ", self.paTextBox)

        self.aortaTextBox = qt.QLineEdit()
        self.aortaTextBox.setReadOnly(True)
        self.textboxesLayout.addRow("Aorta (mm):  ", self.aortaTextBox)

        self.ratioTextBox = qt.QLineEdit()
        self.ratioTextBox.setReadOnly(True)
        self.textboxesLayout.addRow("Ratio PA/A: ", self.ratioTextBox)

        # Save case data
        self.reportsCollapsibleButton = ctk.ctkCollapsibleButton()
        self.reportsCollapsibleButton.text = "Reporting"
        self.layout.addWidget(self.reportsCollapsibleButton)
        self.reportsLayout = qt.QHBoxLayout(self.reportsCollapsibleButton)

        self.storedColumnNames = [
            "caseId", "paDiameter_mm", "aortaDiameter_mm", "pa1r", "pa1a",
            "pa1s", "pa2r", "pa2a", "pa2s", "a1r", "a1a", "a1s", "a2r", "a2a",
            "a2s"
        ]
        self.reportsWidget = CaseReportsWidget(
            "CIP_PAARatio",
            columnNames=self.storedColumnNames,
            parentWidget=self.reportsCollapsibleButton)
        self.reportsWidget.setup()

        self.switchToRedView()

        #####
        # Case navigator
        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)
            self.caseNavigatorWidget.setup()

        self.layout.addStretch()

        # Connections
        self.observers = []
        self.__addSceneObservables__()

        self.volumeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                    self.onVolumeSelectorChanged)
        self.placeDefaultRulersButton.connect('clicked()',
                                              self.oPlaceDefaultRulersClicked)
        self.placeRulersButton.connect('clicked()', self.onPlaceRulersClicked)
        self.moveUpButton.connect('clicked()', self.onMoveUpRulerClicked)
        self.moveDownButton.connect('clicked()', self.onMoveDownRulerClicked)
        self.removeButton.connect('clicked()', self.onRemoveRulerClicked)

        self.reportsWidget.addObservable(
            self.reportsWidget.EVENT_SAVE_BUTTON_CLICKED, self.onSaveReport)
示例#13
0
    def setup(self):
        """This is called one time when the module GUI is initialized
        """
        # Declare ALL the GUI components (depending on the context we will add different ones to the layout)
        self.widgetMainFrame = qt.QFrame()
        self.widgetMainLayout = qt.QGridLayout()
        self.widgetMainFrame.setLayout(self.widgetMainLayout)
        self.layout.addWidget(self.widgetMainFrame)

        ## Context
        self.contextLabel = qt.QLabel("Context")
        self.contextComboBox = qt.QComboBox()
        for context in self.contexts.values():
            self.contextComboBox.addItem(context)

        ## Operation
        self.operationLabel = qt.QLabel("Optimization")
        self.operationComboBox = qt.QComboBox()
        for operation in self.operations.values():
            if operation != self.OPERATION_NONE:
                self.operationComboBox.addItem(operation)
        ## Plane
        self.planeLabel = qt.QLabel("Plane")
        # Buttons group
        self.planesButtonGroup = qt.QButtonGroup()
        # Axial
        self.axialButton = qt.QPushButton()
        self.axialButton.setCheckable(True)
        self.axialButton.toolTip = "Axial plane"
        self.axialButton.setFixedSize(40, 40)
        self.axialButton.setIcon(SlicerUtil.getIcon("axial.png"))
        self.planesButtonGroup.addButton(self.axialButton, self.PLANE_AXIAL)
        # Sagittal
        self.sagittalButton = qt.QPushButton()
        self.sagittalButton.setCheckable(True)
        self.sagittalButton.toolTip = "Sagittal plane"
        self.sagittalButton.setFixedSize(40, 40)
        self.sagittalButton.setIcon(SlicerUtil.getIcon("sagittal.png"))
        self.widgetMainLayout.addWidget(self.sagittalButton, 2, 2,
                                        SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
        self.planesButtonGroup.addButton(self.sagittalButton,
                                         self.PLANE_SAGITTAL)
        # Coronal
        self.coronalButton = qt.QPushButton()
        self.coronalButton.setCheckable(True)
        self.coronalButton.toolTip = "coronal plane"
        self.coronalButton.setFixedSize(40, 40)
        self.coronalButton.setIcon(SlicerUtil.getIcon("coronal.png"))
        self.planesButtonGroup.addButton(self.coronalButton,
                                         self.PLANE_CORONAL)
        # Null button (to uncheck all)
        self.nullPlaneButton = qt.QPushButton()
        self.nullPlaneButton.setCheckable(True)
        self.planesButtonGroup.addButton(self.nullPlaneButton, -1)
        # Buttons labels
        self.axialButtonLabel = qt.QLabel("Axial")
        self.axialButtonLabel.setStyleSheet("margin-bottom: 10px")
        self.sagittalButtonLabel = qt.QLabel("Sagittal")
        self.sagittalButtonLabel.setStyleSheet("margin-bottom: 10px")
        self.coronalButtonLabel = qt.QLabel("Coronal")
        self.coronalButtonLabel.setStyleSheet("margin-bottom: 10px")

        ## Layout
        self.layoutLabel = qt.QLabel("Layout")
        # Buttons group
        self.layoutsButtonGroup = qt.QButtonGroup()
        # Single slice Button
        self.singleSlideViewButton = qt.QPushButton()
        self.singleSlideViewButton.setCheckable(True)
        self.singleSlideViewButton.toolTip = "Single slice view"
        self.singleSlideViewButton.setFixedSize(40, 40)
        self.singleSlideViewButton.setIcon(
            qt.QIcon(":/Icons/LayoutOneUpRedSliceView.png"))
        self.layoutsButtonGroup.addButton(self.singleSlideViewButton,
                                          self.LAYOUT_RED_ONLY)
        # Side by side Button
        self.sideBySideViewButton = qt.QPushButton()
        self.sideBySideViewButton.setCheckable(True)
        self.sideBySideViewButton.toolTip = "Side by side view"
        self.sideBySideViewButton.setFixedSize(40, 40)
        self.sideBySideViewButton.setIcon(
            qt.QIcon(":/Icons/LayoutSideBySideView.png"))
        self.layoutsButtonGroup.addButton(self.sideBySideViewButton,
                                          self.LAYOUT_SIDE_BY_SIDE)
        # Three over three button
        self.threeOverThreeViewButton = qt.QPushButton()
        self.threeOverThreeViewButton.setCheckable(True)
        self.threeOverThreeViewButton.toolTip = "Compare 2 images in their 3 planes"
        self.threeOverThreeViewButton.setFixedSize(40, 40)
        self.threeOverThreeViewButton.setIcon(
            qt.QIcon(":/Icons/LayoutThreeOverThreeView.png"))
        self.layoutsButtonGroup.addButton(self.threeOverThreeViewButton,
                                          self.LAYOUT_THREE_OVER_THREE)
        # Comparative MIP-MinIP button
        self.maxMinCompareViewButton = qt.QPushButton()
        self.maxMinCompareViewButton.setCheckable(True)
        self.maxMinCompareViewButton.toolTip = "MIP and MinIP comparison"
        self.maxMinCompareViewButton.setFixedSize(40, 40)
        self.maxMinCompareViewButton.setIcon(
            qt.QIcon(":/Icons/LayoutFourUpView.png"))
        self.layoutsButtonGroup.addButton(self.maxMinCompareViewButton,
                                          self.LAYOUT_COMPARE)
        # Null button (to uncheck all)
        self.nullLayoutButton = qt.QPushButton()
        self.nullLayoutButton.setCheckable(True)
        self.layoutsButtonGroup.addButton(self.nullLayoutButton, -2)
        # Reset Button
        self.resetViewButton = qt.QPushButton()
        self.resetViewButton.toolTip = "Go back to the original layout"
        self.resetViewButton.setFixedSize(40, 40)
        # self.resetViewButton.setIconSize(qt.QSize(24, 24))
        self.resetViewButton.setIcon(
            qt.QIcon(os.path.join(SlicerUtil.CIP_ICON_DIR, "Reload.png")))
        # Buttons labels
        self.singleSlideButtonLabel = qt.QLabel("Single")
        self.sideBySideButtonLabel = qt.QLabel("Side by side")
        self.threeOverThreeButtonLabel = qt.QLabel("3x3")
        self.maxMinCompareButtonLabel = qt.QLabel("MIP+MinIP")
        self.resetLabel = qt.QLabel("Reset")
        self.resetLabel.setStyleSheet("font-weight: bold")

        # Number of slices (different for each operation). The size of the slider also changes
        self.spacingSliderItems = OrderedDict()
        spacingLabel = qt.QLabel("Slice size " +
                                 self.operations[self.OPERATION_MIP])
        spacingSlider = qt.QSlider()
        spacingSlider.orientation = 1
        spacingSlider.setTickPosition(2)
        spacingSlider.minimum = 0
        spacingSlider.maximum = 1000
        spacingSlider.setPageStep(50)
        spacingMmLabel = qt.QLabel()
        self.spacingSliderItems[self.OPERATION_MIP] = (spacingLabel,
                                                       spacingSlider,
                                                       spacingMmLabel)
        self.setCurrentSpacingInMm(self.OPERATION_MIP, 20)

        spacingLabel = qt.QLabel("Slice size " +
                                 self.operations[self.OPERATION_MinIP])
        spacingSlider = qt.QSlider()
        spacingSlider.orientation = 1
        spacingSlider.setTickPosition(2)
        spacingSlider.minimum = 0
        spacingSlider.maximum = 200
        spacingSlider.setPageStep(50)
        spacingMmLabel = qt.QLabel()
        self.spacingSliderItems[self.OPERATION_MinIP] = (spacingLabel,
                                                         spacingSlider,
                                                         spacingMmLabel)
        self.setCurrentSpacingInMm(self.OPERATION_MinIP, 5)

        spacingLabel = qt.QLabel("Slice size " +
                                 self.operations[self.OPERATION_MEAN])
        spacingSlider = qt.QSlider()
        spacingSlider.orientation = 1
        spacingSlider.setTickPosition(2)
        spacingSlider.minimum = 0
        spacingSlider.maximum = 200
        spacingSlider.setPageStep(50)
        spacingMmLabel = qt.QLabel()
        self.spacingSliderItems[self.OPERATION_MEAN] = (spacingLabel,
                                                        spacingSlider,
                                                        spacingMmLabel)
        self.setCurrentSpacingInMm(self.OPERATION_MEAN, 20)

        # Crosshair
        self.crosshairCheckbox = qt.QCheckBox()
        self.crosshairCheckbox.setText("Crosshair cursor")
        self.crosshairCheckbox.toolTip = "Activate/Desactivate the crosshair cursor for a better visualization"
        self.crosshairCheckbox.setStyleSheet("margin-top:10px")

        # Center button
        self.centerButton = qt.QPushButton()
        self.centerButton.setText("Center volumes")
        self.centerButton.setFixedSize(100, 40)
        self.centerButton.setStyleSheet("margin-top:10px")

        if self.fullModeOn:
            ###### FULL MODE
            # Context
            self.widgetMainLayout.addWidget(self.contextLabel, 0, 0)
            self.widgetMainLayout.addWidget(self.contextComboBox, 0, 1, 1, 3)
            # Operation
            self.widgetMainLayout.addWidget(self.operationLabel, 1, 0)
            self.widgetMainLayout.addWidget(self.operationComboBox, 1, 1, 1, 3)
            # Plane
            self.widgetMainLayout.addWidget(self.planeLabel, 2, 0)
            self.widgetMainLayout.addWidget(
                self.axialButton, 2, 1, SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.coronalButton, 2, 3,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.axialButtonLabel, 3, 1,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.sagittalButtonLabel, 3, 2,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.coronalButtonLabel, 3, 3,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            # Layout
            self.widgetMainLayout.addWidget(self.layoutLabel, 4, 0)
            self.widgetMainLayout.addWidget(
                self.singleSlideViewButton, 4, 1,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.sideBySideViewButton, 4, 2,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.threeOverThreeViewButton, 4, 3,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.maxMinCompareViewButton, 4, 4,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.resetViewButton, 4, 5,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.singleSlideButtonLabel, 5, 1,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.sideBySideButtonLabel, 5, 2,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.threeOverThreeButtonLabel, 5, 3,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.maxMinCompareButtonLabel, 5, 4,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.resetLabel, 5, 5, SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            # Number of slices
            row = 6
            for structure in self.spacingSliderItems.values():
                self.widgetMainLayout.addWidget(structure[0], row, 0, 1, 2)
                self.widgetMainLayout.addWidget(structure[1], row, 2, 1, 3)
                self.widgetMainLayout.addWidget(structure[2], row, 5)
                row += 1
            self.widgetMainLayout.addWidget(self.crosshairCheckbox, row, 0, 1,
                                            2)
            self.crosshairCheckbox.setChecked(True)
            self.widgetMainLayout.addWidget(self.centerButton, row, 2, 1, 2)

        else:
            ##### COLLAPSED MODE
            # Plane
            self.widgetMainLayout.addWidget(self.planeLabel, 0, 0)
            self.widgetMainLayout.addWidget(
                self.axialButton, 0, 1, SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.sagittalButton, 0, 2,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.coronalButton, 0, 3,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.threeOverThreeViewButton, 0, 4,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.axialButtonLabel, 1, 1,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.sagittalButtonLabel, 1, 2,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.coronalButtonLabel, 1, 3,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            self.widgetMainLayout.addWidget(
                self.threeOverThreeButtonLabel, 1, 4,
                SlicerUtil.ALIGNMENT_HORIZONTAL_CENTER)
            # Number of slices
            row = 2
            for structure in self.spacingSliderItems.values():
                self.widgetMainLayout.addWidget(structure[0], row, 0)
                self.widgetMainLayout.addWidget(structure[1], row, 1, 1, 3)
                self.widgetMainLayout.addWidget(structure[2], row, 4)
                row += 1
            self.widgetMainLayout.addWidget(self.crosshairCheckbox, row, 0)
            self.widgetMainLayout.addWidget(self.centerButton, row, 1, 1, 2)

        self.layout.addStretch(1)

        self.__refreshUI__()

        # Connections
        self.contextComboBox.connect("currentIndexChanged (int)",
                                     self.__onContextIndexChanged__)
        self.operationComboBox.connect("currentIndexChanged (int)",
                                       self.__onOperationIndexChanged__)
        self.planesButtonGroup.connect("buttonClicked(int)",
                                       self.__onPlaneButtonClicked__)
        self.singleSlideViewButton.connect("clicked()",
                                           self.__onSingleSlideButtonClicked__)
        self.sideBySideViewButton.connect("clicked()",
                                          self.__onSideBySideButtonClicked__)
        self.threeOverThreeViewButton.connect(
            "clicked()", self.__onThreeOverThreeViewButtonClicked__)
        self.maxMinCompareViewButton.connect(
            "clicked()", self.__onMaxMinCompareViewButtonClicked__)
        self.resetViewButton.connect("clicked()",
                                     self.__onResetViewButtonClicked__)
        for slicer in (item[1] for item in self.spacingSliderItems.values()):
            slicer.connect('valueChanged(int)',
                           self.__onNumberOfSlicesChanged__)
        self.crosshairCheckbox.connect("stateChanged(int)",
                                       self.__onCrosshairCheckChanged__)
        self.centerButton.connect("clicked()", self.__onCenterButtonClicked__)
示例#14
0
    def create(self, widgetType='window', showHeader=False, showPreview=False):
        """
    main window is a frame with widgets from the app
    widget repacked into it along with slicer-specific 
    extra widgets
    """

        # find internals of widget for reference and repacking
        self.toolBar = slicer.util.findChildren(self.dicomApp, 'ToolBar')[0]
        self.databaseNameLabel = slicer.util.findChildren(
            self.dicomApp, 'DatabaseNameLabel')[0]
        self.databaseDirectoryButton = slicer.util.findChildren(
            self.dicomApp, 'DirectoryButton')[0]
        self.tree = slicer.util.findChildren(self.dicomApp, 'TreeView')[0]
        self.userFrame = slicer.util.findChildren(self.dicomApp,
                                                  'UserFrame')[0]
        self.thumbs = slicer.util.findChildren(self.dicomApp,
                                               'ThumbnailsWidget')[0]
        self.widthSlider = slicer.util.findChildren(self.dicomApp,
                                                    'ThumbnailWidthSlider')[0]
        self.preview = slicer.util.findChildren(self.dicomApp,
                                                'PreviewFrame')[0]

        self.widgetType = widgetType
        if widgetType == 'dialog':
            self.window = qt.QDialog(self.dicomApp)
        elif widgetType == 'window':
            self.window = qt.QWidget()
        elif widgetType == 'popup':
            self.window = ctk.ctkPopupWidget(self.dicomApp)
            self.window.orientation = 1
            self.window.horizontalDirection = 0
            self.window.alignment = 0x82
        elif widgetType == 'dock':
            self.dock = qt.QDockWidget(slicer.util.mainWindow())
            self.dock.setFeatures(qt.QDockWidget.DockWidgetFloatable
                                  | qt.QDockWidget.DockWidgetMovable
                                  | qt.QDockWidget.DockWidgetClosable)
            slicer.util.mainWindow().addDockWidget(0x15, self.dock)
            self.window = qt.QFrame()
            self.dock.setWidget(self.window)
        else:
            raise "Unknown widget type - should be dialog, window, dock or popup"

        self.window.setWindowTitle('DICOM Details')

        self.layout = qt.QGridLayout()
        self.window.setLayout(self.layout)

        # overall layout - tree on top, preview and selection below
        toolRow = 0
        treeRow = 1
        selectionRow = 2

        # tool row at top, with commands and database
        self.toolLayout = qt.QHBoxLayout()
        self.layout.addLayout(self.toolLayout, toolRow, 0, 1, 2)
        self.toolLayout.addWidget(self.toolBar)
        self.toolLayout.addWidget(self.databaseNameLabel)
        self.toolLayout.addWidget(self.databaseDirectoryButton)

        # tree goes next, spread across 1 row, 2 columns
        self.layout.addWidget(self.tree, treeRow, 0, 1, 2)

        #
        # preview related column
        #
        self.previewLayout = qt.QVBoxLayout()
        self.layout.addLayout(self.previewLayout, selectionRow, 0)

        self.previewLayout.addWidget(self.thumbs)
        self.previewLayout.addWidget(self.widthSlider)
        if showPreview:
            self.previewLayout.addWidget(self.preview)
        else:
            self.preview.hide()

        #
        # action related column (interacting with slicer)
        #
        self.actionLayout = qt.QVBoxLayout()
        self.layout.addLayout(self.actionLayout, selectionRow, 1)
        self.actionLayout.addWidget(self.userFrame)

        tableWidth = 350 if showHeader else 700
        self.loadableTable = DICOMLoadableTable(self.userFrame,
                                                width=tableWidth)
        self.actionLayout.addWidget(self.loadableTable.widget)

        #
        # button row for action column
        #
        self.actionButtonLayout = qt.QHBoxLayout()
        self.actionLayout.addLayout(self.actionButtonLayout)

        self.uncheckAllButton = qt.QPushButton('Uncheck All')
        self.actionButtonLayout.addWidget(self.uncheckAllButton)
        self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables)

        self.loadButton = qt.QPushButton('Load Selection to Slicer')
        self.loadButton.enabled = False
        self.actionButtonLayout.addWidget(self.loadButton)
        self.loadButton.connect('clicked()', self.loadCheckedLoadables)

        self.closeButton = qt.QPushButton('Close')
        self.actionButtonLayout.addWidget(self.closeButton)
        self.closeButton.connect('clicked()', self.close)

        if self.setBrowserPersistence:
            self.browserPersistentButton = qt.QCheckBox(
                'Make DICOM Browser Persistent')
            self.browserPersistentButton.toolTip = 'When enabled, DICOM Broswer remains open and usable after leaving DICOM module'
            self.actionLayout.addWidget(self.browserPersistentButton)
            self.browserPersistentButton.connect('stateChanged(int)',
                                                 self.setBrowserPersistence)

        #
        # header related column (more details about the selected file)
        #
        if showHeader:
            self.headerLayout = qt.QVBoxLayout()
            self.layout.addLayout(self.headerLayout, selectionRow, 2)
            self.header = DICOMHeaderWidget(self.window)
            self.headerLayout.addWidget(self.header.widget)
示例#15
0
    def setup(self):

        w = qt.QWidget()
        layout = qt.QGridLayout()
        w.setLayout(layout)
        self.layout.addWidget(w)
        w.show()
        self.layout = layout

        ####################IMPORTAR VOLUMEN 4D#################################################3

        ### Se crea la sección para importar
        importDataCollapsibleButton = ctk.ctkCollapsibleButton()
        importDataCollapsibleButton.text = "Import DICOM"
        self.layout.addWidget(importDataCollapsibleButton)
        importDataFormLayout = qt.QFormLayout(importDataCollapsibleButton)
        #### Crear desplegable para seleccionar dirección del volumen
        self.__fDialog = ctk.ctkDirectoryButton()
        self.__fDialog.caption = 'Input directory'
        importDataFormLayout.addRow('Input directory:', self.__fDialog)
        #### Crear desplegable para seleccionar dirección del volumen
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.inputSelector.addEnabled = True  # Se habilita la posibildad al usuario de crear un nuevo nodo con este widget
        self.inputSelector.removeEnabled = True  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        importDataFormLayout.addRow("Input node:", self.inputSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.inputSelector, 'setMRMLScene(vtkMRMLScene*)')

        self.__nameFrame = qt.QLineEdit()
        self.__nameFrame.text = 'NA'
        importDataFormLayout.addRow('Volume Name', self.__nameFrame)

        # Botón de importar
        self.buttonImport = qt.QPushButton("Import")
        self.buttonImport.toolTip = "Run the algorithm."
        importDataFormLayout.addRow("", self.buttonImport)
        self.buttonImport.connect('clicked(bool)', self.importFunction)
        ### Se crea la sección para exportar
        exportDataCollapsibleButton = ctk.ctkCollapsibleButton()
        exportDataCollapsibleButton.text = "Export DICOM"
        self.layout.addWidget(exportDataCollapsibleButton)
        exportDataFormLayout = qt.QFormLayout(exportDataCollapsibleButton)
        ###Selector de volumen donde se guardara el volumen de la direccion
        self.outputSelector = slicer.qMRMLNodeComboBox()
        self.outputSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.outputSelector.addEnabled = False  # Se habilita la posibildad al usuario de crear un nuevo nodo con este widget
        self.outputSelector.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        self.outputSelector.setMRMLScene(slicer.mrmlScene)
        exportDataFormLayout.addRow("Volumen to export:", self.outputSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.outputSelector, 'setMRMLScene(vtkMRMLScene*)')
        #### Crear desplegable para seleccionar direccion del volumen
        self.__fDialogOutput = ctk.ctkDirectoryButton()
        self.__fDialogOutput.caption = 'DICOM directory'
        exportDataFormLayout.addRow('DiCOM directory:', self.__fDialogOutput)
        # Botón de exportar
        self.buttonExport = qt.QPushButton("Export")
        self.buttonExport.toolTip = "Run the algorithm."
        exportDataFormLayout.addRow("", self.buttonExport)
        self.buttonExport.connect('clicked(bool)', self.ExportFunction)

        ####################EXPORTAR MANUALMENTE#################################################3

        ### Se crea la sección para importar
        exportManualDataCollapsibleButton = ctk.ctkCollapsibleButton()
        exportManualDataCollapsibleButton.text = "Exportar manualmente"
        self.layout.addWidget(exportManualDataCollapsibleButton)
        exportManualDataFormLayout = qt.QFormLayout(
            exportManualDataCollapsibleButton)
        #### Crear desplegable para seleccionar dirección del volumen
        self.__fDialogManual = ctk.ctkDirectoryButton()
        self.__fDialogManual.caption = 'Input directory'
        exportManualDataFormLayout.addRow('Input directory:',
                                          self.__fDialogManual)

        self.__dicomID = qt.QLineEdit()
        self.__dicomID.text = 'NA'
        exportManualDataFormLayout.addRow('Patient ID:', self.__dicomID)

        self.__dicomName = qt.QLineEdit()
        self.__dicomName.text = 'NA'
        exportManualDataFormLayout.addRow('Patient ID:', self.__dicomName)

        self.__dicomstudyID = qt.QLineEdit()
        self.__dicomstudyID.text = 'NA'
        exportManualDataFormLayout.addRow('Study ID:', self.__dicomstudyID)

        self.__dicomstudyComments = qt.QLineEdit()
        self.__dicomstudyComments.text = 'NA'
        exportManualDataFormLayout.addRow('Study ID:',
                                          self.__dicomstudyComments)

        self.__dicomstudyDescription = qt.QLineEdit()
        self.__dicomstudyDescription.text = 'NA'
        exportManualDataFormLayout.addRow('study Description:',
                                          self.__dicomstudyDescription)

        self.__dicommodality = qt.QLineEdit()
        self.__dicommodality.text = 'NA'
        exportManualDataFormLayout.addRow('modality:', self.__dicommodality)

        self.__dicommanufacturer = qt.QLineEdit()
        self.__dicommanufacturer.text = 'NA'
        exportManualDataFormLayout.addRow('manufacturer:',
                                          self.__dicommanufacturer)

        self.__dicomseriesNumber = qt.QLineEdit()
        self.__dicomseriesNumber.text = 'NA'
        exportManualDataFormLayout.addRow('series Number:',
                                          self.__dicomseriesNumber)

        self.__dicomseriesDescription = qt.QLineEdit()
        self.__dicomseriesDescription.text = 'NA'
        exportManualDataFormLayout.addRow('series Description:',
                                          self.__dicomseriesDescription)

        self.__dicomPrefix = qt.QLineEdit()
        self.__dicomPrefix.text = 'IMG'
        exportManualDataFormLayout.addRow('dicomPrefix:', self.__dicomPrefix)

        self.__dicomNumberFormat = qt.QLineEdit()
        self.__dicomNumberFormat.text = '%04d'
        exportManualDataFormLayout.addRow('series Description:',
                                          self.__dicomNumberFormat)
示例#16
0
    def construct(self):
        """ Constructs the MetadataEditorSet widget.
        """

        #--------------------
        # Loop through all folders as per
        # Xnat.path.DEFAULT_LEVELS.  We create an AnimatedCollapsible
        # for every folder, one MetadataEditor_Custom and one
        # MetadataEditor_Default, along with the relevant buttons for
        # very folder in XNAT_LEVELS.
        #--------------------
        for xnatLevel in Xnat.path.DEFAULT_LEVELS:

            #
            # Set DEFAULT label per xnat level.
            #
            self.labels[xnatLevel] = []
            self.labels[xnatLevel].append(qt.QLabel('<b>DEFAULT<b>'))
            self.labels[xnatLevel][0].setFont(
                XnatSlicerGlobals.LABEL_FONT_BOLD)

            #
            # Set the collapsible's internal layout
            # (a qt.QGridLayout) per folder.
            #
            self.collapsibleLayouts[xnatLevel] = qt.QGridLayout()
            self.collapsibleLayouts[xnatLevel].\
                addWidget(self.labels[xnatLevel][0], 0, 0)

            #
            # Set the MetadataEditor_Default,
            # add to layout.
            #
            self.defaultMetadataEditors[xnatLevel] = \
            MetadataEditor_Default(xnatLevel)
            self.collapsibleLayouts[xnatLevel].\
                addWidget(self.defaultMetadataEditors[xnatLevel], 1, 0)

            #
            # Set the MetadataEditor_Custom,
            # add to layout.
            #
            self.customMetadataEditors[xnatLevel] = \
                MetadataEditor_Custom(xnatLevel)
            self.collapsibleLayouts[xnatLevel].\
                addWidget(self.customMetadataEditors[xnatLevel], 1, 1, 1, 2)

            #
            # Set DEFAULT label per xnat level.
            #
            self.labels[xnatLevel].append(qt.QLabel('<b>CUSTOM<b>'))
            self.labels[xnatLevel][1].setFont(
                XnatSlicerGlobals.LABEL_FONT_BOLD)
            self.collapsibleLayouts[xnatLevel].\
                addWidget(self.labels[xnatLevel][1], 0, 1)

            #
            # Add the 'editCustom' button.
            #
            # NOTE: The user can choose to hide/show these buttons,
            # based on what's needed.  For isntance, the Settings['METADATA']
            # class hides these buttons as they are not necessary for
            # its workflow.
            #
            self.editCustomButtons[xnatLevel] = \
                XnatSlicerUtils.generateButton(iconOrLabel = \
                    "Edit custom tags for '%s'"%(xnatLevel),
                toolTip = "Adds a custom metadata tag to display in the" +
                                               " 'Info' column.",
                font = XnatSlicerGlobals.LABEL_FONT,
                size = qt.QSize(180, 20),
                enabled = True)

            self.collapsibleLayouts[xnatLevel].\
                addWidget(self.editCustomButtons[xnatLevel], 0, 2)
            self.editCustomButtonGroup.\
                addButton(self.editCustomButtons[xnatLevel])

            #
            # Put all of the widgets into first, a contentsWidget.
            # Then set the widget of the AnimatedCollapsible to the
            # contentsWidget.
            #
            self.collapsibles[xnatLevel] = AnimatedCollapsible(self, \
                                                        xnatLevel.title())
            self.collapsibles[xnatLevel].setMaxExpandedHeight(250)
            self.collapsibles[xnatLevel].setMinExpandedHeight(250)

            contentsWidget = qt.QWidget()
            contentsWidget.setLayout(self.collapsibleLayouts[xnatLevel])
            self.collapsibles[xnatLevel].setContents(contentsWidget)
            self.collapsibles[xnatLevel].setFixedWidth(550)

            #
            # Add collapsible to self.mainLayout.
            #
            self.mainLayout.addWidget(self.collapsibles[xnatLevel])
            self.mainLayout.addSpacing(10)

        #--------------------
        # Set callback to Update XNATSlicer's
        # layout when animating.
        #--------------------
        for key, collapsible in self.collapsibles.items():
            collapsible.onEvent('animate', self.updateLayout)

        #--------------------
        # Set mainLayout to the master layout.
        #--------------------
        self.mainLayout.addStretch()
        self.setLayout(self.mainLayout)

        #--------------------
        # Set the current item tyype to label.
        # The user can change it to 'checkbox'
        # later.
        #--------------------
        self.setItemType('label')
示例#17
0
    def setup(self, wName, parent):
        if self.ctrlWidget:
            return

        self.LinkViewers()
        self.numFrames = len(self.nodeImgList[0][0])

        if parent:
            self.ctrlWidget = parent
        else:
            # Create seperate window
            self.ctrlWidget = slicer.qMRMLWidget()
            self.ctrlWidget.setMRMLScene(slicer.mrmlScene)
            self.ctrlWidget.setLayout(qt.QFormLayout())

        self.ctrlWidget.setWindowTitle(wName)
        ctrlLayout = self.ctrlWidget.layout()

        # Create Slider Panel
        self.sliderPanel = qt.QWidget()
        self.sliderPanel.setLayout(qt.QGridLayout())
        ctrlLayout.addWidget(self.sliderPanel)
        sliderLayout = self.sliderPanel.layout()

        if self.numFrames > 1:
            self.ctrlFrameLabel = qt.QLabel('Frame')
            self.ctrlFrameSlider = ctk.ctkSliderWidget()
            self.ctrlFrameSlider.connect('valueChanged(double)',
                                         self.onSliderFrameChanged)
            sliderLayout.addWidget(self.ctrlFrameLabel, 0, 0)
            sliderLayout.addWidget(self.ctrlFrameSlider, 0, 1)

        self.ctrlLevelLabel = qt.QLabel('Level')
        self.ctrlLevelSlider = ctk.ctkSliderWidget()
        self.ctrlLevelSlider.connect('valueChanged(double)',
                                     self.onSliderLevelChanged)
        sliderLayout.addWidget(self.ctrlLevelLabel, 1, 0)
        sliderLayout.addWidget(self.ctrlLevelSlider, 1, 1)

        self.ctrlWindowLabel = qt.QLabel('Window')
        self.ctrlWindowSlider = ctk.ctkSliderWidget()
        self.ctrlWindowSlider.connect('valueChanged(double)',
                                      self.onSliderWindowChanged)
        sliderLayout.addWidget(self.ctrlWindowLabel, 2, 0)
        sliderLayout.addWidget(self.ctrlWindowSlider, 2, 1)

        self.setSliderRangesAndValues()

        if self.sliceNodeList:
            self.orientPanel = qt.QWidget()
            self.orientPanel.setLayout(qt.QGridLayout())
            ctrlLayout.addWidget(self.orientPanel)

            self.orientationButtons = {}
            index = 0
            for orientation in self.orientations:
                self.orientationButtons[orientation] = qt.QRadioButton()
                self.orientationButtons[orientation].text = orientation
                # self.orientationBox.layout().addWidget(self.orientationButtons[orientation])
                self.orientPanel.layout().addWidget(
                    self.orientationButtons[orientation], 0, index)
                self.orientationButtons[orientation].connect(
                    "clicked()", lambda o=orientation: self.setOrientation(o))
                index += 1

        self.setOrientation(self.selectedOrientation)

        if False:
            #self.plotFrame = ctk.ctkCollapsibleButton()
            #self.plotFrame.text = "Plotting"
            #self.plotFrame.collapsed = 0
            self.plotFrame = qt.QWidget()
            plotFrameLayout = qt.QGridLayout(self.plotFrame)
            ctrlLayout.addWidget(self.plotFrame)

            self.plotSettingsFrame = ctk.ctkCollapsibleButton()
            self.plotSettingsFrame.text = "Settings"
            self.plotSettingsFrame.collapsed = 1
            plotSettingsFrameLayout = qt.QGridLayout(self.plotSettingsFrame)
            #plotFrameLayout.addWidget(self.plotSettingsFrame,0,1)

            self.xLogScaleCheckBox = qt.QCheckBox()
            self.xLogScaleCheckBox.setChecked(0)

            self.yLogScaleCheckBox = qt.QCheckBox()
            self.yLogScaleCheckBox.setChecked(0)

            # taken from  https://github.com/fedorov/MultiVolumeExplorer
            self.__chartView = ctk.ctkVTKChartView(self.ctrlWidget)
            # self.plotFrame)
            #  self.ctrlWidget
            plotFrameLayout.addWidget(self.__chartView, 0, 0)

            self.__chart = self.__chartView.chart()
            self.__chartTable = vtk.vtkTable()
            self.__xArray = vtk.vtkFloatArray()
            self.__yArray = vtk.vtkFloatArray()
            # will crash if there is no name
            self.__xArray.SetName('')
            self.__yArray.SetName('signal intensity')
            self.__chartTable.AddColumn(self.__xArray)
            self.__chartTable.AddColumn(self.__yArray)

            self.onInputChanged()
            self.refreshObservers()

        self.buttonPanel = qt.QWidget()
        self.buttonPanel.setLayout(qt.QGridLayout())
        ctrlLayout.addWidget(self.buttonPanel)

        self.exitButton = qt.QPushButton("Exit")
        self.exitButton.toolTip = "Close down slicer."
        self.exitButton.name = "sviewer exit"
        self.buttonPanel.layout().addWidget(self.exitButton, 0, 0)
        self.exitButton.connect('clicked()', exit)

        # do not do ctrlWin.show() here - for some reason window does not pop up then
        return self.ctrlWidget
示例#18
0
  def setup(self):
    # Instantiate and connect widgets ...

    w = qt.QWidget()
    layout = qt.QGridLayout()
    w.setLayout(layout)
    self.layout.addWidget(w)
    w.show()
    #self.layout = layout

    #
    # 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 = "SequenceRegistration Reload"
    reloadFormLayout.addWidget(self.reloadButton)
    self.reloadButton.connect('clicked()', self.onReload)

    # reload and test button
    # (use this during development, but remove it when delivering
    #  your module to users)
    self.reloadAndTestButton = qt.QPushButton("Reload and Test")
    self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
    reloadFormLayout.addWidget(self.reloadAndTestButton)
    self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

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

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

    #
    # Input fixed image
    #
    self.fixedImageSelector = slicer.qMRMLNodeComboBox()
    self.fixedImageSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    self.fixedImageSelector.selectNodeUponCreation = True
    self.fixedImageSelector.addEnabled = False
    self.fixedImageSelector.removeEnabled = False
    self.fixedImageSelector.noneEnabled = False
    self.fixedImageSelector.showHidden = False
    self.fixedImageSelector.showChildNodeTypes = False
    self.fixedImageSelector.setMRMLScene( slicer.mrmlScene )
    self.fixedImageSelector.setToolTip( "Please select the fixed image node for tracking." )
    parametersFormLayout.addRow("Reference sequence/image node: ", self.fixedImageSelector)

    #
    # Input moving sequence image
    #
    self.movingImageSequenceSelector = slicer.qMRMLNodeComboBox()
    self.movingImageSequenceSelector.nodeTypes = ( ("vtkMRMLSequenceNode"), "" )
    self.movingImageSequenceSelector.selectNodeUponCreation = True
    self.movingImageSequenceSelector.addEnabled = False
    self.movingImageSequenceSelector.removeEnabled = False
    self.movingImageSequenceSelector.noneEnabled = False
    self.movingImageSequenceSelector.showHidden = False
    self.movingImageSequenceSelector.showChildNodeTypes = False
    self.movingImageSequenceSelector.setMRMLScene( slicer.mrmlScene )
    self.movingImageSequenceSelector.setToolTip( "Please select the moving sequence image node for tracking." )
    parametersFormLayout.addRow("Moving sequence/image node: ", self.movingImageSequenceSelector)

    #
    # Input rigid transform
    #
    self.linearTransformSelector = slicer.qMRMLNodeComboBox()
    self.linearTransformSelector.nodeTypes = ( ("vtkMRMLLinearTransformNode"), "" )
    self.linearTransformSelector.selectNodeUponCreation = True
    self.linearTransformSelector.addEnabled = True
    self.linearTransformSelector.removeEnabled = True
    self.linearTransformSelector.noneEnabled = True
    self.linearTransformSelector.showHidden = False
    self.linearTransformSelector.showChildNodeTypes = False
    self.linearTransformSelector.setMRMLScene( slicer.mrmlScene )
    self.linearTransformSelector.setToolTip( "Please select a transform." )
    parametersFormLayout.addRow("Initial transform node: ", self.linearTransformSelector)

    #
    # ROI
    #
    self.InputROISelector = slicer.qMRMLNodeComboBox()
    self.InputROISelector.nodeTypes = ( ("vtkMRMLAnnotationROINode"), "" )
    self.InputROISelector.selectNodeUponCreation = True
    self.InputROISelector.addEnabled = True
    self.InputROISelector.removeEnabled = True
    self.InputROISelector.noneEnabled = True
    self.InputROISelector.showHidden = False
    self.InputROISelector.showChildNodeTypes = False
    self.InputROISelector.setMRMLScene( slicer.mrmlScene )
    parametersFormLayout.addRow("ROI: ", self.InputROISelector)

    self.ROIVisibilityButton = qt.QPushButton("Off")
    self.ROIVisibilityButton.checkable = True
    self.ROIVisibilityButton.checked = False
    self.ROIVisibilityButton.enabled = False
    parametersFormLayout.addRow("ROI Visibility: ", self.ROIVisibilityButton)

    self.InitializeTransformModeOptions = ("Off","useGeometryAlign","useMomentsAlign")
    #
    #Initialization
    #
    self.groupBox = qt.QGroupBox("Initialize Transform Mode")
    self.groupBoxLayout = qt.QHBoxLayout(self.groupBox)
    parametersFormLayout.addRow(self.groupBox)

    #
    # layout selection
    #
    for initializeTransformModeOption in self.InitializeTransformModeOptions:
      initializeTransformModeButton = qt.QRadioButton(initializeTransformModeOption)
      initializeTransformModeButton.connect('clicked()', lambda itmo=initializeTransformModeOption: self.selectInitializeTransformMode(itmo))
      self.groupBoxLayout.addWidget(initializeTransformModeButton)
    #self.groupBoxLayout.addRow("Layout", layoutHolder)

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

    # Connections
    self.fixedImageSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onInputSelect)
    self.movingImageSequenceSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onInputSelect)
    self.InputROISelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onInputSelect)
    self.ROIVisibilityButton.connect('clicked(bool)', self.onROIVisible)
    self.registerButton.connect('clicked(bool)', self.onApply)
    
    #
    # Output Area
    #
    outputsCollapsibleButton1 = ctk.ctkCollapsibleButton()
    outputsCollapsibleButton1.text = "Outputs (at least one output must be specified)"
    self.layout.addWidget(outputsCollapsibleButton1)

    # Layout within the dummy collapsible button
    outputsFormLayout = qt.QFormLayout(outputsCollapsibleButton1)

    #
    # Output rigid transform
    #
    self.outputTransformSequenceSelector = slicer.qMRMLNodeComboBox()
    self.outputTransformSequenceSelector.nodeTypes = ( ("vtkMRMLSequenceNode"), "" )
    self.outputTransformSequenceSelector.selectNodeUponCreation = True
    self.outputTransformSequenceSelector.addEnabled = True
    self.outputTransformSequenceSelector.removeEnabled = True
    self.outputTransformSequenceSelector.noneEnabled = True
    self.outputTransformSequenceSelector.showHidden = False
    self.outputTransformSequenceSelector.showChildNodeTypes = False
    self.outputTransformSequenceSelector.setMRMLScene( slicer.mrmlScene )
    self.outputTransformSequenceSelector.setToolTip( "Please select a sequence transform node." )
    outputsFormLayout.addRow("Output sequence transform node: ", self.outputTransformSequenceSelector)

    #
    # Output images
    #
    self.outputImageSequenceSelector = slicer.qMRMLNodeComboBox()
    self.outputImageSequenceSelector.nodeTypes = ( ("vtkMRMLSequenceNode"), "" )
    self.outputImageSequenceSelector.selectNodeUponCreation = True
    self.outputImageSequenceSelector.addEnabled = True
    self.outputImageSequenceSelector.removeEnabled = True
    self.outputImageSequenceSelector.noneEnabled = True
    self.outputImageSequenceSelector.showHidden = False
    self.outputImageSequenceSelector.showChildNodeTypes = False
    self.outputImageSequenceSelector.setMRMLScene( slicer.mrmlScene )
    self.outputImageSequenceSelector.setToolTip( "Please select a sequence image node." )
    outputsFormLayout.addRow("Output sequence image node: ", self.outputImageSequenceSelector)

	# Comment out the following code as this functionality is not moved to Sequence Browser module
    # plottingCollapsibleButton = ctk.ctkCollapsibleButton()
    # plottingCollapsibleButton.text = "Plotting"
    # plottingCollapsibleButton.collapsed = 0
    # self.layout.addWidget(plottingCollapsibleButton)
    
    # plottingFrameLayout = qt.QGridLayout(plottingCollapsibleButton)

    # self.ChartingDisplayOptions = ("LR","AP","SI")
    # self.chartingDisplayOption = 'LR'
    # #
    # #Initialization
    # #
    # self.chartGroupBox = qt.QGroupBox("Display options:")
    # self.chartGroupBoxLayout = qt.QHBoxLayout(self.chartGroupBox)
    # plottingFrameLayout.addWidget(self.chartGroupBox,0,0,1,3)

    # #
    # # layout selection
    # #
    # for chartingDisplayOption in self.ChartingDisplayOptions:
      # chartingDisplayOptionButton = qt.QRadioButton(chartingDisplayOption)
      # chartingDisplayOptionButton.connect('clicked()', lambda cdo=chartingDisplayOption: self.selectChartingDisplayOption(cdo))
      # self.chartGroupBoxLayout.addWidget(chartingDisplayOptionButton)
    # #self.groupBoxLayout.addRow("Layout", layoutHolder)

    # # add chart container widget
    # self.__chartView = ctk.ctkVTKChartView(w)
    # plottingFrameLayout.addWidget(self.__chartView,1,0,1,3)

    # self.__chart = self.__chartView.chart()
    # self.__chartTable = vtk.vtkTable()
    # self.__xArray = vtk.vtkFloatArray()
    # self.__yArray = vtk.vtkFloatArray()
    # self.__zArray = vtk.vtkFloatArray()
    # self.__mArray = vtk.vtkFloatArray()
    # # will crash if there is no name
    # self.__xArray.SetName('')
    # self.__yArray.SetName('signal intensity')
    # self.__zArray.SetName('')
    # self.__mArray.SetName('signal intensity')
    # self.__chartTable.AddColumn(self.__xArray)
    # self.__chartTable.AddColumn(self.__yArray)
    # self.__chartTable.AddColumn(self.__zArray)
    # self.__chartTable.AddColumn(self.__mArray)

    self.outputTransformSequenceSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onOutputSelect)
    self.outputImageSequenceSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onOutputSelect)

    # Add vertical spacer
    self.layout.addStretch(1)
示例#19
0
    def setup(self):
        """Init the widget """
        # ScriptedLoadableModuleWidget.setup(self)

        settings = qt.QSettings()

        if (SlicerUtil.IsDevelopment):
            # reload button
            self.reloadButton = qt.QPushButton("Reload")
            self.reloadButton.toolTip = "Reload this module."
            self.reloadButton.name = "Reload"
            self.layout.addWidget(self.reloadButton)
            self.reloadButton.connect('clicked()', self.onBtnReloadClicked)

        self.logic = PicasaSnapLogic()
        self.__addObservers__()

        ######## Credentials
        self.credentialsCollapsibleButton = ctk.ctkCollapsibleButton()
        self.credentialsCollapsibleButton.text = "Credentials"
        self.layout.addWidget(self.credentialsCollapsibleButton)
        self.credentialsLayout = qt.QFormLayout(
            self.credentialsCollapsibleButton)

        self.isUserLogged = False

        self.loginLineEdit = qt.QLineEdit()
        self.credentialsLayout.addRow("Login:   "******"Password:   "******"Remember my credentials")
        self.rememberCredentialsCheckBox.toolTip = "Check for an automatic login when the application starts"
        self.loginButton = qt.QPushButton("Login")
        self.loginButton.toolTip = "Login in Picassa service (Google credentials)"
        self.logoutButton = qt.QPushButton("Logout")
        self.logoutButton.toolTip = "Logout to connect with another user's credentials"
        # Add all the items, they will be shown/hidden in refreshCredentialsUI function
        self.credentialsLayout.addRow(self.rememberCredentialsCheckBox,
                                      self.loginButton)
        self.credentialsLayout.addRow(None, self.logoutButton)

        ######## Snapshots (main frame)
        self.mainCollapsibleButton = ctk.ctkCollapsibleButton()
        self.mainCollapsibleButton.text = "Snapshots"
        self.layout.addWidget(self.mainCollapsibleButton)
        self.mainLayout = qt.QVBoxLayout(self.mainCollapsibleButton)

        ############### Current snapshots
        self.currentSnapshotsFrame = qt.QFrame()
        self.currentSnapshotsLayout = qt.QVBoxLayout()
        self.currentSnapshotsFrame.setLayout(self.currentSnapshotsLayout)
        self.currentSnapshotsFrame.setFrameShape(qt.QFrame.StyledPanel)
        self.mainLayout.addWidget(self.currentSnapshotsFrame)

        self.snapshotsLabel = qt.QLabel("Snapshots to upload:")
        self.snapshotsLabel.setStyleSheet(
            "font-weight:bold; font-size:14px; margin-bottom:10px")
        self.currentSnapshotsLayout.addWidget(self.snapshotsLabel)

        # Subframe that contains the checkbox list
        self.currentSnapshotsInnerFrame = qt.QFrame()
        self.currentSnapshotsInnerLayout = qt.QVBoxLayout()
        self.currentSnapshotsInnerFrame.setLayout(
            self.currentSnapshotsInnerLayout)
        self.currentSnapshotsLayout.addWidget(self.currentSnapshotsInnerFrame)

        self.noItemsLabel = qt.QLabel(
            "(There are not any snapshots at the moment)")
        # Add the label by default. It will be hidden if there is any snapshot
        self.currentSnapshotsInnerLayout.addWidget(self.noItemsLabel)

        self.loadExistingSnapshotsFirstLoad()

        ############### Albums
        # Try to login before getting the albums
        self.login()

        msgBox = None
        if self.isUserLogged:
            # Show message box while loading the data
            msgBox = qt.QMessageBox(qt.QMessageBox.Information, 'Login',
                                    'Connecting with Picasa. Please wait...',
                                    qt.QMessageBox.Cancel)
            msgBox.show()

        try:
            self.albumNameFrame = qt.QFrame()
            self.albumNameLayout = qt.QHBoxLayout()
            self.albumNameFrame.setLayout(self.albumNameLayout)
            self.albumNameFrame.setFrameShape(qt.QFrame.StyledPanel)

            self.albumNameLabel = qt.QLabel("Album name:")
            self.albumNameLabel.setStyleSheet("font-weight:bold;")
            self.albumNamesComboBox = qt.QComboBox()
            self.loadAlbums()
            self.albumNameLayout.addWidget(self.albumNameLabel)
            self.albumNameLayout.addWidget(self.albumNamesComboBox)
            self.mainLayout.addWidget(self.albumNameFrame)

            ############### Tags
            self.tagsFrame = qt.QFrame()
            self.tagsLayout = qt.QGridLayout()
            self.tagsFrame.setLayout(self.tagsLayout)
            self.tagsFrame.setFrameShape(qt.QFrame.StyledPanel)

            self.tagsLabel = qt.QLabel(
                "Tags (select all that apply, you can filter o create new tags):"
            )
            self.tagsLabel.setStyleSheet(
                "font-weight: bold; margin-bottom: 10px; margin-top: 5px")
            self.tagsLayout.addWidget(self.tagsLabel, 0, 0, 1, 3)

            # Add input to filter tags and button to add a new one
            self.tagsFilterLineEdit = qt.QLineEdit()
            self.tagsFilterLineEdit.toolTip = "Type here to filter your tags. If you press the return key all the visible tags will be checked"
            #self.tagsFilterLineEdit.setStyleSheet(style)
            self.tagsLayout.addWidget(self.tagsFilterLineEdit, 1, 0, 1, 2)
            self.newTagButton = qt.QPushButton("New tag")
            #self.newTagButton.setStyleSheet("background-color: #5D74C6; color:white")
            self.newTagButton.setIconSize(qt.QSize(20, 20))
            self.newTagButton.setIcon(
                qt.QIcon(self.CIP_ICON_DIR + "/Plus - 48.png"))
            self.newTagButton.setFixedWidth(75)
            self.newTagButton.toolTip = "Add a new tag (the tag will not be created until you upload any picture with it)"
            self.tagsLayout.addWidget(self.newTagButton, 1, 2)

            self.loadTags()

            ############### Upload snapshots controls
            self.uploadSnapsButtonFrame = qt.QFrame()
            self.uploadSnapsLayout = qt.QHBoxLayout()
            self.uploadSnapsButtonFrame.setLayout(self.uploadSnapsLayout)
            #self(qt.QFrame.HLine)
            self.mainLayout.addWidget(self.uploadSnapsButtonFrame)

            self.uploadSnapshotsButton = qt.QPushButton()
            self.uploadSnapshotsButton.text = "Upload to Picasa!"
            self.uploadSnapshotsButton.toolTip = "Upload selected screenshots to Picassa"
            self.uploadSnapshotsButton.setStyleSheet(
                "background-color: #5D74C6; color: white; font-weight: bold; font-size:14px"
            )
            self.uploadSnapshotsButton.setIcon(
                qt.QIcon(self.CIP_ICON_DIR + "/Upload - 64.png"))
            self.uploadSnapshotsButton.setIconSize(qt.QSize(24, 24))
            self.uploadSnapshotsButton.setFixedSize(170, 35)
            self.uploadSnapsLayout.addWidget(self.uploadSnapshotsButton)

            ############### Progress bar
            self.progressBar = qt.QProgressDialog()
            self.progressBar.setMinimum(0)
            self.progressBar.setMinimumDuration(0)
            self.progressBar.setWindowModality(True)

            # Check for updates in CIP
            #autoUpdate = SlicerUtil.settingGetOrSetDefault("PicasaSnap", "AutoUpdate", 1)
            #uw = AutoUpdateWidget(parent=self.parent, autoUpdate=autoUpdate)
            #uw.addAutoUpdateCheckObserver(self.onAutoUpdateStateChanged)

            #     self.uploadProgressFrame = qt.QFrame()
            #     self.uploadProgressLayout = qt.QVBoxLayout()
            #     self.uploadProgressFrame.setLayout(self.uploadProgressLayout)
            #
            #     # Gif image
            #     self.imUploading = qt.QMovie("%s/loading.gif" % self.CIP_ICON_DIR, qt.QByteArray())
            #     # Label to contain the gif
            #     self.lblImLoading = qt.QLabel()
            #     # Fix the dimensions of the image (by fixing the dimensions of the label that contains it)
            #     self.lblImLoading.setFixedWidth(40)
            #     # Other image parameters
            #     self.imUploading.setCacheMode(qt.QMovie.CacheAll)
            #     self.imUploading.setSpeed(100)
            #     # Assign the label to the image (don't start it yet, it will be started when we are uploading)
            #     self.lblImLoading.setMovie(self.imUploading)
            #     #self.imUploading.start()
            #     self.uploadProgressLayout.addWidget(self.lblImLoading)
            #
            #     # Label that will show the progress
            #     self.lblUploading = qt.QLabel("Uploading %i/%i images...")
            #     self.uploadProgressLayout.addWidget(self.lblUploading)
            #
            # Cancel uploading button
            #     self.btnCancelUpload = qt.QPushButton("Cancel")
            #     self.btnCancelUpload.toolTip = "Cancel the process"
            #     self.btnCancelUpload.setFixedWidth(100)
            #     self.uploadProgressLayout.addWidget(self.btnCancelUpload)
            #     self.mainLayout.addWidget(self.uploadProgressFrame)
            #
            #     # Hide the progress frame
            #     self.uploadProgressFrame.hide()

            ######## Connections
            self.uploadSnapshotsButton.connect(
                'clicked (bool)', self.onUploadSnapshotsButtonClicked)
            self.loginButton.connect('clicked (bool)',
                                     self.onLoginButtonClicked)
            self.logoutButton.connect('clicked (bool)',
                                      self.onLogoutButtonClicked)
            self.loginLineEdit.returnPressed.connect(
                self.onLoginPasswordReturnKeyPressed)
            self.passwordLineEdit.returnPressed.connect(
                self.onLoginPasswordReturnKeyPressed)
            self.albumNamesComboBox.connect("currentIndexChanged (int)",
                                            self.onAlbumsCurrentIndexChanged)
            self.newTagButton.connect('clicked (bool)',
                                      self.onNewTagButtonClicked)
            self.tagsFilterLineEdit.connect('textEdited (QString)',
                                            self.onFilterTagsEdited)
            self.tagsFilterLineEdit.returnPressed.connect(
                self.onFilterTagsReturnKeyPressed)

            # Add vertical spacer
            self.layout.addStretch(1)
        finally:
            # Hide MesageBox if it was visible
            if msgBox:
                msgBox.close()
    def setup(self):
        #Collapsible button
        autoMRIBrainCollapsibleButton = ctk.ctkCollapsibleButton()
        autoMRIBrainCollapsibleButton.text = "Collapsible button for Brain MRI auto-segmentation"
        self.layout.addWidget(autoMRIBrainCollapsibleButton)

        #Layout within the collapsible button
        autoMRIBrainFormLayout = qt.QFormLayout(autoMRIBrainCollapsibleButton)

        #Load Brain MRI image button
        # loadMRIBrainButton = qt.QPushButton("Load Brain MRI image and add ROI annotation")
        # loadMRIBrainButton.toolTip = "Click to load Brain MRI image and annotate tumor center location"
        # autoMRIBrainFormLayout.addWidget(loadMRIBrainButton)
        # loadMRIBrainButton.connect('clicked(bool)', self.onloadMRIBrainButtonClicked)

        #Load Brain MRI T1 image button
        loadMRIT1Button = qt.QPushButton("Load Brain MRI T1 image")
        loadMRIT1Button.toolTip = "Click to load Brain MRI T1 image and annotate tumor center location"
        # autoMRIBrainFormLayout.addWidget(loadMRIT1Button)
        loadMRIT1Button.connect('clicked(bool)', self.onloadMRIT1ButtonClicked)

        #Load Brain MRI T2 FLAIR
        loadMRIFLAIRButton = qt.QPushButton("Load Brain MRI T2 FLAIR image")
        loadMRIFLAIRButton.toolTip = "Click to load Brain MRI image and annotate tumor center location"
        # autoMRIBrainFormLayout.addWidget(loadMRIFLAIRButton)
        loadMRIFLAIRButton.connect('clicked(bool)',
                                   self.onloadMRIFLAIRButtonClicked)

        loadMRIBrainButtons = qt.QGridLayout()
        loadMRIBrainButtons.addWidget(loadMRIT1Button, 0, 0)
        loadMRIBrainButtons.addWidget(loadMRIFLAIRButton, 0, 1)
        autoMRIBrainFormLayout.addRow(loadMRIBrainButtons)

        #load ATLAS
        loadATLASButton = qt.QPushButton("Load ALTAS Images")
        loadATLASlabelButton = qt.QPushButton("Load ALTAS Labels")
        loadATLASButton.connect('clicked(bool)', self.onloadATLASButtonClicked)
        loadATLASlabelButton.connect('clicked(bool)',
                                     self.onloadATLASlabelButtonClicked)
        autoMRIBrainFormLayout.addWidget(loadATLASButton)
        autoMRIBrainFormLayout.addWidget(loadATLASlabelButton)

        # Segment T1
        SegT1Button = qt.QPushButton("Segment T1")
        SegT1Button.toolTip = "Click this button to segment tumor if loaded image is T1."
        SegT1Button.connect('clicked(bool)', self.onloadSegT1ButtonClicked)
        # autoMRIBrainFormLayout.addWidget(loadSegT1Button)
        #Segment FLAIR
        SegFLAIRButton = qt.QPushButton("Segment FLAIR")
        SegFLAIRButton.toolTip = "Click this button to segment tumor if loaded image is FLAIR"
        SegFLAIRButton.connect('clicked(bool)',
                               self.onloadSegFLAIRButtonClicked)
        #Buttons to form
        segMRIBrainButtons = qt.QGridLayout()
        segMRIBrainButtons.addWidget(SegT1Button, 0, 0)
        segMRIBrainButtons.addWidget(SegFLAIRButton, 0, 1)
        autoMRIBrainFormLayout.addRow(segMRIBrainButtons)

        ##### Ajust value for volume to keep ##########
        ##########################################
        #        sigmalabel = qt.QLabel()
        #        sigmalabel.setText("Ajust ROI size value for better segmentation (1-10)")
        #        autoMRIBrainFormLayout.addWidget(sigmalabel)
        #        sigmaSlider = qt.QSlider(qt.Qt.Horizontal)
        #        sigmaSlider.toolTip = "Slide to change threshold value"
        #        sigmaSlider.setMinimum(1)
        #        sigmaSlider.setMaximum(10)
        #        sigmaSlider.setValue(1)
        #        sigmaSlider.setTickPosition(qt.QSlider.TicksBelow)
        #        sigmaSlider.setTickInterval(1)
        #        self.sigmaSlider = sigmaSlider
        #        #label for ticks
        #        sigmavalues = qt.QGridLayout()
        #        r1 = qt.QLabel("1")
        #        # r2 = qt.QLabel("3")
        #        # r3 = qt.QLabel("5")
        #        # r4 = qt.QLabel("7")
        #        # r5 = qt.QLabel("9")
        #        sigmavalues.addWidget(sigmaSlider, 0,0,1,5)
        #        sigmavalues.addWidget(r1,1,0,1,1)
        #        # sigmavalues.addWidget(r2,1,1,1,1)
        #        # sigmavalues.addWidget(r3,1,2,1,1)
        #        # sigmavalues.addWidget(r4,1,3,1,1)
        #        # sigmavalues.addWidget(r5,1,4,1,1)
        #        #Apply the changes
        #        sigmaApplyButton = qt.QPushButton("Apply")
        #        sigmaApplyButton.toolTip = "Click to apply new sigma value"
        #        sigmavalues.addWidget(sigmaApplyButton, 0,5,2,1)
        #        sigmaApplyButton.connect('clicked(bool)', self.changesApplyButtonClicked)
        #        autoMRIBrainFormLayout.addRow(sigmavalues)
        #        # Add vertical spacer
        #        self.layout.addStretch(1)

        #ATLAS directories
        # self.atlas_T1_dir = '/Users/lingdao.sha/Documents/Images/Radiology/Brain_MRI_auto/Brain/mni_icbm152_nlin_sym_09a/mni_icbm152_t1_tal_nlin_sym_09a.nii'
        # self.atlas_label_T1_dir = '/Users/lingdao.sha/Documents/Images/Radiology/Brain_MRI_auto/Brain/mni_icbm152_nlin_sym_09a/mni_icbm152_t1_tal_nlin_sym_09a_mask.nii'

        ### Parameters for tweaking ###
        # Elongation threshold (0 = perfect sphere)
        self.elong_thresh = -1  #  default = 0.25; switch to -1 to remove threshold altogether (may be needed in cases where algorithm gives nans or segmented tumor region is not correct)
        # Segmentation to select when refining segmentation
        self.seg_number = 1  # 1 (default) corresponds to largest volume, 2 corresponds to second largest volume, etc. This may need to be changed if eyes are getting segmented instead of tumor
        # change which thresholded segment to keep during t1p segmentation
        self.lowIntEnhance = 0  # 0 (default) takes highest intensity region; 1 takes second highest intensity region
        ### End tweak parameters ###

        # register and resample FLAIR to T1p and perform skull stripping
        self.registerSkullStripImages = 1  # 1 yes; 0 load registered/resampled and sull stripped images from file

        # Output file names
        self.name_T1p_label = 'T1p_label.nrrd'
        self.name_T1p_image = 'T1p_image.nrrd'

        # Output file names
        self.name_FLAIR_label = 'FLAIR_label.nrrd'
        self.name_FLAIR_image = 'FLAIR_image.nrrd'

        # volume thresholds for FLAIR segmented tumors (derived through empiracal results)
        self.volume_FLAIR_lower_threshold = 3000  # Regions with volumes less than this was never the tumor
        self.volume_FLAIR_upper_threshold = 185000  # Regions with volumes greater than this always included many (non-tumor) regions of the brain
  def setup(self):
    # make an instance of the logic 
    self.logic = TwoTensorModelVizLogic()

# 
# Model Selection Area
#
    modelCollapsibleButton = ctk.ctkCollapsibleButton()
    modelCollapsibleButton.text = "Basic"
    self.layout.addWidget(modelCollapsibleButton)
    
    modelFormLayout = qt.QFormLayout(modelCollapsibleButton)
    
    
    # ============Fiber model selector===================
    self.modelSelector = slicer.qMRMLNodeComboBox()
    self.modelSelector.nodeTypes = ( ("vtkMRMLFiberBundleNode"), "" )
    self.modelSelector.selectNodeUponCreation = True
    self.modelSelector.addEnabled = False
    self.modelSelector.removeEnabled = False
    self.modelSelector.noneEnabled = False
    self.modelSelector.showHidden = False
    self.modelSelector.showChildNodeTypes = False
    self.modelSelector.setMRMLScene( slicer.mrmlScene )
    self.modelSelector.setToolTip( "Pick a bundle of fibers." )
    modelFormLayout.addRow("Fiber bundles: ", self.modelSelector)
    self.modelSelector.connect('currentNodeChanged(vtkMRMLNode*)', \
         self.onModelSelect)

    # ============Glyph Space scroller=================
    self.sliderGlyphSpace = ctk.ctkSliderWidget()
    self.sliderGlyphSpace.decimals = 0
    self.sliderGlyphSpace.minimum=1
    self.sliderGlyphSpace.maximum=100
    self.sliderGlyphSpace.value=10
    self.sliderGlyphSpace.enabled = False
    modelFormLayout.addRow("Glyph Space:", self.sliderGlyphSpace)
    self.sliderGlyphSpace.connect('valueChanged(double)', \
         self.onGlyphSpaceChanged)
    
    # ============Glyph Scale scroller=================
    self.sliderGlyphScale = ctk.ctkSliderWidget()
    self.sliderGlyphScale.decimals = 0
    self.sliderGlyphScale.minimum=1
    self.sliderGlyphScale.maximum=10000
    self.sliderGlyphScale.value=2000
    self.sliderGlyphScale.enabled = False
    modelFormLayout.addRow("Glyph Scale:", self.sliderGlyphScale)
    self.sliderGlyphScale.connect('valueChanged(double)', \
         self.onGlyphScaleChanged)

    modelGridLayout=qt.QGridLayout()
    modelFormLayout.addRow("View Items:",modelGridLayout)
    
    # ============Check Box for showing lines==============
    self.checkboxLines=qt.QCheckBox("Lines")
    self.checkboxLines.toolTip="When checked, fiber lines are shown."
    self.checkboxLines.checked=True
    self.checkboxLines.enabled=False
    #modelFormLayout.addRow(self.checkboxLines)
    modelGridLayout.addWidget(self.checkboxLines,0,0)
        

    # ============Check Box for showing tensor 1==============
    self.checkboxTensor1=qt.QCheckBox("Tensor 1")
    self.checkboxTensor1.toolTip="When checked, cylinder glyphs are shown for tensor 1."
    self.checkboxTensor1.checked=True
    self.checkboxTensor1.enabled=False
    modelGridLayout.addWidget(self.checkboxTensor1,0,1)
    
    # ============Check Box for showing tensor 2==============
    self.checkboxTensor2=qt.QCheckBox("Tensor 2")
    self.checkboxTensor2.toolTip="When checked, cylinder glyphs are shown for tensor 2."
    self.checkboxTensor2.checked=True
    self.checkboxTensor2.enabled=False
    modelGridLayout.addWidget(self.checkboxTensor2,0,2)

    # ============Check Box for showing tube==============
    self.checkboxTubes=qt.QCheckBox("Tubes")
    self.checkboxTubes.toolTip="When checked, tubes will be shown."
    self.checkboxTubes.checked=True
    self.checkboxTubes.enabled=False
    modelGridLayout.addWidget(self.checkboxTubes,0,3)
    
# 
# Fiber Filter Area
#
    filterCollapsibleButton = ctk.ctkCollapsibleButton()
    filterCollapsibleButton.text = "Fiber Filter"
    self.layout.addWidget(filterCollapsibleButton)
       
    filterFormLayout = qt.QFormLayout(filterCollapsibleButton)
    
    
    # ============Line Space scroller=================
    self.sliderLineSpace = ctk.ctkSliderWidget()
    self.sliderLineSpace.decimals = 0
    self.sliderLineSpace.minimum=1
    self.sliderLineSpace.maximum=100
    self.sliderLineSpace.value=10
    self.sliderLineSpace.enabled = False
    filterFormLayout.addRow("One of n Fibers:", self.sliderLineSpace)
    self.sliderLineSpace.connect('valueChanged(double)', \
         self.onLineSpaceChanged)
    
    # ============Line Num scroller=================
    self.sliderLineNum = ctk.ctkSliderWidget()
    self.sliderLineNum.decimals = 0
    self.sliderLineNum.minimum=1
    self.sliderLineNum.maximum=100
    self.sliderLineNum.value=1
    self.sliderLineNum.enabled = False
    filterFormLayout.addRow("Specific Fiber No:", self.sliderLineNum)
    self.sliderLineNum.connect('valueChanged(double)', \
         self.onLineNumChanged)
    
    # ============Check Box for showing one fiber==============
    self.checkboxOnlyOneLine=qt.QCheckBox("Only show the specific fiber")
    self.checkboxOnlyOneLine.toolTip="When checked, only the specified fiber is shown."
    self.checkboxOnlyOneLine.checked=False
    self.checkboxOnlyOneLine.enabled=False
    filterFormLayout.addWidget(self.checkboxOnlyOneLine)
   
# 
# Cylinder Color Mapping Area
#
    cylinderColorCollapsibleButton = ctk.ctkCollapsibleButton()
    cylinderColorCollapsibleButton.text = "Cylinder Boby Color"
    self.layout.addWidget(cylinderColorCollapsibleButton)
    
    cylinderVBoxLayOut = qt.QVBoxLayout(cylinderColorCollapsibleButton)
    
    # Add a TabWidget
    cylinderTabWidget=qt.QTabWidget()
    cylinderVBoxLayOut.addWidget(cylinderTabWidget)
    
    # Create four pages and the GridLayOut
    redPage=qt.QWidget()
    redGrid=qt.QGridLayout(redPage)
    cylinderTabWidget.addTab(redPage,'Red')
    
    greenPage=qt.QWidget()
    greenGrid=qt.QGridLayout(greenPage)
    cylinderTabWidget.addTab(greenPage,'Green')

    bluePage=qt.QWidget()
    blueGrid=qt.QGridLayout(bluePage)
    cylinderTabWidget.addTab(bluePage,'Blue')

    alphaPage=qt.QWidget()
    alphaGrid=qt.QGridLayout(alphaPage)
    cylinderTabWidget.addTab(alphaPage,'Alpha')
    
    #========= Set the Red page ==============
    groupBox=qt.QGroupBox()
    grid = qt.QGridLayout(groupBox)
    redGrid.addWidget(groupBox,0,1)
    
    self.bodRadioR1=qt.QRadioButton("Fixed to:")
    self.bodRadioR2=qt.QRadioButton("Mapped to:")
    self.bodRadioR1.checked=True
       
    self.bodSliderR = ctk.ctkSliderWidget()
    self.bodSliderR.decimals = 0
    self.bodSliderR.minimum=0
    self.bodSliderR.maximum=255
    self.bodSliderR.value=1
    self.bodSliderR.enabled = True
    
    self.bodComboR = qt.QComboBox()
    self.bodComboR.duplicatesEnabled= False
    grid.addWidget(self.bodRadioR1,0,0)
    grid.addWidget(self.bodRadioR2,1,0)
    grid.addWidget(self.bodSliderR,0,1)
    grid.addWidget(self.bodComboR,1,1)

    #========= Set the Green page ==============
    groupBox=qt.QGroupBox()
    grid = qt.QGridLayout(groupBox)
    greenGrid.addWidget(groupBox,0,1)
    
    self.bodRadioG1=qt.QRadioButton("Fixed to:")
    self.bodRadioG2=qt.QRadioButton("Mapped to:")
    self.bodRadioG1.checked=True
       
    self.bodSliderG = ctk.ctkSliderWidget()
    self.bodSliderG.decimals = 0
    self.bodSliderG.minimum=0
    self.bodSliderG.maximum=255
    self.bodSliderG.value=1
    self.bodSliderG.enabled = True
    
    self.bodComboG = qt.QComboBox()
    self.bodComboG.duplicatesEnabled= False
    grid.addWidget(self.bodRadioG1,0,0)
    grid.addWidget(self.bodRadioG2,1,0)
    grid.addWidget(self.bodSliderG,0,1)
    grid.addWidget(self.bodComboG,1,1)
    
    #========= Set the Blue page ==============
    groupBox=qt.QGroupBox()
    grid = qt.QGridLayout(groupBox)
    blueGrid.addWidget(groupBox,0,1)
   
    self.bodRadioB1=qt.QRadioButton("Fixed to:")
    self.bodRadioB2=qt.QRadioButton("Mapped to:")
    self.bodRadioB1.checked=True
       
    self.bodSliderB = ctk.ctkSliderWidget()
    self.bodSliderB.decimals = 0
    self.bodSliderB.minimum=0
    self.bodSliderB.maximum=255
    self.bodSliderB.value=1
    self.bodSliderB.enabled = True
    
    self.bodComboB = qt.QComboBox()
    self.bodComboB.duplicatesEnabled= False
    grid.addWidget(self.bodRadioB1,0,0)
    grid.addWidget(self.bodRadioB2,1,0)
    grid.addWidget(self.bodSliderB,0,1)
    grid.addWidget(self.bodComboB,1,1)
    
    #========= Set the Alpha page ==============
    groupBox=qt.QGroupBox()
    grid = qt.QGridLayout(groupBox)
    alphaGrid.addWidget(groupBox,0,1)
    
    self.bodRadioA1=qt.QRadioButton("Fixed to:")
    self.bodRadioA2=qt.QRadioButton("Mapped to:")
    self.bodRadioA1.checked=True
       
    self.bodSliderA = ctk.ctkSliderWidget()
    self.bodSliderA.decimals = 0
    self.bodSliderA.minimum=0
    self.bodSliderA.maximum=255
    self.bodSliderA.value=1
    self.bodSliderA.enabled = True
    
    self.bodComboA = qt.QComboBox()
    self.bodComboA.duplicatesEnabled= False
    grid.addWidget(self.bodRadioA1,0,0)
    grid.addWidget(self.bodRadioA2,1,0)
    grid.addWidget(self.bodSliderA,0,1)
    grid.addWidget(self.bodComboA,1,1)

# 
# Tube Mapping Area
#
    tubeColorCollapsibleButton = ctk.ctkCollapsibleButton()
    tubeColorCollapsibleButton.text = "Tube Mapping"
    self.layout.addWidget(tubeColorCollapsibleButton)
    
    tubeVboxLayOut = qt.QVBoxLayout(tubeColorCollapsibleButton)
    
    # Add a TabWidget
    tubeTabWidget=qt.QTabWidget()
    tubeVboxLayOut.addWidget(tubeTabWidget)

    # Create three pages and the GridLayOut
    tubeColorPage=qt.QWidget()
    tubeColorGrid=qt.QGridLayout(tubeColorPage)
    tubeTabWidget.addTab(tubeColorPage,'Color')

    tubeSizePage=qt.QWidget()
    tubeSizeGrid=qt.QGridLayout(tubeSizePage)
    tubeTabWidget.addTab(tubeSizePage,'Size')

    #========= Set the color page ==============
    groupBox=qt.QGroupBox()
    grid = qt.QGridLayout(groupBox)
    tubeColorGrid.addWidget(groupBox,0,0)
            
    self.tubeRadioFixedTo=qt.QRadioButton("Fixed to")
    self.tubeRadioByOrientation=qt.QRadioButton("Color by orientation")
    self.tubeRadioSameAsCylinderBody=qt.QRadioButton("Same as Cylinder Body")
    
    self.tubeRadioByOrientation.checked=True
    
    grid.addWidget(self.tubeRadioFixedTo,0,0)
    grid.addWidget(self.tubeRadioByOrientation,1,0)
    grid.addWidget(self.tubeRadioSameAsCylinderBody,2,0)
    
    self.tubeColorButton=qt.QPushButton('Specifying Color')
    self.tubeColorButton.setAutoFillBackground(True)
    
    grid.addWidget(self.tubeColorButton,0,1)
    self.tubeColorButton.connect('clicked()', \
        self.onTubeFixedColor)

    #========= Set the size page ==============
    self.tubeSizeRadio1=qt.QRadioButton("Fixed to:")
    self.tubeSizeRadio2=qt.QRadioButton("Mapped to:")
    self.tubeSizeRadio1.checked=True
    self.tubeSizeSlider = ctk.ctkSliderWidget()
    self.tubeSizeSlider.decimals = 2
    self.tubeSizeSlider.minimum=0.0
    self.tubeSizeSlider.maximum=5.0
    self.tubeSizeSlider.value=0.1
    self.tubeSizeSlider.enabled = True
    self.tubeComboBox = qt.QComboBox()
    self.tubeComboBox.duplicatesEnabled= False  
    
    tubeSizeGrid.addWidget(self.tubeSizeRadio1,0,0)
    tubeSizeGrid.addWidget(self.tubeSizeRadio2,1,0)
    tubeSizeGrid.addWidget(self.tubeSizeSlider,0,1)
    tubeSizeGrid.addWidget(self.tubeComboBox,1,1)
    
    # ============Scale scroller=================
    label=qt.QLabel('Tube Scale:')
    self.sliderTubeScale = ctk.ctkSliderWidget()
    self.sliderTubeScale.decimals = 0
    self.sliderTubeScale.minimum=1
    self.sliderTubeScale.maximum=100
    self.sliderTubeScale.value=5
    self.sliderTubeScale.enabled = False
    tubeSizeGrid.addWidget(label,2,0)
    tubeSizeGrid.addWidget(self.sliderTubeScale,2,1)
    self.sliderTubeScale.connect('valueChanged(double)', \
         self.onTubeScaleChanged)

#    
# ============Apply button=================
#
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Apply the visualization."
    self.applyButton.enabled = False
    self.applyButton.setPalette(qt.QPalette(qt.QColor(128,255,128)))
    self.parent.layout().addWidget(self.applyButton) 
    self.applyButton.connect('clicked()', \
         self.onApply)
#
# ============Clear button=================
#
    self.clearButton = qt.QPushButton("Clear")
    self.clearButton.toolTip = "Clear objects rendered in 3D view windows."
    self.clearButton.enabled = False
    self.clearButton.setPalette(qt.QPalette(qt.QColor(255,128,128)))
    self.parent.layout().addWidget(self.clearButton)
    self.clearButton.connect('clicked()', \
        self.onClear)


# ===========Finally, Add vertical spacer================
    self.layout.addStretch(2)
示例#22
0
    def __init__(self, parent, MODULE=None):
        """ Init function.
        """

        self.MODULE = MODULE

        #--------------------
        # Call parent init.
        #--------------------
        super(XnatFolderMaker, self).__init__()

        #--------------------
        # Adjust window features.
        #--------------------
        self.setWindowTitle("Add Folder to Xnat")
        self.setWindowModality(2)

        #--------------------
        # Hide the widget initially.
        #--------------------
        self.hide()

        #--------------------
        # Set fixed width.
        #--------------------
        self.setFixedWidth(500)
        self.setFixedHeight(250)

        #--------------------
        # Make the xsiList for experiment
        # creation.
        #--------------------
        self.xsiList = qt.QComboBox()
        self.xsiList.addItems([
            key
            for key, value in self.MODULE.GLOBALS.XNAT_XSI_TYPES.iteritems()
        ])

        #--------------------
        # Displayable wigets.
        #--------------------
        self.levelLabels = {}
        self.nameLabels = {}
        self.lineEdits = {}
        self.errorLines = {}
        self.levelLayouts = {}
        self.labelLineStacks = {}
        self.levelRows = {}

        #--------------------
        # Make the buttons:
        # create, cancel,
        # etc.
        #--------------------
        self.addButton = qt.QPushButton()
        self.addButton.setText("Add")
        self.addButton.setEnabled(False)
        self.cancelButton = qt.QPushButton()
        self.cancelButton.setText("Cancel")
        buttonRow = qt.QDialogButtonBox()
        buttonRow.addButton(self.cancelButton, 2)
        buttonRow.addButton(self.addButton, 0)

        #-------------------
        # Create the keys in the displayable widgets.
        #--------------------
        self.addFolderXnatLevels = ['projects', 'subjects', 'experiments']
        for level in self.addFolderXnatLevels:

            #
            # Labels (name and level)
            #
            self.levelLabels[level] = qt.QLabel(self)
            self.levelLabels[level].setFixedHeight(25)
            self.nameLabels[level] = qt.QLabel(self)
            self.nameLabels[level].setFixedHeight(25)

            #
            # Line edits
            #
            self.lineEdits[level] = qt.QLineEdit(self)
            self.lineEdits[level].installEventFilter(self)
            self.lineEdits[level].setFixedHeight(25)

            #
            # Error lines
            #
            self.errorLines[level] = qt.QLabel(self)
            self.errorLines[level].setTextFormat(1)
            self.errorLines[level].setFixedHeight(25)

            #
            # Make the label-line stacks, adjusting
            # for 'experiments' as necessary.
            #
            self.labelLineStacks[level] = qt.QStackedLayout()
            if level == 'experiments':
                experimentRow = qt.QHBoxLayout()
                experimentRow.addWidget(self.xsiList)
                experimentRow.addWidget(self.lineEdits[level])
                experimentWidget = qt.QWidget()
                experimentWidget.setLayout(experimentRow)
                self.labelLineStacks[level].addWidget(experimentWidget)
            else:
                self.labelLineStacks[level].addWidget(self.nameLabels[level])
                self.labelLineStacks[level].addWidget(self.lineEdits[level])

            #
            # make row widgets
            #
            self.levelRows[level] = qt.QWidget(self)
            levelRowLayout = qt.QGridLayout()
            levelRowLayout.addWidget(self.levelLabels[level], 0, 0)
            levelRowLayout.addLayout(self.labelLineStacks[level], 0, 1)
            levelRowLayout.addWidget(self.errorLines[level], 1, 1)
            self.levelRows[level].setLayout(levelRowLayout)

        #--------------------
        # Connect button click events.
        #--------------------
        buttonRow.connect('clicked(QAbstractButton*)', self.onAddButtonClicked)

        #--------------------
        # Make the mainLayout and add all widgets.
        #--------------------
        self.mainLayout = qt.QVBoxLayout()
        for level in self.addFolderXnatLevels:
            self.mainLayout.addWidget(self.levelRows[level])
        self.mainLayout.addStretch()
        self.mainLayout.addWidget(buttonRow)
        self.setLayout(self.mainLayout)
示例#23
0
    def setup(self):

        w = qt.QWidget()
        layout = qt.QGridLayout()
        w.setLayout(layout)
        self.layout.addWidget(w)
        w.show()
        self.layout = layout

        ####################IMPORTAR VOLUMEN 4D#################################################3

        ### Se crea la sección para cargar el volumen 4D en una pestaña desplegable
        importDataCollapsibleButton = ctk.ctkCollapsibleButton()
        importDataCollapsibleButton.text = "Import Data"
        self.layout.addWidget(importDataCollapsibleButton)

        importDataFormLayout = qt.QFormLayout(importDataCollapsibleButton)

        #### Crear desplegable para seleccionar dirección del volumen
        self.__fDialog = ctk.ctkDirectoryButton()
        self.__fDialog.caption = 'Input directory'
        importDataFormLayout.addRow('Input directory:', self.__fDialog)

        ###Selector de volumen donde se guardara el volumen de la direccion
        self.outputSelector = slicer.qMRMLNodeComboBox()
        self.outputSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.outputSelector.addEnabled = True  # Se habilita la posibildad al usuario de crear un nuevo nodo con este widget
        self.outputSelector.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        self.outputSelector.setMRMLScene(slicer.mrmlScene)
        importDataFormLayout.addRow("Output node:", self.outputSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.outputSelector, 'setMRMLScene(vtkMRMLScene*)')

        ### Parametros avanzados

        self.__dicomTag = qt.QLineEdit()
        self.__dicomTag.text = 'NA'
        importDataFormLayout.addRow('Frame identifying DICOM tag:',
                                    self.__dicomTag)

        self.__veLabel = qt.QLineEdit()
        self.__veLabel.text = 'na'
        importDataFormLayout.addRow('Frame identifying units:', self.__veLabel)

        self.__veInitial = qt.QDoubleSpinBox()
        self.__veInitial.value = 0
        importDataFormLayout.addRow('Initial value:', self.__veInitial)

        self.__veStep = qt.QDoubleSpinBox()
        self.__veStep.value = 1
        importDataFormLayout.addRow('Step:', self.__veStep)

        self.__te = qt.QDoubleSpinBox()
        self.__te.value = 1
        importDataFormLayout.addRow('EchoTime:', self.__te)

        self.__tr = qt.QDoubleSpinBox()
        self.__tr.value = 1
        importDataFormLayout.addRow('RepetitionTime:', self.__tr)

        self.__fa = qt.QDoubleSpinBox()
        self.__fa.value = 1
        importDataFormLayout.addRow('FlipAngle:', self.__fa)

        # Botón de importar

        self.buttonImport = qt.QPushButton("Import")
        self.buttonImport.toolTip = "Run the algorithm."
        ##self.buttonImport.enabled = True
        importDataFormLayout.addRow("                                       ",
                                    self.buttonImport)

        self.buttonImport.connect('clicked(bool)', self.importFunction)
        ##self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

        ###########################REGISTRO##########################################

        ##    # Se crea una sección de parámetros en una pestaña desplegable
        registerCollapsibleButton = ctk.ctkCollapsibleButton()
        registerCollapsibleButton.text = "Register"
        self.layout.addWidget(registerCollapsibleButton)

        registerFormLayout = qt.QFormLayout(registerCollapsibleButton)

        #Se crea una ventana desplegable en la cual se ingresa el volumen 4D de
        #entrada que se quiere registrar, este volumen debe ser de tipo
        #"vtkMRMLMultiVolumeNode", además si se tienen varios multivolumenes cargados
        #se puede elegir entre ellos el que se desea registrar
        self.inputRegSelector = slicer.qMRMLNodeComboBox()
        self.inputRegSelector.nodeTypes = ["vtkMRMLMultiVolumeNode"]
        self.inputRegSelector.selectNodeUponCreation = True
        self.inputRegSelector.addEnabled = True
        self.inputRegSelector.removeEnabled = False
        self.inputRegSelector.noneEnabled = True
        self.inputRegSelector.showHidden = False
        self.inputRegSelector.showChildNodeTypes = False
        self.inputRegSelector.setMRMLScene(slicer.mrmlScene)
        self.inputRegSelector.setToolTip("Pick the input to the algorithm.")
        registerFormLayout.addRow("Volumen 4D: ", self.inputRegSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.inputRegSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        ###Selector de volumen donde se guardara el volumen de la direccion
        self.outputRegSelector = slicer.qMRMLNodeComboBox()
        self.outputRegSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.outputRegSelector.addEnabled = True  # Se habilita la posibildad al usuario de crear un nuevo nodo con este widget
        self.outputRegSelector.removeEnabled = False  # Se le quita al usuario la posibilidad de eliminar el nodo seleccionado en ese momento
        self.outputRegSelector.setMRMLScene(slicer.mrmlScene)
        registerFormLayout.addRow("Output node:", self.outputRegSelector)
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.outputRegSelector,
                            'setMRMLScene(vtkMRMLScene*)')

        # Botón de Registro
        #Este botón solo se activa si el multivolumen ha sido seleccionado en la
        #ventana desplegable de Volumen 4D. Al presionarlo, el algoritmo
        #realiza el registro de los diferentes volumenes en el volumen 4D
        self.applyButton = qt.QPushButton("Registrar")
        self.applyButton.toolTip = "Run the algorithm."
        self.applyButton.enabled = True
        registerFormLayout.addRow(self.applyButton)

        # Conexiones necesarias para el algoritmo
        #entrega al algoritmo el volumen 4D de entrada y conecta la función del botón
        #con la ejecución del registro
        self.applyButton.connect('clicked(bool)', self.registrarButton)
    def setup(self):
        # Instantiate and connect widgets ...

        # Collapsible button
        autoCTCollapsibleButton = ctk.ctkCollapsibleButton()
        autoCTCollapsibleButton.text = "Collapsible button for CT auto-segmentation"
        self.layout.addWidget(autoCTCollapsibleButton)

        # Layout within the sample collapsible button
        autoCTFormLayout = qt.QFormLayout(autoCTCollapsibleButton)

        #Load CT image button
        loadCTButton = qt.QPushButton("Load CT image and add ROI annotation")
        loadCTButton.toolTip = "Click to load CT image and then annotate tumor location"
        autoCTFormLayout.addWidget(loadCTButton)
        loadCTButton.connect('clicked(bool)', self.onloadCTButtonClicked)

        #Number of nodule to operate
        #        loadCTnodulelabel = qt.QInputDialog()
        #        loadCTnodulelabel.toolTip = "The tumor number to segment"
        #        loadCTnodulelabel.getInt(self, "Get integer","Percentage:")
        #        autoCTFormLayout.addWidget(loadCTnodulelabel)
        #        loadCTnodulelabel.connect('clicked(bool)', self.onloadCTnodulelabelButtonClicked)
        #

        ####Ajust sigma value for CT##########
        #########################################
        #        nodulelabel1 = qt.QLabel()
        #        nodulelabel1.setText("Enter the nodule number to process")
        #        autoCTFormLayout.addWidget(nodulelabel1)
        #        noduleSlider1 = qt.QInputDialog()
        #        noduleSlider1.toolTip = "Slide to change nodule number"
        #        autoCTFormLayout.addWidget(noduleSlider1)
        ##        noduleSlider1.setMinimum(0.0)
        ##        noduleSlider1.setMaximum(20)
        ##        noduleSlider1.setValue(1.0)
        ##        noduleSlider.setTickPosition(qt.QSlider.TicksBelow)
        ##        noduleSlider.setTickInterval(1)
        #        self.noduleSlider1 = noduleSlider1

        nodulelabel = qt.QLabel()
        nodulelabel.setText("Enter the nodule number to segment (1-10)")
        autoCTFormLayout.addWidget(nodulelabel)
        noduleSlider = qt.QSlider(qt.Qt.Horizontal)
        noduleSlider.toolTip = "Slide to change nodule number"
        noduleSlider.setMinimum(0.0)
        noduleSlider.setMaximum(20)
        noduleSlider.setValue(1.0)
        noduleSlider.setTickPosition(qt.QSlider.TicksBelow)
        noduleSlider.setTickInterval(1)
        self.noduleSlider = noduleSlider
        #label for ticks
        nodulevalues = qt.QGridLayout()
        r1 = qt.QLabel("0")
        r2 = qt.QLabel("2")
        r3 = qt.QLabel("4")
        r4 = qt.QLabel("6")
        r5 = qt.QLabel("8")
        nodulevalues.addWidget(noduleSlider, 0, 0, 1, 5)
        nodulevalues.addWidget(r1, 1, 0, 1, 1)
        nodulevalues.addWidget(r2, 1, 1, 1, 1)
        nodulevalues.addWidget(r3, 1, 2, 1, 1)
        nodulevalues.addWidget(r4, 1, 3, 1, 1)
        nodulevalues.addWidget(r5, 1, 4, 1, 1)
        #Apply the changes
        #        noduleApplyButton = qt.QPushButton("Apply")
        #        noduleApplyButton.toolTip = "Click to apply new sigma value"
        #        nodulevalues.addWidget(noduleApplyButton, 0,5,2,1)
        #        noduleApplyButton.connect('clicked(bool)', self.changesApplyButtonClicked)
        autoCTFormLayout.addRow(nodulevalues)
        # Add vertical spacer
        self.layout.addStretch(1)

        #########Button for CT segmentation and 3D generation##########
        ###########################################################
        CTSeg3D_tumorButton = qt.QPushButton("CTSeg3D_tumor")
        CTSeg3D_tumorButton.toolTip = "Click to generate auto segmentation and 3D view of tumor"
        autoCTFormLayout.addWidget(CTSeg3D_tumorButton)
        CTSeg3D_tumorButton.connect('clicked(bool)',
                                    self.onCTSeg3D_tumorButtonClicked)

        ####Ajust multipler value for CT (fine tuning)##########
        #########################################

        #        CTfinetuneButton = qt.QPushButton("Fine_tuning")
        #        CTfinetuneButton.toolTip = "Fine tuning segmentation for better ROI"
        #        autoCTFormLayout.addWidget(CTfinetuneButton)
        #        CTfinetuneButton.connect('clicked(bool)', self.onCTfinetuneButtonClicked)

        ############## Button segment out lung ############
        CTSeg3D_lungButton = qt.QPushButton("CTSeg3D_lung")
        CTSeg3D_lungButton.toolTip = "Click to generate auto segmentation and 3D view of lung"
        autoCTFormLayout.addWidget(CTSeg3D_lungButton)
        CTSeg3D_lungButton.connect('clicked(bool)',
                                   self.onCTSeg3D_lungButtonClicked)

        self.image_loaded = False
示例#25
0
    def setup(self):
        #
        # Input frame
        #
        self.__inputFrame = ctk.ctkCollapsibleButton()
        self.__inputFrame.text = "Input"
        self.__inputFrame.collapsed = 0
        inputFrameLayout = qt.QFormLayout(self.__inputFrame)

        self.layout.addWidget(self.__inputFrame)

        # Active report node
        label = qt.QLabel('Report: ')
        self.__reportSelector = slicer.qMRMLNodeComboBox()
        self.__reportSelector.nodeTypes = ['vtkMRMLReportingReportNode']
        self.__reportSelector.setMRMLScene(slicer.mrmlScene)
        self.__reportSelector.addEnabled = 1
        self.__reportSelector.removeEnabled = 0

        inputFrameLayout.addRow(label, self.__reportSelector)

        self.__reportSelector.connect('mrmlSceneChanged(vtkMRMLScene*)',
                                      self.onMRMLSceneChanged)
        self.__reportSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                      self.onReportNodeChanged)

        # Volume being annotated (only one is allowed for the report)
        label = qt.QLabel(
            'NOTE: Only volumes loaded from DICOM can be annotated!')
        inputFrameLayout.addRow(label)
        label = qt.QLabel('Annotated volume: ')
        self.__volumeSelector = slicer.qMRMLNodeComboBox()
        self.__volumeSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        # only allow volumes with the attribute DICOM.instanceUIDs
        self.__volumeSelector.addAttribute('vtkMRMLScalarVolumeNode',
                                           'DICOM.instanceUIDs')
        self.__volumeSelector.setMRMLScene(slicer.mrmlScene)
        self.__volumeSelector.addEnabled = False

        inputFrameLayout.addRow(label, self.__volumeSelector)

        self.__volumeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                      self.onAnnotatedVolumeNodeChanged)
        self.__volumeSelector.connect('mrmlSceneChanged(vtkMRMLScene*)',
                                      self.onMRMLSceneChanged)

        #
        # Annotation frame -- vocabulary-based description of what is
        # being annotated/marked up in this report
        #
        self.__annotationsFrame = ctk.ctkCollapsibleButton()
        self.__annotationsFrame.text = "Annotation"
        self.__annotationsFrame.collapsed = 0
        annotationsFrameLayout = qt.QFormLayout(self.__annotationsFrame)

        self.layout.addWidget(self.__annotationsFrame)

        self.__defaultColorNode = self.__logic.GetDefaultColorNode()

        self.__toolsColor = EditColor(self.__annotationsFrame,
                                      colorNode=self.__defaultColorNode)

        #
        # Markup frame -- summary of all the markup elements contained in the
        # report
        #
        self.__markupFrame = ctk.ctkCollapsibleButton()
        self.__markupFrame.text = "Markup"
        self.__markupFrame.collapsed = 0
        markupFrameLayout = qt.QFormLayout(self.__markupFrame)

        self.layout.addWidget(self.__markupFrame)

        # Add a flag to switch between different tree view models
        self.__useNewTreeView = 1

        # Add the tree widget
        if self.__useNewTreeView == 1:
            self.__markupTreeView = slicer.modulewidget.qMRMLReportingTreeView(
            )
            self.__markupTreeView.sceneModelType = "DisplayableHierarchy"
        else:
            self.__markupTreeView = slicer.qMRMLTreeView()
            self.__markupTreeView.sceneModelType = "Displayable"
        self.__markupTreeView.setMRMLScene(self.__logic.GetMRMLScene())

        self.__markupSliceText = qt.QLabel()
        markupFrameLayout.addRow(self.__markupSliceText)
        markupFrameLayout.addRow(self.__markupTreeView)

        # Editor frame
        self.__editorFrame = ctk.ctkCollapsibleButton()
        self.__editorFrame.text = 'Segmentation'
        self.__editorFrame.collapsed = 0
        editorFrameLayout = qt.QFormLayout(self.__editorFrame)

        label = qt.QLabel('Segmentation volume: ')
        self.__segmentationSelector = slicer.qMRMLNodeComboBox()
        self.__segmentationSelector.nodeTypes = ['vtkMRMLScalarVolumeNode']
        self.__segmentationSelector.setMRMLScene(slicer.mrmlScene)
        self.__segmentationSelector.addEnabled = 1
        self.__segmentationSelector.noneEnabled = 1
        self.__segmentationSelector.removeEnabled = 0
        self.__segmentationSelector.showHidden = 0
        self.__segmentationSelector.showChildNodeTypes = 0
        self.__segmentationSelector.selectNodeUponCreation = 1
        self.__segmentationSelector.addAttribute('vtkMRMLScalarVolumeNode',
                                                 'LabelMap', 1)

        editorFrameLayout.addRow(label, self.__segmentationSelector)

        editorWidgetParent = slicer.qMRMLWidget()
        editorWidgetParent.setLayout(qt.QVBoxLayout())
        editorWidgetParent.setMRMLScene(slicer.mrmlScene)
        self.__editorWidget = EditorWidget(parent=editorWidgetParent,
                                           showVolumesFrame=False)
        self.__editorWidget.setup()
        self.__editorWidget.toolsColor.frame.setVisible(False)
        editorFrameLayout.addRow(editorWidgetParent)

        markupFrameLayout.addRow(self.__editorFrame)

        self.__segmentationSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                            self.onSegmentationNodeChanged)
        self.__segmentationSelector.connect('mrmlSceneChanged(vtkMRMLScene*)',
                                            self.onMRMLSceneChanged)

        # IO frame
        self.__ioFrame = ctk.ctkCollapsibleButton()
        self.__ioFrame.text = 'Import/Export'
        self.__ioFrame.collapsed = 1
        ioFrameLayout = qt.QGridLayout(self.__ioFrame)

        self.layout.addWidget(self.__ioFrame)

        # Buttons to save/load report using AIM XML serialization
        label = qt.QLabel('Export folder')
        self.__exportFolderPicker = ctk.ctkDirectoryButton()
        exportButton = qt.QPushButton('Export')
        exportButton.connect('clicked()', self.onReportExport)
        ioFrameLayout.addWidget(label, 0, 0)
        ioFrameLayout.addWidget(self.__exportFolderPicker, 0, 1)
        ioFrameLayout.addWidget(exportButton, 0, 2)

        label = qt.QLabel('AIM file to import')
        self.__aimFilePicker = qt.QPushButton('N/A')
        self.__aimFilePicker.connect('clicked()', self.onSelectAIMFile)
        button = qt.QPushButton('Import')
        button.connect('clicked()', self.onReportImport)
        ioFrameLayout.addWidget(label, 1, 0)
        ioFrameLayout.addWidget(self.__aimFilePicker, 1, 1)
        ioFrameLayout.addWidget(button, 1, 2)
        self.__importAIMFile = None

        self.__reportSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                      self.updateWidgets)
        self.__volumeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                      self.updateWidgets)
        self.updateWidgets()

        self.layout.addStretch(1)

        self.__editorParameterNode = self.editUtil.getParameterNode()

        self.__editorParameterNode.AddObserver(
            vtk.vtkCommand.ModifiedEvent, self.onEditorParameterNodeChanged)
    def createUserInterface(self):

        self.__layout = self.__parent.createUserInterface()
        ''' 
      # Input fiducials node selector
      #self.inputFiducialsNodeSelector = slicer.qMRMLNodeComboBox()
      self.inputFiducialsNodeSelector.toolTip = "Select a fiducial to define an insertion point for a screw."
      self.inputFiducialsNodeSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "")
      self.inputFiducialsNodeSelector.addEnabled = False
      self.inputFiducialsNodeSelector.removeEnabled = False
      self.inputFiducialsNodeSelector.setMRMLScene( slicer.mrmlScene ) 
      self.inputFiducialsNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.fidChanged)
      self.__layout.addRow("Select Insertion Point:", self.inputFiducialsNodeSelector)
      self.fid = self.inputFiducialsNodeSelector.currentNode()
      self.sliceChange()
      '''
        '''
      # Input model selector
      self.inputScrewSelector = ctk.ctkComboBox()
      self.inputScrewSelector.toolTip = "Select a screw to insert."
      screwList = ['Select a screw','475x30', '475x35', '475x45', '550x30', '550x40', '550x45', '625x35', '625x40', '625x45', '625x50', '700x35', '700x40', '700x45', '700x50']
      self.inputScrewSelector.addItems(screwList)
      self.connect(self.inputScrewSelector, PythonQt.QtCore.SIGNAL('activated(QString)'), self.combo_chosen)
      self.__layout.addRow("Choose Screw:", self.inputScrewSelector)
      
       vText = qt.QLabel("1st Instrumented Level:")
       iText = qt.QLabel("# to Instrument:")
       aText = qt.QLabel("Approach Direction:")
       self.vSelector = qt.QComboBox()
       self.vSelector.setMaximumWidth(120)
       self.levels = ("C1","C2","C3","C4","C5","C6","C7","T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12","L1", "L2", "L3", "L4", "L5","S1")
       self.vSelector.addItems(self.levels)
       self.iSelector = qt.QComboBox()
       self.iSelector.setMaximumWidth(120)
       self.iSelector.addItems(['1','2','3','4','5','6','7','8','9','10','11','12'])
       self.aSelector = qt.QComboBox()
       self.aSelector.setMaximumWidth(120)
       self.aSelector.addItems(['Posterior','Anterior','Left','Right'])
       blank = qt.QLabel("  ")
       blank.setMaximumWidth(30)
       #self.__layout.addWidget(vText)
       #self.__layout.addWidget(self.vSelector)
       #self.__layout.addWidget(iText)
       #self.__layout.addWidget(self.iSelector)
    
       self.vertebraeGridBox = qt.QGridLayout()
       self.vertebraeGridBox.addWidget(vText,0,0)
       self.vertebraeGridBox.addWidget(self.vSelector,1,0)
       self.vertebraeGridBox.addWidget(blank,0,1)
       self.vertebraeGridBox.addWidget(iText,0,2)
       self.vertebraeGridBox.addWidget(blank,1,1)
       self.vertebraeGridBox.addWidget(self.iSelector,1,2)
       self.vertebraeGridBox.addWidget(blank,0,3)
       self.vertebraeGridBox.addWidget(aText,0,4)
       self.vertebraeGridBox.addWidget(blank,1,3)
       self.vertebraeGridBox.addWidget(self.aSelector,1,4)
       self.__layout.addRow(self.vertebraeGridBox)
      '''

        self.fiducial = ctk.ctkComboBox()
        self.fiducial.toolTip = "Select an insertion site."
        self.fiducial.addItems(self.fiduciallist)
        self.connect(self.fiducial,
                     PythonQt.QtCore.SIGNAL('activated(QString)'),
                     self.fiducial_chosen)

        #self.screwGridLayout.addWidget(self.fiducial,0,0)

        self.__layout.addRow("Insertion Site:", self.fiducial)
        self.__fiducial = ''
        measuredText1 = qt.QLabel("     Measured:")
        measuredText2 = qt.QLabel("     Measured:")
        lengthText = qt.QLabel("Screw Length:   ")
        widthText = qt.QLabel("Screw Width:    ")
        self.length = ctk.ctkComboBox()
        self.length.toolTip = "Select a screw to insert."
        screwList = ['Select a length (mm)', '475', '550', '625', '700']
        self.length.addItems(screwList)
        self.connect(self.length, PythonQt.QtCore.SIGNAL('activated(QString)'),
                     self.length_chosen)
        self.lengthMeasure = qt.QLineEdit()
        #self.__layout.addRow("Screw Length:", self.length)
        #self.__layout.addRow("Measured Pedicle Length:", self.lengthMeasure)
        self.__length = ''

        self.QHBox1 = qt.QHBoxLayout()
        self.QHBox1.addWidget(lengthText)
        self.QHBox1.addWidget(self.length)
        self.QHBox1.addWidget(measuredText1)
        self.QHBox1.addWidget(self.lengthMeasure)
        self.__layout.addRow(self.QHBox1)

        self.diameter = ctk.ctkComboBox()
        self.diameter.toolTip = "Select a screw to insert."
        screwList = ['Select a diameter (mm)', '30', '35', '45', '50']
        self.diameter.addItems(screwList)
        self.widthMeasure = qt.QLineEdit()
        self.connect(self.diameter,
                     PythonQt.QtCore.SIGNAL('activated(QString)'),
                     self.diameter_chosen)
        #self.__layout.addRow("Screw Diameter:", self.diameter)
        #self.__layout.addRow("Measured Pedicle Width:", self.widthMeasure)
        self.__diameter = ''

        self.QHBox2 = qt.QHBoxLayout()
        self.QHBox2.addWidget(widthText)
        self.QHBox2.addWidget(self.diameter)
        self.QHBox2.addWidget(measuredText2)
        self.QHBox2.addWidget(self.widthMeasure)
        self.__layout.addRow(self.QHBox2)

        # Load Screw Button
        self.__loadScrewButton = qt.QPushButton("Load Screw")
        self.__loadScrewButton.enabled = False
        #self.__layout.addWidget(self.__loadScrewButton)
        self.__loadScrewButton.connect('clicked(bool)', self.loadScrew)

        # Delete Screw Button
        self.__delScrewButton = qt.QPushButton("Delete Screw")
        self.__delScrewButton.enabled = True
        #self.__layout.addWidget(self.__delScrewButton)
        self.__delScrewButton.connect('clicked(bool)', self.delScrew)

        self.QHBox3 = qt.QHBoxLayout()
        self.QHBox3.addWidget(self.__loadScrewButton)
        self.QHBox3.addWidget(self.__delScrewButton)
        self.__layout.addRow(self.QHBox3)

        # Input model node selector
        self.modelNodeSelector = slicer.qMRMLNodeComboBox()
        self.modelNodeSelector.toolTip = "."
        self.modelNodeSelector.nodeTypes = (("vtkMRMLModelNode"), "")
        self.modelNodeSelector.addEnabled = False
        self.modelNodeSelector.removeEnabled = False
        self.modelNodeSelector.setMRMLScene(slicer.mrmlScene)
        #self.__layout.addRow("Current Screws:", self.modelNodeSelector)

        self.transformGrid = qt.QGridLayout()
        vText = qt.QLabel("Vertical Adjustment:")
        iText = qt.QLabel("Horizontal Adjustment:")
        self.transformGrid.addWidget(vText, 0, 0)
        self.transformGrid.addWidget(iText, 0, 2)

        self.b = ctk.ctkDoubleSpinBox()
        self.b.minimum = -45
        self.b.maximum = 45

        self.transformGrid.addWidget(self.b, 1, 0)

        # Transform Sliders
        self.transformSlider1 = ctk.ctkDoubleSlider()
        self.transformSlider1.minimum = -45
        self.transformSlider1.maximum = 45
        self.transformSlider1.connect('valueChanged(double)',
                                      self.transformSlider1ValueChanged)
        self.transformSlider1.connect('valueChanged(double)', self.b.setValue)
        self.transformSlider1.setMinimumHeight(120)
        #self.__layout.addRow("Rotate IS", self.transformSlider1)
        self.transformGrid.addWidget(self.transformSlider1, 1, 1)

        self.b.connect('valueChanged(double)', self.transformSlider1.setValue)

        # Transform Sliders
        self.transformSlider2 = ctk.ctkSliderWidget()
        self.transformSlider2.minimum = -45
        self.transformSlider2.maximum = 45
        self.transformSlider2.connect('valueChanged(double)',
                                      self.transformSlider2ValueChanged)
        self.transformSlider2.setMaximumWidth(200)
        #self.__layout.addRow("Rotate LR", self.transformSlider2)
        self.transformGrid.addWidget(self.transformSlider2, 1, 2)
        self.__layout.addRow(self.transformGrid)
        '''
      # Transfors Sliders
      self.transformSlider3 = ctk.ctkSliderWidget()
      self.transformSlider3.minimum = 0
      self.transformSlider3.maximum = 100
      self.transformSlider3.connect('valueChanged(double)', self.transformSlider3ValueChanged)
      self.__layout.addRow("Drive Screw", self.transformSlider3)
      '''
        # Insert Screw Button
        self.insertScrewButton = qt.QPushButton("Insert Screw")
        self.insertScrewButton.enabled = True
        #self.__layout.addWidget(self.__loadScrewButton)
        self.insertScrewButton.connect('clicked(bool)', self.insertScrew)

        # Backout Screw Button
        self.backoutScrewButton = qt.QPushButton("Backout Screw")
        self.backoutScrewButton.enabled = False
        #self.__layout.addWidget(self.__delScrewButton)
        self.backoutScrewButton.connect('clicked(bool)', self.backoutScrew)

        # Reset Screw Button
        self.resetScrewButton = qt.QPushButton("Reset Screw")
        self.resetScrewButton.enabled = True
        #self.__layout.addWidget(self.__delScrewButton)
        self.resetScrewButton.connect('clicked(bool)', self.resetScrew)

        self.QHBox4 = qt.QHBoxLayout()
        self.QHBox4.addWidget(self.insertScrewButton)
        self.QHBox4.addWidget(self.backoutScrewButton)
        self.QHBox4.addWidget(self.resetScrewButton)
        self.__layout.addRow(self.QHBox4)

        # Hide ROI Details
        #measurementsTable = ctk.ctkCollapsibleButton()
        #measurementsTable.text = "Measurements Table"
        #self.__layout.addWidget(measurementsTable)
        #measurementsTable.collapsed = True
        '''
      self.view = qt.QTableView()
      self.model = qt.QStandardItemModel()
      self.view.setModel(self.model)
      item = qt.QStandardItem()
      item.setText("item")
      self.model.setItem(0,0,item)
      self.__layout.addWidget(self.view)
      '''
        #self.__layout.addRow(self.screwGridLayout)
        # self.updateWidgetFromParameters(self.parameterNode())
        qt.QTimer.singleShot(0, self.killButton)
        self.currentFidIndex = self.fiducial.currentIndex
        self.currentFidLabel = self.fiducial.currentText
        self.fidNode.GetNthFiducialPosition(self.currentFidIndex, self.coords)
        logging.debug("Coords: {0}".format(self.coords))
        self.updateMeasurements()
        self.cameraFocus(self.coords)
示例#27
0
    def open(self):

        # main dialog
        self.dialog = qt.QDialog(slicer.util.mainWindow())
        self.dialog.setWindowTitle('Export to DICOM Study')
        self.dialog.setWindowModality(1)
        layout = qt.QVBoxLayout()
        self.dialog.setLayout(layout)

        self.studyLabel = qt.QLabel('Attach Data to Study: %s' % self.studyUID)
        layout.addWidget(self.studyLabel)

        # scene or volume option
        self.selectFrame = qt.QFrame(self.dialog)
        layout.addWidget(self.selectFrame)
        self.selectLayout = qt.QGridLayout()
        self.selectFrame.setLayout(self.selectLayout)
        self.exportScene = qt.QRadioButton("Export Entire Scene",
                                           self.selectFrame)
        self.exportScene.setToolTip(
            "Create a Slicer Data Bundle in a DICOM Private Creator\n(Only compatible with Slicer)"
        )
        self.exportVolume = qt.QRadioButton("Export Selected Volume",
                                            self.selectFrame)
        self.exportVolume.setToolTip(
            "Create a compatible DICOM series of slice images")
        self.exportVolume.checked = True
        self.selectLayout.addWidget(self.exportScene, 0, 0)
        self.selectLayout.addWidget(self.exportVolume, 1, 0)
        self.exportScene.connect('toggled(bool)', self.onExportRadio)
        self.exportVolume.connect('toggled(bool)', self.onExportRadio)

        # select volume
        self.volumeSelector = slicer.qMRMLNodeComboBox(self.dialog)
        self.volumeSelector.nodeTypes = ("vtkMRMLScalarVolumeNode", "")
        self.volumeSelector.selectNodeUponCreation = False
        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.setToolTip("Pick the label map to edit")
        self.selectLayout.addWidget(self.volumeSelector, 1, 1)

        # DICOM Parameters
        self.dicomFrame = qt.QFrame(self.dialog)
        self.dicomFormLayout = qt.QFormLayout()
        self.dicomFrame.setLayout(self.dicomFormLayout)
        self.dicomEntries = {}
        exporter = DICOMLib.DICOMExporter(self.studyUID)
        self.dicomParameters = exporter.parametersFromStudy()
        self.dicomParameters['Series Description'] = '3D Slicer Export'
        for label in self.dicomParameters.keys():
            self.dicomEntries[label] = qt.QLineEdit()
            self.dicomEntries[label].text = self.dicomParameters[label]
            self.dicomFormLayout.addRow(label + ": ", self.dicomEntries[label])
        layout.addWidget(self.dicomFrame)

        # button box
        bbox = qt.QDialogButtonBox(self.dialog)
        bbox.addButton(bbox.Ok)
        bbox.addButton(bbox.Cancel)
        bbox.connect('accepted()', self.onOk)
        bbox.connect('rejected()', self.onCancel)
        layout.addWidget(bbox)

        self.dialog.open()
示例#28
0
    def setup(self):
        # Instantiate and connect widgets

        #
        # 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 = "PlusRemote Reload"
        reloadFormLayout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        # reload and test button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadAndTestButton = qt.QPushButton("Reload and Test")
        self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
        #reloadFormLayout.addWidget(self.reloadAndTestButton)
        #self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

        # Module requires openigtlinkremote
        try:
            slicer.modules.openigtlinkremote
        except:
            self.errorLabel = qt.QLabel(
                "Could not find OpenIGTLink Remote module")
            self.layout.addWidget(self.errorLabel)
            return

        # IGTLink Connector
        connectorCollapsibleButton = ctk.ctkCollapsibleButton()
        connectorCollapsibleButton.text = "OpenIGTLink Connector"
        self.layout.addWidget(connectorCollapsibleButton)
        connectorLayout = qt.QFormLayout(connectorCollapsibleButton)

        self.linkInputSelector = slicer.qMRMLNodeComboBox()
        self.linkInputSelector.nodeTypes = (("vtkMRMLIGTLConnectorNode"), "")
        self.linkInputSelector.selectNodeUponCreation = True
        self.linkInputSelector.addEnabled = False
        self.linkInputSelector.removeEnabled = True
        self.linkInputSelector.noneEnabled = False
        self.linkInputSelector.showHidden = False
        self.linkInputSelector.showChildNodeTypes = False
        self.linkInputSelector.setMRMLScene(slicer.mrmlScene)
        self.linkInputSelector.setToolTip("Pick connector node")
        connectorLayout.addRow("OpenIGTLinkConnector: ",
                               self.linkInputSelector)

        # Recording
        recordingCollapsibleButton = ctk.ctkCollapsibleButton()
        recordingCollapsibleButton.text = "Recording"
        self.layout.addWidget(recordingCollapsibleButton)
        recordingLayout = qt.QFormLayout(recordingCollapsibleButton)

        self.captureIDBox = qt.QLineEdit()
        recordingLayout.addRow("Capture Device ID: ", self.captureIDBox)

        self.fileNameBox = qt.QLineEdit()
        recordingLayout.addRow("Filename: ", self.fileNameBox)

        # Move to the same row, use grid layout

        recordingControlsLayout = qt.QGridLayout()
        self.startRecordingButton = qt.QPushButton("Start Recording")
        recordingControlsLayout.addWidget(self.startRecordingButton, 0, 0)
        self.stopRecordingButton = qt.QPushButton("Stop Recording")
        recordingControlsLayout.addWidget(self.stopRecordingButton, 0, 1)
        recordingLayout.addRow(recordingControlsLayout)

        # Reconstruction
        reconstructionCollapsibleButton = ctk.ctkCollapsibleButton()
        reconstructionCollapsibleButton.text = "Reconstruction"
        self.layout.addWidget(reconstructionCollapsibleButton)
        reconstructionLayout = qt.QFormLayout(reconstructionCollapsibleButton)

        liveReconstructionLayout = qt.QGridLayout()
        self.startReconstuctionButton = qt.QPushButton(
            "Start Live Reconstruction")
        liveReconstructionLayout.addWidget(self.startReconstuctionButton, 0, 0)
        self.stopReconstructionButton = qt.QPushButton(
            "Stop Live Reconstruction")
        liveReconstructionLayout.addWidget(self.stopReconstructionButton, 0, 1)
        reconstructionLayout.addRow(liveReconstructionLayout)

        self.reconstructVolumeButton = qt.QPushButton(
            "Reconstruct Recorded Volume")
        reconstructionLayout.addRow(self.reconstructVolumeButton)

        # Transform Update
        transformUpdateCollapsibleButton = ctk.ctkCollapsibleButton()
        transformUpdateCollapsibleButton.text = "Transform Update"
        self.layout.addWidget(transformUpdateCollapsibleButton)
        transformUpdateLayout = qt.QFormLayout(
            transformUpdateCollapsibleButton)

        self.transformUpdateInputSelector = slicer.qMRMLNodeComboBox()
        self.transformUpdateInputSelector.nodeTypes = ((
            "vtkMRMLLinearTransformNode"), "")
        self.transformUpdateInputSelector.selectNodeUponCreation = True
        self.transformUpdateInputSelector.addEnabled = False
        self.transformUpdateInputSelector.removeEnabled = True
        self.transformUpdateInputSelector.renameEnabled = True
        self.transformUpdateInputSelector.noneEnabled = False
        self.transformUpdateInputSelector.showHidden = False
        self.transformUpdateInputSelector.showChildNodeTypes = False
        self.transformUpdateInputSelector.setMRMLScene(slicer.mrmlScene)
        self.transformUpdateInputSelector.setToolTip("Pick transform node")
        transformUpdateLayout.addRow("Transform node: ",
                                     self.transformUpdateInputSelector)

        self.updateTransformButton = qt.QPushButton("Update")
        transformUpdateLayout.addRow(self.updateTransformButton)

        self.configFileNameBox = qt.QLineEdit()
        transformUpdateLayout.addRow("Filename: ", self.configFileNameBox)

        self.saveTransformButton = qt.QPushButton("Save Config")
        transformUpdateLayout.addRow(self.saveTransformButton)

        replyUpdateCollapsibleButton = ctk.ctkCollapsibleButton()
        replyUpdateCollapsibleButton.text = "Reply"
        self.layout.addWidget(replyUpdateCollapsibleButton)
        replyLayout = qt.QFormLayout(replyUpdateCollapsibleButton)

        self.replyBox = qt.QPlainTextEdit()
        self.replyBox.setReadOnly(True)
        replyLayout.addRow(self.replyBox)

        # connections
        self.startRecordingButton.connect('clicked(bool)',
                                          self.onStartRecording)
        self.stopRecordingButton.connect('clicked(bool)', self.onStopRecording)

        self.startReconstuctionButton.connect('clicked(bool)',
                                              self.onStartReconstruction)
        self.stopReconstructionButton.connect('clicked(bool)',
                                              self.onStopReconstruction)
        self.reconstructVolumeButton.connect('clicked(bool)',
                                             self.onReconstVolume)

        self.updateTransformButton.connect('clicked(bool)',
                                           self.onUpdateTransform)
        self.saveTransformButton.connect('clicked(bool)', self.onSaveTransform)

        self.layout.addStretch(1)
    def createUserInterface(self):

        self.__layout = self.__parent.createUserInterface()

        vText = qt.QLabel("1st Instrumented Level:")
        iText = qt.QLabel("# to Instrument:")
        aText = qt.QLabel("Approach Direction:")
        self.vSelector = qt.QComboBox()
        self.vSelector.setMaximumWidth(120)
        self.levels = ("C1", "C2", "C3", "C4", "C5", "C6", "C7", "T1", "T2",
                       "T3", "T4", "T5", "T6", "T7", "T8", "T9", "T10", "T11",
                       "T12", "L1", "L2", "L3", "L4", "L5", "S1")
        self.vSelector.addItems(self.levels)
        self.iSelector = qt.QComboBox()
        self.iSelector.setMaximumWidth(120)
        self.iSelector.addItems(
            ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'])
        self.aSelector = qt.QComboBox()
        self.aSelector.setMaximumWidth(120)
        self.aSelector.addItems(['Posterior', 'Anterior', 'Left', 'Right'])
        blank = qt.QLabel("  ")
        blank.setMaximumWidth(30)
        #self.__layout.addWidget(vText)
        #self.__layout.addWidget(self.vSelector)
        #self.__layout.addWidget(iText)
        #self.__layout.addWidget(self.iSelector)

        self.vertebraeGridBox = qt.QGridLayout()
        self.vertebraeGridBox.addWidget(vText, 0, 0)
        self.vertebraeGridBox.addWidget(self.vSelector, 1, 0)
        self.vertebraeGridBox.addWidget(blank, 0, 1)
        self.vertebraeGridBox.addWidget(iText, 0, 2)
        self.vertebraeGridBox.addWidget(blank, 1, 1)
        self.vertebraeGridBox.addWidget(self.iSelector, 1, 2)
        self.vertebraeGridBox.addWidget(blank, 0, 3)
        self.vertebraeGridBox.addWidget(aText, 0, 4)
        self.vertebraeGridBox.addWidget(blank, 1, 3)
        self.vertebraeGridBox.addWidget(self.aSelector, 1, 4)
        self.__layout.addRow(self.vertebraeGridBox)

        #self.__layout.addRow("Starting Instrumented Vertebra:",self.vSelector)
        #self.__layout.addRow("Number of Vertebrae to Instrument:",self.iSelector)

        # Hide ROI Details
        roiCollapsibleButton = ctk.ctkCollapsibleButton()
        #roiCollapsibleButton.setMaximumWidth(320)
        roiCollapsibleButton.text = "ROI Details"
        self.__layout.addWidget(roiCollapsibleButton)
        roiCollapsibleButton.collapsed = True

        # Layout
        roiLayout = qt.QFormLayout(roiCollapsibleButton)

        #label for ROI selector
        roiLabel = qt.QLabel('Select ROI:')
        font = roiLabel.font
        font.setBold(True)
        roiLabel.setFont(font)

        #creates combobox and populates it with all vtkMRMLAnnotationROINodes in the scene
        self.__roiSelector = slicer.qMRMLNodeComboBox()
        self.__roiSelector.nodeTypes = ['vtkMRMLAnnotationROINode']
        self.__roiSelector.toolTip = "ROI defining the structure of interest"
        self.__roiSelector.setMRMLScene(slicer.mrmlScene)
        self.__roiSelector.addEnabled = 1

        #add label + combobox
        roiLayout.addRow(roiLabel, self.__roiSelector)

        self.__roiSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                   self.onROIChanged)

        # the ROI parameters
        # GroupBox to hold ROI Widget
        voiGroupBox = qt.QGroupBox()
        voiGroupBox.setTitle('Define VOI')
        roiLayout.addRow(voiGroupBox)

        # create form layout for GroupBox
        voiGroupBoxLayout = qt.QFormLayout(voiGroupBox)

        # create ROI Widget and add it to the form layout of the GroupBox
        self.__roiWidget = PythonQt.qSlicerAnnotationsModuleWidgets.qMRMLAnnotationROIWidget(
        )
        voiGroupBoxLayout.addRow(self.__roiWidget)

        # # Hide VR Details
        # vrCollapsibleButton = ctk.ctkCollapsibleButton()
        # #roiCollapsibleButton.setMaximumWidth(320)
        # vrCollapsibleButton.text = "Rendering Details"
        # self.__layout.addWidget(vrCollapsibleButton)
        # vrCollapsibleButton.collapsed = True

        # # Layout
        # vrLayout = qt.QFormLayout(vrCollapsibleButton)

        # # the ROI parameters
        # # GroupBox to hold ROI Widget
        # vrGroupBox = qt.QGroupBox()
        # vrGroupBox.setTitle( 'Define Rendering' )
        # vrLayout.addRow( vrGroupBox )

        # # create form layout for GroupBox
        # vrGroupBoxLayout = qt.QFormLayout( vrGroupBox )

        # # create ROI Widget and add it to the form layout of the GroupBox
        # self.__vrWidget = PythonQt.qSlicerVolumeRenderingModuleWidgets.qSlicerPresetComboBox()
        # #self.__vrWidget = PythonQt.qSlicerVolumeRenderingModuleWidgets.qMRMLVolumePropertyNodeWidget()
        # vrGroupBoxLayout.addRow( self.__vrWidget )

        # # initialize VR
        # self.__vrLogic = slicer.modules.volumerendering.logic()

        # self.updateWidgetFromParameters(self.parameterNode())
        qt.QTimer.singleShot(0, self.killButton)
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)
    self.dbpath = None
    self.dbcsvpath = None
    self.flirttemplate = '/usr/share/fsl/5.0/data/standard/MNI152_T1_2mm_brain.nii.gz' 

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

    self.clearButton              = qt.QPushButton("Clear Scene")
    self.clearButton.toolTip      = "Clear all the volumes and models in 3D views"
    self.clearButton.name         = "AdniDemonsDatabase Clear"
    reloadFormLayout.addWidget(self.clearButton)
    self.clearButton.connect('clicked()', self.onClear)

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

    # Get the test methods create a button for each of them
    testklsdir = dir(AdniDemonsDatabaseTest)
    # reload and test button
    # (use this during development, but remove it when delivering your module to users)
    # reload and run specific tests
    # scenarios                     = ('All', 'Model', 'Volume', 'SceneView_Simple', 'SceneView_Complex')
    scenarios = [n for n in testklsdir if n.startswith('test_')]

    for scenario in scenarios:
        button                      = qt.QPushButton("Reload and Test %s" % scenario)
        button.toolTip              = "Reload this module and then run the self test on %s." % scenario
        reloadFormLayout.addWidget(button)
        button.connect('clicked()', lambda s = scenario: self.onReloadAndTest(scenario = s))

    #
    # Test All Button
    #
    self.testallButton             = qt.QPushButton("Test All")
    self.testallButton.toolTip     = "Run all the logic tests"
    self.testallButton.name        = "Reload & Test All"
    reloadFormLayout.addWidget(self.testallButton)
    self.testallButton.connect('clicked()', self.onTestAll)

    #
    # Settings Area
    #
    settingCollapsibleButton      = ctk.ctkCollapsibleButton()
    settingCollapsibleButton.text = "ADNI Demons Database Generation"
    self.layout.addWidget(settingCollapsibleButton)
    settingFormLayout             = qt.QGridLayout(settingCollapsibleButton) 

    #
    # DB Directory Selection Button
    #
    self.dbButton                 = qt.QPushButton("Set ADNI Database Directory")
    self.dbButton.toolTip         = "Set ANDI Database Directory"
    self.dbButton.enabled         = True 
    settingFormLayout.addWidget(self.dbButton, 0, 0)
    self.dblabel = qt.QLabel(self.dbpath if self.dbpath != None else 'Empty')
    settingFormLayout.addWidget(self.dblabel, 0, 1)

    #
    # DB csv file Selection Button
    #
    csvbtntxt = "Set *.csv File For DB Record"
    self.dbcsvpath = '' if self.dbButton.text.find(':') == -1 else join(self.dbpath, 'db.csv')
    self.csvButton                 = qt.QPushButton(csvbtntxt if len(self.dbcsvpath) == 0 else csvbtntxt + ' : ' + self.dbcsvpath)
    self.csvButton.toolTip         = "Set ANDI Database csv file path, which can be downloaded in the data collection"
    self.csvButton.enabled         = True 
    settingFormLayout.addWidget(self.csvButton, 1, 0)
    self.csvlabel = qt.QLabel(self.dbcsvpath if self.dbcsvpath != None and self.dbpath != None else 'Empty')
    settingFormLayout.addWidget(self.csvlabel, 1, 1)

    #
    # Flirt Template Selection Button
    #
    self.betflirt_templatebutton                 = qt.QPushButton("Select Flirt Template")
    self.betflirt_templatebutton.toolTip         = "Select Flirt Template"
    self.betflirt_templatebutton.enabled         = True 
    settingFormLayout.addWidget(self.betflirt_templatebutton, 2, 0)
    self.flirtlabel = qt.QLabel(self.flirttemplate if self.flirttemplate != None else 'Empty')
    settingFormLayout.addWidget(self.flirtlabel, 2, 1)

    # They should be connected afterwards their initiation
    self.dbButton.connect('clicked(bool)', lambda: self.onFileButton('db'))
    self.csvButton.connect('clicked(bool)', lambda: self.onFileButton('csv'))
    self.betflirt_templatebutton.connect('clicked(bool)', lambda: self.onFileButton('flirt'))

    #
    # Bet & Flirt Threshold
    #
    self.betflirtspin = qt.QDoubleSpinBox()
    self.betflirtspin.setRange(0.0, 1.0)
    self.betflirtspin.setSingleStep(0.05)
    self.betflirtspin.setValue(0.2)
    settingFormLayout.addWidget(qt.QLabel("Bet Threashold"), 3 ,0)
    settingFormLayout.addWidget(self.betflirtspin, 3, 1)

    #
    # Checkbox for Bet & Flirt
    #
    self.betflirtcheck = qt.QCheckBox("Run Bet + Flirt")
    self.betflirtcheck.setToolTip("Only the image IDs listed in the csv file will be processed. flirted images will be saved in path/to/db/flirted")
    self.betflirtcheck.checked = 0
    settingFormLayout.addWidget(self.betflirtcheck, 4, 0)

    #
    # Checkbox for Running Demons Registration 
    #
    self.demonscheck = qt.QCheckBox("Run Demons")
    self.demonscheck.setToolTip("Only the image IDs listed in the csv file will be processed. Image sources will only be retrieved from path/to/db/flirted")
    self.demonscheck.checked = 0
    self.demonscheck.enabled = True 
    settingFormLayout.addWidget(self.demonscheck, 4, 1)

    #
    # Interval Selection : 6m | 12m
    #
    self.intervalCombo = qt.QComboBox()
    self.intervalCombo.addItem("6 Month")
    self.intervalCombo.addItem("12 Month")
    settingFormLayout.addWidget(qt.QLabel("Extract Interval"), 5 ,0)
    settingFormLayout.addWidget(self.intervalCombo, 5, 1)

    #
    # Sequence Label Selection: All, Stable: NL, Stable: MCI, Stable: AD, NL2MCI, MCI2AD 
    #
    self.seqCombo = qt.QComboBox()
    self.seqCombo.enabled = False 
    self.seqCombo.addItems(["All", "Stable: NL", "Stable: MCI", "Stable: AD", "NL2MCI", "MCI2AD"])
    settingFormLayout.addWidget(qt.QLabel("Sequence Type"), 6 ,0)
    settingFormLayout.addWidget(self.seqCombo, 6, 1)

    actionCollapsibleButton       = ctk.ctkCollapsibleButton()
    actionCollapsibleButton.text  = "Database Generation Actions"
    self.layout.addWidget(actionCollapsibleButton)
    actionFormLayout              = qt.QFormLayout(actionCollapsibleButton) 

    #
    # Generate Database csv
    #
    self.dbgenButton = qt.QPushButton("Generate Database Sequence csv")
    self.dbgenButton.toolTip = "Generate A csv with required fields by merging the image collection csv and the dxsum. To make this button functional, pls make sure R language is installed in your system and \'RScript\' is in the $PATH. \'dbgen.csv\' will be generated in the database directory"
    self.dbgenButton.enabled = False 
    actionFormLayout.addRow(self.dbgenButton)
    self.dbgenButton.connect('clicked(bool)', self.onDbgenButton)

    #
    # Validate Database see if all the images exist 
    #
    self.validateDbButton = qt.QPushButton("Validate Database")
    self.validateDbButton.toolTip = "Check if all the image ids in the dbgen.csv exist in the data folder"
    self.validateDbButton.enabled = False 
    actionFormLayout.addRow(self.validateDbButton)
    self.validateDbButton.connect('clicked(bool)', self.onValidateDbButton)

    #
    # Validate Bet and Flirt see if all the images were flirted and betted successfully 
    #
    self.validateBetAndFlirtButton = qt.QPushButton("Validate Bet&Flirt")
    self.validateBetAndFlirtButton.toolTip = "Check if all the image were successfully betted and flirted"
    self.validateBetAndFlirtButton.enabled = True 
    actionFormLayout.addRow(self.validateBetAndFlirtButton)
    self.validateBetAndFlirtButton.connect('clicked(bool)', self.onValidateBetAndFlirtButton)

    #
    # Apply Button
    #
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the algorithm."
    self.applyButton.enabled = True 
    actionFormLayout.addRow(self.applyButton)
    self.applyButton.connect('clicked(bool)', self.onApplyButton)

    #
    # Flirt Clear Button
    #
    self.clearFlirtButton = qt.QPushButton("Clear Flirt")
    self.clearFlirtButton.toolTip = "Clear the files created by flirt."
    self.clearFlirtButton.enabled = False
    actionFormLayout.addRow(self.clearFlirtButton)
    self.clearFlirtButton.connect('clicked(bool)', self.onFlirtClear)

    #
    # Evaluate DB Area
    #
    evaluateCollapsibleButton      = ctk.ctkCollapsibleButton()
    evaluateCollapsibleButton.text = "Evaluate DB"
    self.layout.addWidget(evaluateCollapsibleButton)
    evaluateFormLayout             = qt.QGridLayout(evaluateCollapsibleButton) 

    #
    # MAP setting
    #
    self.kmapspin = qt.QDoubleSpinBox()
    self.kmapspin.setRange(0.0, 10.0)
    self.kmapspin.setSingleStep(1.0)
    self.kmapspin.setValue(5)
    evaluateFormLayout.addWidget(qt.QLabel("K value for MAP"), 1 ,0)
    evaluateFormLayout.addWidget(self.kmapspin, 1, 1)

    #
    # DB Evaluate Button
    #
    self.evaluateDbButton = qt.QPushButton('Evaluate DB')
    self.evaluateDbButton.toolTip = "Set ANDI Database Directory. Assume in this folder, you have already generated a database with ADNI Demons DB Creator"
    self.evaluateDbButton.enabled = True 
    evaluateFormLayout.addWidget(self.evaluateDbButton, 2, 0)
    self.evaluateDbButton.connect('clicked(bool)', self.onEvaluateDbButton)

    #
    # Regenerate DB matrix check
    #
    self.regenMatCheck = qt.QCheckBox('Regenerate Dissimilarity Matrix')
    self.regenMatCheck.checked = False
    self.regenMatCheck.enabled = True
    evaluateFormLayout.addWidget(self.regenMatCheck, 2, 1)

    #
    # Testing Ariea
    #
    statusCollapsibleButton = ctk.ctkCollapsibleButton()
    statusCollapsibleButton.text  = "Console"
    self.layout.addWidget(statusCollapsibleButton)
    self.statusLayout              = qt.QFormLayout(statusCollapsibleButton) 

    #
    # Show a Return Message
    #
    self.returnMsg = qt.QLabel("Ready") 
    self.statusLayout.addRow(self.returnMsg)

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