ibllib.io.extractors.ephys_fpga

Data extraction from raw FPGA output Complete FPGA data extraction depends on Bpod extraction

Functions

data_for_keys

Check keys exist in 'data' dict and contain values other than None

extract_all

For the IBL ephys task, reads ephys binary file and extract:

extract_behaviour_sync

Extract wheel positions and times from sync fronts dictionary

extract_sync

Reads ephys binary file (s) and extract sync within the binary file folder Assumes ephys data is within a raw_ephys_data folder

extract_wheel_sync

Extract wheel positions and times from sync fronts dictionary for all 16 chans Output position is in radians, mathematical convention

get_ibl_sync_map

Gets default channel map for the version/binary file type combination

get_main_probe_sync

From 3A or 3B multiprobe session, returns the main probe (3A) or nidq sync pulses with the attached channel map (default chmap if none)

get_sync_and_chn_map

Return sync and channel map for session based on collection where main sync is stored

get_sync_fronts

get_wheel_positions

Gets the wheel position from synchronisation pulses

load_channel_map

Load syncing channel map for session path and collection

load_sync

Load sync files from session path and collection

Classes

FpgaTrials

data_for_keys(keys, data)[source]

Check keys exist in ‘data’ dict and contain values other than None

get_ibl_sync_map(ef, version)[source]

Gets default channel map for the version/binary file type combination

Parameters

ef – ibllib.io.spikeglx.glob_ephys_file dictionary with field ‘ap’ or ‘nidq’

Returns

channel map dictionary

get_sync_fronts(sync, channel_nb, tmin=None, tmax=None)[source]
extract_wheel_sync(sync, chmap=None)[source]

Extract wheel positions and times from sync fronts dictionary for all 16 chans Output position is in radians, mathematical convention

Parameters
  • sync – dictionary ‘times’, ‘polarities’ of fronts detected on sync trace

  • chmap – dictionary containing channel indices. Default to constant. chmap = {‘rotary_encoder_0’: 13, ‘rotary_encoder_1’: 14}

Returns

timestamps (np.array)

Returns

positions (np.array)

extract_behaviour_sync(sync, chmap=None, display=False, bpod_trials=None)[source]

Extract wheel positions and times from sync fronts dictionary

Parameters
  • sync – dictionary ‘times’, ‘polarities’ of fronts detected on sync trace for all 16 chans

  • chmap – dictionary containing channel index. Default to constant. chmap = {‘bpod’: 7, ‘frame2ttl’: 12, ‘audio’: 15}

  • display – bool or matplotlib axes: show the full session sync pulses display

defaults to False :return: trials dictionary

extract_sync(session_path, overwrite=False, ephys_files=None, namespace='spikeglx')[source]

Reads ephys binary file (s) and extract sync within the binary file folder Assumes ephys data is within a raw_ephys_data folder

Parameters
  • session_path – ‘/path/to/subject/yyyy-mm-dd/001’

  • overwrite – Bool on re-extraction, forces overwrite instead of loading existing files

Returns

list of sync dictionaries

get_wheel_positions(sync, chmap)[source]

Gets the wheel position from synchronisation pulses

Parameters
  • sync

  • chmap

Return:wheel

dictionary with keys ‘timestamps’ and ‘position’ moves: dictionary with keys ‘intervals’ and ‘peakAmplitude’

get_main_probe_sync(session_path, bin_exists=False)[source]

From 3A or 3B multiprobe session, returns the main probe (3A) or nidq sync pulses with the attached channel map (default chmap if none)

Parameters

session_path

Returns

class FpgaTrials(*args, **kwargs)[source]

Bases: BaseExtractor

save_names = ('_ibl_trials.intervals_bpod.npy', '_ibl_trials.goCueTrigger_times.npy', None, None, None, None, None, None, None, '_ibl_trials.stimOff_times.npy', None, None, None, None, '_ibl_trials.table.pqt', '_ibl_wheel.timestamps.npy', '_ibl_wheel.position.npy', '_ibl_wheelMoves.intervals.npy', '_ibl_wheelMoves.peakAmplitude.npy')
var_names = ('intervals_bpod', 'goCueTrigger_times', 'stimOnTrigger_times', 'stimOffTrigger_times', 'stimFreezeTrigger_times', 'errorCueTrigger_times', 'errorCue_times', 'itiIn_times', 'stimFreeze_times', 'stimOff_times', 'valveOpen_times', 'phase', 'position', 'quiescence', 'table', 'wheel_timestamps', 'wheel_position', 'wheelMoves_intervals', 'wheelMoves_peakAmplitude')
bpod_rsync_fields = ('intervals', 'response_times', 'goCueTrigger_times', 'stimOnTrigger_times', 'stimOffTrigger_times', 'stimFreezeTrigger_times', 'errorCueTrigger_times')
bpod_fields = ('feedbackType', 'choice', 'rewardVolume', 'contrastLeft', 'contrastRight', 'probabilityLeft', 'intervals_bpod', 'phase', 'position', 'quiescence')
extract_all(session_path, sync_collection='raw_ephys_data', save=True)[source]
For the IBL ephys task, reads ephys binary file and extract:
  • sync

  • wheel

  • behaviour

  • video time stamps

Parameters
  • session_path – ‘/path/to/subject/yyyy-mm-dd/001’

  • save – Bool, defaults to False

Returns

outputs, files

get_sync_and_chn_map(session_path, sync_collection)[source]

Return sync and channel map for session based on collection where main sync is stored

Parameters
  • session_path

  • sync_collection

Returns

load_channel_map(session_path, sync_collection)[source]

Load syncing channel map for session path and collection

Parameters
  • session_path

  • collection

Returns

load_sync(session_path, sync_collection)[source]

Load sync files from session path and collection

Parameters
  • session_path

  • sync_collection

Returns