task¶
Classes:
|
Generic Task metaclass |
-
class
Task
(*args, **kwargs)[source]¶ Bases:
object
Generic Task metaclass
- Variables
PARAMS (
collections.OrderedDict
) –Params to define task, like:
PARAMS = odict() PARAMS[‘reward’] = {‘tag’:’Reward Duration (ms)’,
’type’:’int’}
- PARAMS[‘req_reward’] = {‘tag’:’Request Rewards’,
’type’:’bool’}
dict for necessary hardware, like:
- HARDWARE = {
- ‘POKES’:{
‘L’: hardware.Beambreak, …
}, ‘PORTS’:{
’L’: hardware.Solenoid, …
}
}
Dict of plotting parameters, like:
- PLOT = {
- ‘data’: {
‘target’ : ‘point’, ‘response’ : ‘segment’, ‘correct’ : ‘rollmean’
}, ‘chance_bar’ : True, # Draw a red bar at 50% ‘roll_window’ : 50 # number of trials to roll window over
}
Trial_Data (
tables.IsDescription
) –Data table description, like:
- class TrialData(tables.IsDescription):
trial_num = tables.Int32Col() target = tables.StringCol(1) response = tables.StringCol(1) correct = tables.Int32Col() correction = tables.Int32Col() RQ_timestamp = tables.StringCol(26) DC_timestamp = tables.StringCol(26) bailed = tables.Int32Col()
STAGE_NAMES (list) – List of stage method names
stage_block (
threading.Event
) – Signal when task stages complete.punish_stim (bool) – Do a punishment stimulus
stages (iterator) – Some generator or iterator that continuously returns the next stage method of a trial
triggers (dict) – Some mapping of some pin to callback methods
pins (dict) – Dict to store references to hardware
pin_id (dict) – Reverse dictionary, pin numbers back to pin letters.
punish_block (
threading.Event
) – Event to mark when punishment is occuringlogger (
logging.Logger
) – gets the ‘main’ logger for now.
Attributes:
Classes:
Methods:
Use the HARDWARE dict that specifies what we need to run the task alongside the HARDWARE subdict in
prefs
to tell us how they’re plugged in to the piset_reward
([vol, duration, port])Set the reward value for each of the ‘PORTS’.
handle_trigger
(pin[, level, tick])All GPIO triggers call this function with the pin number, level (high, low), and ticks since booting pigpio.
set_leds
([color_dict])Set the color of all LEDs at once.
flash lights for punish_dir
end
()Release all hardware objects
-
PARAMS
= OrderedDict()¶
-
HARDWARE
= {}¶
-
STAGE_NAMES
= []¶
-
PLOT
= {}¶
-
class
TrialData
¶ Bases:
tables.description.IsDescription
Attributes:
-
columns
= { 'session': Int32Col(shape=(), dflt=0, pos=None), 'trial_num': Int32Col(shape=(), dflt=0, pos=None)}¶
-
-
init_hardware
()[source]¶ Use the HARDWARE dict that specifies what we need to run the task alongside the HARDWARE subdict in
prefs
to tell us how they’re plugged in to the piInstantiate the hardware, assign it
Task.handle_trigger()
as a callback if it is a trigger.
-
set_reward
(vol=None, duration=None, port=None)[source]¶ Set the reward value for each of the ‘PORTS’.
- Parameters
vol (float, int) – Volume of reward in uL
duration (float) – Duration to open port in ms
port (None, Port_ID) – If None, set everything in ‘PORTS’, otherwise only set port
-
handle_trigger
(pin, level=None, tick=None)[source]¶ All GPIO triggers call this function with the pin number, level (high, low), and ticks since booting pigpio.
Calls any trigger assigned to the pin in self.triggers , unless during punishment (returns).
- Parameters
pin (int) – BCM Pin number
level (bool) – True, False high/low
tick (int) – ticks since booting pigpio