コード例 #1
0
  def updateTable(self):
    self.itemsLoc = []
    self.itemsLD = []
    self.itemsAng = []
    # self.itemsDia = []

    self.screwList = slicer.modules.PedicleScrewPlannerWidget.measurementsStep.screwList
    self.screwNumber = len(self.screwList)
    self.screwTable.setRowCount(self.screwNumber)
    for i in range(self.screwNumber):
      currentScrew = self.screwList[i]
      self.screwLoc = str(currentScrew[0])
      screwLD = str(currentScrew[3]) + " x " + str(currentScrew[4])
      screwAng = str(currentScrew[1]) + " / " + str(currentScrew[2])

      qtscrewLoc = qt.QTableWidgetItem(self.screwLoc)
      qtscrewLD = qt.QTableWidgetItem(screwLD)
      qtscrewAng = qt.QTableWidgetItem(screwAng)
      #qtscrewDia = qt.QTableWidgetItem(screwDia)

      self.itemsLoc.append(qtscrewLoc)
      self.itemsLD.append(qtscrewLD)
      self.itemsAng.append(qtscrewAng)
      #self.itemsDia.append(qtscrewDia)
      self.screwName.append("Isthmus_Screw_{}".format(self.screwLoc))

    # logging.debug(self.screwName)
      logging.debug("self.screwName:{}".format(self.screwName))


      self.screwTable.setItem(i, 0, qtscrewLoc)
      self.screwTable.setItem(i, 1, qtscrewLD)
      self.screwTable.setItem(i, 2, qtscrewAng)
コード例 #2
0
ファイル: DICOMWidgets.py プロジェクト: spujol/Slicer
 def setLoadables(self,loadablesByPlugin):
   """Load the table widget with a list
   of volume options (of class DICOMVolume)
   """
   loadableCount = 0
   for plugin in loadablesByPlugin:
     for loadable in loadablesByPlugin[plugin]:
       loadableCount += 1
   self.widget.clearContents()
   self.widget.setColumnCount(2)
   self.widget.setHorizontalHeaderLabels(['DICOM Data','Warnings'])
   self.widget.setColumnWidth(0,int(self.width * 0.4))
   self.widget.setColumnWidth(1,int(self.width * 0.6))
   self.widget.setRowCount(loadableCount)
   row = 0
   for plugin in loadablesByPlugin:
     for selectState in (True,False):
       for loadable in loadablesByPlugin[plugin]:
         if loadable.selected == selectState:
           # name and check state
           self.loadables[row] = loadable
           item = qt.QTableWidgetItem(loadable.name)
           item.setCheckState(loadable.selected * 2)
           self.items.append(item)
           self.widget.setItem(row,0,item)
           item.setToolTip(loadable.tooltip)
           # warning
           if loadable.warning:
             warnItem = qt.QTableWidgetItem(loadable.warning)
             self.items.append(warnItem)
             self.widget.setItem(row,1,warnItem)
             item.setToolTip(item.toolTip() + "\n" + loadable.warning)
             warnItem.setToolTip(item.toolTip())
           row += 1
   self.widget.setVerticalHeaderLabels(row * [""])
コード例 #3
0
    def updateTable(self):
        #print pNode.GetParameter('vertebrae')
        self.fiducial = slicer.mrmlScene.GetNodeByID(
            'vtkMRMLMarkupsFiducialNode1')
        self.fidNumber = self.fiducial.GetNumberOfFiducials()
        self.fidLabels = []
        self.fidLevels = []
        self.fidSides = []
        self.itemsLabels = []
        self.itemsLevels = []
        self.itemsSides = []
        self.rulerList = []
        self.lengthCombo = []
        self.widthCombo = []

        self.angleTable.setRowCount(self.fidNumber)

        for i in range(0, self.fidNumber):
            self.fidLabels.append(
                slicer.modules.PedicleScrewSimulator_v3Widget.landmarksStep.
                table2.item(i, 0).text())
            self.fidLevels.append(
                slicer.modules.PedicleScrewSimulator_v3Widget.landmarksStep.
                table2.cellWidget(i, 1).currentText)
            self.fidSides.append(
                slicer.modules.PedicleScrewSimulator_v3Widget.landmarksStep.
                table2.cellWidget(i, 2).currentText)

        for i in range(0, self.fidNumber):
            Label = str(self.fidLabels[i])
            Level = str(self.fidLevels[i])
            Side = str(self.fidSides[i])
            #print Label
            #print Level
            #print Side
            #print self.levelselection[i] + "loop"
            qtLabel = qt.QTableWidgetItem(Label)
            qtLevel = qt.QTableWidgetItem(Level)
            qtSide = qt.QTableWidgetItem(Side)
            self.itemsLabels.append(qtLabel)
            self.itemsLevels.append(qtLevel)
            self.itemsSides.append(qtSide)
            #print self.items
            self.angleTable.setItem(i, 0, qtLabel)
            self.angleTable.setItem(i, 1, qtLevel)
            self.angleTable.setItem(i, 2, qtSide)

            self.lengthCombo.insert(i, qt.QComboBox())
            self.widthCombo.insert(i, qt.QComboBox())
            self.lengthCombo[i].addItem(" ")
            self.widthCombo[i].addItem(" ")
            #self.rulerMeasures()
            #self.measuresLength = qt.QComboBox()
            #self.measuresLength.addItems(self.rulerList)
            #self.measuresWidth = qt.QComboBox()
            #self.measuresWidth.addItems(self.rulerList)
            if self.entryCount == 0:
                self.angleTable.setCellWidget(i, 3, self.lengthCombo[i])
                self.angleTable.setCellWidget(i, 4, self.widthCombo[i])
        self.entryCount = 1
コード例 #4
0
    def addFiducialToTable(self, observer, event):
      logging.debug("Modified - {0}".format(event))
      self.fiducial = self.fiducialNode()
      self.fidNumber = self.fiducial.GetNumberOfFiducials()
      slicer.modules.markups.logic().SetAllMarkupsVisibility(self.fiducial,1)
      logging.debug(self.fidNumber)
      self.fidLabels = []
      self.items = []
      self.Label = qt.QTableWidgetItem()

      self.table2.setRowCount(self.fidNumber)


      for i in range(0,self.fidNumber):
          self.Label = qt.QTableWidgetItem(self.fiducial.GetNthFiducialLabel(i))
          self.items.append(self.Label)
          self.table2.setItem(i, 0, self.Label)
          self.comboLevel = qt.QComboBox()
          self.comboLevel.addItems(self.levelselection)
          self.comboSide = qt.QComboBox()
          self.comboSide.addItems(["Left","Right"])
          self.table2.setCellWidget(i,1, self.comboLevel)
          self.table2.setCellWidget(i,2, self.comboSide)
          if i == 0 or i == 1:
            self.table2.cellWidget(i,1).setCurrentIndex(0)
            if i == 1:
              self.table2.cellWidget(i,2).setCurrentIndex(1)
          elif i == 2 or i == 3:
            self.table2.cellWidget(i,1).setCurrentIndex(1)
            if i == 3:
              self.table2.cellWidget(i,2).setCurrentIndex(1)
          elif i == 4 or i == 5:
            self.table2.cellWidget(i,1).setCurrentIndex(2)
            if i == 5:
              self.table2.cellWidget(i,2).setCurrentIndex(1)
