Exemplo n.º 1
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
Exemplo n.º 2
0
 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:
     warning = loadable.warning
   else:
     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" + warning)
   warnItem.setToolTip(item.toolTip())
Exemplo n.º 3
0
 def updateObjectTable(self):
   for i in range(self.numObjects):
     if self.currentLabel == str(self.objectTable.item(i,0).text()) and float(self.confidences[i]) > self.confidenceSlider.value/100.0:
       self.objectTable.setItem(i,1,qt.QTableWidgetItem("Yes"))
       self.objectTable.setItem(i,2,qt.QTableWidgetItem(self.confidences[i]))
       self.currentConfidence = self.confidences[i]
     else:
       self.objectTable.setItem(i, 1, qt.QTableWidgetItem("No"))
       self.objectTable.setItem(i, 2, qt.QTableWidgetItem(self.confidences[i]))
Exemplo n.º 4
0
    def onWatchDogStatusChange(self, observer, eventId):

        for dog in range(self.watchDog.GetNumberOfWatchedNodes()):
            if self.watchDog.GetWatchedNodeUpToDate(dog):
                self.table.setItem(
                    dog, 1, qt.QTableWidgetItem('Tool currently in View'))
            else:
                self.table.setItem(
                    dog, 1, qt.QTableWidgetItem('Tool currently NOT in View'))
            dog += 1
Exemplo n.º 5
0
 def onModelSelected(self):
   if self.modelSelector.currentText != "Select model":
     self.applyButton.enabled = True
     self.currentModelDirectory = os.path.join(self.moduleDir, os.pardir, "Models", self.modelSelector.currentText)
     modelObjectClasses = os.listdir(os.path.join(self.currentModelDirectory,"training_photos"))
     self.currentObjectClasses = [dir for dir in modelObjectClasses if dir.find(".") == -1]
     self.objectTable.setRowCount(len(self.currentObjectClasses))
     for i in range (len(self.currentObjectClasses)):
       self.objectTable.setItem(i,0,qt.QTableWidgetItem(self.currentObjectClasses[i]))
       self.objectTable.setItem(i,1,qt.QTableWidgetItem("No"))
Exemplo n.º 6
0
    def run(self):
        """
    Run the actual algorithm
    """

        if not self.input_data_is_valid():
            slicer.util.errorDisplay('No input volume.')
            return False

        if not self.has_image_data():
            slicer.util.errorDisplay(
                'Input volume does not contain image data.')
            return False

        volume_info = DicomAttributesInterface(cn)
        if not volume_info.number_of_slices:
            slicer.util.errorDisplay(
                'Input volume does not contain any slices.')
            return False

        if not volume_info.supported_modality():
            slicer.util.errorDisplay('Image modality not supported.')
            return False

        self.tags["Patient ID"] = volume_info.patient_id
        self.tags["Patient Name"] = volume_info.patient_name
        self.tags["Patient Birth Date"] = volume_info.patient_birth_date
        self.tags["Patient Sex"] = volume_info.patient_sex
        self.tags["Study ID"] = volume_info.study_id
        self.tags["Study Date"] = volume_info.study_date
        self.tags["Study Description"] = volume_info.study_description
        self.tags["Study Instance UID"] = volume_info.study_instance_uid
        self.tags["Series Number"] = volume_info.series_number
        self.tags["Modality"] = volume_info.modality
        self.tags["Series Date"] = volume_info.series_date
        self.tags["Series Description"] = volume_info.series_description
        self.tags["Protocol Name"] = volume_info.protocol_name
        self.tags["Body Part Examined"] = volume_info.body_part_examined
        self.tags["Patient Position"] = volume_info.patient_position
        self.tags["Columns"] = volume_info.columns
        self.tags["Rows"] = volume_info.rows
        self.tags["Number of Slices"] = volume_info.number_of_slices
        self.tags["Pixel Spacing"] = volume_info.pixel_spacing
        self.tags["Slice Thickness"] = volume_info.slice_thickness
        self.tags[
            "Spacing Between Slices"] = volume_info.spacing_between_slices
        self.tags["Voxel Size"] = volume_info.voxel_size
        self.tags["Field of View"] = volume_info.field_of_view
        self.tags["Series Instance UID"] = volume_info.series_instance_uid

        for i, key in enumerate(self.taglist):
            self.table.setItem(i, 0, qt.QTableWidgetItem(key))
            self.table.setItem(i, 1, qt.QTableWidgetItem(self.tags[key]))

        return True
Exemplo n.º 7
0
 def updateObjectTable(self):
     for i in range(self.numObjects):
         if self.currentLabel == str(
                 self.objectTable.item(i, 0).text() + "\n"):
             self.objectTable.setItem(i, 1, qt.QTableWidgetItem("Yes"))
             self.objectTable.setItem(
                 i, 2, qt.QTableWidgetItem(self.confidences[i]))
         else:
             self.objectTable.setItem(i, 1, qt.QTableWidgetItem("No"))
             self.objectTable.setItem(
                 i, 2, qt.QTableWidgetItem(self.confidences[i]))
Exemplo n.º 8
0
  def set_table_data(self, data_dict):
    """ Write doccumentation.
    """

    for i, key in enumerate(TAGLIST):
      self.setItem(i, 0, qt.QTableWidgetItem(key))
      if data_dict(key) is not None:
        self.setItem(i, 1, qt.QTableWidgetItem(data_dict(key)))
      else:
        self.setItem(i, 1, qt.QTableWidgetItem(u'N/A'))
    self.resizeColumnsToContents()
    self.resizeRowsToContents()
