Пример #1
0
#Set the mode of the pins (broadcom vs local)
GPIO.setmode(GPIO.BCM)

#set the enable pins for L and R stepper motors to 1 to prevent overheating
GPIO.setup(L_enablePIN, GPIO.OUT, initial=1)
GPIO.setup(R_enablePIN, GPIO.OUT, initial=1)

#create Stepper class instances for left and right reward delivery
water_L = core.stepper(L_enablePIN, L_directionPIN, L_stepPIN, L_emptyPIN)
water_R = core.stepper(R_enablePIN, R_directionPIN, R_stepPIN, R_emptyPIN)

#create lickometer class instances for left and right lickometers
lick_port_L = core.lickometer(L_lickometer)
lick_port_R = core.lickometer(R_lickometer)

tone_go = core.tones(go_tone_freq, 0.75)

camera = PiCamera()

#----------------------------
#Initialize experiment
#----------------------------

camera.start_preview(rotation=180, fullscreen=False, window=(0, -44, 350, 400))

#Set the time for the beginning of the block
trials = np.arange(n_trials)
data = core.data(n_trials, mouse_number, block_number)

#start L and R reward counters
total_reward_L = 0
Пример #2
0
GPIO.setup(L_enablePIN, GPIO.OUT, initial=1)
GPIO.setup(R_enablePIN, GPIO.OUT, initial=1)

#initialize the mixer (for tones) at the proper sampling rate.
mixer.init(frequency=44100)

#create Stepper class instances for left and right reward delivery
water_L = core.stepper(L_enablePIN, L_directionPIN, L_stepPIN, L_emptyPIN)
water_R = core.stepper(R_enablePIN, R_directionPIN, R_stepPIN, R_emptyPIN)

#create lickometer class instances for left and right lickometers
lick_port_L = core.lickometer(L_lickometer)
lick_port_R = core.lickometer(R_lickometer)

#create instruction tones
lowfreq_singlepulse = core.tones(low_freq, sample_tone_length,
                                 single_pulse_length)  #1000Hz single pulse
lowfreq_multipulse = core.tones(low_freq, sample_tone_length,
                                multi_pulse_length)  #1000Hz multi pulse
highfreq_singlepulse = core.tones(high_freq, sample_tone_length,
                                  single_pulse_length)  #4000Hz single pulse
highfreq_multipulse = core.tones(high_freq, sample_tone_length,
                                 multi_pulse_length)  #4000Hz multi pulse

#create tone that is used as an error signal
tone_wrong = core.tones(wrong_tone_freq, wrong_tone_length, wrong_tone_length)

if ttl_experiment == 'y':
    #set up ttl class instances triggers and marker TTL output
    TTL_trigger = core.ttl(TTL_trigger_PIN, TTL_pulse_length)
    TTL_marker = core.ttl(TTL_marker_PIN, TTL_pulse_length)
Пример #3
0
GPIO.setup(L_enablePIN, GPIO.OUT, initial=1)
GPIO.setup(R_enablePIN, GPIO.OUT, initial=1)

#initialize the mixer (for tones) at the proper sampling rate.
mixer.init(frequency=44100)

#create Stepper class instances for left and right reward delivery
water_L = core.stepper(L_enablePIN, L_directionPIN, L_stepPIN, L_emptyPIN)
water_R = core.stepper(R_enablePIN, R_directionPIN, R_stepPIN, R_emptyPIN)

#create lickometer class instances for left and right lickometers
lick_port_L = core.lickometer(L_lickometer)
lick_port_R = core.lickometer(R_lickometer)

#create tones
tone_L = core.tones(L_tone_freq, sample_tone_length)
tone_R = core.tones(R_tone_freq, sample_tone_length)

# tone_go = core.tones(go_tone_freq, go_tone_length)
tone_wrong = core.tones(wrong_tone_freq, wrong_tone_length)

if ttl_experiment == 'y':
    #set up ttl class instances triggers and marker TTL output
    TTL_trigger = core.ttl(TTL_trigger_PIN, TTL_pulse_length)
    TTL_marker = core.ttl(TTL_marker_PIN, TTL_pulse_length)

