ibllib.io.extractors.training_trials

class ibllib.io.extractors.training_trials.CameraTimestamps(session_path=None)

Get the camera timestamps from the Bpod

The camera events are logged only during the events not in between, so the times need to be interpolated

class ibllib.io.extractors.training_trials.Choice(session_path=None)

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]
class ibllib.io.extractors.training_trials.ContrastLR(session_path=None)

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.

class ibllib.io.extractors.training_trials.ErrorCueTriggerTimes(session_path=None)
class ibllib.io.extractors.training_trials.FeedbackTimes(session_path=None)

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.

class ibllib.io.extractors.training_trials.FeedbackType(session_path=None)

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 trigered (applies to no-go) Sets feedbackType to +1 if reward state was triggered

class ibllib.io.extractors.training_trials.GoCueTimes(session_path=None)

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 the future microphone OR the new xonar soundcard and setup developed by Sanworks guarantees a set latency (in testing).

class ibllib.io.extractors.training_trials.GoCueTriggerTimes(session_path=None)

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).

class ibllib.io.extractors.training_trials.IncludedTrials(session_path=None)
class ibllib.io.extractors.training_trials.Intervals(session_path=None)

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 timpestamp values form PyBpod.

class ibllib.io.extractors.training_trials.ItiDuration(session_path=None)

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.

class ibllib.io.extractors.training_trials.ItiInTimes(session_path=None)
class ibllib.io.extractors.training_trials.ProbabilityLeft(session_path=None)
class ibllib.io.extractors.training_trials.RepNum(session_path=None)

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]
class ibllib.io.extractors.training_trials.ResponseTimes(session_path=None)

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.

class ibllib.io.extractors.training_trials.RewardVolume(session_path=None)

Load reward volume delivered for each trial. Optional: saves _ibl_trials.rewardVolume.npy

Uses reward_current to accumulate the amount of

class ibllib.io.extractors.training_trials.StimFreezeTriggerTimes(session_path=None)
class ibllib.io.extractors.training_trials.StimOffTriggerTimes(session_path=None)
class ibllib.io.extractors.training_trials.StimOnOffFreezeTimes(session_path=None)

Extracts stim on / off and freeze times from Bpod BNC1 detected fronts

class ibllib.io.extractors.training_trials.StimOnTimes(session_path=None)
static get_stimOn_times_ge5(session_path, data=False)

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)

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 ibllib.io.extractors.training_trials.StimOnTriggerTimes(session_path=None)
class ibllib.io.extractors.training_trials.TrialType(session_path=None)