Press Button Until Tone
Description
This behavioral experiment is designed to test subject attention by having them press a button for a randomized time until a tone plays.
When the paradigm starts, enter a pre-trial phase in which the subject must fixate on a cue light for a set period. If the subject succeeds in fixating, move to the trial phase; if not, restart the pre-trial phase.
During the trial phase, the subject must press and hold a button for a randomized time until a tone plays. If the subject remains pressing the button until the tone is played, then it receives a reward. If the subject releases the button before the tone completes, then it fails and receives adverse stimulation.
After the trial phase the pre-trial phase begins again.
Flow Chart
A flow diagram outlining all the major stages, decisions, and outputs for this paradigm |
Connection diagram in Synapse showing the full experiment tree routing. Inputs and Outputs to Pynapse gizmos should be setup first before proceeding with writing code |
Flow diagram output from Pynapse code |
from random import randint
class Always: #StateID = 0
def s_Umode_start():
p_State.switch(PreTrial) #move to PreTrial upon start
print('Start')
class PreTrialWait: #StateID = ?
def s_State_enter():
p_State.setTimeout(10, PreTrial) #wait for 10 seconds before jumping to pre trial
class PreTrial: #StateID = ?
def s_State_enter():
p_Output.CueLED.turnOn() #turn Cue LED on
def s_NosePoke_pass():
p_State.switch(Trial) #move to trial if nose poke fixation lasts for duration testing
def s_NosePoke_fail():
p_State.switch(PreTrialWait) #restart pre-trial if nose poke fixation fails, but go to a waiting period first
def s_Button1_rise():
p_State.switch(Invalid) #restart and make invalid if animal prematurely pushes button
def s_State_exit():
p_Output.CueLED.turnOff() #turn off LED when leaving
class Trial: #StateID = ?
def s_State_enter():
p_State.setTimeout(5, Invalid) #wait 5 seconds for animal to initial button press
# if no button press within 5 seconds, invalid trial
def s_Button1_rise():
wait_timeout = randint(0, 10)
print("The ITI is: " , wait_timeout)
p_State.setTimeout(wait_timeout, TrialStim)
def s_Button1_fall():
p_State.switch(Failure)
class TrialStim: #StateID = ?
def s_State_enter():
p_Output.StimFire.fire()
def s_AudSync_fall():
p_State.switch(Reward)
class Invalid: #StateID = ?
def s_State_enter():
p_Global.invalid.inc() #increment global var invalid
print(p_Global.invalid.toPretty()) #print current invalid value
p_State.setTimeout(5, PreTrialWait)
class Reward: #StateID = ?
def s_State_enter():
p_Output.Reward.fire()
p_Global.success.inc()
print(p_Global.success.toPretty())
p_State.setTimeout(5, PreTrial)
class Failure: #StateID = ?
def s_State_enter():
p_Output.Shock.fire()
p_Global.fail.inc()
print(p_Global.fail.toPretty())
p_State.setTimeout(5, PreTrial)