Exemplo n.º 9
0
    def addLabel(self, row, rgb, val):
        #print "add row", row, rgb
        self.selectLabels.setRowCount(row+1)

        item0 = qt.QTableWidgetItem('')
        item0.setFlags(qt.Qt.ItemIsUserCheckable | qt.Qt.ItemIsEnabled)
        item0.setCheckState(qt.Qt.Unchecked)
        self.selectLabels.setItem(row,0,item0)

        item1 = qt.QTableWidgetItem('')
        color=qt.QColor()
        color.setRgbF(rgb[0],rgb[1],rgb[2])
        item1.setData(qt.Qt.BackgroundRole,color)
        item1.setText(val)
        self.selectLabels.setItem(row,1,item1)
Exemplo n.º 10
0
    def addLabel(self, row, rgb, values):
        self.selectLabels.setRowCount(row + 1)

        item0 = qt.QTableWidgetItem('')
        item0.setFlags(qt.Qt.ItemIsUserCheckable | qt.Qt.ItemIsEnabled)
        item0.setCheckState(qt.Qt.Unchecked)
        self.selectLabels.setItem(row, 0, item0)

        for ii, val in enumerate(values):
            item1 = qt.QTableWidgetItem('')
            color = qt.QColor()
            color.setRgbF(rgb[0], rgb[1], rgb[2])
            item1.setData(qt.Qt.BackgroundRole, color)
            item1.setText("%.02f" % val)
            self.selectLabels.setItem(row, 1 + ii, item1)
Exemplo n.º 11
0
 def addWarningColumn(self, item, loadable, row):
     warning = loadable.warning if loadable.warning else ''
     warnItem = qt.QTableWidgetItem(warning)
     warnItem.setFlags(warnItem.flags() ^ qt.Qt.ItemIsEditable)
     self.setItem(row, 2, warnItem)
     item.setToolTip(item.toolTip() + "\n" + warning)
     warnItem.setToolTip(item.toolTip())
Exemplo n.º 12
0
 def addReaderColumn(self, item, reader, row):
     if not reader:
         return
     readerItem = qt.QTableWidgetItem(reader)
     readerItem.setFlags(readerItem.flags() ^ qt.Qt.ItemIsEditable)
     self.setItem(row, 1, readerItem)
     readerItem.setToolTip(item.toolTip())
Exemplo n.º 13
0
    def readResponseCSVFile(self, cacheFile):
        table = self.clinicalDataTableWidget
        self.tableItems = []
        table.clear()
        accessLabelText = 'Accessed: ' + time.ctime(
            os.path.getmtime(self.cacheFile))
        self.accessLabel.setText(accessLabelText)
        data = []
        data = list(csv.reader(open(self.cacheFile, 'rb'), delimiter='\t'))
        headers = data[0]
        table.setRowCount(len(headers))
        table.setColumnCount(1)
        table.setVerticalHeaderLabels(headers)
        horizontalHeader = table.horizontalHeader()
        horizontalHeader.hide()
        horizontalHeader.setStretchLastSection(True)
        patient = None

        for row in data:
            for item in row:
                if self.patient in item:
                    patient = row

        if patient != None:
            for index, item in enumerate(patient):
                tableItem = qt.QTableWidgetItem(str(item))
                table.setItem(index, 0, tableItem)
                self.tableItems.append(tableItem)
        else:
            message = "The Selected Patient is not in the list provided by cBioportal Server"
            qt.QMessageBox.critical(slicer.util.mainWindow(), 'TCIA Browser',
                                    message, qt.QMessageBox.Ok)
            print 'patient not in the query'
Exemplo n.º 14
0
 def addLoadableRow(self, loadable, row, reader):
     self.insertRow(row)
     self.loadables[row] = loadable
     item = qt.QTableWidgetItem(loadable.name)
     self.setItem(row, 0, item)
     self.setCheckState(item, loadable)
     self.addReaderColumn(item, reader, row)
     self.addWarningColumn(item, loadable, row)
Exemplo n.º 15
0
 def updateResultsTable( self, errorList ):
   self.resultsTable.setRowCount( len( errorList ) )
   
   for i in range( len( errorList ) ):
     errorElement = errorList[ i ]
   
     fromItem = qt.QTableWidgetItem( errorElement[ self.RESULTS_IMAGE_POINTS_INDEX ] )
     self.resultsTable.setItem( i, self.RESULTS_IMAGE_POINTS_INDEX, fromItem )
     toItem = qt.QTableWidgetItem( errorElement[ self.RESULTS_PROBE_POINTS_INDEX ] )
     self.resultsTable.setItem( i, self.RESULTS_PROBE_POINTS_INDEX, toItem )
     errorItem = qt.QTableWidgetItem( str( round( errorElement[ self.RESULTS_ERROR_INDEX ], 2 ) ) )
     self.resultsTable.setItem( i, self.RESULTS_ERROR_INDEX, errorItem )
     
     deleteButton = qt.QPushButton()
     deleteButton.setIcon( slicer.app.style().standardIcon( qt.QStyle.SP_DialogDiscardButton ) )
     deleteButton.connect( "clicked()", partial( self.pbucLogic.DeleteNthPoint, self.frwNodeSelector.currentNode(), i ) )
     self.resultsTable.setCellWidget( i, self.RESULTS_DELETE_INDEX, deleteButton )
    def onTCIACollectionChanged(self, item):
        print 'onTCIACollectionChanged()'
        self.patientsTable.clear()
        self.patientsTable.setSortingEnabled(False)
        self.patientsTable.setHorizontalHeaderLabels(
            self.patientsTableHeaderLabels)
        self.patientGroupBox.setTitle('Patient Selection (TCIA)')
        self.examinePatientButton.disconnect('clicked(bool)')
        self.examinePatientButton.setText("Download && Examine Patient")
        self.examinePatientButton.connect('clicked(bool)',
                                          self.onDownloadAndExaminePatient)
        # populate table using methods from TCIA browser
        resp = self.tcia.TCIAClient.get_patient(
            collection=self.collectionsComboBox.currentText)
        patients = json.load(resp)
        count = 0
        self.patientsTable.setRowCount(len(patients))
        for patient in patients:
            keys = patient.keys()
            for key in keys:
                if key == 'PatientID':
                    self.patientsTable.setItem(
                        count, 0,
                        qt.QTableWidgetItem(str(patient['PatientID'])))
                if key == 'PatientName':
                    self.patientsTable.setItem(
                        count, 1,
                        qt.QTableWidgetItem(str(patient['PatientName'])))
                if key == 'PatientBirthDate':
                    self.patientsTable.setItem(
                        count, 2,
                        qt.QTableWidgetItem(str(patient['PatientBirthDate'])))
                if key == 'PatientSex':
                    self.patientsTable.setItem(
                        count, 3,
                        qt.QTableWidgetItem(str(patient['PatientSex'])))
            count += 1

        self.patientsTable.resizeColumnsToContents()
        self.patientsTableHeader.setStretchLastSection(True)
        self.patientsTable.setSortingEnabled(True)
        self.patientsTableHeader.setSortIndicator(0,
                                                  0)  # order by patient name
        self.patientsTable.selectRow(0)
        self.examinePatientButton.enabled = True
