ibllib.io.extractors.training_wheel
Functions
Extract the wheel data. |
|
Extracts the time of the first sufficiently large wheel movement for each trial. |
|
Extract wheel positions and times from sync fronts dictionary |
|
Gets wheel timestamps and position from Bpod data. |
|
Given an array of wheel positions, infer the rotary encoder resolution, encoding type and units |
|
Classes
Get wheel data from raw files and converts positions into radians mathematical convention |
- sync_rotary_encoder(session_path, bpod_data=None, re_events=None, task_collection='raw_behavior_data')[source]
- get_wheel_position(session_path, bp_data=None, display=False, task_collection='raw_behavior_data')[source]
Gets wheel timestamps and position from Bpod data. Position is in radian (constant above for radius is 1) mathematical convention.
- Parameters:
session_path –
(optional) (display) – bpod trials read from jsonable file
(optional) – (bool)
- Returns:
timestamps (np.array)
- Returns:
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
- Parameters:
re_ts – numpy array of rotary encoder timestamps
re_pos – numpy array of rotary encoder positions
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
- Parameters:
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:
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', 'wheelMoves_intervals', 'wheelMoves_peakAmplitude', 'peakVelocity_times', 'firstMovement_times', 'is_final_movement')
- extract_all(session_path, bpod_trials=None, settings=None, save=False, task_collection='raw_behavior_data', save_path=None)[source]
Extract the wheel data.
NB: Wheel extraction is now called through ibllib.io.training_trials.extract_all
- Parameters:
session_path (str, pathlib.Path) – The path to the session
save (bool) – If true save the data files to ALF
bpod_trials (list of dicts) – The Bpod trial dicts loaded from the _iblrig_taskData.raw dataset
settings (dict) – The Bpod settings loaded from the _iblrig_taskSettings.raw dataset
- Return type:
A list of extracted data and a list of file paths if save is True (otherwise None)