camera = PiCamera()  #create camera object

#----------------------------
#Initialize experiment
#----------------------------
Пример #4
0
GPIO.setup(R_enablePIN, GPIO.OUT, initial = 1)

#initialize the mixer (for tones) at the proper sampling rate.
mixer.init(frequency = 44100)

#create Stepper class instances for left and right reward delivery
water_L = core.stepper(L_enablePIN, L_directionPIN, L_stepPIN, L_emptyPIN)
water_R = core.stepper(R_enablePIN, R_directionPIN, R_stepPIN, R_emptyPIN)

#create lickometer class instances for left and right lickometers
lick_port_L = core.lickometer(L_lickometer)
lick_port_R = core.lickometer(R_lickometer)

#create tones

tone_go = core.tones(go_tone_freq, go_tone_length) #create "go" tone

camera = PiCamera() #create camera object

#----------------------------
#Initialize experiment
#----------------------------

camera.start_preview(rotation = 180, fullscreen = False, window = (0,-44,350,400))

#Set the time for the beginning of the block
trials = np.arange(n_trials)
data = core.data(protocol_description, n_trials, mouse_number, block_number)

total_reward_L = 0
total_reward_R = 0
Пример #5
0
GPIO.setup(L_enablePIN, GPIO.OUT, initial=1)
GPIO.setup(R_enablePIN, GPIO.OUT, initial=1)

#initialize the mixer (for tones) at the proper sampling rate.
mixer.init(frequency=44100)

#create stepper class instances for left and right reward delivery
water_L = core.stepper(L_enablePIN, L_directionPIN, L_stepPIN, L_emptyPIN)
water_R = core.stepper(R_enablePIN, R_directionPIN, R_stepPIN, R_emptyPIN)

#create lickometer class instances for left and right lickometers
lick_port_L = core.lickometer(L_lickometer)
lick_port_R = core.lickometer(R_lickometer)

#create tones
tone_L = core.tones(L_tone_freq, sample_tone_length)
tone_R = core.tones(R_tone_freq, sample_tone_length)

tone_go = core.tones(go_tone_freq, go_tone_length)
tone_wrong = core.tones(wrong_tone_freq, wrong_tone_length)

#set up ttl class instances triggers and marker TTL output
TTL_trigger = core.ttl(TTL_trigger_PIN, TTL_pulse_length)
TTL_marker = core.ttl(TTL_marker_PIN, TTL_pulse_length)

camera = PiCamera()  #create camera object

#----------------------------
#Initialize experiment
#----------------------------
Пример #6
0
GPIO.setup(L_enablePIN, GPIO.OUT, initial=1)
GPIO.setup(R_enablePIN, GPIO.OUT, initial=1)

#initialize the mixer (for tones) at the proper sampling rate.
mixer.init(frequency=44100)

#create Stepper class instances for left and right reward delivery
water_L = core.stepper(L_enablePIN, L_directionPIN, L_stepPIN, L_emptyPIN)
water_R = core.stepper(R_enablePIN, R_directionPIN, R_stepPIN, R_emptyPIN)

#create lickometer class instances for left and right lickometers
lick_port_L = core.lickometer(L_lickometer)
lick_port_R = core.lickometer(R_lickometer)

#create tones
tone_L = core.tones(L_tone_freq, sample_tone_length)  #create left tone
tone_R = core.tones(R_tone_freq, sample_tone_length)  #create right tone

tone_go = core.tones(go_tone_freq, go_tone_length)  #create "go" tone

camera = PiCamera()  #create camera object
camera.resolution = (320, 240)  #set picam resolution
camera.rotation = (180)  #invert the image
filename = f'{mouse_number}_{date}_block{block_number}.h264'
camera.annotate_text_size = (20)

#----------------------------
#Initialize experiment
#----------------------------

camera.start_preview(rotation=180, fullscreen=False, window=(0, -44, 350, 400))
Пример #7
0
GPIO.setup(L_enablePIN, GPIO.OUT, initial = 1)
GPIO.setup(R_enablePIN, GPIO.OUT, initial = 1)