Exemplo n.º 17
0
    def onWatchDogCollapsibleButton(self):
        if self.watchDog == None:
            self.watchDog = slicer.vtkMRMLWatchdogNode()
            self.watchDog.SetName('RFNavigationToolWatcher')
            slicer.mrmlScene.AddNode(self.watchDog)
        igtConnections = slicer.mrmlScene.GetNodesByClass(
            'vtkMRMLIGTLConnectorNode')

        for i in range(igtConnections.GetNumberOfItems()):
            if igtConnections.GetItemAsObject(i).GetState() == 2:
                row = 0
                for j in range(
                        igtConnections.GetItemAsObject(
                            i).GetNumberOfIncomingMRMLNodes()):
                    if "Reference" in igtConnections.GetItemAsObject(
                            i).GetIncomingMRMLNode(j).GetName():
                        self.watchDog.AddWatchedNode(
                            igtConnections.GetItemAsObject(
                                i).GetIncomingMRMLNode(j))
                        self.watchDog.SetWatchedNodePlaySound(row, True)
                        self.table.insertRow(row)
                        self.table.setItem(
                            row, 0,
                            qt.QTableWidgetItem(
                                igtConnections.GetItemAsObject(
                                    i).GetIncomingMRMLNode(j).GetName()))
                        if self.watchDog.GetWatchedNodeUpToDate(row):
                            self.table.setItem(
                                row, 1,
                                qt.QTableWidgetItem('Tool currently in View'))
                        else:
                            self.table.setItem(
                                row, 1,
                                qt.QTableWidgetItem(
                                    'Tool currently NOT in View'))

                        tag = self.watchDog.GetWatchedNode(row).AddObserver(
                            vtk.vtkCommand.ModifiedEvent,
                            self.onWatchDogStatusChange)
                        row = row + 1
            else:
                pass
Exemplo n.º 18
0
 def updateTable(self):
   self.resetTable()
   if not self.currentNode:
     return
   nOfControlPoints = self.currentNode.GetNumberOfFiducials()
   if self.table.rowCount != nOfControlPoints:
     self.table.setRowCount(nOfControlPoints)
   for i in range(nOfControlPoints):
     label = self.currentNode.GetNthFiducialLabel(i)
     cellLabel = qt.QTableWidgetItem(label)
     self.table.setItem(i, 0, cellLabel)
     self.addDeleteButton(i, 1)
Exemplo n.º 19
0
 def displaySearchResults( self, searchResults ): # look into highlighting query rows or another option to remove session numbers
   # Add a table with all the search results
   searchResultsTable = qt.QTableWidget()
   searchResultsTable.setWindowTitle( "Sessions" )
   searchResultsTable.resize( 6 * SEARCH_TABLE_ID_COLUMN_WIDTH, 4 * SEARCH_TABLE_ID_COLUMN_WIDTH )
   
   searchResultsTable.setRowCount( len( searchResults ) )
   searchResultsTable.setColumnCount( SEARCH_TABLE_NUMBER_OF_COLUMNS )
   searchResultsTable.setHorizontalHeaderItem( 0, qt.QTableWidgetItem( "User ID" ) )
   searchResultsTable.setColumnWidth( 0, SEARCH_TABLE_ID_COLUMN_WIDTH )
   searchResultsTable.setHorizontalHeaderItem( 1, qt.QTableWidgetItem( "Study ID" ) )
   searchResultsTable.setColumnWidth( 1, SEARCH_TABLE_ID_COLUMN_WIDTH )
   searchResultsTable.setHorizontalHeaderItem( 2, qt.QTableWidgetItem( "Trial ID" ) )
   searchResultsTable.setColumnWidth( 2, SEARCH_TABLE_ID_COLUMN_WIDTH )
   searchResultsTable.setHorizontalHeaderItem( 3, qt.QTableWidgetItem( "Skill Level" ) )
   searchResultsTable.setColumnWidth( 3, SEARCH_TABLE_ID_COLUMN_WIDTH )
   searchResultsTable.setHorizontalHeaderItem( 4, qt.QTableWidgetItem( "Date" ) )
   searchResultsTable.setColumnWidth( 4, 2 * SEARCH_TABLE_ID_COLUMN_WIDTH )
   
   for row in range( len( searchResults ) ):
     for col in range( SEARCH_TABLE_NUMBER_OF_COLUMNS ):
       searchResultsTable.setItem( row, col, qt.QTableWidgetItem( searchResults[ row ][ col ] ) )
   
   searchResultsTable.show() 
   
   searchResultsTable.connect( "cellDoubleClicked(int,int)", partial( self.onLoadSession, searchResultsTable, searchResults ) )           
 def updateForm(self):
     datasetId = self.getSelectedId()
     if datasetId == -1:  # clear form
         pass
     datasetname = self.datasets[datasetId]
     self.customFormName.text = datasetname
     url = self.projectURL + '/ViewMD/index.html?src=../resources/db_info/' + datasetname + '_Info.md'
     self.customFormDatasetInfo.text = '<a href=\"' + url + '\">info</a>'
     datasetFiles = self.listFilesForDataset(datasetname)
     self.customFormFiles.setRowCount(len(datasetFiles))
     for i in range(len(datasetFiles)):
         fname = datasetFiles[i]["name"]
         fsize = datasetFiles[i]["size"]
         remoteName = os.path.join(datasetname, fname.replace('/', os.sep))
         localName = os.path.join(self.localCashFolder, remoteName)
         downloaded = os.path.exists(localName)
         self.customFormFiles.setItem(i, 0, qt.QTableWidgetItem())
         self.customFormFiles.item(i, 0).setIcon(
             self.storedIcon if downloaded else self.downloadIcon)
         self.customFormFiles.item(i, 0).setToolTip(
             'downloaded' if downloaded else 'available for download')
         self.customFormFiles.setItem(i, 1, qt.QTableWidgetItem(fname))
         self.customFormFiles.setItem(
             i, 2, qt.QTableWidgetItem(self.hrSize(fsize)))
