nafc
Classes:
|
A Two-alternative forced choice task. |
- class Nafc(stage_block=None, stim=None, reward=50, req_reward=False, punish_stim=False, punish_dur=100, correction=False, correction_pct=50.0, bias_mode=False, bias_threshold=20, stim_light=True, **kwargs)[source]
Bases:
autopilot.tasks.task.Task
A Two-alternative forced choice task.
(can’t have number as first character of class.)
Stages
request - compute stimulus, set request trigger in center port.
discrim - respond to input, set reward/punishment triggers on target/distractor ports
reinforcement - deliver reward/punishment, end trial.
- Variables
target ("L", "R") – Correct response
distractor ("L", "R") – Incorrect response
stim – Current stimulus
response ("L", "R") – Response to discriminand
correct (0, 1) – Current trial was correct/incorrect
correction_trial (bool) – If using correction trials, last trial was a correction trial
trial_counter (
itertools.count
) – Which trial are we on?discrim_playing (bool) – Is the stimulus playing?
bailed (0, 1) – Subject answered before stimulus was finished playing.
current_stage (int) – As each stage is reached, update for asynchronous event reference
- Parameters
stage_block (
threading.Event
) – Signal when task stages complete.stim (dict) –
Stimuli like:
"sounds": { "L": [{"type": "Tone", ...}], "R": [{"type": "Tone", ...}] }
reward (float) – duration of solenoid open in ms
req_reward (bool) – Whether to give a water reward in the center port for requesting trials
punish_stim (bool) – Do a white noise punishment stimulus
punish_dur (float) – Duration of white noise in ms
correction (bool) – Should we do correction trials?
correction_pct (float) – (0-1), What proportion of trials should randomly be correction trials?
bias_mode (False, “thresholded_linear”) – False, or some bias correction type (see
managers.Bias_Correction
)bias_threshold (float) – If using a bias correction mode, what threshold should bias be corrected for?
current_trial (int) – If starting at nonzero trial number, which?
stim_light (bool) – Should the LED be turned blue while the stimulus is playing?
**kwargs
Attributes:
Classes:
Methods:
request
(*args, **kwargs)Stage 0: compute stimulus, set request trigger in center port.
discrim
(*args, **kwargs)Stage 1: respond to input, set reward/punishment triggers on target/distractor ports
reinforcement
(*args, **kwargs)Stage 2 - deliver reward/punishment, end trial.
punish
()Flash lights, play punishment sound if set
respond
(pin)Set self.response
mark discrim_playing = true
stim_end
()called by stimulus callback
flash lights for punish_dir
- STAGE_NAMES = ['request', 'discrim', 'reinforcement']
- PARAMS = OrderedDict([ ('reward', {'tag': 'Reward Duration (ms)', 'type': 'int'}), ('req_reward', {'tag': 'Request Rewards', 'type': 'bool'}), ( 'punish_stim', {'tag': 'White Noise Punishment', 'type': 'bool'}), ( 'punish_dur', {'tag': 'Punishment Duration (ms)', 'type': 'int'}), ('correction', {'tag': 'Correction Trials', 'type': 'bool'}), ( 'correction_pct', { 'depends': {'correction': True}, 'tag': '% Correction Trials', 'type': 'int'}), ( 'bias_mode', { 'tag': 'Bias Correction Mode', 'type': 'list', 'values': { 'None': 0, 'Proportional': 1, 'Thresholded Proportional': 2}}), ( 'bias_threshold', { 'depends': {'bias_mode': 2}, 'tag': 'Bias Correction Threshold (%)', 'type': 'int'}), ('stim', {'tag': 'Sounds', 'type': 'sounds'})])
- PLOT = { 'chance_bar': True, 'data': {'correct': 'rollmean', 'response': 'segment', 'target': 'point'}, 'roll_window': 50}
- class TrialData
Bases:
tables.description.IsDescription
Attributes:
- columns = { 'DC_timestamp': StringCol(itemsize=26, shape=(), dflt=b'', pos=None), 'RQ_timestamp': StringCol(itemsize=26, shape=(), dflt=b'', pos=None), 'bailed': Int32Col(shape=(), dflt=0, pos=None), 'correct': Int32Col(shape=(), dflt=0, pos=None), 'correction': Int32Col(shape=(), dflt=0, pos=None), 'response': StringCol(itemsize=1, shape=(), dflt=b'', pos=None), 'target': StringCol(itemsize=1, shape=(), dflt=b'', pos=None), 'trial_num': Int32Col(shape=(), dflt=0, pos=None)}
- HARDWARE = { 'LEDS': {'C': 'LED_RGB', 'L': 'LED_RGB', 'R': 'LED_RGB'}, 'POKES': {'C': 'Digital_In', 'L': 'Digital_In', 'R': 'Digital_In'}, 'PORTS': {'C': 'Solenoid', 'L': 'Solenoid', 'R': 'Solenoid'}}
- request(*args, **kwargs)[source]
Stage 0: compute stimulus, set request trigger in center port.
- Returns
With fields:
{ 'target': self.target, 'trial_num' : self.current_trial, 'correction': self.correction_trial, 'type': stimulus type, **stim.PARAMS }
- Return type
data (dict)
- discrim(*args, **kwargs)[source]
Stage 1: respond to input, set reward/punishment triggers on target/distractor ports
- Returns
- With fields::
{ ‘RQ_timestamp’: datetime.datetime.now().isoformat(), ‘trial_num’: self.current_trial, }
- Return type
data (dict)
- reinforcement(*args, **kwargs)[source]
Stage 2 - deliver reward/punishment, end trial.
- Returns
With fields:
{ 'DC_timestamp': datetime.datetime.now().isoformat(), 'response': self.response, 'correct': self.correct, 'bailed': self.bailed, 'trial_num': self.current_trial, 'TRIAL_END': True }
- Return type
data (dict)