ibllib.io.extractors.training_wheel
Extractors for the wheel position, velocity, and detected movement.
Functions
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
Wheel extractor. |
- 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 (dict)
trials (dict) – dictionary of trial data
min_qt (float)
wheel_moves – Dictionary of detected wheel movement onsets and peak amplitudes for use in extracting each trial’s time of first movement.
trials – Dictionary of trial data.
min_qt – The minimum quiescence period in seconds, if None a default is used.
- Returns:
numpy array of
- Returns:
numpy.array – First movement times.
numpy.array – Bool array indicating whether movement crossed response threshold.
numpy.array – Indices for wheel_moves arrays.
- class Wheel(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Wheel extractor.
- 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)
The filenames of each extracted dataset, or None if array should not be saved.
- Type:
tuple of str
- var_names = ('wheel_timestamps', 'wheel_position', 'wheelMoves_intervals', 'wheelMoves_peakAmplitude', 'peakVelocity_times', 'firstMovement_times', 'is_final_movement')
A list of names for the extracted variables. These become the returned output keys.
- Type:
tuple of str