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:
Trialwise Data for a Two-Alternative Forced Choice Task
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}
- pydantic model TrialData[source]
Bases:
autopilot.data.models.protocol.Trial_Data
Trialwise Data for a Two-Alternative Forced Choice Task
Show JSON schema
{ "title": "TrialData", "description": "Trialwise Data for a Two-Alternative Forced Choice Task", "type": "object", "properties": { "group": { "title": "Group", "description": "Path of the parent step group", "type": "string" }, "session": { "title": "Session", "description": "Current training session, increments every time the task is started", "type": "integer" }, "session_uuid": { "title": "Session Uuid", "description": "Each session gets a unique uuid, regardless of the session integer, to enable independent addressing of sessions when session numbers might overlap (eg. reassignment)", "type": "string" }, "trial_num": { "title": "Trial Num", "description": "Trial data is grouped within, well, trials, which increase (rather than resetting) across sessions within a task", "datajoint": { "key": true }, "type": "integer" }, "target": { "title": "Target", "description": "Which side is the correct side this trial", "datajoint": { "datatype": "enum", "kwargs": { "args": [ "L", "R" ] } }, "enum": [ "L", "R" ], "type": "string" }, "response": { "title": "Response", "description": "The side that was poked", "datajoint": { "datatype": "enum", "kwargs": { "args": [ "L", "R" ] } }, "enum": [ "L", "R" ], "type": "string" }, "correct": { "title": "Correct", "description": "Whether the subject's response matched the target", "type": "boolean" }, "correction": { "title": "Correction", "description": "Whether this trial was a correction trial or not", "type": "boolean" }, "RQ_timestamp": { "title": "Rq Timestamp", "description": "The time where the stimulus was presented and the trial was requested", "type": "string", "format": "date-time" }, "DC_timestamp": { "title": "Dc Timestamp", "description": "The time when the subject responded", "type": "string", "format": "date-time" }, "bailed": { "title": "Bailed", "description": "Whether the subject bailed the trial from a timeout or any other reason they did not finish", "type": "boolean" } }, "required": [ "session", "trial_num", "target", "response", "correct", "correction", "RQ_timestamp", "DC_timestamp", "bailed" ] }
- Fields
DC_timestamp (datetime.datetime)
RQ_timestamp (datetime.datetime)
bailed (bool)
correct (bool)
correction (bool)
response (Literal['L', 'R'])
target (Literal['L', 'R'])
- field target: Literal['L', 'R'] [Required]
Which side is the correct side this trial
- field response: Literal['L', 'R'] [Required]
The side that was poked
- field RQ_timestamp: datetime.datetime [Required]
The time where the stimulus was presented and the trial was requested
- field DC_timestamp: datetime.datetime [Required]
The time when the subject responded
- 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)