Ejemplo n.º 1
0
def check_ingestion_position_concurrency(tset_raw, tset_at_loc, loc='F'):
    """ check device events and position at device concurrency
        returns array with corrected events and errors removed
        this function is not used starting May 8th, 2018
    """
    i_raw = Intervals(tset_raw)
    i_at_device = Intervals(tset_at_loc)
    i_true = i_raw.intersect(i_at_device)
    tset_errors = (i_raw - i_true).intervals  # photobeam firing when mouse not at device
    np.testing.assert_almost_equal(np.diff(tset_raw).sum(),
                                   np.diff(tset_errors).sum() + np.diff(i_true.intervals).sum(), decimal=2)
    num_errors = len(tset_errors)
    tot = i_raw.intervals.shape[0]
    err_time = np.diff(tset_errors).sum() / 60.
    error_msg = ""
    if num_errors:
        # todo: check this is working. plot on rasters
        tset = i_true.intervals
        error_msg = "{}: {}/{} events removed, device firing while mouse not at device " \
                    "(total time involved={:.2f} min)".format(act_to_actlabel[loc], num_errors, tot, err_time)
    else:
        tset = tset_raw
    return tset, tset_errors, error_msg