def setup(self):
    # # Instantiate and connect widgets
    
    connectorCollapsibleButton = ctk.ctkCollapsibleButton()
    connectorCollapsibleButton.text = "Leap Motion Controller Connector"
    self.layout.addWidget(connectorCollapsibleButton)    
    connectorLayout = qt.QFormLayout(connectorCollapsibleButton)    

    # Start and stop listening
    self.startButton = qt.QPushButton("Start Recording")
    connectorLayout.addRow(self.startButton)
    
    self.stopButton = qt.QPushButton("Stop Recording")
    connectorLayout.addRow(self.stopButton)
    
    #Buttons, boxes
    self.schemeBrowserSelector = ctk.ctkComboBox()
    self.schemeBrowserSelector.addItem('%s. Pointer Browser' % 0)
    self.schemeBrowserSelector.addItem('%s. Spinner Browser' % 1)
    connectorLayout.addRow("Browser Type:", self.schemeBrowserSelector)
    
    self.browserButton = qt.QPushButton("Open Browser")
    connectorLayout.addRow(self.browserButton)  
    
    self.updateButton = qt.QPushButton("Update")
    connectorLayout.addRow(self.updateButton)    
    
    # Debug box
    self.textBox = qt.QTextEdit()
    self.layout.addWidget(self.textBox)
    
    
    self.layout.addStretch(1)
    
    #Connections
    self.startButton.connect('clicked(bool)', self.onStart)
    self.stopButton.connect('clicked(bool)', self.onStop)
    self.browserButton.connect('clicked(bool)', self.onOpenBrowser)

    self.updateButton.connect('clicked(bool)', self.onUpdate)   
    
    # Instantiate timer
    self.timer = qt.QTimer()
    
    # Instantiate Leap Motion device
    self.controller = LeapLib.Leap.Controller()
    self.controller.enable_gesture(LeapLib.Leap.Gesture.TYPE_CIRCLE);
    self.controller.enable_gesture(LeapLib.Leap.Gesture.TYPE_KEY_TAP);
    self.controller.enable_gesture(LeapLib.Leap.Gesture.TYPE_SCREEN_TAP);
    self.controller.enable_gesture(LeapLib.Leap.Gesture.TYPE_SWIPE);    
  def setup(self):
    QCLib.genericPanel.setup(self)

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

    parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

    #
    # ROI volume selector
    #
    self.ROISelector = slicer.qMRMLNodeComboBox()
    # self.ROISelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    # self.ROISelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 1 )
    self.ROISelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.ROISelector.selectNodeUponCreation = False
    self.ROISelector.addEnabled = False
    self.ROISelector.removeEnabled = False
    self.ROISelector.noneEnabled = True
    self.ROISelector.showHidden = False
    self.ROISelector.showChildNodeTypes = False
    self.ROISelector.setMRMLScene( slicer.mrmlScene )
    self.ROISelector.setToolTip( "ROI for analysis" )
    parametersFormLayout.addRow("Rectangular ROI: ", self.ROISelector)

    #object type selector
    self.typeSel = ctk.ctkComboBox()
    types=["Edge","Line (Not Implemented)","Point","Droedge (Not Implemented)"]
    self.typeSel.addItems(types)
    self.typeSel.editable=False
    self.typeSel.setCurrentIndex(0)
    parametersFormLayout.addRow("Type of Analysis", self.typeSel)

    # #edge algorithm selector
    # self.algorithmSel = ctk.ctkComboBox()
    # algorithms=["Canny","Sobel","Zero Crossing Based"]
    # self.algorithmSel.addItems(algorithms)
    # #self.algorithmSel.enabled=False
    # self.algorithmSel.editable=False
    # self.algorithmSel.setCurrentIndex(0)
    # parametersFormLayout.addRow("Edge Detection Algorithm", self.algorithmSel)

    # #distance transform algorithm selector
    # self.distalgorithmSel = ctk.ctkComboBox()
    # distalgorithms=["Maurer Signed","Approximate Signed","Danielsson Signed","VTK Unsigned"]
    # self.distalgorithmSel.addItems(distalgorithms)
    # self.distalgorithmSel.editable=False
    # self.distalgorithmSel.setCurrentIndex(0)
    # parametersFormLayout.addRow("Distance Transform Algorithm", self.distalgorithmSel)

    #save intermediate
    self.intermediateCB = ctk.ctkCheckBox()
    self.intermediateCB.setChecked(False)
    parametersFormLayout.addRow("Save intermediate images and curves",self.intermediateCB)

    #options
    optionsCollapsibleButton = ctk.ctkCollapsibleButton()
    optionsCollapsibleButton.text = "Options"
    self.framelayout.addWidget(optionsCollapsibleButton)

    optionsFormLayout = qt.QFormLayout(optionsCollapsibleButton)

    self.edgeoptionframe=qt.QFrame()
    self.edgeoptionframe.enabled=False
    edgeoptionFormLayout = qt.QFormLayout(self.edgeoptionframe)
    self.pointoptionframe=qt.QFrame()
    self.pointoptionframe.enabled=False
    pointoptionFormLayout = qt.QFormLayout(self.pointoptionframe)

    optionsCollapsibleButton.layout().addWidget(self.edgeoptionframe)
    optionsCollapsibleButton.layout().addWidget(self.pointoptionframe)
    
    #edge options
    
    #symmetrize LSF
    self.symmetrizeCB = ctk.ctkCheckBox()
    self.symmetrizeCB.setChecked(True)
    self.symmetrizeCB.enabled=True
    edgeoptionFormLayout.addRow("Symmetrize LSF",self.symmetrizeCB)

    #point options

    #detection point criteria
    self.pointCB = ctk.ctkCheckBox()
    self.pointCB.setChecked(True)
    self.pointCB.enabled=True
    pointoptionFormLayout.addRow("Point object BRIGHTER than background",self.pointCB)

    # self.objradSB=ctk.ctkDoubleSpinBox()
    # self.objradSB.minimum=0
    # self.objradSB.maximum=10
    # self.objradSB.value=0.5
    # pointoptionFormLayout.addRow("Radius of object point(mm)",self.objradSB)

    self.setOptions()

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

    arrayValCollapsibleButton = ctk.ctkCollapsibleButton()
    arrayValCollapsibleButton.text = "Array Value"
    self.framelayout.addWidget(arrayValCollapsibleButton)

    # Layout within the dummy collapsible button
    arrayValFormLayout = qt.QFormLayout(arrayValCollapsibleButton)

    #
    # Array selector
    #
    self.ArraySelector = slicer.qMRMLNodeComboBox()
    self.ArraySelector.nodeTypes = ( ("vtkMRMLDoubleArrayNode"), "" )
    self.ArraySelector.selectNodeUponCreation = False
    self.ArraySelector.addEnabled = False
    self.ArraySelector.removeEnabled = False
    self.ArraySelector.noneEnabled = True
    self.ArraySelector.showHidden = False
    self.ArraySelector.showChildNodeTypes = False
    self.ArraySelector.setMRMLScene( slicer.mrmlScene )
    self.ArraySelector.setToolTip( "Array for analysis" )
    arrayValFormLayout.addRow("Function to interpolate: ", self.ArraySelector)

    self.abscissaSB=ctk.ctkDoubleSpinBox()
    self.abscissaSB.minimum=0
    self.abscissaSB.maximum=0
    self.abscissaSB.value=0
    self.abscissaSB.enabled=False
    arrayValFormLayout.addRow("Abscissa Value: ",self.abscissaSB)

    self.ordinateVal=qt.QLineEdit()
    self.ordinateVal.readOnly=True
    self.ordinateVal.text=""
    arrayValFormLayout.addRow("Value: ",self.ordinateVal)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.masterSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.ROISelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.ArraySelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelectArray)
    self.abscissaSB.connect("valueChanged(double)",self.getOrdinate)
    self.typeSel.connect("currentIndexChanged(int)",self.setOptions)
    # Add vertical spacer
    self.layout.addStretch(1)
    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)