コード例 #5
0
    def updateFiducialsTable(self):
        if not self.logic.SourceNode or self.logic.SourceNode == None:
            self.FiducialTable.clear()
            self.FiducialTable.setHorizontalHeaderLabels(
                self.FiducialTableHeaders)
        else:
            self.FiducialTableData = []
            numControlPoints = self.logic.SourceNode.GetNumberOfFiducials()
            self.FiducialTable.setRowCount(numControlPoints)

            for i in range(numControlPoints):
                name = self.logic.SourceNode.GetNthFiducialLabel(i)
                pos = [0, 0, 0]
                self.logic.SourceNode.GetNthFiducialPosition(i, pos)
                cellName = qt.QTableWidgetItem(name)
                cellX = qt.QTableWidgetItem('%.3f' % pos[0])
                cellY = qt.QTableWidgetItem('%.3f' % pos[1])
                cellZ = qt.QTableWidgetItem('%.3f' % pos[2])
                row = [cellName, cellX, cellY, cellZ]
                self.FiducialTable.setItem(i, 0, row[0])
                self.FiducialTable.setItem(i, 1, row[1])
                self.FiducialTable.setItem(i, 2, row[2])
                self.FiducialTable.setItem(i, 3, row[3])
                self.FiducialTableData.append(row)

            self.FiducialTable.show()
コード例 #6
0
ファイル: DICOMWidgets.py プロジェクト: ikolesov/Slicer
 def addLoadableRow(self,loadable,row,reader):
   """Add a row to the loadable table
   """
   # name and check state
   qt_ItemIsEditable = 2 # not in PythonQt
   self.loadables[row] = loadable
   item = qt.QTableWidgetItem(loadable.name)
   item.setCheckState(loadable.selected * 2)
   self.items.append(item)
   self.widget.setItem(row,0,item)
   item.setToolTip(loadable.tooltip)
   # reader
   if reader:
     readerItem = qt.QTableWidgetItem(reader)
     readerItem.setFlags(readerItem.flags() ^ qt_ItemIsEditable)
     self.items.append(readerItem)
     self.widget.setItem(row,1,readerItem)
     readerItem.setToolTip(item.toolTip())
   # warning
   if loadable.warning:
     warnItem = qt.QTableWidgetItem(loadable.warning)
     warnItem.setFlags(warnItem.flags() ^ qt_ItemIsEditable)
     self.items.append(warnItem)
     self.widget.setItem(row,2,warnItem)
     item.setToolTip(item.toolTip() + "\n" + loadable.warning)
     warnItem.setToolTip(item.toolTip())
コード例 #7
0
    def updateTable(self):
      self.itemsLoc = []
      self.itemsLen = []
      self.itemsDia = []
      
      self.screwList = slicer.modules.PedicleScrewSimulator_v3Widget.screwStep.screwList
      self.screwNumber = len(self.screwList)
      self.screwTable.setRowCount(self.screwNumber)

      for i in range(0,self.fidNumber):
          currentScrew = self.screwList[i]
          screwLoc = str(currentScrew[0])
          screwLen = str(currentScrew[1]) + " x " + str(currentScrew[2])
          
          
          
                    
          qtscrewLoc = qt.QTableWidgetItem(screwLoc)
          qtscrewLen = qt.QTableWidgetItem(screwLen)
          #qtscrewDia = qt.QTableWidgetItem(screwDia)
          
          self.itemsLoc.append(qtscrewLoc)
          self.itemsLen.append(qtscrewLen)
          #self.itemsDia.append(qtscrewDia)
          
          self.screwTable.setItem(i, 0, qtscrewLoc)
          self.screwTable.setItem(i, 1, qtscrewLen)
コード例 #8
0
    def setHeader(self, file):
        """Load the table widget with header values for the file
    """
        self.widget.clearContents()
        self.widget.setColumnCount(2)
        self.widget.setHorizontalHeaderLabels(['Tag', 'Value'])
        self.widget.setColumnWidth(0, 100)
        self.widget.setColumnWidth(1, 200)

        if not file:
            return

        slicer.dicomDatabase.loadFileHeader(file)
        keys = slicer.dicomDatabase.headerKeys()
        self.widget.setRowCount(len(keys))
        row = 0
        for key in keys:
            item = qt.QTableWidgetItem(key)
            self.widget.setItem(row, 0, item)
            self.items.append(item)
            dump = slicer.dicomDatabase.headerValue(key)
            try:
                value = dump[dump.index('[') + 1:dump.index(']')]
            except ValueError:
                value = "Unknown"
            item = qt.QTableWidgetItem(value)
            self.widget.setItem(row, 1, item)
            self.items.append(item)
            row += 1
コード例 #9
0
  def setHeader(self,reportNode):
    """Load the table widget with annotations for the report
    """
    Helper.Debug('setHeader() called')
    self.widget.clearContents()
    self.widget.setColumnCount(2)
    self.widget.setHorizontalHeaderLabels(['Markup','Visibility'])
    self.widget.horizontalHeader().setResizeMode(0, qt.QHeaderView.Stretch)
    self.widget.horizontalHeader().setResizeMode(1, qt.QHeaderView.Fixed)
    self.widget.setEditTriggers(qt.QAbstractItemView.NoEditTriggers)

    if not reportNode:
      return
    # get the volume node associated with this report
    volumeID = reportNode.GetVolumeNodeID()     
    Helper.Debug('volumeID = '+volumeID)

    if volumeID == "":
      return
    volumeNode = slicer.mrmlScene.GetNodeByID(volumeID)
    if not volumeNode:
      return

    # get the annotations associated with this report
    # find displayble nodes that are associated with this volume
    numDisplayableNodes = slicer.mrmlScene.GetNumberOfNodesByClass("vtkMRMLDisplayableNode")
    nodeIDList = [volumeID]
    for n in range(numDisplayableNodes): 
      displayableNode = slicer.mrmlScene.GetNthNodeByClass(n, "vtkMRMLDisplayableNode")
      # how best to get at module widget logic?
      Helper.Debug('Will check if in report here for '+displayableNode.GetID())
      inReport = slicer.modules.reporting.logic().IsInReport(displayableNode)
      Helper.Debug('Checked for report')
      if inReport:
        Helper.Debug('Found node associated with the report node: ' + displayableNode.GetName())
        nodeIDList.append(displayableNode.GetID())
      else:
        Helper.Debug('Failed to found associated node')

    self.widget.setRowCount(len(nodeIDList))
    row = 0
    for nodeID in nodeIDList:
      node = Helper.getNodeByID(nodeID)
      item = qt.QTableWidgetItem(node.GetName())
      self.widget.setItem(row,0,item)
      self.items.append(item)
      if node.IsA("vtkMRMLAnnotationNode"):
        item = qt.QTableWidgetItem()
        # save the id for toggling visibility on the node
        # TODO: make this more elegant instead of overloading the what's this role with the id
        item.setData(qt.Qt.WhatsThisRole, node.GetID())
        if node.GetDisplayVisibility() == 1:
          item.setData(qt.Qt.DecorationRole,qt.QPixmap(":/Icons/Small/SlicerVisible.png"))
        else:
          item.setData(qt.Qt.DecorationRole,qt.QPixmap(":/Icons/Small/SlicerInvisible.png"))
        self.widget.setItem(row,1,item)
        self.items.append(item)
      row += 1
