AHF_Stimulator

Much of the Task control is handled by this AHF_Stimulator. Refer to the modules below for task descriptions, and to ensure the correct task is being used for the cage.

AHF_Stimulator.AHF_Stimulator module

class AHF_Stimulator.AHF_Stimulator(taskP, settingsDictP)

Bases: AHF_Base.AHF_Base

Stimulator does all stimulation and reward during a head fix task. All events and their timings in a head fix, including camera control and rewards, are controlled by a Stimulator.

static config_user_get(starterDict={})

static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.

abstract quitting()
abstract run(level=0, resultsDict={}, settingsDict={})

Called at start of each head fix. Does whatever

startVideo()
stop()
stopVideo()

AHF_Stimulator.AHF_Stimulator_LEDs module

class AHF_Stimulator_LEDs.AHF_Stimulator_LEDs(taskP)

Bases: AHF_Stimulator_Rewards.AHF_Stimulator_Rewards

static about()

Returns a brief message describing your sub-class, used when asking user to pick a sub-class of this class

configStim(mouse)
config_subject_get(starterDict={})
Returns

dict – the default dictionary for individualized parameters

static config_user_get()

static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.

config_user_subject_get(starterDict={})

Prompts the user for individualized parameters, with default responses from starterDict, and returns starterDict with settings as edited by the user.

hardwareTest()

Tests functionality, gives user a chance to change settings. :Returns: bool – True if any settings have changed

logFile()

Called after each head fix, prints more detailed text to the log file, perhaps a line for each event

You may wish to use the same format as writeToLogFile function in __main__.py

Or you may wish to override with pass and log from the run method

logfile()
run(resultsDict={}, settingsDict={})

Called at start of each head fix. Does whatever

setup()

does hardware initialization with(possibly updated) info in self.settingsDict Run by __init__, or can be run separately after editing the settingsDict

Returns

code

bool whether setup completed without errors

AHF_Stimulator_LEDs.random() x in the interval [0, 1).

AHF_Stimulator.AHF_Stimulator_Lever module

class AHF_Stimulator_Lever.AHF_Stimulator_Lever(taskP, settingsDictP)

Bases: AHF_Stimulator.AHF_Stimulator

AHF_Stimulator_Lever runs a lever task by calling ptLeverThread C-module code that records lever position and puts torque on the lever

LEVER_FREQ = 250
MAX_FORCE_ARRAY_SIZE = 125
static about()

Returns a brief message describing your sub-class, used when asking user to pick a sub-class of this class

config_subject_get(starterDict={})
Returns

dict – the default dictionary for individualized parameters

static config_user_get(starterDict={})

static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.

config_user_subject_get(starterDict={})

Prompts the user for individualized parameters, with default responses from starterDict, and returns starterDict with settings as edited by the user.

defaultConstForce = 0.3

constant force on lever at start of trial that mouse must pull against, as opposed to perturbForce set during a trial a 12 bit value, 0 to 4095

defaultDemoteRate = 0.25

training for goal position

defaultGoalCenter = 200
defaultGoalCueFreq = 0

frequency for goal cue - 0 means DC, i.e., turn ON and OFF

defaultGoalCuePin = 23

GPIO pin to use for a cue played when lever is in goal pos

defaultGoalEndWidth = 10
defaultGoalIncr = 5

training for holdTime

defaultGoalStartWidth = 100
defaultGoalTrainOn = 0
defaultGoalWidth = 100

Perturbation settings for starting a mouse. Force on lever is adjusted up or down relative to const force, and then left at new value, and lever must be kept in goal area

defaultHoldEndTime = 2
defaultHoldIncr = 0.1
defaultHoldStartTime = 0.1
defaultHoldTime = 0.2
defaultHoldTrainOn = False
defaultLeverIsReversed = False

False means lever position numbers start at 0 and get bigger when mouse pulls lever, True means numbers get smaller

defaultMotorDir = 0

If MOTOR_DIR_PIN = 0, 16 bit force output(0 - 4095) goes from full counterclockwise force to full clockwise force with midpoint(2048) being no force on lever. If MOTOR_DIR_PIN is non-zero, 0-4095 maps from no force to full force, and MOTOR_DIR_PIN is the GPIO pin that controls the direction of the force, clockwise or counter-clockwise.

defaultMotorEnable = 20

GPIO Pin to enable motor

defaultMotorIsReversed = False
defaultPerturbForceOffset = 0
defaultPerturbForceRandom = 400

Training settings

defaultPerturbPercent = 0.0
defaultPerturbRampDur = 0.25
defaultPerturbStartRandom = 0
defaultPerturbStartTime = 1
defaultPrePullTime = 0.25

this many seconds of time before the lever reaches goal position is saved in a circular buffer

defaultPromoteRate = 0.75
defaultRecordingTime = 4

maximum of seconds of lever position data that will be recorded per trial

defaultStartCueDur = 0.1

duration in seconds of start cue

defaultStartCueFreq = 0

frequency for start cue - 0 means DC, i.e., turn ON and OFF

defaultStartCuePin = 27

GPIO pin to use for a cue when mouse should start a trial, this can be a pulse(freq =0) or a train

defaultToGoalTime = 0.25
defaultTrainSize = 50
defaultTrialIsCued = False

True means trials will be started with the start cue; False means mouse starts pulling lever whenever he likes

defaultTrialTimeout = 0.5

time in seconds between end of one trial(ended for any reason) and start of the next trial. Lever is rezeroed here

