def getintervalsingle(stimulus, td, kind):
    """
    get the interval list for a single stimulus
    
    input: stimulus struct; trackdata; kind of stimulus
    output: list of (t1, t2) intervals
    """
    
    tmin, tmax = td.findtimerange()
    
    stimonset = stimulus.onset
    stimduration = stimulus.duration
    stimoffset = stimonset + stimduration
    offsetduration = tmax - (stimonset + stimduration)
    
    if kind == "basic stats":
        intervallist = [
            (0.0, stimonset),
            (stimonset + 1, stimonset + 4),
            (stimonset, stimonset + 0.5 * stimduration),
            (stimonset + 0.5 * stimduration, stimoffset),
            (stimoffset, stimoffset + 0.5 * offsetduration),
            (stimoffset + 0.5 * offsetduration, tmax),
            ]
    elif kind == "line fits":
        intervallist = [
            (stimonset, stimonset + 2.0),
            (stimonset + 2.0, stimonset + 4.0),
            (stimonset + 0.5 * stimduration, stimoffset),
            (stimoffset, tmax),
            (stimonset + 0.5 * stimduration, tmax),
            ]
        # this interval is only valid for long enough durations:
        if stimonset + 4.0 < stimonset + 0.5 * stimduration:
            intervallist.append((stimonset + 4.0, stimonset + 0.5 * stimduration))
    elif kind == "xy-motion":
        intervallist = [
            (0.0, stimonset),
            (stimonset, stimoffset),
            (stimonset, stimonset + 30),
            (stimonset + 30, tmax),
            ]
    else:
        raise ValueError("unknown interval kind %s" % kind)
    
    return intervallist
    
    # end getintervalsingle()