コード例 #10
0
 def saveApi(self):
   table = self.apiTable
   apiNameTableItem = qt.QTableWidgetItem(str(self.apiNameLineEdit.text))
   apiKeyTableItem = qt.QTableWidgetItem(str(self.apiKeyLineEdit.text))
   self.apiKeyTableItems.append(apiKeyTableItem)
   self.apiNameTableItems.append(apiNameTableItem)
   if self.dialogRole == 'Add':
     self.numberOfRows += 1
     table.setRowCount(self.numberOfRows)
     table.setItem(self.numberOfRows -1, 0, apiNameTableItem)
     table.setItem(self.numberOfRows -1, 1, apiKeyTableItem)
   elif self.dialogRole == 'Edit':
     table.setItem(self.currentAPIRow, 0, apiNameTableItem)
     table.setItem(self.currentAPIRow, 1, apiKeyTableItem)
   self.restartLabel.setVisible(True)
コード例 #11
0
 def addNewEmptyRow(self, rowIndex):   
   item = qt.QTableWidgetItem("dummy") 
   self.fiducialsWidget.fiducialsList.setItem(rowIndex,0,item.clone())
   self.fiducialsWidget.fiducialsList.setItem(rowIndex,1,item.clone())
   self.fiducialsWidget.fiducialsList.setItem(rowIndex,2,item.clone())
   self.fiducialsWidget.fiducialsList.setItem(rowIndex,3,item.clone())
   self.fiducialsWidget.fiducialsList.setItem(rowIndex,4,item.clone())  
コード例 #12
0
    def initializeTable(self):
        print("initialize table")

        self.table.setRowCount(len(self.landmarks))

        i = 0
        for landmark in self.landmarks:
            landmarkName = qt.QTableWidgetItem(landmark.name)
            landmarkPlaced = qt.QTableWidgetItem(str(landmark.placed))
            self.landmarkNamesInTable.append(landmark.name)

            self.table.setItem(i, 0, landmarkName)
            self.table.setItem(i, 2, 0)
            self.table.setItem(i, 3, 0)
            self.table.setItem(i, 4, 0)
            i += 1
        self.table.selectRow(self.selectedTableRow)
コード例 #13
0
    def updateTargetFiducialsTable(self):

        if not self.targetFiducialsNode:
            self.fiducialsTable.clear()
            self.fiducialsTable.setHorizontalHeaderLabels(
                self.fiducialsTableHeaders)

        else:

            extrapolate = self.extrapolateCheckBox.isChecked()
            showErrorVec = self.showErrorVectorCheckBox.isChecked()

            self.fiducialsTableData = []
            nOfControlPoints = self.targetFiducialsNode.GetNumberOfFiducials()

            if self.fiducialsTable.rowCount != nOfControlPoints:
                self.fiducialsTable.setRowCount(nOfControlPoints)

            dist = ''
            for i in range(nOfControlPoints):

                label = self.targetFiducialsNode.GetNthFiducialLabel(i)
                pos = [0.0, 0.0, 0.0]

                self.targetFiducialsNode.GetNthFiducialPosition(i, pos)
                (err, evec) = self.logic.distanceToPoint(pos, extrapolate)

                posstr = '(%.3f, %.3f, %.3f)' % (pos[0], pos[1], pos[2])
                if showErrorVec:
                    dist = '%.3f (%.3f, %.3f, %.3f)' % (err, evec[0], evec[1],
                                                        evec[2])
                else:
                    dist = '%.3f' % err

                cellLabel = qt.QTableWidgetItem(label)
                cellPosition = qt.QTableWidgetItem(posstr)
                cellDistance = qt.QTableWidgetItem(dist)
                row = [cellLabel, cellPosition, cellDistance]

                self.fiducialsTable.setItem(i, 0, row[0])
                self.fiducialsTable.setItem(i, 1, row[1])
                self.fiducialsTable.setItem(i, 2, row[2])
                self.fiducialsTableData.append(row)

        self.fiducialsTable.show()
コード例 #14
0
  def setupManualSampleTable( self, mrmlNode ):
    '''
    '''
    vtkId = self.mrmlManager().MapMRMLNodeIDToVTKNodeID( mrmlNode.GetID() )

    # number of volumes
    numberOfVolumes = self.mrmlManager().GetTargetNumberOfSelectedVolumes()
    numberOfSamples = self.mrmlManager().GetTreeNodeDistributionNumberOfSamples( vtkId )

    # empty all old items, we need a class variable here to store the references
    # if not, the items will be all lost!!
    self.__items = []

    # erase all items in the manual sampling table
    for r in range( self.__manualSampleTable.rowCount ):
      self.__manualSampleTable.removeRow( r )
    for c in range( self.__manualSampleTable.columnCount ):
      self.__manualSampleTable.removeColumn( c )

    self.__manualSampleTable.rowCount = 0
    self.__manualSampleTable.columnCount = 0

    # configure the rows and columns of the table
    volumes = []
    for n in range( numberOfVolumes ):
      # save the columns
      volumeId = self.mrmlManager().GetTargetSelectedVolumeNthID( n )
      volumeName = self.mrmlManager().GetVolumeName( volumeId )
      volumes.append( volumeName )

      # create new column
      self.__manualSampleTable.insertColumn( self.__manualSampleTable.columnCount )

    self.__manualSampleTable.setHorizontalHeaderLabels( volumes )

    # add the manual sample intensity values to the table
    for m in range( numberOfSamples ):

      # create new row
      self.__manualSampleTable.insertRow( self.__manualSampleTable.rowCount )

      for n in range( numberOfVolumes ):

        # fill the new row

        volumeId = self.mrmlManager().GetTargetSelectedVolumeNthID( n )
        intensity = self.mrmlManager().GetTreeNodeDistributionSampleIntensityValue( vtkId, m, volumeId )

        self.__items.append( qt.QTableWidgetItem( str( intensity ) ) )
        self.__manualSampleTable.setItem( m, n, self.__items[-1] )

    self.mrmlManager().ResetTreeNodeDistributionLogMeanCorrection( vtkId );
    self.mrmlManager().ResetTreeNodeDistributionLogCovarianceCorrection( vtkId );

    self.__vtkId = vtkId

    self.__manualSampling = True
コード例 #15
0
  def populateAPITable(self):

    settings = qt.QSettings()
    table = self.apiTable
    settings.beginGroup("TCIABrowser/API-Keys")
    userApiNames = settings.childKeys()
    self.numberOfRows = len(userApiNames)
    table.setRowCount(self.numberOfRows)
    row = 0
    for api in userApiNames:
      apiNameTableItem = qt.QTableWidgetItem(str(api))
      apiKeyTableItem = qt.QTableWidgetItem(str(settings.value(api)))
      table.setItem( row, 0, apiNameTableItem) 
      self.apiNameTableItems.append(apiNameTableItem)
      table.setItem( row, 1, apiKeyTableItem) 
      self.apiKeyTableItems.append(apiKeyTableItem)
      row += 1
    settings.endGroup()
