task

Classes:

Task(*args, **kwargs)

Generic Task metaclass

datetime(year, month, day[, hour[, minute[, …)

The year, month and day arguments are required.

odict

alias of collections.OrderedDict

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’}

  • HARDWARE (dict) –

    dict for necessary hardware, like:

    HARDWARE = {
    ‘POKES’:{

    ‘L’: hardware.Beambreak, …

    }, ‘PORTS’:{

    ’L’: hardware.Solenoid, …

    }

    }

  • PLOT (dict) –

    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 occuring

  • logger (logging.Logger) – gets the ‘main’ logger for now.

Attributes:

HARDWARE

PARAMS

PLOT

STAGE_NAMES

Classes:

TrialData()

Methods:

end()

Release all hardware objects

flash_leds()

flash lights for punish_dir

handle_trigger(pin[, level, tick])

All GPIO triggers call this function with the pin number, level (high, low), and ticks since booting pigpio.

init_hardware()

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 pi

init_logging()

Initialize logging to a timestamped file in prefs.LOGDIR .

set_leds([color_dict])

Set the color of all LEDs at once.

set_reward([vol, duration, port])

Set the reward value for each of the ‘PORTS’.

PARAMS = {}
HARDWARE = {}
STAGE_NAMES = []
PLOT = {}
class TrialData

Bases: tables.description.IsDescription

Attributes:

columns

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 pi

Instantiate the hardware, assign it Task.handle_trigger() as a callback if it is a trigger.

init_logging()[source]

Initialize logging to a timestamped file in prefs.LOGDIR .

The logger name will be ‘node.{id}’ .

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

set_leds(color_dict=None)[source]

Set the color of all LEDs at once.

Parameters

color_dict (dict) – If None, turn LEDs off, otherwise like:

{‘pin’: [R,G,B], ‘pin2: [R,G,B]}

flash_leds()[source]

flash lights for punish_dir

end()[source]

Release all hardware objects