#initialize the mixer (for tones) at the proper sampling rate.
mixer.init(frequency = 44100)

#create Stepper class instances for left and right reward delivery
water_L = core.stepper(L_enablePIN, L_directionPIN, L_stepPIN, L_emptyPIN)
water_R = core.stepper(R_enablePIN, R_directionPIN, R_stepPIN, R_emptyPIN)

#create lickometer class instances for left and right lickometers
lick_port_L = core.lickometer(L_lickometer)
lick_port_R = core.lickometer(R_lickometer)

#create tones
tone_go = core.tones(go_tone_freq, go_tone_length)

tone_reward = core.tones(reward_tone_freq, reward_tone_length) #create a reward tone
tone_no_reward = core.tones(no_reward_tone_freq, reward_tone_length) #create a "no reward" tone

tone_wrong = core.tones(wrong_tone_freq, reward_tone_length)

camera = PiCamera() #create camera object

#----------------------------
#Initialize experiment
#----------------------------

camera.start_preview(rotation = 180, fullscreen = False, window = (0,-44,350,400))

#Set the time for the beginning of the block
Пример #8
0
GPIO.setmode(GPIO.BCM)

#set the enable pins for L and R stepper motors to 1 to prevent overheating
GPIO.setup(L_enablePIN, GPIO.OUT, initial = 1)
GPIO.setup(R_enablePIN, GPIO.OUT, initial = 1)

#create Stepper class instances for left and right reward delivery
water_L = core.stepper(L_enablePIN, L_directionPIN, L_stepPIN, L_emptyPIN)
water_R = core.stepper(R_enablePIN, R_directionPIN, R_stepPIN, R_emptyPIN)

#create lickometer class instances for left and right lickometers
lick_port_L = core.lickometer(L_lickometer)
lick_port_R = core.lickometer(R_lickometer)

#create tones
tone_L = core.tones(L_tone_freq, 1)
tone_R = core.tones(R_tone_freq, 1)

tone_go = core.tones(go_tone_freq, 0.75)

camera = PiCamera()

#----------------------------
#Initialize experiment
#----------------------------

camera.start_preview(rotation = 180, fullscreen = False, window = (0,-44,350,400))

#Set the time for the beginning of the block
trials = np.arange(n_trials)
data = core.data(n_trials, mouse_number, block_number)
Пример #9
0
    #The thread will run the stepper.Refill method, and can run several instances simultaneously

    left_thread.start()  #start thread for L syringe
    right_thread.start()  #start thread for R syringe

    tube_fill = input('Reconnect and fill water tubes (ENTER) ')
    #reminder to reconnect and manually spin the syringe pumps

#----------------------------
#Test speakers:
#----------------------------

#initialize the mixer (for tones) at the proper sampling rate.
mixer.init(frequency=44100)

test_tone = core.tones(
    1000, 2, 2)  #generates a .wav file with a 2 second tone at 1000Hz

print('Testing speakers.')

speaker_test = 'a'  #Initialize speaker_test variable to 'a'; see below
while speaker_test == 'a':

    test_tone.Play()  #play the test tone
    speaker_test = input('Did you hear the tone? y:yes, a:again: ')

test_tone.Delete()  #delete the .wav file that was created

#----------------------------
#Test lick detection:
#----------------------------
Пример #10
0
#Set the mode of the pins (broadcom vs local)
GPIO.setmode(GPIO.BCM)

#set the enable pins for L and R stepper motors to 1 to prevent overheating
GPIO.setup(L_enablePIN, GPIO.OUT, initial=1)
GPIO.setup(R_enablePIN, GPIO.OUT, initial=1)

#initialize the mixer (for tones) at the proper sampling rate.
mixer.init(frequency=44100)

#create Stepper class instance
water = core.stepper(L_enablePIN, L_directionPIN, L_stepPIN, L_emptyPIN)

#create  tone
tone = core.tones(tone_freq, sample_tone_length,
                  single_pulse_length)  #1000Hz single pulse

loop = True

while loop == True:

    raw_input = input('Ready to play tone (ENTER) ')

    tone.Play()
    water.Reward()

    time.sleep(2)

    water.Reward()
    tone.play()