コード例 #16
0
    def updateTable(self):

        print "updateTable() is called"
        if not self.targetFiducialsNode:
            self.table.clear()
            self.table.setHorizontalHeaderLabels(self.headers)
        else:

            self.tableData = []
            nOfControlPoints = self.targetFiducialsNode.GetNumberOfFiducials()

            if self.table.rowCount != nOfControlPoints:
                self.table.setRowCount(nOfControlPoints)

            for i in range(nOfControlPoints):

                label = self.targetFiducialsNode.GetNthFiducialLabel(i)
                pos = [0.0, 0.0, 0.0]

                self.targetFiducialsNode.GetNthFiducialPosition(i, pos)
                (indexX, indexY, depth,
                 inRange) = self.logic.computeNearestPath(pos)

                posstr = '(%.3f, %.3f, %.3f)' % (pos[0], pos[1], pos[2])
                cellLabel = qt.QTableWidgetItem(label)
                cellIndex = qt.QTableWidgetItem('(%s, %s)' % (indexX, indexY))
                cellDepth = None
                if inRange:
                    cellDepth = qt.QTableWidgetItem('%.3f' % depth)
                else:
                    cellDepth = qt.QTableWidgetItem('(%.3f)' % depth)
                cellPosition = qt.QTableWidgetItem(posstr)
                row = [cellLabel, cellIndex, cellDepth, cellPosition]

                self.table.setItem(i, 0, row[0])
                self.table.setItem(i, 1, row[1])
                self.table.setItem(i, 2, row[2])
                self.table.setItem(i, 3, row[3])

                self.tableData.append(row)

        self.table.show()
コード例 #17
0
    def addFiducialToTable(self, observer, event):
        logging.debug("Modified - {0}".format(event))

        self.fidNumber = self.fidNode.GetNumberOfFiducials()
        slicer.modules.markups.logic().SetAllMarkupsVisibility(self.fidNode, 1)
        logging.debug(self.fidNumber)
        self.fidLabels = []
        self.items = []
        self.Label = qt.QTableWidgetItem()

        self.table2.setRowCount(self.fidNumber)

        for i in range(0, self.fidNumber):
            self.Label = qt.QTableWidgetItem(
                self.fidNode.GetNthFiducialLabel(i))
            self.items.append(self.Label)
            self.table2.setItem(i, 0, self.Label)
            self.combofidlist = qt.QComboBox()
            self.combofidlist.addItems(self.fiduciallist)
            self.table2.setCellWidget(i, 1, self.combofidlist)
コード例 #18
0
    def updateTable(self):
        # logging.debug(pNode.GetParameter('vertebrae'))
        self.fiducial = self.fiducialNode()
        self.fidNumber = self.fiducial.GetNumberOfFiducials()
        logging.debug(self.fidNumber)
        self.fidLabels = []
        self.items = []
        self.Label = qt.QTableWidgetItem()

        self.table2.setRowCount(self.fidNumber)
        logging.debug(self.fiduciallist)
        for i in range(0, self.fidNumber):
            self.Label = qt.QTableWidgetItem(
                self.fiducial.GetNthFiducialLabel(i))
            self.items.append(self.Label)
            self.table2.setItem(i, 0, self.Label)
            self.combofidlist = qt.QComboBox()
            self.combofidlist.addItems(self.fiduciallist)
            self.table2.setCellWidget(i, 1, self.combofidlist)
        logging.debug(self.fiduciallist)
コード例 #19
0
    def getPositionsOfFiducials(self):
        print ("get fiducial positions")
        fidNode = slicer.mrmlScene.GetNodeByID('vtkMRMLMarkupsFiducialNode1')
        numFids = fidNode.GetNumberOfFiducials()

        for i in range(0, numFids):
            position = [0, 0, 0]
            fidNode.GetNthFiducialPosition(i, position)
            print(position)

            self.landmarks[i].x = position[0]
            self.landmarks[i].y = position[1]
            self.landmarks[i].z = position[2]

            x = qt.QTableWidgetItem(str(position[0]))
            y = qt.QTableWidgetItem(str(position[1]))
            z = qt.QTableWidgetItem(str(position[2]))

            self.table.setItem(i, 2, x)
            self.table.setItem(i, 3, y)
            self.table.setItem(i, 4, z)
コード例 #20
0
    def updateTable(self):
      #logging.debug(pNode.GetParameter('vertebrae'))
      self.fiducial = self.fiducialNode()
      self.fidNumber = self.fiducial.GetNumberOfFiducials()
      logging.debug(self.fidNumber)
      self.fidLabels = []
      self.items = []
      self.Label = qt.QTableWidgetItem()

      self.table2.setRowCount(self.fidNumber)


      for i in range(0,self.fidNumber):
          self.Label = qt.QTableWidgetItem(self.fiducial.GetNthFiducialLabel(i))
          self.items.append(self.Label)
          self.table2.setItem(i, 0, self.Label)
          self.comboLevel = qt.QComboBox()
          self.comboLevel.addItems(self.levelselection)
          self.comboSide = qt.QComboBox()
          self.comboSide.addItems(["Left","Right"])
          self.table2.setCellWidget(i,1, self.comboLevel)
          self.table2.setCellWidget(i,2, self.comboSide)
      logging.debug(self.Label.text())
コード例 #21
0
 def addLoadableRow(self, loadable, row, reader):
     """Add a row to the loadable table
 """
     # set checked state to unckecked if there is a loadable with the
     # same file list in the table already
     if len(self.loadables) > 0:
         for addedRow in self.loadables.keys():
             if len(self.loadables[addedRow].files) == 1 and len(
                     loadable.files) == 1:
                 # needed because of the tuple-sequence comparison does not work,
                 # and sometimes tuples are created by some reason
                 if self.loadables[addedRow].files[0] == loadable.files[0]:
                     loadable.selected = False
                     break
             elif self.loadables[addedRow].files == loadable.files:
                 loadable.selected = False
                 break
     # name and check state
     self.loadables[row] = loadable
     item = qt.QTableWidgetItem(loadable.name)
     item.setCheckState(loadable.selected * 2)
     self.items.append(item)
     self.widget.setItem(row, 0, item)
     item.setToolTip(loadable.tooltip)
     # reader
     if reader:
         readerItem = qt.QTableWidgetItem(reader)
         self.items.append(readerItem)
         self.widget.setItem(row, 1, readerItem)
         readerItem.setToolTip(item.toolTip())
     # warning
     if loadable.warning:
         warnItem = qt.QTableWidgetItem(loadable.warning)
         self.items.append(warnItem)
         self.widget.setItem(row, 2, warnItem)
         item.setToolTip(item.toolTip() + "\n" + loadable.warning)
         warnItem.setToolTip(item.toolTip())
コード例 #22
0
    def updateStatsTable(self, release_downloads):
        self.statsTable.setRowCount(len(release_downloads))
        self.statsTable.setColumnCount(len(self.statsTableHeader))
        self.statsTable.setHorizontalHeaderLabels(self.statsTableHeader)

        self.items = []
        row = 0
        for release, downloads in release_downloads.items():
            item = qt.QTableWidgetItem(release)
            self.items.append(
                item)  # required, otherwise the item does not appear
            item.setFlags(item.flags()
                          ^ qt.Qt.ItemIsEditable)  # make the item read-only
            self.statsTable.setItem(row, 0, item)
            item = qt.QTableWidgetItem(str(downloads))
            self.items.append(
                item)  # required, otherwise the item does not appear
            item.setFlags(item.flags()
                          ^ qt.Qt.ItemIsEditable)  # make the item read-only
            self.statsTable.setItem(row, 1, item)
            row = row + 1

        self.statsTable.horizontalHeader().setResizeMode(
            qt.QHeaderView.Stretch)