hardwareTest()

Tests functionality, gives user a chance to change settings. :Returns: bool – True if any settings have changed

quitting()

Called before AutoHEadFix exits. Gives stimulator chance to do any needed cleanup

A stimulator may, e.g., open files and wish to close them before exiting, or use hardware that needs to be cleaned up

run(level=- 1, settingsDict={}, resultsDict={})

Called at start of each head fix. Does whatever

setdown()

oppposite of setup. Releases any hardware resouces. can be run before editing settings so GPIO pins can be reused, for example. This strategy should be used in hardwareTest method.

setup()

does hardware initialization with(possibly updated) info in self.settingsDict Run by __init__, or can be run separately after editing the settingsDict

Returns

code

bool whether setup completed without errors

AHF_Stimulator_Lever.random() x in the interval [0, 1).

AHF_Stimulator.AHF_Stimulator_LickWithhold module

class AHF_Stimulator_LickWithhold.AHF_Stimulator_LickWithhold(taskP, settingsDictP)

Bases: AHF_Stimulator.AHF_Stimulator

AHF_Stimulator_LickWithhold gives mice rewards based on their “level”
within the program. These rewards are given based on the mouse’s response
to a defined stimulus. Levels are as follows:
Level 0: Mouse gets periodic rewards paired with a stimulus. No input
required from the mouse at this stage.
Level 1: Mouse gets periodic rewards, again paired with a stimulus. The
mouse must refrain from licking for a defined withhold time before another
reward is given. If they lick within the withhold time, a buzzer sounds.
Level 2: Mouse must lick after a given delay time from the stimulus, and
within a defined response time, in order to receive a reward. In brief,
this is the “GO” task.
Level 3: Mouse must differentiate between two stimuluses, either one pulse
for “GO” or two successive pulses for “NO-GO”. In either case, they must
wait for the delay time before responding, and then within the response
time decide to either lick or not lick. “NO-GO” trials can be rewarded
with water or not if desired.
For levels 2 and 3, the outcome of the task is recorded as follows:
“GO”:
-4: licked within delay time, failure
-2: did not lick, failure
+2: waited until response time to lick and then licked, success
“NO-GO”:
-3: licked within delay time, failure
-1: waited until response time to lick and then licked, failure
+1: did not lick, success
static about()

Returns a brief message describing your sub-class, used when asking user to pick a sub-class of this class

config_subject_get(starterDict={})
Returns

dict – the default dictionary for individualized parameters

static config_user_get(starterDict={})

static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.

config_user_subject_get(starterDict={})

Prompts the user for individualized parameters, with default responses from starterDict, and returns starterDict with settings as edited by the user.

delayTime_def = 0.5
discrimTask()
goLikelihood_def = 0.5
goTask()

A GO trial. Mouse must lick before getting a reward.

hardwareTest()

Tests functionality, gives user a chance to change settings. :Returns: bool – True if any settings have changed

lickWithholdTime_def = 1
lickWrongTimeout_def = 5
noGoTask()
quitting()

Called before AutoHEadFix exits. Gives stimulator chance to do any needed cleanup

A stimulator may, e.g., open files and wish to close them before exiting, or use hardware that needs to be cleaned up

responseTime_def = 2.5
rewardNoGo_def = True
rewardTask()
run(level=- 1, resultsDict={}, settingsDict={}, tag=0)

Called at start of each head fix. Does whatever

setdown()

oppposite of setup. Releases any hardware resouces. can be run before editing settings so GPIO pins can be reused, for example. This strategy should be used in hardwareTest method.

setup()

does hardware initialization with(possibly updated) info in self.settingsDict Run by __init__, or can be run separately after editing the settingsDict

Returns

code

bool whether setup completed without errors

speakerDuty_def = 0.8
speakerFreq_def = 300
speakerOffForReward_def = 1.5
speakerPin_def = 25
withholdWait(endTime)
AHF_Stimulator_LickWithhold.random() x in the interval [0, 1).

AHF_Stimulator.AHF_Stimulator_Rewards module

class AHF_Stimulator_Rewards.AHF_Stimulator_Rewards(taskP, settingsDictP)

Bases: AHF_Stimulator.AHF_Stimulator

static about()

Returns a brief message describing your sub-class, used when asking user to pick a sub-class of this class

config_subject_get(starterDict={})
Returns

dict – the default dictionary for individualized parameters

static config_user_get(starterDict={})

static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.

config_user_subject_get(starterDict={})

Prompts the user for individualized parameters, with default responses from starterDict, and returns starterDict with settings as edited by the user.

defaultInterval = 3
defaultRewards = 5
hardwareTest()

Tests functionality, gives user a chance to change settings. :Returns: bool – True if any settings have changed

nextDay()

Called when the next day starts. The stimulator is given the new log file pointer. Can do other things as needed :param newFP: the file pointer for the new day’s log file

quitting()

Called before AutoHEadFix exits. Gives stimulator chance to do any needed cleanup

A stimulator may, e.g., open files and wish to close them before exiting, or use hardware that needs to be cleaned up

run(level=0, resultsDict={}, settingsDict={})

Called at start of each head fix. Does whatever

setdown()

oppposite of setup. Releases any hardware resouces. can be run before editing settings so GPIO pins can be reused, for example. This strategy should be used in hardwareTest method.

setup()

does hardware initialization with(possibly updated) info in self.settingsDict Run by __init__, or can be run separately after editing the settingsDict

Returns

code

bool whether setup completed without errors