Exemplo n.º 21
0
    def showRecordingResult(self):
        import json
        eventCount = len(self.logic.recordedEvents)
        self.ui.recordingTableWidget.setRowCount(eventCount)
        columnNameToEventProperty = [['Node name', 'nodeName'],
                                     ['Event type', 'event'],
                                     ['Event ID', 'eventId'],
                                     ['Node ID', 'nodeId']]
        for rowIndex, eventInfo in enumerate(self.logic.recordedEvents):
            for columnName, eventProperty in columnNameToEventProperty:
                if eventProperty in eventInfo:
                    text = str(eventInfo[eventProperty])
                else:
                    text = ''
                self.ui.recordingTableWidget.setItem(
                    rowIndex, self.recordingTableColumnNames.index(columnName),
                    qt.QTableWidgetItem(text))

            widget = self.ui.recordingTableWidget.item(rowIndex, 0)
            widget.setData(qt.Qt.UserRole, json.dumps(eventInfo))
Exemplo n.º 22
0
  def displayResults(self): # look into highlighting query rows or another option to remove session numbers
    numRows = len(self.results)
    self.table.setRowCount(numRows)
    self.table.setHorizontalHeaderItem(0, qt.QTableWidgetItem("UserID"))
    self.table.setHorizontalHeaderItem(1, qt.QTableWidgetItem("StudyID"))
    self.table.setColumnWidth(1, 150)
    self.table.setHorizontalHeaderItem(2, qt.QTableWidgetItem("TrialID"))
    self.table.setHorizontalHeaderItem(3, qt.QTableWidgetItem("Skill Level"))
    self.table.setColumnWidth(3, 150)
    self.table.setHorizontalHeaderItem(4, qt.QTableWidgetItem("Date"))
    self.table.setColumnWidth(4, 300)
    for row in range(0, numRows):
       for col in range(0, 5):
          self.table.setItem(row, col, qt.QTableWidgetItem(self.results[row][col]))

    self.queryResultsCollapsibleButton.setVisible(True)
Exemplo n.º 23
0
  def show_deer_db_table(self):
    if self._parameterNode is None or self._updatingGUIFromParameterNode:
      return

    wasModified = self._parameterNode.StartModify()

    sids = []   

    if self.ui.cbShowControl.checked:
      sids.extend([sid for sid in self.logic.deers.keys() if self.logic.deers[sid].group == "c"])
    if self.ui.cbShowNonControl.checked:
      sids.extend([sid for sid in self.logic.deers.keys() if self.logic.deers[sid].group == "p"])
    sids = sorted(sids)

    tbl = self.ui.tblDeers
    tbl.clear()
    tbl.clearContents()

    db_info_filter = ["sid","spieces","group","count","abnorm","done"]
    
    tbl.setColumnCount(len(db_info_filter))
    tbl.setRowCount(len(sids))
    
    for i in range(len(sids)):
      deer = self.logic.deers[sids[i]]
      deer.update_done(self.logic.dbTable)
      for j in range(len(db_info_filter)):
        tbl.setItem(i,j,qt.QTableWidgetItem(deer.db_info.get(db_info_filter[j])))
        if j!=(len(db_info_filter)-1):
          #tbl.item(i,j).setFlags(qt.Qt.ItemIsEnabled)
          pass

      if deer.db_info.get("done") == str(1):
        for j in range(self.ui.tblDeers.columnCount):
          tbl.item(i,j).setBackground(qt.QColor(0,127,0))


    tbl.setHorizontalHeaderLabels(db_info_filter)
    tbl.resizeColumnsToContents()
    self._parameterNode.EndModify(wasModified) 
