ibllib.io.extractors.training_wheel

Functions

extract_all

extract_first_movement_times

Extracts the time of the first sufficiently large wheel movement for each trial.

extract_wheel_moves

Extract wheel positions and times from sync fronts dictionary :param re_ts: numpy array of rotary encoder timestamps :param re_pos: numpy array of rotary encoder positions :param display: bool: show the wheel position and velocity for full session with detected movements highlighted :return: wheel_moves dictionary

get_trial_start_times

get_wheel_position

Gets wheel timestamps and position from Bpod data.

infer_wheel_units

Given an array of wheel positions, infer the rotary encoder resolution, encoding type and units

sync_rotary_encoder

Classes

Wheel

Get wheel data from raw files and converts positions into radians mathematical convention

get_trial_start_times(session_path, data=None)[source]
sync_rotary_encoder(session_path, bpod_data=None, re_events=None)[source]
get_wheel_position(session_path, bp_data=None, display=False)[source]

Gets wheel timestamps and position from Bpod data. Position is in radian (constant above for radius is 1) mathematical convention. :param session_path: :param bp_data (optional): bpod trials read from jsonable file :param display (optional): (bool) :return: timestamps (np.array) :return: positions (np.array)

infer_wheel_units(pos)[source]

Given an array of wheel positions, infer the rotary encoder resolution, encoding type and units

The encoding type varies across hardware (Bpod uses X1 while FPGA usually extracted as X4), and older data were extracted in linear cm rather than radians.

Parameters

pos – a 1D array of extracted wheel positions

Return units

the position units, assumed to be either ‘rad’ or ‘cm’

Return resolution

the number of decoded fronts per 360 degree rotation

Return encoding

one of {‘X1’, ‘X2’, ‘X4’}

extract_wheel_moves(re_ts, re_pos, display=False)[source]

Extract wheel positions and times from sync fronts dictionary :param re_ts: numpy array of rotary encoder timestamps :param re_pos: numpy array of rotary encoder positions :param display: bool: show the wheel position and velocity for full session with detected movements highlighted :return: wheel_moves dictionary

extract_first_movement_times(wheel_moves, trials, min_qt=None)[source]

Extracts the time of the first sufficiently large wheel movement for each trial. To be counted, the movement must occur between go cue / stim on and before feedback / response time. The movement onset is sometimes just before the cue (occurring in the gap between quiescence end and cue start, or during the quiescence period but sub- threshold). The movement is sufficiently large if it is greater than or equal to THRESH :param wheel_moves: dictionary of detected wheel movement onsets and peak amplitudes for use in extracting each trial’s time of first movement. :param trials: dictionary of trial data :param min_qt: the minimum quiescence period, if None a default is used :return: numpy array of first movement times, bool array indicating whether movement crossed response threshold, and array of indices for wheel_moves arrays

class Wheel(session_path=None)[source]

Bases: ibllib.io.extractors.base.BaseBpodTrialsExtractor

Get wheel data from raw files and converts positions into radians mathematical convention

(anti-clockwise = +) and timestamps into seconds relative to Bpod clock.

Optional: saves _ibl_wheel.times.npy and _ibl_wheel.position.npy

Times: Gets Rotary Encoder timestamps (us) for each position and converts to times. Synchronize with Bpod and outputs

Positions: Radians mathematical convention

save_names = ('_ibl_wheel.timestamps.npy', '_ibl_wheel.position.npy', '_ibl_wheelMoves.intervals.npy', '_ibl_wheelMoves.peakAmplitude.npy', None, '_ibl_trials.firstMovement_times.npy', None)
var_names = ('wheel_timestamps', 'wheel_position', 'wheel_moves_intervals', 'wheel_moves_peak_amplitude', 'peakVelocity_times', 'firstMovement_times', 'is_final_movement')
extract_all(session_path, bpod_trials=None, settings=None, save=False)[source]