Esempio n. 4
0
  def createUserInterface( self ):

    self.__layout = self.__parent.createUserInterface()

    self.fid = Helper.Screws()

    self.fids = len(self.fid)
    self.fidlist = ["Choose the puncture site"]
    self.dimeter = []
    self.length = []
    self.PSA = []
    self.PTA = []
    self.CZn = 0
    self.CXn = 0
    self.CLstep = 0
    self.CData = 3.5
    self.cScrew = ""
    self.csNo=0
    self.screwList=[]
    self.manulYn=0

    # logging.debug("fids: {0}".format(self.fids))
    # zheli
    pNode = self.parameterNode()
    print(pNode)
    self.vertebra = str(pNode.GetParameter('vertebra'))
    # logging.debug("椎体")
    logging.debug(self.vertebra)
    self.inst_length = str(pNode.GetParameter('inst_length'))
    self.sides = str(pNode.GetParameter('sides'))

    for i in range(self.levels.index(self.vertebra), self.levels.index(self.vertebra) + int(self.inst_length)):
      # if self.vertebra == "部位":
      #   self.fidlist.append(self.vertebra + "_" + str(i))
      # else:
      if self.sides == "L&R":
        self.fidlist.append(self.levels[i] + "_" + "L")
        self.fidlist.append(self.levels[i] + "_" + "R")
      else:
        self.fidlist.append(self.levels[i] + "_" + self.sides)
    for i, v in enumerate(self.fidlist[1:]):
      Helper.addFid(self.fid[i][1],1,"Isthmus-{}".format(i),v,"pink")

    logging.debug("Fidlist: {0}".format(self.fidlist))
    logging.debug(self.fidlist[0])
    sText = qt.QLabel('Choose the puncture site:')
    self.sSelector = ctk.ctkComboBox()
    self.sSelector.toolTip = "Choose the puncture site"
    # screwList = ['选择穿刺部位', "cS1","cS2","cS3","cS4","cS5"]
    self.sSelector.addItems(self.fidlist)
    self.connect(self.sSelector, PythonQt.QtCore.SIGNAL('activated(QString)'), self.sSelector_chosen)
    self.__sSelector=''

    dText = qt.QLabel('Select screw diameter:')
    self.dSelector = ctk.ctkComboBox()
    self.dSelector.toolTip = "Select screw diameter"
    dimList = ['Select screw diametermm', "2.5","3","3.5","4","4.5","5","5.5","6","6.5","7","7.5","8"]
    self.dSelector.addItems(dimList)
    self.connect(self.dSelector, PythonQt.QtCore.SIGNAL('activated(QString)'), self.dSelector_chosen)
    self.__dSelector=''

    self.QHBox0 = qt.QHBoxLayout()
    self.QHBox0.addWidget(sText)
    self.QHBox0.addWidget(self.sSelector)
    self.QHBox0.addWidget(self.dSelector)
    self.__layout.addRow(self.QHBox0)

    self.manButton = qt.QPushButton("Update")
    self.okButton = qt.QPushButton("OK")
    self.resetButton = qt.QPushButton("Reset")

    self.QHBox9 = qt.QHBoxLayout()
    self.QHBox9.addWidget(self.manButton)
    self.QHBox9.addWidget(self.okButton)
    self.QHBox9.addWidget(self.resetButton)
    # self.QHBox9.addWidget(self.okButton)
    self.__layout.addRow(self.QHBox9)

    self.manButton.connect('clicked(bool)', self.manualUp)
    self.okButton.connect('clicked(bool)', self.okShow)
    self.resetButton.connect('clicked(bool)', self.reset)

    # self.screwsTable.setHorizontalHeaderLabels(horizontalHeaders)
    self.items = []


    # Camera Transform Sliders

    transCam = ctk.ctkCollapsibleButton()
    transCam.text = "Shift Camera Position"
    transCam.collapsed = True
    self.__layout.addWidget(transCam)
    # transCam.collapsed = True
    camLayout = qt.QFormLayout(transCam)
    a = PythonQt.qMRMLWidgets.qMRMLTransformSliders()
    a.setMRMLTransformNode(slicer.mrmlScene.GetNodeByID('vtkMRMLLinearTransformNode4'))
    camLayout.addRow(a)

    qt.QTimer.singleShot(0, self.killButton)
  def setup(self):
    QCLib.genericPanel.setup(self)

    #
    # Output Volume collapsible button
    #
    self.output = ctk.ctkCollapsibleButton(self.frame)
    self.output.setText("Output Volume")
    self.output.enabled=False
    self.framelayout.addWidget(self.output)

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

    #
    # output volume selector
    #
    self.outputSelector = slicer.qMRMLNodeComboBox()
    #self.outputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.outputSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    #self.outputSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 1 )
    self.outputSelector.selectNodeUponCreation = True
    self.outputSelector.addEnabled = True
    self.outputSelector.removeEnabled = True
    self.outputSelector.noneEnabled = False
    self.outputSelector.renameEnabled = True
    self.outputSelector.showHidden = False
    self.outputSelector.showChildNodeTypes = False
    self.outputSelector.setMRMLScene(slicer.mrmlScene)
    self.outputSelector.setToolTip("Output Volume")
    #self.outputSelector.enabled=False
    parametersFormLayout.addRow("Output Volume: ", self.outputSelector)

    #algorithm selector
    self.algorithmSel = ctk.ctkComboBox()
    algorithms=["Canny","Sobel","Zero Crossing Based"]
    self.algorithmSel.addItems(algorithms)
    #self.algorithmSel.enabled=False
    self.algorithmSel.editable=False
    self.algorithmSel.setCurrentIndex(0)
    parametersFormLayout.addRow("Edge Detection Algorithm", self.algorithmSel)

    self.optionFrame=qt.QFrame()
    self.optionFrame.setLayout(qt.QFormLayout())
    self.optionFrame.enabled=False
    self.framelayout.addWidget(self.optionFrame)

    #variance slider
    self.varianceSlider = ctk.ctkSliderWidget()
    self.varianceSlider.minimum = 0
    self.varianceSlider.maximum = 100
    self.varianceSlider.setValue(2)
    #self.varianceSlider.enabled = False
    self.varianceSlider.setToolTip("Variance of the pre gaussian filter")
    self.optionFrame.layout().addRow("Variance", self.varianceSlider)

    #threshold slider
    self.threshSlider=ctk.ctkRangeWidget()
    self.threshSlider.minimum = 0
    self.threshSlider.maximum = 0
    self.threshSlider.setValues(0,0)
    #self.threshSlider.enabled=False
    self.threshSlider.setToolTip("Threshold of output volume")
    self.optionFrame.layout().addRow("Threshold", self.threshSlider)

    #
    # Apply Button
    #
    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.toolTip = "Run the edge detection algotrithm"
    self.applyButton.enabled = False
    self.framelayout.addWidget(self.applyButton)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.masterSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelectInput)
    self.masterSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelectOutput)
    self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.algorithmSel.connect("currentIndexChanged(int)", self.setOptionEnabled)

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

    count = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLSliceCompositeNode')
    for n in xrange(count):
      compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLSliceCompositeNode')
      compNode.SetForegroundOpacity(1.0)
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        # -------------------------------------------------------------------------------------
        self.modelList = list()
        self.fieldList = list()
        self.ROIList = list()
        self.ROIDict = dict()  # Key = Name of ROI
                               # Value = Dictionary of Fields (key = Name of Field
                               #                               Value = dictionary of shapes
                               #                                             key = name of shapes
                               #                                             value = Statistics store()

        self.logic = MeshStatisticsLogic()
        # ------------------------------------------------------------------------------------
        #                                    SHAPES INPUT
        # ------------------------------------------------------------------------------------
        self.inputComboBox = slicer.qMRMLCheckableNodeComboBox()
        self.inputComboBox.nodeTypes = ['vtkMRMLModelNode']
        self.inputComboBox.setMRMLScene(slicer.mrmlScene)
        inputLayout = qt.QFormLayout()
        inputLayout.addRow(' Models: ', self.inputComboBox)
        self.layout.addLayout(inputLayout)

        self.inputComboBox.connect('checkedNodesChanged()', self.onInputComboBoxCheckedNodesChanged)
        # ------------------------------------------------------------------------------------
        #                                  ROI TABLE
        # ------------------------------------------------------------------------------------
        self.ROIComboBox = ctk.ctkComboBox()
        self.ROIComboBox.adjustSize()
        self.ROICheckBox = qt.QCheckBox('All')
        ROILayout = qt.QHBoxLayout()
        ROILayout_0 = qt.QFormLayout()
        ROILayout_0.addRow(' Region considered: ', self.ROIComboBox)
        ROILayout.addLayout(ROILayout_0)
        ROILayout.addWidget(self.ROICheckBox)

        self.layout.addLayout(ROILayout)
        self.ROICheckBox.connect('stateChanged(int)', self.onROICheckBoxStateChanged)
        # ------------------------------------------------------------------------------------
        #                                  FIELD TABLE
        # ------------------------------------------------------------------------------------
        self.tableField = qt.QTableWidget()
        self.tableField.setColumnCount(2)
        self.tableField.setMinimumHeight(250)
        self.tableField.setHorizontalHeaderLabels([' ', ' Field Name '])
        self.tableField.setColumnWidth(0, 20)
        self.tableField.setColumnWidth(1, 260)
        self.tableField.setSizePolicy(qt.QSizePolicy().Expanding, qt.QSizePolicy().Expanding)
        
        label = qt.QLabel(' Select a Field to compute statistics on:')
        self.fieldLayout = qt.QVBoxLayout()
        self.fieldLayout.addWidget(label)
        self.fieldLayout.addWidget(self.tableField)
        self.layout.addLayout(self.fieldLayout)
        # ------------------------------------------------------------------------------------
        #                                    RUN
        # ------------------------------------------------------------------------------------
        self.runButton = qt.QPushButton(' Run ')
        self.runButton.enabled = False
        roiLayout = qt.QHBoxLayout()
        roiLayout.addWidget(self.runButton)
        self.layout.addLayout(roiLayout)
        self.runButton.connect('clicked()', self.onRunButton)
        # ------------------------------------------------------------------------------------
        #                          Statistics Table - Export
        # ------------------------------------------------------------------------------------
        self.tabROI = qt.QTabWidget()
        self.tabROI.setTabPosition(0)
        self.tabROI.adjustSize()
        # ---------------------------- Directory - Export Button -----------------------------
        self.directoryExport = ctk.ctkDirectoryButton()
        self.exportCheckBox = qt.QCheckBox('Separate Files')
        self.exportCheckBox.setChecked(True)
        self.exportButton = qt.QPushButton(' Export ')
        self.exportButton.enabled = True
        self.exportPointValueCheckBox = qt.QCheckBox('Export Value on Each Point')
        
        self.exportLayout = qt.QVBoxLayout()
        self.directoryAndExportLayout = qt.QHBoxLayout()
        self.directoryAndExportLayout.addWidget(self.directoryExport)
        self.directoryAndExportLayout.addWidget(self.exportCheckBox)
        self.directoryAndExportLayout.addWidget(self.exportPointValueCheckBox)
        self.exportButtonsLayout = qt.QHBoxLayout()
        self.exportButtonsLayout.addWidget(self.exportButton)
        

        self.exportLayout.addLayout(self.directoryAndExportLayout)
        self.exportLayout.addLayout(self.exportButtonsLayout)
        
        self.layout.addStretch(1)
        self.logic.updateInterface(self.tableField, self.ROIComboBox, self.ROIList, self.modelList, self.layout)

        # ------------------------------------------------------------------------------------
        #                                   OBSERVERS
        # ------------------------------------------------------------------------------------
        def onCloseScene(obj, event):
            # initialize Parameters
            globals()['MeshStatistics'] = slicer.util.reloadScriptedModule('MeshStatistics')
        slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent, onCloseScene)