コード例 #23
0
  def onApply(self):
    self.applyButton.text = "Working..."
    self.applyButton.repaint()
    slicer.app.processEvents()
    self.logic = MarginCalculatorLogic()
    self.logic.run(self.inputDoseVolumeSelector.currentNode(), self.referenceDoseVolumeSelector.currentNode(), self.inputContourSelector.currentNode(), self.numberOfSimulations, self.numberOfFractions, self.systematicErrorRange, self.randomErrorRange, self.doseGrowRange, self.ROIRadiusX, self.ROIRadiusY, self.ROIRadiusZ, self.doseGrowingOption)
    self.applyButton.text = "Calculate"

    marginResult = self.logic.getMarginResult()
    print marginResult
    if marginResult:
      self.saveButton.enabled = True
    numberOfRows = len(marginResult)
    self.tableWidget.clearContents()
    self.tableWidget.setRowCount(numberOfRows)
    for i in range(numberOfRows):
      item = qt.QTableWidgetItem()
      item.setText(str(marginResult[i][0]))
      self.items.append(item)
      self.tableWidget.setItem(i, 0, item )
      item2 = qt.QTableWidgetItem()
      item2.setText(str(marginResult[i][1]))
      self.items.append(item2)
      self.tableWidget.setItem(i, 1, item2 )
      item3 = qt.QTableWidgetItem()
      item3.setText(str(marginResult[i][2]))
      self.items.append(item3)
      self.tableWidget.setItem(i, 2, item3 )
      item4 = qt.QTableWidgetItem()
      item4.setText(str(marginResult[i][3]))
      self.items.append(item4)
      self.tableWidget.setItem(i, 3, item4 )
      item5 = qt.QTableWidgetItem()
      item5.setText(str(marginResult[i][4]))
      self.items.append(item5)
      self.tableWidget.setItem(i, 4, item5 )
コード例 #24
0
 def addContentItemRow(self, stringCont, row):
     """Add a row to the loadable table
 """
     colStrs = string.split(stringCont, ',')
     col = 0
     for colStr in colStrs:
         # name and check state
         self.strings.append(colStr)
         item = qt.QTableWidgetItem(colStr[1:-1])
         item.setCheckState(0)
         #if not self.multiSelect:
         #  item.setFlags(33)
         #else:
         #  # allow checkboxes interaction
         #  item.setFlags(49)
         self.items.append(item)
         self.widget.setItem(row, col, item)
         col += 1
コード例 #25
0
    def placeFiducialAsLandmark(self, observer, event):
        print(event)
        fiducial = slicer.mrmlScene.GetNodeByID('vtkMRMLMarkupsFiducialNode1')
        fidNumber = fiducial.GetNumberOfFiducials()

        if (fidNumber > self.curNumberOfFids):
            print ("Fiducial added")
            slicer.modules.markups.logic().SetAllMarkupsVisibility(fiducial, 1)
            print (fidNumber)
            fiducialID = qt.QTableWidgetItem(fiducial.GetNthFiducialLabel(fidNumber - 1))

            self.table.setItem(self.selectedTableRow, 1, fiducialID)
            self.table.selectRow(self.selectedTableRow + 1)

            self.selectedTableRow += 1
            self.curNumberOfFids += 1

        if (self.selectedTableRow >= len(self.landmarks)):
            self.stop()
            self.btnBeginPlacingLandmarks.hide()
コード例 #26
0
ファイル: Settings_Hosts.py プロジェクト: fepegar/XNATSlicer
    def addNameAndUrl(self, name, url):
        """ 
        Adds a name and url to the table by adding a 
        new row.

        @param name: The name of the host to add.
        @type name: str

        @param url: The url of the host to add.
        @type url: str
        """

        #--------------------
        # Add the hostName and hostUrl items
        # accordingly.
        #--------------------
        hostNameItem = qt.QTableWidgetItem(name)
        hostUrlItem = qt.QTableWidgetItem(url)

        #--------------------
        # Add the username item.
        #--------------------
        usernameItem = qt.QTableWidgetItem('No username stored.')

        #--------------------
        # Turn sorting off.
        #--------------------
        self.setSortingEnabled(False)

        #--------------------
        # NOTE: QTableWiget quirk: we have to
        # set the rowcount of the table beforehand.
        #--------------------
        self.setRowCount(self.rowCount + 1)

        #--------------------
        # Add the new items to the 'trackedItems'
        # variable otherwise the table will destroy them
        # and the items will disappear immediately on
        # add.
        #--------------------
        self.trackedItems[self.rowCount - 1] = {}
        self.trackedItems[self.rowCount - 1]['name'] = hostNameItem
        self.trackedItems[self.rowCount - 1]['url'] = hostUrlItem
        self.trackedItems[self.rowCount - 1]['stored login'] = usernameItem

        #--------------------
        # Set the added items' aeshetics.
        #--------------------
        for key, item in self.trackedItems[self.rowCount - 1].iteritems():
            item.setFont(Settings_Hosts.FONT)

        #--------------------
        # Call on the QTableWidget 'setItem' function.
        #--------------------
        self.setItem(self.rowCount - 1, self.getColumn('name'), hostNameItem)
        self.setItem(self.rowCount - 1, self.getColumn('url'), hostUrlItem)
        self.setItem(self.rowCount-1, self.getColumn('stored login'), \
                     usernameItem)

        #--------------------
        # Again, turn sorting off.
        #--------------------
        self.setSortingEnabled(False)
