AllenInstitute / visual_behavior_analysis

Python package for analyzing behavioral data for Brain Observatory: Visual Behavior
Other
22 stars 6 forks source link

extended_dataframe key errors #177

Closed saharmanavi closed 6 years ago

saharmanavi commented 6 years ago

A running list of key errors I'm running into when using visual_behavior_analysis functions:

data = pd.read_pickle(path)
time_arr = np.hstack((0, np.cumsum(data['vsyncintervals']) / 1000.))
 core_data = foraging.data_to_change_detection_core(data, time_arr)
 df = create_extended_dataframe(
        trials=trials,
        metadata=core_data['metadata'],
        licks = core_data['licks'],
        time=core_data['time'])

gives key error: endframe when trying to create the extended dataframe. manually adding the column to the core_data['trails'] dataframe fixes this issue.

Using visual_behavior.visualization.extended_trials.daily -> make_daily_figure with the df output from above (with endframe added in) gives the key error: trial_length

I'll continue to update as I find more.

saharmanavi commented 6 years ago

by the way, this was my fix for the endframe issue. Probably not the cleanest, but just in case it's helpful:

def add_endframe(trials, metadata):
    trials['frame_diff'] = core_data['trials']['startframe'].diff().shift(periods=-1)

    endframe = []
    for idx, row in trials.iterrows():
        ef = row['startframe'] + (row['frame_diff'] - 1.)
        endframe.append(ef)

    trials['endframe'] = endframe
    trials.at[trials.index[-1], 'endframe'] = metadata['n_stimulus_frames']

    del trials['frame_diff']

    return trials
dougollerenshaw commented 6 years ago

@ryval already created issue #165 to address the 'endframe' issue. I submitted PR #169 to address that. Awaiting review from @neuromusic

I'll investigate the 'trial_length' issue. Assigning myself.

saharmanavi commented 6 years ago

got it, will search for errors before posting them.

I did this to fix the trial_length issue, put in after the extended_dataframe was created:

df['trial_length'] = df['endtime'].subtract(df['starttime'])

neuromusic commented 6 years ago

should be fixed in #169

saharmanavi commented 6 years ago

@dougollerenshaw @neuromusic I see this issue was closed, but the trial_length key error still exists.

neuromusic commented 6 years ago

@saharmanavi can you check this again? I think #212 should have fixed this