Esempio n. 7
0
    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."
      #fiducialList = ['Select an insertion landmark', self.fiduciallist]
      #print self.fiduciallist
      #print fiducialList
      #self.fiducial.addItem("Select an insertion site, no really")
      #self.fiducial.addItem("Select an insertion site.")
      self.fiducial.addItems(self.fiduciallist)
      self.connect(self.fiducial, PythonQt.QtCore.SIGNAL('activated(QString)'), self.fiducial_chosen)
      #self.connect(self.fiducial, PythonQt.QtCore.SIGNAL('activated(QString)'), self.fidChanged)
      
      #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)
      print self.coords
      self.updateMeasurements()
      self.cameraFocus(self.coords)
  def setup(self):
    QCLib.genericPanel.setup(self)

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

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

    #
    # ROI volume selector
    #
    self.ROISelector = slicer.qMRMLNodeComboBox()
    # self.ROISelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
    # self.ROISelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 1 )
    self.ROISelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"]
    self.ROISelector.selectNodeUponCreation = False
    self.ROISelector.addEnabled = False
    self.ROISelector.removeEnabled = False
    self.ROISelector.noneEnabled = True
    self.ROISelector.showHidden = False
    self.ROISelector.showChildNodeTypes = False
    self.ROISelector.setMRMLScene( slicer.mrmlScene )
    self.ROISelector.setToolTip( "ROI for analysis" )
    parametersFormLayout.addRow("Rectangular ROI: ", self.ROISelector)

    #object type selector
    self.typeSel = ctk.ctkComboBox()
    types=["Wedge","Ramp"]
    self.typeSel.addItems(types)
    self.typeSel.editable=False
    self.typeSel.setCurrentIndex(0)
    parametersFormLayout.addRow("Type of Analysis", self.typeSel)

    self.angleSB=ctk.ctkDoubleSpinBox()
    self.angleSB.minimum=0
    self.angleSB.maximum=360
    self.angleSB.value=11.3
    self.angleSB.enabled=True
    parametersFormLayout.addRow("Angle Value: ",self.angleSB)

    #direction selector
    self.directionSel = ctk.ctkComboBox()
    directions=["x vs y","y vs x","z vs x"]#todo: add all directions
    self.directionSel.addItems(directions)
    self.directionSel.editable=False
    self.directionSel.setCurrentIndex(0)
    parametersFormLayout.addRow("Direction: ", self.directionSel)

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

    resultCollapsibleButton = ctk.ctkCollapsibleButton()
    resultCollapsibleButton.text = "Results"
    self.framelayout.addWidget(resultCollapsibleButton)

    # Layout within the dummy collapsible button
    resultFormLayout = qt.QFormLayout(resultCollapsibleButton)

    #
    # Array selector
    #
    self.ArraySelector = slicer.qMRMLNodeComboBox()
    self.ArraySelector.nodeTypes = ( ("vtkMRMLDoubleArrayNode"), "" )
    self.ArraySelector.selectNodeUponCreation = False
    self.ArraySelector.addEnabled = False
    self.ArraySelector.removeEnabled = False
    self.ArraySelector.noneEnabled = True
    self.ArraySelector.showHidden = False
    self.ArraySelector.showChildNodeTypes = False
    self.ArraySelector.setMRMLScene( slicer.mrmlScene )
    self.ArraySelector.setToolTip( "Ramp profile" )
    resultFormLayout.addRow("Ramp profile: ", self.ArraySelector)

    self.FWHMVal=qt.QLineEdit()
    self.FWHMVal.readOnly=True
    self.FWHMVal.text=""
    resultFormLayout.addRow("FWHM: ",self.FWHMVal)

    self.SliceThkVal=qt.QLineEdit()
    self.SliceThkVal.readOnly=True
    self.SliceThkVal.text=""
    resultFormLayout.addRow("SliceThk: ",self.SliceThkVal)

    # connections
    self.applyButton.connect('clicked(bool)', self.onApplyButton)
    self.masterSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.ROISelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    self.ArraySelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelectArray)

    # Add vertical spacer
    self.layout.addStretch(1)
