ibllib.io.extractors.training_trials
Functions
Extract trials and wheel data. |
Classes
Get the subject's choice in every trial. |
|
Get left and right contrasts from raw datafile. |
|
Get the times the water or error tone was delivered to the animal. |
|
Get the feedback that was delivered to subject. |
|
Get trigger times of goCue from state machine. |
|
Get trigger times of goCue from state machine. |
|
Trial start to trial end. |
|
Calculate duration of iti from state timestamps. |
|
Extracts stimulus phase, position and quiescence from Bpod data. |
|
Count the consecutive repeated trials. |
|
Time (in absolute seconds from session start) when a response was recorded. |
|
Load reward volume delivered for each trial. |
|
Extracts stim on / off and freeze times from Bpod BNC1 detected fronts |
|
Extracts the following into a table from Bpod raw data: |
- class FeedbackType(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Get the feedback that was delivered to subject. Optional: saves _ibl_trials.feedbackType.npy
Checks in raw datafile for error and reward state. Will raise an error if more than one of the mutually exclusive states have been triggered.
Sets feedbackType to -1 if error state was triggered (applies to no-go) Sets feedbackType to +1 if reward state was triggered
- save_names = '_ibl_trials.feedbackType.npy'
- var_names = 'feedbackType'
- class ContrastLR(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Get left and right contrasts from raw datafile. Optionally, saves _ibl_trials.contrastLeft.npy and _ibl_trials.contrastRight.npy to alf folder.
Uses signed_contrast to create left and right contrast vectors.
- save_names = ('_ibl_trials.contrastLeft.npy', '_ibl_trials.contrastRight.npy')
- var_names = ('contrastLeft', 'contrastRight')
- class ProbabilityLeft(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- save_names = '_ibl_trials.probabilityLeft.npy'
- var_names = 'probabilityLeft'
- class Choice(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Get the subject’s choice in every trial. Optional: saves _ibl_trials.choice.npy to alf folder.
Uses signed_contrast and trial_correct. -1 is a CCW turn (towards the left) +1 is a CW turn (towards the right) 0 is a no_go trial If a trial is correct the choice of the animal was the inverse of the sign of the position.
>>> choice[t] = -np.sign(position[t]) if trial_correct[t]
- save_names = '_ibl_trials.choice.npy'
- var_names = 'choice'
- class RepNum(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Count the consecutive repeated trials. Optional: saves _ibl_trials.repNum.npy to alf folder.
Creates trial_repeated from trial[‘contrast’][‘type’] == ‘RepeatContrast’
>>> trial_repeated = [0, 1, 1, 0, 1, 0, 1, 1, 1, 0] >>> repNum = [0, 1, 2, 0, 1, 0, 1, 2, 3, 0]
- save_names = '_ibl_trials.repNum.npy'
- var_names = 'repNum'
- class RewardVolume(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Load reward volume delivered for each trial. Optional: saves _ibl_trials.rewardVolume.npy
Uses reward_current to accumulate the amount of
- save_names = '_ibl_trials.rewardVolume.npy'
- var_names = 'rewardVolume'
- class FeedbackTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Get the times the water or error tone was delivered to the animal. Optional: saves _ibl_trials.feedback_times.npy
Gets reward and error state init times vectors, checks if theintersection of nans is empty, then merges the 2 vectors.
- save_names = '_ibl_trials.feedback_times.npy'
- var_names = 'feedback_times'
- class Intervals(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Trial start to trial end. Trial end includes 1 or 2 seconds after feedback, (depending on the feedback) and 0.5 seconds of iti. Optional: saves _ibl_trials.intervals.npy
Uses the corrected Trial start and Trial end timestamp values form PyBpod.
- save_names = '_ibl_trials.intervals.npy'
- var_names = 'intervals'
- class ResponseTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Time (in absolute seconds from session start) when a response was recorded. Optional: saves _ibl_trials.response_times.npy
Uses the timestamp of the end of the closed_loop state.
- save_names = '_ibl_trials.response_times.npy'
- var_names = 'response_times'
- class ItiDuration(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Calculate duration of iti from state timestamps. Optional: saves _ibl_trials.iti_duration.npy
Uses Trial end timestamp and get_response_times to calculate iti.
- save_names = '_ibl_trials.itiDuration.npy'
- var_names = 'iti_dur'
- class GoCueTriggerTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Get trigger times of goCue from state machine.
Current software solution for triggering sounds uses PyBpod soft codes. Delays can be in the order of 10’s of ms. This is the time when the command to play the sound was executed. To measure accurate time, either getting the sound onset from xonar soundcard sync pulse (latencies may vary).
- save_names = '_ibl_trials.goCueTrigger_times.npy'
- var_names = 'goCueTrigger_times'
- class TrialType(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- save_names = '_ibl_trials.type.npy'
- var_name = 'trial_type'
- class GoCueTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Get trigger times of goCue from state machine.
Current software solution for triggering sounds uses PyBpod soft codes. Delays can be in the order of 10-100s of ms. This is the time when the command to play the sound was executed. To measure accurate time, either getting the sound onset from the future microphone OR the new xonar soundcard and setup developed by Sanworks guarantees a set latency (in testing).
- save_names = '_ibl_trials.goCue_times.npy'
- var_names = 'goCue_times'
- class IncludedTrials(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- save_names = '_ibl_trials.included.npy'
- var_names = 'included'
- class ItiInTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- var_names = 'itiIn_times'
- class ErrorCueTriggerTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- var_names = 'errorCueTrigger_times'
- class StimFreezeTriggerTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- var_names = 'stimFreezeTrigger_times'
- class StimOffTriggerTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- var_names = 'stimOffTrigger_times'
- class StimOnTriggerTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- save_names = '_ibl_trials.stimOnTrigger_times.npy'
- var_names = 'stimOnTrigger_times'
- class StimOnTimes_deprecated(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- save_names = '_ibl_trials.stimOn_times.npy'
- var_names = 'stimOn_times'
- static get_stimOn_times_ge5(session_path, data=False)[source]
Find first and last stim_sync pulse of the trial. stimOn_times should be the first after the stim_on state. (Stim updates are in BNC1High and BNC1Low - frame2TTL device) Check that all trials have frame changes. Find length of stim_on_state [start, stop]. If either check fails the HW device failed to detect the stim_sync square change Substitute that trial’s missing or incorrect value with a NaN. return stimOn_times
- static get_stimOn_times_lt5(session_path, data=False)[source]
Find the time of the statemachine command to turn on hte stim (state stim_on start or rotary_encoder_event2) Find the next frame change from the photodiodeafter that TS. Screen is not displaying anything until then. (Frame changes are in BNC1High and BNC1Low)
- class StimOnOffFreezeTimes(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Extracts stim on / off and freeze times from Bpod BNC1 detected fronts
- save_names = ('_ibl_trials.stimOn_times.npy', None, None)
- var_names = ('stimOn_times', 'stimOff_times', 'stimFreeze_times')
- class PhasePosQuiescence(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
Extracts stimulus phase, position and quiescence from Bpod data. For extraction of pre-generated events, use the ProbaContrasts extractor instead.
- save_names = (None, None, None)
- var_names = ('phase', 'position', 'quiescence')
- class TrialsTable(session_path=None)[source]
Bases:
BaseBpodTrialsExtractor
- Extracts the following into a table from Bpod raw data:
intervals, goCue_times, response_times, choice, stimOn_times, contrastLeft, contrastRight, feedback_times, feedbackType, rewardVolume, probabilityLeft, firstMovement_times
- Additionally extracts the following wheel data:
wheel_timestamps, wheel_position, wheel_moves_intervals, wheel_moves_peak_amplitude
- save_names = ('_ibl_trials.table.pqt', None, None, '_ibl_wheel.timestamps.npy', '_ibl_wheel.position.npy', '_ibl_wheelMoves.intervals.npy', '_ibl_wheelMoves.peakAmplitude.npy', None, None)
- var_names = ('table', 'stimOff_times', 'stimFreeze_times', 'wheel_timestamps', 'wheel_position', 'wheel_moves_intervals', 'wheel_moves_peak_amplitude', 'peakVelocity_times', 'is_final_movement')
- extract_all(session_path, save=False, bpod_trials=None, settings=None)[source]
Extract trials and wheel data.
For task versions >= 5.0.0, outputs wheel data and trials.table dataset (+ some extra datasets)
- 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)