def extract_signal(s):
    """
    Returns the portion of s between the (first) pair of parentheses,
    or the whole of s if there are no parentheses.
    """
    loc0 = s.find("(")
    if loc0 >= 0:
        loc1 = s.find(")")
        if loc1 >= 0:
            return s[loc0 + 1 : s.find(")")]
    return s