Esempio n. 9
0
    def createUserInterface( self ):

        self.__layout = qt.QFormLayout( self )
        self.__layout.setVerticalSpacing( 5 )

        # Add empty rows
        self.__layout.addRow( "", qt.QWidget() )
        self.__layout.addRow( "", qt.QWidget() )

        viewText = qt.QLabel("Viewpoint:")
        self.views = ctk.ctkComboBox()
        self.views.toolTip = "Select your view point."
        self.views.addItem("Left")
        self.views.addItem("Right")
        self.connect(self.views, PythonQt.QtCore.SIGNAL('activated(QString)'), self.cameraSide)

        workText = qt.QLabel("Screw Insertion Workflow")
        self.QHBox = qt.QHBoxLayout()
        self.QHBox.addWidget(workText)
        self.__layout.addRow(self.QHBox)
        self.startMeasurements = qt.QPushButton("Click to Add")
        self.startMeasurements.connect('clicked(bool)', self.addFiducials)
        self.markerPosition = qt.QPushButton("Click to Add")
        self.markerPosition.connect('clicked(bool)', self.addPositions)
        self.adjustClamp = qt.QPushButton("Click to Adjust")
        self.adjustClamp.connect('clicked(bool)', self.moveAruco)
        self.adjustClamp.enabled = False
        self.findSP = qt.QPushButton("Click to find startpoint")
        self.findSP.connect('clicked(bool)', self.findStartPoints)
        self.findSP.enabled = False
        self.stopTracking = qt.QPushButton("Click to stop tracking")
        self.stopTracking.connect('clicked(bool)', self.stopSPTracking)
        self.stopTracking.enabled = False
        self.aPoints= qt.QPushButton("Click to choose points")
        self.aPoints.connect('clicked(bool)', self.selectAPoints)
        self.aPoints.enabled = False

        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.fidChanged)

        eText = qt.QLabel("1. Add Entry Point:")
        self.QHBox1 = qt.QHBoxLayout()
        self.QHBox1.addWidget(eText)
        self.QHBox1.addWidget(self.startMeasurements)
        self.__layout.addRow(self.QHBox1)

        sText = qt.QLabel("2. Active Entry Point:")
        self.QHBox2 = qt.QHBoxLayout()
        self.QHBox2.addWidget(sText)
        self.QHBox2.addWidget(self.fiducial)
        self.__layout.addRow(self.QHBox2)

        qText = qt.QLabel("3. Add Clamp Position Point")
        self.arucoBox = qt.QHBoxLayout()
        self.arucoBox.addWidget(qText)
        self.arucoBox.addWidget(self.markerPosition)
        self.__layout.addRow(self.arucoBox)

        mText = qt.QLabel("4. Adjust Clamp Position")
        self.clampBox = qt.QHBoxLayout()
        self.clampBox.addWidget(mText)
        self.clampBox.addWidget(self.adjustClamp)
        self.__layout.addRow(self.clampBox)

        aText = qt.QLabel("5. Add anatomical points:")
        self.anatomBox = qt.QHBoxLayout()
        self.anatomBox.addWidget(aText)
        self.anatomBox.addWidget(self.aPoints)
        self.__layout.addRow(self.anatomBox)

        tText = qt.QLabel("6. Start Tracking")
        self.trackingBox = qt.QHBoxLayout()
        self.trackingBox.addWidget(tText)
        self.trackingBox.addWidget(self.findSP)
        self.__layout.addRow(self.trackingBox)

        stText = qt.QLabel("7. Stop Tracking")
        self.trackingBoxStop = qt.QHBoxLayout()
        self.trackingBoxStop.addWidget(stText)
        self.trackingBoxStop.addWidget(self.stopTracking)
        self.__layout.addRow(self.trackingBoxStop)

        self.transformGrid = qt.QGridLayout()
        self.__layout.addRow(self.transformGrid)

        self.delSP = qt.QPushButton("Remove Start Point")
        self.delSP.enabled = False
        self.delSP.connect('clicked(bool)', self.delStartPoint)

        self.QHBox4 = qt.QHBoxLayout()
        self.QHBox4.addWidget(self.delSP)
        self.__layout.addRow(self.QHBox4)

        navCollapsibleButton = ctk.ctkCollapsibleButton()
        navCollapsibleButton.text = "Navigation"
        self.__layout.addWidget(navCollapsibleButton)
        navCollapsibleButton.collapsed = True

        # Layout
        navLayout = qt.QFormLayout(navCollapsibleButton)
        self.resetSliceButton = qt.QPushButton("Reset Slice Views")
        navLayout.addRow(self.resetSliceButton)
        self.resetSliceButton.connect('clicked(bool)', self.resetSliceViews)

        qt.QTimer.singleShot(0, self.killButton)