Exemplo n.º 24
0
    def importFiles(self, filePaths):

        numCases = 0
        self.SubjectsTableWidget.setColumnCount(1)
        self.SubjectsTableWidget.setHorizontalHeaderLabels(['Subject name'])
        self.SubjectsTableWidget.verticalHeader().setVisible(False)
        self.SubjectsTableWidget.setSelectionBehavior(
            qt.QAbstractItemView.SelectRows)
        self.SubjectsTableWidget.setSelectionMode(
            qt.QAbstractItemView.SingleSelection)

        if self.logic.importFiles(filePaths):

            for path in filePaths:
                # load each file
                pathPair = os.path.split(path)
                fileName = pathPair[1]

                # extract just the filename, and populate the tablewidget
                rowPosition = self.SubjectsTableWidget.rowCount
                self.SubjectsTableWidget.insertRow(rowPosition)
                self.SubjectsTableWidget.setItem(rowPosition, 0,
                                                 qt.QTableWidgetItem(fileName))
                numCases = numCases + 1
            self.SubjectsTableWidget.setCurrentCell(0, 0)
        else:
            return

        labelRangeInCohort = self.logic.getLabelRangeInCohort()
        self.StructuresSliderWidget.minimum = int(labelRangeInCohort[0])
        self.StructuresSliderWidget.maximum = int(labelRangeInCohort[1])
        self.StructuresSliderWidget.setValue(0)

        # Populate the topology table
        self.logic.populateTopologyDictionary()

        self.onSubjectTableWidgetClicked(0, 0)
Exemplo n.º 25
0
    def updateIntersectionTable(self):
        ##    logic = PathCollisionAnalysisLogic()
        modelHierarchyNode = self.inputModelHierarchySelector.currentNode()
        fiducialNode = self.inputFiducialSelector.currentNode()

        if (not modelHierarchyNode) or (not fiducialNode):
            self.intersectionTable.clear()
            self.intersectionTable.setHorizontalHeaderLabels(
                self.intersectionTableHeader)

        else:
            nObjects = len(self.objectIDs)
            self.intersectionTable.setRowCount(nObjects)
            for i in range(nObjects):
                # "Model", "Entry 1", "Entry 2", "Length", "Curvature 1", "Curvature 2"
                self.intersectionTable.setItem(
                    i, 0, qt.QTableWidgetItem(self.objectNames[i]))
                angles = self.entryAngles[i]
                normals = self.normalVectors[i]
                curv = self.curvatures[i]
                radNormals = self.radiusNormals[i]
                nEntry = 2
                if len(angles) < 2:
                    nEntry = 1
                for j in range(2):
                    if j < nEntry:
                        lb = "%f (%f, %f, %f)" % (angles[j], normals[j][0],
                                                  normals[j][1], normals[j][2])
                        self.intersectionTable.setItem(i, j + 1,
                                                       qt.QTableWidgetItem(lb))
                        lb = "%f (%f, %f, %f)" % (curv[j], radNormals[j][0],
                                                  radNormals[j][1],
                                                  radNormals[j][2])
                        self.intersectionTable.setItem(i, j + 4,
                                                       qt.QTableWidgetItem(lb))
                    else:
                        self.intersectionTable.setItem(
                            i, j + 1, qt.QTableWidgetItem("--"))
                        self.intersectionTable.setItem(
                            i, j + 4, qt.QTableWidgetItem("--"))
                self.intersectionTable.setItem(
                    i, 3,
                    qt.QTableWidgetItem("%f" % self.totalLengthInObject[i]))
        self.intersectionTable.show()
Exemplo n.º 26
0
 def onMarkupAdded(self, fiducialNodeCaller, event):
   # Set the location and index to zero because its needs to be initialized
   centroid=[0,0,0]
   # This checks if there is not a display node 
   if self.fiducialNode.GetDisplayNode() is None:
     # then creates one if that is the case 
     self.fiducialNode.CreateDefaultDisplayNodes()
     # This sets a variable as the display node
   displayNode = self.fiducialNode.GetDisplayNode()
   # This sets the type to be a cross hair
   displayNode.SetGlyphType(3)
   # This sets the size
   displayNode.SetGlyphScale(2.5)
   # This says that you dont want text
   displayNode.SetTextScale(0)
   # This sets the color
   displayNode.SetSelectedColor(0, 0, 1)
   # This saves the location the markup is place
   # Collect the point in image space
   self.fiducialNode.GetMarkupPoint(self.fiducialNode.GetNumberOfMarkups()-1, 0, centroid)
   tipToProbeTransform = vtk.vtkMatrix4x4()
   self.TransformSelector.currentNode().GetMatrixTransformToWorld(tipToProbeTransform)
   origin = [tipToProbeTransform.GetElement(0, 3), tipToProbeTransform.GetElement(1,3), tipToProbeTransform.GetElement(2,3)]
   dir = [tipToProbeTransform.GetElement(0, 2), tipToProbeTransform.GetElement(1,2), tipToProbeTransform.GetElement(2,2)]
   if self.fidCount == 0:
     self.logic.AddPointAndLineMan([centroid[0],centroid[1],0], origin, dir)
   if self.fidCount == 1: 
     self.logic.AddPointAndLineMan([0,centroid[1],centroid[2]], origin, dir)
   self.ImageToProbe = self.logic.manualRegLogic.CalculateRegistration()
   self.transformTable.setItem(0,0, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(0,0))))
   self.transformTable.setItem(0,1, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(0,1))))
   self.transformTable.setItem(0,2, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(0,2))))
   self.transformTable.setItem(0,3, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(0,3))))
   self.transformTable.setItem(1,0, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(1,0))))
   self.transformTable.setItem(1,1, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(1,1))))
   self.transformTable.setItem(1,2, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(1,2))))
   self.transformTable.setItem(1,3, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(1,3))))
   self.transformTable.setItem(2,0, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(2,0))))
   self.transformTable.setItem(2,1, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(2,1))))
   self.transformTable.setItem(2,2, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(2,2))))
   self.transformTable.setItem(2,3, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(2,3))))
   self.transformTable.setItem(3,0, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(3,0))))
   self.transformTable.setItem(3,1, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(3,1))))
   self.transformTable.setItem(3,2, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(3,2))))
   self.transformTable.setItem(3,3, qt.QTableWidgetItem(str(self.ImageToProbe.GetElement(3,3))))
   self.transformTable.resizeColumnToContents(0)
   self.transformTable.resizeColumnToContents(1)
   self.transformTable.resizeColumnToContents(2)
   self.transformTable.resizeColumnToContents(3)
   self.fiducialNode.RemoveAllMarkups()
   self.fiducialNode.RemoveObserver(self.markupAddedObserverTag) 
   slicer.mrmlScene.RemoveNode(self.fiducialNode)
   self.fiducialNode = None
   if slicer.mrmlScene.GetNodesByClass("vtkMRMLSequenceNode").GetNumberOfItems() == 0:
     if self.fidCount == 0: 
       slicer.modules.markups.logic().StartPlaceMode(0)
       self.redWidget.setCursor(qt.QCursor(2))
       self.yellowWidget.setCursor(qt.QCursor(2))
     if self.fidCount == 1:
       self.connectorNode.Start()
       self.connectorNode2.Start()
       self.connectButton.text = "Disconnect"
       self.freezeButton.text = "Freeze"
