code: def getBestMatchingCell(self, c, activeState):
      
      # Collect all cells in column c that have at least minThreshold in the most
      # activated segment
      bestActivityInCol = self.minThreshold
      bestSegIdxInCol = -1
      bestCellInCol = -1
  
      for i in xrange(self.cellsPerColumn):
  
        maxSegActivity = 0
        maxSegIdx = 0
  
        for j,s in enumerate(self.cells[c][i]):
  
          activity = self.getSegmentActivityLevel(s, activeState, connectedSynapsesOnly =False)
  
          if self.verbosity >= 6:
            print " Segment Activity for column ", c, " cell ", i, " segment ", " j is ", activity
  
          if activity > maxSegActivity:
            maxSegActivity = activity
            maxSegIdx = j
  
        if maxSegActivity >= bestActivityInCol:
          bestActivityInCol = maxSegActivity
          bestSegIdxInCol = maxSegIdx
          bestCellInCol = i
  
      if self.verbosity >= 6:
        print "Best Matching Cell In Col: ", bestCellInCol
      if bestCellInCol == -1:
        return (None, None)
      else:
        return bestCellInCol, self.cells[c][bestCellInCol][bestSegIdxInCol]
docs: Find weakly activated cell in column. Returns index and segment of most
      activated segment above minThreshold.