def test_posneg_offset(): # make sure that you can use a positive or a negative offset ds, es = pandas_dfs_from_asc(paths['mono250']) fixations = es.EFIX[3:-1] ext = extract_events(ds, fixations, duration=500, offset=-250, units=TIME_UNITS) ext = extract_events(ds, fixations, duration=500, offset=250, units=TIME_UNITS) assert(True)
def test_extracted__bino250_cols(): ds, es = pandas_dfs_from_asc(paths['bino250']) rs = es.ESACC[:-3] ext = extract_events(ds, rs, duration=40, offset=0, units=TIME_UNITS) test_cols = ['x_l', 'y_l', 'pup_l', 'x_r', 'y_r', 'pup_r', 'samp_warns', 'orig_idx'] assert_array_equal(test_cols, ds.columns.tolist())
def test_binoRemote250_cols(): ds, es = pandas_dfs_from_asc(paths['binoRemote250']) test_cols = [ 'x_l', 'y_l', 'pup_l', 'x_r', 'y_r', 'pup_r', 'samp_warns', 'targ_x', 'targ_y', 'targ_dist', 'remote_warns' ] assert_array_equal(test_cols, ds.columns.tolist())
def test_esacc_fields(): ds, es = pandas_dfs_from_asc(paths['binoRemote500']) test_fields = [ 'name', 'eye', 'last_onset', 'duration', 'x_start', 'y_start', 'x_end', 'y_end', 'vis_angle', 'peak_velocity' ] assert_array_equal(es.ESACC.columns.values, test_fields)
def test_timeunit_extract_underbounds(): ds, es = pandas_dfs_from_asc(paths['mono1000']) ext = extract_events(ds, es.EFIX, offset=-10000, duration=3000, units=TIME_UNITS)
def test_extracted_monoRemote500_cols(): ds, es = pandas_dfs_from_asc(paths['monoRemote500']) rs = es.ESACC[:-3] ext = extract_events(ds, rs, duration=500, offset=0, units=TIME_UNITS) test_cols = ['x_l', 'y_l', 'pup_l', 'samp_warns', 'targ_x', 'targ_y', 'targ_dist', 'remote_warns', 'orig_idx'] assert_array_equal(test_cols, ds.columns.tolist())
def test_extracted_bino1000_cols(): ds, es = pandas_dfs_from_asc(paths['bino1000']) rs = es.ESACC[:-3] ext = extract_events(ds, rs, duration=500, offset=0, units=TIME_UNITS) test_cols = [ 'x_l', 'y_l', 'pup_l', 'x_r', 'y_r', 'pup_r', 'samp_warns', 'orig_idx' ] assert_array_equal(test_cols, ds.columns.tolist())
def get_0_percentage(asc_path): from cili.util import pandas_dfs_from_asc import pandas as pd # grab the data ds, _ = pandas_dfs_from_asc(asc_path) p_fields = [f for f in ds.columns if f in PUP_FIELDS] if len(p_fields) == 0: return 1. # if you can't find a pupil field, we'll call that "bad" return (float(len(ds[ds[p_fields[0]] == 0])) / float(len(ds)))
def test_extracted_monoRemote250_cols(): ds, es = pandas_dfs_from_asc(paths['monoRemote250']) rs = es.EFIX[:-3] ext = extract_events(ds, rs, duration=500, offset=0, units=TIME_UNITS) test_cols = [ 'x_l', 'y_l', 'pup_l', 'samp_warns', 'targ_x', 'targ_y', 'targ_dist', 'remote_warns', 'orig_idx' ] assert_array_equal(test_cols, ds.columns.tolist())
def test_borrowed_fields(): ds, es = pandas_dfs_from_asc(paths['binoRemote500']) rs = es.ESACC[:-3] ext = extract_events(ds, rs, duration=500, offset=0, units=TIME_UNITS, borrow_attributes=['peak_velocity']) assert_true('peak_velocity' in ext.columns)
def test_posneg_offset(): # make sure that you can use a positive or a negative offset ds, es = pandas_dfs_from_asc(paths['mono250']) fixations = es.EFIX[3:-1] ext = extract_events(ds, fixations, duration=500, offset=-250, units=TIME_UNITS) ext = extract_events(ds, fixations, duration=500, offset=250, units=TIME_UNITS) assert (True)
def test_esacc_fields(): ds, es = pandas_dfs_from_asc(paths["binoRemote500"]) test_fields = [ "name", "eye", "last_onset", "duration", "x_start", "y_start", "x_end", "y_end", "vis_angle", "peak_velocity", ] assert_array_equal(es.ESACC.columns.values, test_fields)
def test_binoRemote250_cols(): ds, es = pandas_dfs_from_asc(paths["binoRemote250"]) test_cols = [ "x_l", "y_l", "pup_l", "x_r", "y_r", "pup_r", "samp_warns", "targ_x", "targ_y", "targ_dist", "remote_warns", ] assert_array_equal(test_cols, ds.columns.tolist())
def load_eyelink_dataset(file_name): """ Parses eyelink data to return samples and events. For now, we can only parse events from .asc files. If you hand us a .txt, we'll parse out the samples, but not the events. Parameters ---------- file_name (string) The .asc or .txt file you'd like to parse. Returns ------- (Samples object, Events object (or None)) """ root, ext = os.path.splitext(file_name) if ext == '.asc': s, e = pandas_dfs_from_asc(file_name) elif ext in ['.txt']: s = load_tdf(file_name) e = None else: raise ValueError("only .asc and .txt files supported at the moment...") return s, e
def test_eblink_fields(): ds, es = pandas_dfs_from_asc(paths["binoRemote500"]) test_fields = ["name", "eye", "last_onset", "duration"] assert_array_equal(es.EBLINK.columns.values, test_fields)
def test_efix_fields(): ds, es = pandas_dfs_from_asc(paths["binoRemote500"]) test_fields = ["name", "eye", "last_onset", "duration", "x_pos", "y_pos", "p_size"] assert_array_equal(es.EFIX.columns.values, test_fields)
def test_load_asc_binoRemote250(): pandas_dfs_from_asc(paths['binoRemote250'])
def test_efix_fields(): ds, es = pandas_dfs_from_asc(paths['binoRemote500']) test_fields = [ 'name', 'eye', 'last_onset', 'duration', 'x_pos', 'y_pos', 'p_size' ] assert_array_equal(es.EFIX.columns.values, test_fields)
def test_load_asc_monoRemote500(): pandas_dfs_from_asc(paths["monoRemote500"])
def test_load_asc_binoRemote250(): pandas_dfs_from_asc(paths["binoRemote250"])
def test_msg_fields(): ds, es = pandas_dfs_from_asc(paths["binoRemote500"]) test_fields = ["name", "label", "content"] assert_array_equal(es.MSG.columns.values, test_fields)
def test_msg_fields(): ds, es = pandas_dfs_from_asc(paths['binoRemote500']) test_fields = ['name', 'label', 'content'] assert_array_equal(es.MSG.columns.values, test_fields)
def test_binoRemote250_cols(): ds, es = pandas_dfs_from_asc(paths['binoRemote250']) test_cols = ['x_l', 'y_l', 'pup_l', 'x_r', 'y_r', 'pup_r', 'samp_warns', 'targ_x', 'targ_y', 'targ_dist', 'remote_warns'] assert_array_equal(test_cols, ds.columns.tolist())
def test_timeunit_extract_samplecount_250(): ds, es = pandas_dfs_from_asc(paths['mono250']) fixations = es.EFIX[:-2] sc_time_test(ds, fixations, 250, 400)
def test_bino1000_cols(): ds, es = pandas_dfs_from_asc(paths['bino1000']) test_cols = ['x_l', 'y_l', 'pup_l', 'x_r', 'y_r', 'pup_r', 'samp_warns'] assert_array_equal(test_cols, ds.columns.tolist())
def test_load_asc_monoRemote500(): pandas_dfs_from_asc(paths['monoRemote500'])
def test_load_asc_mono250(): pandas_dfs_from_asc(paths['mono250'])
def test_start_fields(): ds, es = pandas_dfs_from_asc(paths["binoRemote500"]) test_fields = ["name", "eye", "types"] assert_array_equal(es.START.columns.values, test_fields)
def test_mono2000_idx(): ds, es = pandas_dfs_from_asc(paths['mono2000']) diffs = np.diff(ds.index) diffs = np.unique(diffs[diffs < 100]) assert_equal(diffs, 4)
def test_eblink_fields(): ds, es = pandas_dfs_from_asc(paths['binoRemote500']) test_fields = ['name', 'eye', 'last_onset', 'duration'] assert_array_equal(es.EBLINK.columns.values, test_fields)
def test_start_fields(): ds, es = pandas_dfs_from_asc(paths['binoRemote500']) test_fields = ['name', 'eye', 'types'] assert_array_equal(es.START.columns.values, test_fields)
def test_load_asc_bino1000(): pandas_dfs_from_asc(paths["bino1000"])
def test_timeunit_extract_samplecount_1000(): ds, es = pandas_dfs_from_asc(paths['mono1000']) fixations = es.EFIX[:-1] sc_time_test(ds, fixations, 1000, 500) sc_time_test(ds, fixations, 1000, 1000)
def test_load_asc_mono250(): pandas_dfs_from_asc(paths["mono250"])
def test_load_asc_monoRemote250(): pandas_dfs_from_asc(paths['monoRemote250'])
def test_bino1000_cols(): ds, es = pandas_dfs_from_asc(paths["bino1000"]) test_cols = ["x_l", "y_l", "pup_l", "x_r", "y_r", "pup_r", "samp_warns"] assert_array_equal(test_cols, ds.columns.tolist())
def test_end_fields(): ds, es = pandas_dfs_from_asc(paths['binoRemote500']) test_fields = ['name', 'types', 'x_res', 'y_res'] assert_array_equal(es.END.columns.values, test_fields)
def test_negative_duration(): ds, es = pandas_dfs_from_asc(paths['mono250']) fixations = es.EFIX[:-1] ext = extract_events(ds, fixations, duration=-1000, units=TIME_UNITS)
def test_load_asc_bino1000(): pandas_dfs_from_asc(paths['bino1000'])
def test_sampleunit_extract_samplecount_2000(): ds, es = pandas_dfs_from_asc(paths['mono2000']) fixations = es.EFIX[:-1] sc_samp_test(ds, fixations, 350) sc_samp_test(ds, fixations, 700)
def test_load_asc_mono2000(): pandas_dfs_from_asc(paths['mono2000'])
def test_mono2000_idx(): ds, es = pandas_dfs_from_asc(paths["mono2000"]) diffs = np.diff(ds.index) diffs = np.unique(diffs[diffs < 100]) assert_equal(diffs, 4)
def test_event_types(): # make sure the full list of events is there ds, es = pandas_dfs_from_asc(paths['binoRemote500']) test_evs = ['END', 'EFIX', 'EBLINK', 'START', 'ESACC', 'MSG'] assert_array_equal(list(es.dframes.keys()), test_evs)
def test_load_asc_bino250(): pandas_dfs_from_asc(paths['bino250'])
def test_timeunit_extract_overbounds(): ds, es = pandas_dfs_from_asc(paths['mono1000']) ext = extract_events(ds, es.EFIX, duration=3000, units=TIME_UNITS)
def test_end_fields(): ds, es = pandas_dfs_from_asc(paths["binoRemote500"]) test_fields = ["name", "types", "x_res", "y_res"] assert_array_equal(es.END.columns.values, test_fields)
def test_event_types(): # make sure the full list of events is there ds, es = pandas_dfs_from_asc(paths["binoRemote500"]) test_evs = ["END", "EFIX", "EBLINK", "START", "ESACC", "MSG"] assert_array_equal(es.dframes.keys(), test_evs)
def test_load_asc_binoRemote500(): pandas_dfs_from_asc(paths['binoRemote500'])