コード例 #27
0
    def contact(self, input, screwModel, fidName, screwIndex):
        #Get points in shaft of screw
        insidePoints = self.cropPoints(screwModel)
        
        #Get scalars to array
        scalarsArray = input.GetPolyData().GetPointData().GetScalars('NRRDImage')
        self.pointsArray = screwModel.GetPolyData()
        
        #Get total number of tuples/points
        value = scalarsArray.GetNumberOfTuples()
        
        #Reset variables
        point = [0]
        point2 = [0,0,0]
        corticalCount = 0
        cancellousCount = 0
        totalCount = 0
        bounds = [0]
        shaftBounds = 0
        count00 = 0
        points00 = 0
        avg00 = 0.0
        count10 = 0
        points10 = 0
        avg10 = 0.0
        count20 = 0
        points20 = 0
        avg20 = 0.0
        count30 = 0
        points30 = 0
        avg30 = 0.0
        count40 = 0
        points40 = 0
        avg40 = 0.0 
        count50 = 0
        points50 = 0
        avg50 = 0.0 
        count60 = 0
        points60 = 0
        avg60 = 0.0 
        count70 = 0
        points70 = 0
        avg70 = 0.0 
        count80 = 0
        points80 = 0
        avg80 = 0.0 
        count90 = 0
        points90 = 0
        avg90 = 0.0
        avgTotal = []
        avgQuad1 = []
        avgQuad2 = []
        avgQuad3 = []
        avgQuad4 = []
        countQ1_00 = 0
        pointsQ1_00 = 0
        countQ2_00 = 0
        pointsQ2_00 = 0
        countQ3_00 = 0
        pointsQ3_00 = 0
        countQ4_00 = 0
        pointsQ4_00 = 0
        countQ1_10 = 0
        pointsQ1_10 = 0
        countQ2_10 = 0
        pointsQ2_10 = 0
        countQ3_10 = 0
        pointsQ3_10 = 0
        countQ4_10 = 0
        pointsQ4_10 = 0
        countQ1_20 = 0
        pointsQ1_20 = 0
        countQ2_20 = 0
        pointsQ2_20 = 0
        countQ3_20 = 0
        pointsQ3_20 = 0
        countQ4_20 = 0
        pointsQ4_20 = 0
        countQ1_30 = 0
        pointsQ1_30 = 0
        countQ2_30 = 0
        pointsQ2_30 = 0
        countQ3_30 = 0
        pointsQ3_30 = 0
        countQ4_30 = 0
        pointsQ4_30 = 0
        countQ1_40 = 0
        pointsQ1_40 = 0
        countQ2_40 = 0
        pointsQ2_40 = 0
        countQ3_40 = 0
        pointsQ3_40 = 0
        countQ4_40 = 0
        pointsQ4_40 = 0
        countQ1_50 = 0
        pointsQ1_50 = 0
        countQ2_50 = 0
        pointsQ2_50 = 0
        countQ3_50 = 0
        pointsQ3_50 = 0
        countQ4_50 = 0
        pointsQ4_50 = 0
        countQ1_60 = 0
        pointsQ1_60 = 0
        countQ2_60 = 0
        pointsQ2_60 = 0
        countQ3_60 = 0
        pointsQ3_60 = 0
        countQ4_60 = 0
        pointsQ4_60 = 0
        countQ1_70 = 0
        pointsQ1_70 = 0
        countQ2_70 = 0
        pointsQ2_70 = 0
        countQ3_70 = 0
        pointsQ3_70 = 0
        countQ4_70 = 0
        pointsQ4_70 = 0
        countQ1_80 = 0
        pointsQ1_80 = 0
        countQ2_80 = 0
        pointsQ2_80 = 0
        countQ3_80 = 0
        pointsQ3_80 = 0
        countQ4_80 = 0
        pointsQ4_80 = 0
        countQ1_90 = 0
        pointsQ1_90 = 0
        countQ2_90 = 0
        pointsQ2_90 = 0
        countQ3_90 = 0
        pointsQ3_90 = 0
        countQ4_90 = 0
        pointsQ4_90 = 0
        
        
        xCenter = 0
        zCenter = 0         
        
        bounds = self.pointsArray.GetPoints().GetBounds()
        lowerBound = bounds[2] #+ 17
        shaftBounds = 30 # FOR NOW
        print bounds
        xCenter = (bounds[0] + bounds[1])/2
        zCenter = (bounds[4] + bounds[5])/2
        
        #For each point in the screw model...
        for i in range(0, value):
            #If the point is in the shaft of the screw...
            if insidePoints.IsInside(i) == 1:  
              totalCount += 1
              #Read scalar value at point to "point" array
              scalarsArray.GetTupleValue(i, point)
              print point
              self.pointsArray.GetPoints().GetPoint(i,point2)
              print point2
              if point2[1] >= lowerBound and point2[1] < (lowerBound + (shaftBounds*0.1)):
                  print "00%"
                  count00 = count00 + point[0]
                  points00 += 1
                  print xCenter
                  print point2[0]
                  print zCenter
                  print point2[2]  
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1"
                      countQ1_00 = countQ1_00 + point[0]
                      pointsQ1_00 += 1
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_00 = countQ2_00 + point[0]
                      pointsQ2_00 += 1
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_00 = countQ3_00 + point[0]
                      pointsQ3_00 += 1
                  else:
                      print "Quadrant 4"
                      countQ4_00 = countQ4_00 + point[0]
                      pointsQ4_00 += 1    
              elif point2[1] >= (lowerBound + (shaftBounds*0.1)) and point2[1] < (lowerBound + (shaftBounds*0.2)):
                  print "10%"
                  count10 = count10 + point[0]
                  points10 += 1
                  print xCenter
                  print point2[0]
                  print zCenter
                  print point2[2]    
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1"
                      countQ1_10 = countQ1_10 + point[0]
                      pointsQ1_10 += 1
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_10 = countQ2_10 + point[0]
                      pointsQ2_10 += 1
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_10 = countQ3_10 + point[0]
                      pointsQ3_10 += 1
                  else:
                      print "Quadrant 4"
                      countQ4_10 = countQ4_10 + point[0]
                      pointsQ4_10 += 1  
              elif point2[1] >= (lowerBound + (shaftBounds*0.2)) and point2[1] < (lowerBound + (shaftBounds*0.3)):
                  print "20%"
                  count20 = count20 + point[0]
                  points20 += 1
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1"
                      countQ1_20 = countQ1_20 + point[0]
                      pointsQ1_20 += 1
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_20 = countQ2_20 + point[0]
                      pointsQ2_20 += 1
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_20 = countQ3_20 + point[0]
                      pointsQ3_20 += 1
                  else:
                      print "Quadrant 4"
                      countQ4_20 = countQ4_20 + point[0]
                      pointsQ4_20 += 1      
              elif point2[1] >= (lowerBound + (shaftBounds*0.3)) and point2[1] < (lowerBound + (shaftBounds*0.4)):
                  print "30%"
                  count30 = count30 + point[0]
                  points30 += 1
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1"
                      countQ1_30 = countQ1_30 + point[0]
                      pointsQ1_30 += 1
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_30 = countQ2_30 + point[0]
                      pointsQ2_30 += 1
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_30 = countQ3_30 + point[0]
                      pointsQ3_30 += 1
                  else:
                      print "Quadrant 4"  
                      countQ4_30 = countQ4_30 + point[0]
                      pointsQ4_30 += 1    
              elif point2[1] >= (lowerBound + (shaftBounds*0.4)) and point2[1] < (lowerBound + (shaftBounds*0.5)):
                  print "40%"
                  count40 = count40 + point[0]
                  points40 += 1
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1"
                      countQ1_40 = countQ1_40 + point[0]
                      pointsQ1_40 += 1
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_40 = countQ2_40 + point[0]
                      pointsQ2_40 += 1
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_40 = countQ3_40 + point[0]
                      pointsQ3_40 += 1
                  else:
                      print "Quadrant 4"  
                      countQ4_40 = countQ4_40 + point[0]
                      pointsQ4_40 += 1    
              elif point2[1] >= (lowerBound + (shaftBounds*0.5)) and point2[1] < (lowerBound + (shaftBounds*0.6)):
                  print "50%"
                  count50 = count50 + point[0]
                  points50 += 1
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1"
                      countQ1_50 = countQ1_50 + point[0]
                      pointsQ1_50 += 1 
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_50 = countQ2_50 + point[0]
                      pointsQ2_50 += 1
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_50 = countQ3_50 + point[0]
                      pointsQ3_50 += 1
                  else:
                      print "Quadrant 4" 
                      countQ4_50 = countQ4_50 + point[0]
                      pointsQ4_50 += 1     
              elif point2[1] >= (lowerBound + (shaftBounds*0.6)) and point2[1] < (lowerBound + (shaftBounds*0.7)):
                  print "60%"
                  count60 = count60 + point[0]
                  points60 += 1
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1"
                      countQ1_60 = countQ1_60 + point[0]
                      pointsQ1_60 += 1
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_60 = countQ2_60 + point[0]
                      pointsQ2_60 += 1
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_60 = countQ3_60 + point[0]
                      pointsQ3_60 += 1
                  else:
                      print "Quadrant 4"  
                      countQ4_60 = countQ4_60 + point[0]
                      pointsQ4_60 += 1    
              elif point2[1] >= (lowerBound + (shaftBounds*0.7)) and point2[1] < (lowerBound + (shaftBounds*0.8)):
                  print "70%"
                  count70 = count70 + point[0]
                  points70 += 1
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1" 
                      countQ1_70 = countQ1_70 + point[0]
                      pointsQ1_70 += 1 
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_70 = countQ2_70 + point[0]
                      pointsQ2_70 += 1 
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_70 = countQ3_70 + point[0]
                      pointsQ3_70 += 1 
                  else:
                      print "Quadrant 4"  
                      countQ4_70 = countQ4_70 + point[0]
                      pointsQ4_70 += 1     
              elif point2[1] >= (lowerBound + (shaftBounds*0.8)) and point2[1] < (lowerBound + (shaftBounds*0.9)):
                  print "80%"
                  count80 = count80 + point[0]
                  points80 += 1
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1"
                      countQ1_80 = countQ1_80 + point[0]
                      pointsQ1_80 += 1
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_80 = countQ2_80 + point[0]
                      pointsQ2_80 += 1
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_80 = countQ3_80 + point[0]
                      pointsQ3_80 += 1
                  else:
                      print "Quadrant 4" 
                      countQ4_80 = countQ4_80 + point[0]
                      pointsQ4_80 += 1     
              elif point2[1] >= (lowerBound + (shaftBounds*0.9)) and point2[1] < (lowerBound + (shaftBounds*1)):
                  print "90%"
                  count90 = count90 + point[0]
                  points90 += 1
                  if point2[0] < xCenter and point2[2] >= zCenter:
                      print "Quadrant 1"
                      countQ1_90 = countQ1_90 + point[0]
                      pointsQ1_90 += 1
                  elif point2[0] >= xCenter and point2[2] >= zCenter:
                      print "Quadrant 2"
                      countQ2_90 = countQ2_90 + point[0]
                      pointsQ2_90 += 1
                  elif point2[0] < xCenter and point2[2] < zCenter:
                      print "Quadrant 3"
                      countQ3_90 = countQ3_90 + point[0]
                      pointsQ3_90 += 1
                  else:
                      print "Quadrant 4" 
                      countQ4_90 = countQ4_90 + point[0]
                      pointsQ4_90 += 1        
              else:
                  print "no" 
                 
              #print totalCount
              #Keep track of number of points that fall into cortical threshold and cancellous threshold respectively
              if point[0] >= self.__corticalMin:
                  corticalCount += 1
              elif point[0] < self.__corticalMin and point[0] >= self.__cancellousMin:
                  cancellousCount += 1
        #Calculate averages
        avgQuad1.extend([float(countQ1_00 / pointsQ1_00), float(countQ1_10 / pointsQ1_10), float(countQ1_20 / pointsQ1_20), float(countQ1_30 / pointsQ1_30), float(countQ1_40 / pointsQ1_40), float(countQ1_50 / pointsQ1_50), float(countQ1_60 / pointsQ1_60), float(countQ1_70 / pointsQ1_70), float(countQ1_80 / pointsQ1_80), float(countQ1_90 / pointsQ1_90)])
        avgQuad2.extend([float(countQ2_00 / pointsQ2_00), float(countQ2_10 / pointsQ2_10), float(countQ2_20 / pointsQ2_20), float(countQ2_30 / pointsQ2_30), float(countQ2_40 / pointsQ2_40), float(countQ2_50 / pointsQ2_50), float(countQ2_60 / pointsQ2_60), float(countQ2_70 / pointsQ2_70), float(countQ2_80 / pointsQ2_80), float(countQ2_90 / pointsQ2_90)])
        avgQuad3.extend([float(countQ3_00 / pointsQ3_00), float(countQ3_10 / pointsQ3_10), float(countQ3_20 / pointsQ3_20), float(countQ3_30 / pointsQ3_30), float(countQ3_40 / pointsQ3_40), float(countQ3_50 / pointsQ3_50), float(countQ3_60 / pointsQ3_60), float(countQ3_70 / pointsQ3_70), float(countQ3_80 / pointsQ3_80), float(countQ3_90 / pointsQ3_90)])
        avgQuad4.extend([float(countQ4_00 / pointsQ4_00), float(countQ4_10 / pointsQ4_10), float(countQ4_20 / pointsQ4_20), float(countQ4_30 / pointsQ4_30), float(countQ4_40 / pointsQ4_40), float(countQ4_50 / pointsQ4_50), float(countQ4_60 / pointsQ4_60), float(countQ4_70 / pointsQ4_70), float(countQ4_80 / pointsQ4_80), float(countQ4_90 / pointsQ4_90)])
        print avgQuad1
        print avgQuad2
        print avgQuad3
        print avgQuad4

        if points00 != 0:
            avg00 = count00 / points00
            avgTotal.append(avg00)
        if points10 != 0:
            avg10 = count10 / points10
            avgTotal.append(avg10)
        if points20 != 0:
            avg20 = count20 / points20
            avgTotal.append(avg20)
        if points30 != 0:
            avg30 = count30 / points30
            avgTotal.append(avg30)
        if points40 != 0:
            avg40 = count40 / points40
            avgTotal.append(avg40)
        if points50 != 0:
            avg50 = count50 / points50
            avgTotal.append(avg50)
        if points60 != 0:
            avg60 = count60 / points60
            avgTotal.append(avg60)
        if points70 != 0:
            avg70 = count70 / points70
            avgTotal.append(avg70)
        if points80 != 0:
            avg80 = count80 / points80
            avgTotal.append(avg80)
        if points90 != 0:
            avg90 = count90 / points90
            avgTotal.append(avg90)    
        print avg00
        print points00
        print avg10
        print points10
        print avg20
        print points20
        print avg30
        print points30
        print avg40
        print points40
        print avg50
        print points50
        print avg60
        print points60
        print avg70
        print points70
        print avg80
        print points80
        print avg90
        print points90
        
        self.screwContact.insert(screwIndex, avgTotal)
        '''
              
        '''
        #Calculate percentages 
        corticalPercent = float(corticalCount) / float(totalCount) *100
        cancellousPercent = float(cancellousCount) / float(totalCount) *100
        otherPercent = 100 - corticalPercent - cancellousPercent
        
        print corticalPercent
        print cancellousPercent
        
        coP = str("%.0f" % corticalPercent)
        caP = str("%.0f" % cancellousPercent)
        otP = str("%.0f" % otherPercent)
          
        qtcoP = qt.QTableWidgetItem(coP)
        qtcap = qt.QTableWidgetItem(caP)
        qtotP = qt.QTableWidgetItem(otP)
          
        self.itemsqtcoP.append(qtcoP)
        self.itemsqtcaP.append(qtcap)
        self.itemsqtotP.append(qtotP)
        
        print screwIndex    
        self.screwTable.setItem(screwIndex, 4, qtcoP)
        self.screwTable.setItem(screwIndex, 3, qtcap)
        self.screwTable.setItem(screwIndex, 2, qtotP)