Exemplo n.º 27
0
    def updateTable(self):
        self.fiducialsCollapsibleButton.show()
        fiducialsLogic = slicer.modules.markups.logic()
        originalActiveListID = fiducialsLogic.GetActiveListID()
        originalActiveList = SlicerUtil.getNode(originalActiveListID)
        self.tableWidget.show()
        self.deleteButton.enabled = True
        self.deleteAllButton.enabled = True

        if originalActiveList.GetName() == 'LO':

            if self.tableWidget.rowCount == 0:
                self.tableWidget.setRowCount(1)
            elif self.leftRow >= self.rightObliqueRow and self.leftRow >= self.rightHorizontalRow:
                self.tableWidget.setRowCount(self.leftRow + 1)
            elif self.rightObliqueRow > self.leftRow and self.rightObliqueRow > self.rightHorizontalRow:
                self.tableWidget.setRowCount(self.rightObliqueRow)
            elif self.rightHorizontalRow > self.leftRow and self.rightHorizontalRow > self.rightObliqueRow:
                self.tableWidget.setRowCount(self.rightHorizontalRow)

            lastElement = originalActiveList.GetNumberOfFiducials() - 1
            item = qt.QTableWidgetItem(
                originalActiveList.GetNthFiducialLabel(lastElement))
            item.setToolTip(originalActiveList.GetName())
            self.tableItems.append(item)
            self.tableWidget.setItem(self.leftRow, 0, item)
            self.leftRow += 1

        elif originalActiveList.GetName() == 'RO':

            if self.tableWidget.rowCount == 0:
                self.tableWidget.setRowCount(1)
            elif self.leftRow > self.rightObliqueRow and self.leftRow > self.rightHorizontalRow:
                self.tableWidget.setRowCount(self.leftRow)
            elif self.rightObliqueRow >= self.leftRow and self.rightObliqueRow >= self.rightHorizontalRow:
                self.tableWidget.setRowCount(self.rightObliqueRow + 1)
            elif self.rightHorizontalRow > self.leftRow and self.rightHorizontalRow > self.rightObliqueRow:
                self.tableWidget.setRowCount(self.rightHorizontalRow)

            lastElement = originalActiveList.GetNumberOfFiducials() - 1
            item = qt.QTableWidgetItem(
                originalActiveList.GetNthFiducialLabel(lastElement))
            item.setToolTip(originalActiveList.GetName())
            self.tableItems.append(item)
            self.tableWidget.setItem(self.rightObliqueRow, 1, item)
            self.rightObliqueRow += 1

        elif originalActiveList.GetName() == 'RH':

            if self.tableWidget.rowCount == 0:
                self.tableWidget.setRowCount(1)
            elif self.leftRow > self.rightObliqueRow and self.leftRow > self.rightHorizontalRow:
                self.tableWidget.setRowCount(self.leftRow)
            elif self.rightObliqueRow > self.leftRow and self.rightObliqueRow > self.rightHorizontalRow:
                self.tableWidget.setRowCount(self.rightObliqueRow)
            elif self.rightHorizontalRow >= self.leftRow and self.rightHorizontalRow >= self.rightObliqueRow:
                self.tableWidget.setRowCount(self.rightHorizontalRow + 1)

            lastElement = originalActiveList.GetNumberOfFiducials() - 1
            item = qt.QTableWidgetItem(
                originalActiveList.GetNthFiducialLabel(lastElement))
            item.setToolTip(originalActiveList.GetName())
            self.tableItems.append(item)
            self.tableWidget.setItem(self.rightHorizontalRow, 2, item)
            self.rightHorizontalRow += 1
 def updateTableElement(self, identifier):
     datasetname = self.datasets[identifier]
     self.table.setItem(identifier, 0, qt.QTableWidgetItem(datasetname))
