ibllib.io.extractors.video_motion

A module for aligning the wheel motion with the rotary encoder. Currently used by the camera QC in order to check timestamp alignment.

Functions

find_nearest

Classes

MotionAlignment

find_nearest(array, value)[source]
class MotionAlignment(eid=None, one=None, log=<Logger ibllib.io.extractors.video_motion (WARNING)>, **kwargs)[source]

Bases: object

roi = {'body': ((402, 481), (31, 103)), 'left': ((800, 1020), (233, 1096)), 'right': ((426, 510), (104, 545))}
align_all_trials(side='all')[source]

Align all wheel motion for all trials

static set_roi(video_path)[source]

Manually set the ROIs for a given set of videos TODO Improve docstring TODO A method for setting ROIs by label

load_data(download=False)[source]

Load wheel, trial and camera timestamp data :return: wheel, trials

align_motion(period=(-inf, inf), side='left', sd_thresh=10, display=False)[source]

Align video to the wheel using cross-correlation of the video motion signal and the rotary encoder.

Parameters
  • period ((float, float)) – The time period over which to do the alignment.

  • side ({'left', 'right'}) – With which camera to perform the alignment.

  • sd_thresh (float) – For plotting where the motion energy goes above this standard deviation threshold.

  • display (bool) – When true, displays the aligned wheel motion energy along with the rotary encoder signal.

Returns

  • int – Frame offset, i.e. by how many frames the video was shifted to match the rotary encoder signal. Negative values mean the video was shifted backwards with respect to the wheel timestamps.

  • float – The peak cross-correlation.

  • numpy.ndarray – The motion energy used in the cross-correlation, i.e. the frame difference for the period given.

plot_alignment(energy=True, save=False)[source]