コード例 #28
0
    def contact(self, input, screwModel, fidName, screwIndex):
        #Get points in shaft of screw
        insidePoints = self.cropPoints(screwModel)

        #Get scalars to array
        scalarsArray = input.GetPolyData().GetPointData().GetScalars(
            'NRRDImage')
        self.pointsArray = screwModel.GetPolyData()

        #Get total number of tuples/points
        value = scalarsArray.GetNumberOfTuples()

        #Reset variables
        bounds = [0]
        shaftBounds = 0

        corticalCount = 0
        cancellousCount = 0
        totalCount = 0
        count = [0] * 10  # sum of values along the screw
        points = [0] * 10  # number of points along the screw
        countQ = [
            [0] * 10
        ] * 4  # sum of values in countQ[quadrant][longitudinalSection]
        pointsQ = [
            [0] * 10
        ] * 4  # number of points in pointQ[quadrant][longitudinalSection]

        xCenter = 0
        zCenter = 0

        bounds = self.pointsArray.GetPoints().GetBounds()
        lowerBound = bounds[2]  #+ 17
        shaftBounds = 30  # FOR NOW
        logging.debug(bounds)
        xCenter = (bounds[0] + bounds[1]) / 2
        zCenter = (bounds[4] + bounds[5]) / 2

        #For each point in the screw model...
        point = [0]
        point2 = [0, 0, 0]
        for i in range(0, value):
            #If the point is in the shaft of the screw...
            if insidePoints.IsInside(i) != 1:
                continue
            totalCount += 1
            #Read scalar value at point to "point" array
            scalarsArray.GetTypedTuple(i, point)
            #logging.debug(point)
            self.pointsArray.GetPoints().GetPoint(i, point2)
            #logging.debug(point2)

            longitudinalIndex = int(
                math.floor((point2[1] - lowerBound) / shaftBounds * 10.0))
            if longitudinalIndex < 0 or longitudinalIndex >= 10:
                continue

            if point2[0] < xCenter and point2[2] >= zCenter:
                quadrantIndex = 0
            elif point2[0] >= xCenter and point2[2] >= zCenter:
                quadrantIndex = 1
            elif point2[0] < xCenter and point2[2] < zCenter:
                quadrantIndex = 2
            else:
                quadrantIndex = 3

            count[longitudinalIndex] += point[0]
            points[longitudinalIndex] += 1
            countQ[quadrantIndex][longitudinalIndex] += point[0]
            pointsQ[quadrantIndex][longitudinalIndex] += 1

            #logging.debug(totalCount)
            #Keep track of number of points that fall into cortical threshold and cancellous threshold respectively
            if point[0] >= self.__corticalMin:
                corticalCount += 1
            elif point[0] < self.__corticalMin and point[
                    0] >= self.__cancellousMin:
                cancellousCount += 1

        #Calculate averages
        avgQuad = [[0] * 10] * 4  # average in quadrants
        for quadrantIndex in range(4):
            for longitudinalIndex in range(10):
                numSamples = pointsQ[quadrantIndex][longitudinalIndex]
                if numSamples == 0:
                    continue
                avgQuad[quadrantIndex][longitudinalIndex] = float(
                    countQ[quadrantIndex][longitudinalIndex] / numSamples)

        avg = [0.0] * 10  # average along the screw
        for longitudinalIndex in range(10):
            if points[longitudinalIndex] > 0:
                avg[longitudinalIndex] = count[longitudinalIndex] / points[
                    longitudinalIndex]

        self.screwContact.insert(screwIndex, avg)
        '''
              
        '''
        #Calculate percentages
        corticalPercent = float(corticalCount) / float(totalCount) * 100
        cancellousPercent = float(cancellousCount) / float(totalCount) * 100
        otherPercent = 100 - corticalPercent - cancellousPercent

        coP = str("%.0f" % corticalPercent)
        caP = str("%.0f" % cancellousPercent)
        otP = str("%.0f" % otherPercent)

        qtcoP = qt.QTableWidgetItem(coP)
        qtcap = qt.QTableWidgetItem(caP)
        qtotP = qt.QTableWidgetItem(otP)

        self.itemsqtcoP.append(qtcoP)
        self.itemsqtcaP.append(qtcap)
        self.itemsqtotP.append(qtotP)

        logging.debug(screwIndex)
        self.screwTable.setItem(screwIndex, 4, qtcoP)
        self.screwTable.setItem(screwIndex, 3, qtcap)
        self.screwTable.setItem(screwIndex, 2, qtotP)
