def getActiveSegment(self, c, i, timeStep):
    """ For a given cell, return the segment with the strongest _connected_
    activation, i.e. sum up the activations of the connected synapses of the
    segments only. That is, a segment is active only if it has enough connected
    synapses.
    """

    # todo: put back preference for sequence segments.

    nSegments = len(self.cells[c][i])

    bestActivation = self.activationThreshold
    which = -1

    for j,s in enumerate(self.cells[c][i]):

      activity = self.getSegmentActivityLevel(s, self.activeState[timeStep], connectedSynapsesOnly = True)

      if activity >= bestActivation:
        bestActivation = activity
        which = j

    if which != -1:
      return self.cells[c][i][which]
    else:
      return None
For a given cell, return the segment with the strongest _connected_
    activation, i.e. sum up the activations of the connected synapses of the
    segments only. That is, a segment is active only if it has enough connected
    synapses.