Exemplo n.º 29
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)

    # Instantiate and connect widgets ...

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

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

    #
    # input volume selector
    #
    self.inputSelector = slicer.qMRMLNodeComboBox()
    self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.inputSelector.selectNodeUponCreation = True
    self.inputSelector.addEnabled = False
    self.inputSelector.removeEnabled = False
    self.inputSelector.noneEnabled = False
    self.inputSelector.showHidden = False
    self.inputSelector.showChildNodeTypes = False
    self.inputSelector.setMRMLScene( slicer.mrmlScene )
    self.inputSelector.setToolTip( "Pick the input to the algorithm." )
    parametersFormLayout.addRow("Input Volume: ", self.inputSelector)

    # 
    # Spawn table view for common DICOM tags and their values
    # 
    self.taglist = {
      "Patient ID" : "N/A",
      "Patient Name" : "N/A",
      "Patient Birth Date" : "N/A",
      "Patient Sex" : "N/A",
      "Study ID" : "N/A",
      "Study Date" : "N/A",
      "Study Description" : "N/A",
      "Study Instance UID" : "N/A",
      "Series Number" : "N/A",
      "Modality" : "N/A",
      "Series Date" : "N/A",
      "Series Description" : "N/A",
      "Protocol Name" : "N/A",
      "Body Part Examined" : "N/A",
      "Patient Position" : "N/A",
      "Columns" : "N/A",
      "Rows" : "N/A",
      "Number of Slices" : "N/A",
      "Pixel Spacing" : "N/A",
      "Slice Thickness" : "N/A",
      "Spacing Between Slices" : "N/A",
      "Voxel Size" : "N/A",
      "Field of View" : "N/A",
      "Series Instance UID" : "N/A",
    }
    self.table = qt.QTableWidget(parametersCollapsibleButton)
    self.table.setColumnCount(2)
    #self.table.setRowCount(24)
    self.table.setRowCount(len(self.taglist))
    self.table.setHorizontalHeaderLabels(["Attribute", "Value"]) # This must follow table resize

    i = 0
    for key, value in self.taglist.iteritems():
      self.table.setItem(i, 0, qt.QTableWidgetItem(key))
      self.table.setItem(i, 1, qt.QTableWidgetItem(value))
      i = i + 1
    #for i in range(25):
    #  self.table.setItem(i, 1, qt.QTableWidgetItem("N/A"))

    self.table.resizeColumnsToContents()
    self.table.resizeRowsToContents()
    self.table.setAlternatingRowColors(True)
    self.table.setShowGrid(False)
    self.table.verticalHeader().hide()
    parametersFormLayout.addRow("Volume Info:", self.table)

    # connections
    self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

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

    # Refresh Table view state
    self.onSelect(self.inputSelector.currentNode())
