AllenInstitute / visual_behavior_analysis

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

returning time in foraging2 for interactive plotting #837

Closed arielleleon closed 1 year ago

arielleleon commented 1 year ago

@seanmcculloch

seanmcculloch commented 1 year ago

Lines 50-58 in https://github.com/AllenInstitute/mindscope_qc_metrics/blob/main/mindscope_qc_metrics/datasets/change_detection.py Is where the running_speed_df is loaded. It first tries foraging, then foraging2 if there is an error. If it uses foraging2 it ends up calling compute_running_speed on line 788 of https://github.com/AllenInstitute/visual_behavior_analysis/blob/master/visual_behavior/translator/foraging2/extract.py

It further processes it like below and returns speed = compute_running_speed(dx_raw, time, v_sig, v_in) `

# accel = calc_deriv(speed, time)
# jerk = calc_deriv(accel, time)

running_speed = pd.DataFrame({
    'time': time,
    'frame': range(len(time)),
    'speed': speed,
    'dx': dx_raw,
    'v_sig': v_sig,
    'v_in': v_in,
    # 'acceleration (cm/s^2)': accel,
    # 'jerk (cm/s^3)': jerk,
})
return running_speed`

Hope this helps!
arielleleon commented 1 year ago

Thanks @seanmcculloch

I just asked a very confusing question....so much so that I confused myself. What I didn't see is that after compute_running_speed the get_running_speed in foraging2 does return a dataframe. This was also confused by the fact that I put the times return in the foraging return call in change_detection.py (I got the two mixed up).

Basically - I thought foraging2 was returning an array and foraging was returning a dataframe. I knew I was wrong I just needed to look a few lines down in foraging2. I will close this and fix the mindscope_qc_metrics repository (my current PR)