def SummarizeWindow(states):
    """Collapse the set or list of values in a particular temporal activity window
    into a single summary.  Valid values are ambiguous, inactive, activation,
    inhibition.
    """
    # Verify that all states are recognized
    validStates = set(["ambiguous", "inactive", "activation", "inhibition"])
    for state in states:
        if state not in validStates:
            raise RuntimeError("Invalid temporal activity state: %s" % state)

    # If any are ambiguous, the entire window is ambiguous
    if "ambiguous" in states:
        return "ambiguous"

    # If all are activation or inhibition, return that state
    if all([s == "activation" for s in states]):
        return "activation"
    if all([s == "inhibition" for s in states]):
        return "inhibition"

    # A combination of activation and inhibition is ambiguous, regardless
    # of whether there is also inactive
    if "activation" in states and "inhibition" in states:
        return "ambiguous"

    # If all inactive, return inactive
    if all([s == "inactive" for s in states]):
        return "inactive"

    # Otherwise the states are a mix of inactive and activation or inhibition
    # so activation/inhibition dominates
    if "activation" in states:
        return "activation"
    if "inhibition" in states:
        return "inhibition"

    raise RuntimeError("Invalid case reached")