def compute_latency(p, phases=[2,4]):
    """
    p : rows from data.phases for a single trial
    returns latency from onset of phases[0] to onset of phases[1]
    """
    p = p[p.phase.isin(phases)]
    p0 = p[p.phase==phases[0]].start_time.values
    p1 = p[p.phase==phases[1]].start_time.values
    assert len(p0) == len(p1)
    res = p1-p0
    return res