Exemplo n.º 30
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)
    # layoutLogic = slicer.app.layoutManager.layoutLogic()
    slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutSideBySideView)    
    l = slicer.modules.createmodels.logic()
    self.needleModel = l.CreateNeedle(150, 0.4, 0, False)
    self.redWidget = slicer.app.layoutManager().sliceWidget('Red')
    self.yellowWidget = slicer.app.layoutManager().sliceWidget('Yellow')    
    self.usContainer = ctk.ctkCollapsibleButton()
    #This is what the button will say 
    self.usContainer.text = "Connection Information"
    #Thiss actually creates that button
    #This creates a variable that describes layout within this collapsible button 
    self.usLayout = qt.QFormLayout(self.usContainer)

    if slicer.mrmlScene.GetNodesByClass("vtkMRMLSequenceNode").GetNumberOfItems() == 0:
      #This is a push button 
      self.connectButton = qt.QPushButton()
      self.connectButton.setDefault(False)
      #This button says connect 
      self.connectButton.text = "Connect"
      #help tooltip that explains the funciton 
      self.connectButton.toolTip = "Connects to ultrasound"
      #adds the widget to the layout      
      self.usLayout.addWidget(self.connectButton)
    
    # self.normalImageButton = qt.QCheckBox() 
    # self.normalImageButton.text = "Select if performing a 2D Calibration"
    # self.usLayout.addRow(self.normalImageButton)
    
    self.imageSelector = slicer.qMRMLNodeComboBox()
    self.imageSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.imageSelector.selectNodeUponCreation = True
    self.imageSelector.addEnabled = False
    self.imageSelector.removeEnabled = False
    self.imageSelector.noneEnabled = True
    self.imageSelector.showHidden = False
    self.imageSelector.showChildNodeTypes = False
    self.imageSelector.setMRMLScene( slicer.mrmlScene )
    self.imageSelector.setToolTip( "Pick the image to be used." )
    self.usLayout.addRow("Left view volume: ", self.imageSelector)
    
    
    self.imageSelector2 = slicer.qMRMLNodeComboBox()
    self.imageSelector2.nodeTypes = ["vtkMRMLScalarVolumeNode"]
    self.imageSelector2.selectNodeUponCreation = True
    self.imageSelector2.addEnabled = False
    self.imageSelector2.removeEnabled = False
    self.imageSelector2.noneEnabled = True
    self.imageSelector2.showHidden = False
    self.imageSelector2.showChildNodeTypes = False
    self.imageSelector2.setMRMLScene( slicer.mrmlScene )
    self.imageSelector2.setToolTip( "Pick the image to be used." )
    self.usLayout.addRow("Right view volume: ", self.imageSelector2)
    
        #add combo box for linear transform node 
    self.TransformSelector = slicer.qMRMLNodeComboBox()
    self.TransformSelector.nodeTypes = ["vtkMRMLLinearTransformNode"]
    self.TransformSelector.selectNodeUponCreation = True
    self.TransformSelector.addEnabled = False
    self.TransformSelector.removeEnabled = False
    self.TransformSelector.noneEnabled = True
    self.TransformSelector.showHidden = False
    self.TransformSelector.showChildNodeTypes = False
    self.TransformSelector.setMRMLScene( slicer.mrmlScene )
    self.TransformSelector.setToolTip( "Pick the transform representing the straw line." )
    self.usLayout.addRow("Tip to Probe: ", self.TransformSelector)
    
    self.recordContainer = ctk.ctkCollapsibleButton()
    #This is what the button will say 
    self.recordContainer.text = "Recording Options"
    #Thiss actually creates that button
    #This creates a variable that describes layout within this collapsible button 
    self.recordLayout = qt.QFormLayout(self.recordContainer)
    
    self.RecordButton = qt.QPushButton() 
    self.RecordButton.text = "Start Recording" 
    self.recordLayout.addWidget(self.RecordButton)
    
    self.StopRecordButton = qt.QPushButton() 
    self.StopRecordButton.text = "Stop Recording" 
    self.recordLayout.addWidget(self.StopRecordButton)
    
    self.pathInput = qt.QLineEdit()
    self.pathInput.setPlaceholderText("Enter the path to save files to")
    self.pathText = qt.QLabel("File Path:")
    self.recordLayout.addRow(self.pathText, self.pathInput)

    self.SaveRecordButton = qt.QPushButton() 
    self.SaveRecordButton.text = "Save Recording" 
    self.recordLayout.addWidget(self.SaveRecordButton)
    
    # This creates another collapsible button
    self.fiducialContainer = ctk.ctkCollapsibleButton()
    self.fiducialContainer.text = "Registration"

    self.fiducialLayout = qt.QFormLayout(self.fiducialContainer)

    self.freezeButton = qt.QPushButton()
    if slicer.mrmlScene.GetNodesByClass("vtkMRMLSequenceNode").GetNumberOfItems() == 0:
      self.freezeButton.text = "Freeze"
    else:
      self.freezeButton.text = "Place Fiducial"
    self.freezeButton.toolTip = "Freeze the ultrasound image for fiducial placement"
    self.fiducialLayout.addRow(self.freezeButton)
    self.shortcut = qt.QShortcut(qt.QKeySequence('f'), slicer.util.mainWindow())
    
    self.numFidLabel = qt.QLabel()
    self.fiducialLayout.addRow(qt.QLabel("Fiducials collected:"), self.numFidLabel)

    self.transformTable = qt.QTableWidget() 
    self.transTableItem = qt.QTableWidgetItem()
    self.fidError = qt.QLabel()
    self.transformTable.setRowCount(4)
    self.transformTable.setColumnCount(4)
    self.transformTable.horizontalHeader().hide()
    self.transformTable.verticalHeader().hide()
    self.transformTable.setItem(0,0, qt.QTableWidgetItem("1"))
    self.transformTable.setItem(0,1, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(0,2, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(0,3, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(1,0, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(1,1, qt.QTableWidgetItem("1"))
    self.transformTable.setItem(1,2, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(1,3, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(2,0, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(2,1, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(2,2, qt.QTableWidgetItem("1"))
    self.transformTable.setItem(2,3, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(3,0, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(3,1, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(3,2, qt.QTableWidgetItem("0"))
    self.transformTable.setItem(3,3, qt.QTableWidgetItem("1"))
    self.transformTable.setSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.MinimumExpanding)
    self.copyIcon =qt.QIcon(":Icons/Medium/SlicerEditCopy.png")
    self.copyButton = qt.QPushButton()
    self.copyButton.setIcon(self.copyIcon)
    self.copyButton.setMaximumWidth(64)
    self.copyButton.enabled = False 
    if self.numFidLabel >= 2: 
      self.copyButton.enabled = True 
      
    self.fiducialLayout.addRow(qt.QLabel("Image to probe transform:"))
    self.fiducialLayout.addRow(self.transformTable)
    self.fiducialLayout.addRow("Copy:", self.copyButton)
    
    self.validationContainer = ctk.ctkCollapsibleButton()
    self.validationContainer.text = "Validation"
    self.validationLayout = qt.QFormLayout(self.validationContainer)

    self.visualizeButton = qt.QPushButton('Show 3D Scene')
    self.visualizeButton.toolTip = "This button enables the 3D view for visual validation"
    self.validationLayout.addRow(self.visualizeButton)
    self.visualizeButton.connect('clicked(bool)', self.onVisualizeButtonClicked)
    
    self.layout.addWidget(self.usContainer)
    if slicer.mrmlScene.GetNodesByClass("vtkMRMLSequenceNode").GetNumberOfItems() == 0:
      self.layout.addWidget(self.recordContainer)
    self.layout.addWidget(self.fiducialContainer)
    self.layout.addWidget(self.validationContainer)
    
    if slicer.mrmlScene.GetNodesByClass("vtkMRMLSequenceNode").GetNumberOfItems() == 0:
      self.connectButton.connect('clicked(bool)', self.onConnectButtonClicked)
      self.freezeButton.connect('clicked(bool)', self.onConnectButtonClicked)
      self.shortcut.connect('activated()', self.onConnectButtonClicked)
      self.RecordButton.connect('clicked(bool)', self.onRecordButtonClicked)
      self.StopRecordButton.connect('clicked(bool)', self.onStopButtonClicked)
      self.SaveRecordButton.connect('clicked(bool)', self.onSaveButtonClicked)
    else: 
      self.shortcut.connect('activated()', self.onFiducialClicked)
      self.freezeButton.connect('clicked(bool)', self.onFiducialClicked)
    self.imageSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onImageChanged)
    self.imageSelector2.connect('currentNodeChanged(vtkMRMLNode*)', self.onImageChanged2)
    self.TransformSelector.connect('currentNodeChanged(vtkMRMLNode*)',self.onTransformChanged)
    self.copyButton.connect('clicked(bool)', self.onCopyButtonClicked)
    
    self.layout.addStretch(1)
  
    self.sceneObserverTag = slicer.mrmlScene.AddObserver(slicer.mrmlScene.NodeAddedEvent, self.onNodeAdded)