ibllib.io.extractors.training_wheel

Training wheel extractor from Pybpod output.

ibllib.io.extractors.training_wheel.check_alf_folder(session_path)

Check if alf folder exists, creates it if it doesn’t.

Parameters:session_path (str) – absolute path of session folder
ibllib.io.extractors.training_wheel.get_velocity(session_path, save=False, data_wheel=None)

Compute velocity from non-uniformly acquired positions and timestamps. Optional: save _ibl_trials.velocity.npy

Uses signed_contrast to create left and right contrast vectors.

Parameters:
  • session_path (str) – absolute path of session folder
  • save (bool, optional) – wether to save the corresponding alf file to the alf folder, defaults to False
Returns:

numpy.ndarray

Return type:

dtype(‘float64’)

ibllib.io.extractors.training_wheel.get_wheel_data(session_path, bp_data=None, save=False)

Get wheel data from raw files and converts positions into centimeters and timestamps into seconds. Optional: saves _ibl_wheel.times.npy and _ibl_wheel.position.npy

Times: Gets Rotary Encoder timestamps (ms) for each position and converts to times.

Uses time_converter to extract and convert timstamps (ms) to times (s).

Positions: Positions are in (cm) of RE perimeter relative to 0. The 0 resets every trial.

cmtick = radius (cm) * 2 * pi / n_ticks cmtick = 3.1 * 2 * np.pi / 1024

Parameters:
  • session_path (str) – absolute path of session folder
  • data (dict, optional) – dictionary containing the contents pybppod jsonable file read with raw.load_data
  • save (bool, optional) – wether to save the corresponding alf file to the alf folder, defaults to False
Returns:

Numpy structured array.

Return type:

numpy.ndarray

ibllib.io.extractors.training_wheel.time_converter_session(session_path, kind)

Create interp1d functions to convert values from one clock to another given a set of synchronization pulses.

The task global sync pulse is at trial_start from Bpod to: Rotary Encoder, Cameras and e-phys system. Depends on getter functions that extract from the raw data the timestamps of the trial_start sync pulse event for each clock.

2b
re2b cam2b, ephys2b
2re b2re
cam2re ephys2re
2cam b2cam re2cam
ephys2cam
2ephys b2ephys re2ephys cam2ephys

Default converters for times are assumed to be of kind 2b unless ephys data is present in that case converters for ‘times’ will be of kind 2ephys

Parameters:
  • session_path (str) – absolute path of session folder
  • kind (str, optional) – [‘re2b’, ‘b2re’], defaults to ‘re2b’
Returns:

Function that converts from clock A to clock B defined by kind.

Return type:

scipy.interpolate.interpolate.interp1d

ibllib.io.extractors.training_wheel.time_interpolation(tref, target)

From 2 arrays of timestamps, return an interpolation function that allows to go from one to the other. If sizes are different, only work with the first elements.