コード例 #29
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)
コード例 #30
0
    def addNameAndUrl(self, name, url, setModfiable = [True, True]):
        """ Adds a name and url to the table by adding a 
            new row.
        """

        #--------------------
        # Create the modifiable flags corresponding with
        # the 'setModifiable' argument for
        # feeding into the XnatSettingsFile.
        #--------------------
        flags = []
        for state in setModfiable:
            if state:
                flags.append(None)
            else:
                flags.append(1)

                

        #--------------------
        # Add the hostName and hostUrl items
        # accordingly.
        #--------------------                
        hostNameItem = qt.QTableWidgetItem(name)
        if flags[0]:
            hostNameItem.setFlags(flags[0])
        
        hostUrlItem = qt.QTableWidgetItem(url)
        if flags[1]:
            hostUrlItem.setFlags(flags[1])


            
        #--------------------
        # Add the username item.
        #--------------------    
        usernameItem = qt.QTableWidgetItem('No username stored.')


        
        #--------------------
        # Turn sorting off.
        #--------------------         
        self.setSortingEnabled(False)


        
        #--------------------
        # NOTE: QTableWiget quirk: we have to 
        # set the rowcount of the table beforehand.
        #--------------------     
        self.setRowCount(self.rowCount + 1)
    


        #--------------------
        # Add the new items to the 'trackedItems'
        # variable otherwise the table will destroy them
        # and the items will disappear immediately on
        # add.
        #--------------------
        self.trackedItems[self.rowCount-1] = {}
        self.trackedItems[self.rowCount-1]['name'] = hostNameItem
        self.trackedItems[self.rowCount-1]['url'] = hostUrlItem
        self.trackedItems[self.rowCount-1]['stored login'] = usernameItem



        #--------------------
        # Set the added items' aeshetics.
        #--------------------
        for key, item in self.trackedItems[self.rowCount-1].iteritems():
            item.setFont(self.MODULE.GLOBALS.LABEL_FONT)



        #--------------------
        # Call on the QTableWidget 'setItem' function.
        #--------------------
        self.setItem(self.rowCount-1, self.getColumn('name'), hostNameItem)
        self.setItem(self.rowCount-1, self.getColumn('url'), hostUrlItem)
        self.setItem(self.rowCount-1, self.getColumn('stored login'), usernameItem)
 


        #--------------------
        # Again, turn sorting off.
        #--------------------  
        self.setSortingEnabled(False)