本文整理汇总了Python中pyoperant.utils.wait函数的典型用法代码示例。如果您正苦于以下问题:Python wait函数的具体用法?Python wait怎么用?Python wait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: feed
def feed(self,dur=2.0,error_check=True):
"""Performs a feed
Parameters
---------
dur : float, optional
duration of feed in seconds
Returns
-------
(datetime, float)
Timestamp of the feed and the feed duration
Raises
------
HopperAlreadyUpError
The Hopper was already up at the beginning of the feed.
HopperWontComeUpError
The Hopper did not raise for the feed.
HopperWontDropError
The Hopper did not drop fater the feed.
"""
assert self.max_lag < dur, "max_lag (%ss) must be shorter than duration (%ss)" % (self.max_lag,dur)
try:
self.check()
except HopperActiveError as e:
self.solenoid.write(False)
raise HopperAlreadyUpError(e)
feed_time = self.up()
utils.wait(dur)
feed_over = self.down()
feed_duration = feed_over - feed_time
return (feed_time,feed_duration)
开发者ID:MarvinT,项目名称:pyoperant,代码行数:35,代码来源:components.py
示例2: sound_then_feeder
def sound_then_feeder(self, filename="", duration=12, flash=False, flash_dur=3):
""" Pairs the sound playback with the feeder coming up.
Hit Ctrl+C to stop the sound or put the feeder down.
:param filename: path to sound file.
:param duration: duration the feeder is up (seconds)
:param flash: whether or not to flash the button at the start (default False)
"""
if not filename:
filename = self._default_sound_file
self.speaker.queue(filename)
if flash:
self.peck_port.flash(dur=flash_dur)
self.speaker.play()
try:
while self.speaker.output.interface.stream.is_active():
utils.wait(0.1)
except KeyboardInterrupt:
pass
finally:
self.speaker.stop()
try:
self.feeder.feed(duration)
except KeyboardInterrupt:
self.feeder.down()
开发者ID:siriuslee,项目名称:pyoperant,代码行数:28,代码来源:local_tlab.py
示例3: stimulus_main
def stimulus_main(self):
## 1. present cue
if 'cue' in self.this_trial.annotations:
cue = self.this_trial.annotations["cue"]
self.log.debug("cue light turning on")
cue_start = dt.datetime.now()
if cue=="red":
self.panel.cue.red()
elif cue=="green":
self.panel.cue.green()
elif cue=="blue":
self.panel.cue.blue()
utils.wait(self.parameters["cue_duration"])
self.panel.cue.off()
cue_dur = (dt.datetime.now() - cue_start).total_seconds()
cue_time = (cue_start - self.this_trial.time).total_seconds()
cue_event = utils.Event(time=cue_time,
duration=cue_dur,
label='cue',
name=cue,
)
self.this_trial.events.append(cue_event)
utils.wait(self.parameters["cuetostim_wait"])
## 2. play stimulus
stim_start = dt.datetime.now()
self.this_trial.stimulus_event.time = (stim_start - self.this_trial.time).total_seconds()
self.panel.speaker.play() # already queued in stimulus_pre()
开发者ID:gentnerlab,项目名称:pyoperant,代码行数:28,代码来源:two_alt_choice.py
示例4: trial_post
def trial_post(self):
'''things to do at the end of a trial'''
self.this_trial.duration = (dt.datetime.now() - self.this_trial.time).total_seconds()
self.analyze_trial()
self.save_trial(self.this_trial)
self.write_summary()
utils.wait(self.parameters['intertrial_min'])
# determine if next trial should be a correction trial
self.do_correction = True
if len(self.trials) > 0:
if self.parameters['correction_trials']:
if self.this_trial.correct == True:
self.do_correction = False
elif self.this_trial.response == 'none':
if self.this_trial.type_ == 'normal':
self.do_correction = self.parameters['no_response_correction_trials']
else:
self.do_correction = False
else:
self.do_correction = False
if self.check_session_schedule()==False:
raise EndSession
if self._check_free_food_block(): return 'free_food_block'
开发者ID:gentnerlab,项目名称:pyoperant,代码行数:25,代码来源:two_alt_choice.py
示例5: temp
def temp():
if t_min == t_max:
t = t_max
else:
t = random.randrange(t_min, t_max)
utils.wait(t)
return next_state
开发者ID:theilmbh,项目名称:pyoperant,代码行数:7,代码来源:shape.py
示例6: up
def up(self):
self.solenoid.write(True)
utils.wait(self.lag)
try:
self.check()
except HopperInactiveError as e:
raise HopperWontComeUpError(e)
return True
开发者ID:neuromusic,项目名称:pyoperant,代码行数:8,代码来源:components.py
示例7: timeout
def timeout(self,dur=10.0):
""" turn off light for a few seconds """
timeout_time = datetime.datetime.now()
self.light.write(False)
utils.wait(dur)
timeout_duration = datetime.datetime.now() - timeout_time
self.light.write(True)
return (timeout_time,timeout_duration)
开发者ID:neuromusic,项目名称:pyoperant,代码行数:8,代码来源:components.py
示例8: trial_post
def trial_post(self):
'''things to do at the end of a trial'''
self.analyze_trial()
self.save_trial(self.this_trial)
self.write_summary()
utils.wait(self.parameters['intertrial_min'])
return None
开发者ID:neuromusic,项目名称:pyoperant,代码行数:8,代码来源:two_alt_choice.py
示例9: down
def down(self):
""" drop hopper """
self.solenoid.write(False)
utils.wait(self.lag)
try:
self.check()
except HopperActiveError as e:
raise HopperWontDropError(e)
return True
开发者ID:neuromusic,项目名称:pyoperant,代码行数:9,代码来源:components.py
示例10: sleep_main
def sleep_main(self):
""" reset expal parameters for the next day """
self.log.debug("sleeping...")
self.panel.house_light.off()
utils.wait(self.parameters["idle_poll_interval"])
if not utils.check_time(self.parameters["light_schedule"]):
return "main"
else:
return "post"
开发者ID:theilmbh,项目名称:pyoperant,代码行数:9,代码来源:shape.py
示例11: run
def run(self):
""" Checks every poll interval whether the panel should be sleeping and puts it to sleep """
while True:
logger.debug("sleeping")
self.experiment.panel.sleep()
utils.wait(self.poll_interval)
if not self.check():
break
self.experiment.panel.wake()
开发者ID:siriuslee,项目名称:pyoperant,代码行数:10,代码来源:states.py
示例12: _run_idle
def _run_idle(self):
if self.check_light_schedule() == False:
return 'sleep'
elif self.check_session_schedule():
return 'session'
else:
self.panel_reset()
self.log.debug('idling...')
utils.wait(self.parameters['idle_poll_interval'])
return 'idle'
开发者ID:MarvinT,项目名称:pyoperant,代码行数:10,代码来源:base.py
示例13: calibrate
def calibrate(self):
self.peck_port.off()
while True:
is_pecked = self.peck_port.status()
if is_pecked:
current_time = dt.datetime.now()
print("%s: Pecked!" % current_time.strftime("%H:%M:%S"))
self.peck_port.on()
utils.wait(0.05)
self.peck_port.off()
开发者ID:siriuslee,项目名称:pyoperant,代码行数:11,代码来源:local_tlab.py
示例14: secondary_reinforcement
def secondary_reinforcement(self,value=1.0):
if "cue" in dir(self.panel):
self.panel.cue.red()
utils.wait(.05)
self.panel.cue.off()
self.panel.cue.red()
utils.wait(.05)
self.panel.cue.off()
return
else:
return self.panel.center.flash(dur=value)
开发者ID:gentnerlab,项目名称:pyoperant,代码行数:11,代码来源:text_markov.py
示例15: flash
def flash(self,dur=1.0,isi=0.1):
""" flash the LED """
LED_state = self.LED.read()
flash_time = datetime.datetime.now()
flash_duration = datetime.datetime.now() - flash_time
while flash_duration < datetime.timedelta(seconds=dur):
self.LED.toggle()
utils.wait(isi)
flash_duration = datetime.datetime.now() - flash_time
self.LED.write(LED_state)
return (flash_time,flash_duration)
开发者ID:neuromusic,项目名称:pyoperant,代码行数:11,代码来源:components.py
示例16: test
def test(self):
self.reset()
dur = 2.0
for output in self.outputs:
output.write(True)
utils.wait(dur)
output.write(False)
self.reset()
self.reward(value=dur)
self.punish(value=dur)
self.speaker.queue("/usr/local/stimuli/A1.wav")
self.speaker.play()
return True
开发者ID:neuromusic,项目名称:pyoperant,代码行数:13,代码来源:local_vogel.py
示例17: trial_pre
def trial_pre(self):
""" Store data that is specific to this experiment, and compute a wait time for an intertrial interval
"""
stimulus = self.this_trial.stimulus.file_origin
if isinstance(self.intertrial_interval, (list, tuple)):
iti = np.random.uniform(*self.intertrial_interval)
else:
iti = self.intertrial_interval
logger.debug("Waiting for %1.3f seconds" % iti)
self.this_trial.annotate(stimulus_name=stimulus,
intertrial_interval=iti)
utils.wait(iti)
开发者ID:siriuslee,项目名称:pyoperant,代码行数:14,代码来源:simple_stimulus_playback.py
示例18: test
def test(self):
self.reset()
dur = 2.0
for output in self.outputs:
output.write(True)
utils.wait(dur)
output.write(False)
self.reset()
self.reward(value=dur)
self.punish(value=dur)
self.speaker.queue('/home/pi/test.wav')
self.speaker.play()
time.sleep(1.0)
self.speaker.stop()
return True
开发者ID:gentnerlab,项目名称:pyoperant,代码行数:15,代码来源:local_pi.py
示例19: feed
def feed(self,dur=2.0):
"""Performs a feed
arguments:
feedsecs -- duration of feed in seconds (default: %default)
"""
assert self.lag < dur, "lag (%ss) must be shorter than duration (%ss)" % (self.lag,dur)
try:
self.check()
except HopperInactiveError as e:
raise HopperAlreadyUpError(e)
feed_time = datetime.datetime.now()
self.up() # includes a lag
utils.wait(dur - self.lag)
feed_duration = datetime.datetime.now() - feed_time
self.down() # includes a lag
return (feed_time,feed_duration)
开发者ID:neuromusic,项目名称:pyoperant,代码行数:17,代码来源:components.py
示例20: stimulus_main
def stimulus_main(self):
""" Queue the sound and play it """
logger.info("Trial %d - %s - %s" % (
self.this_trial.index,
self.this_trial.time.strftime("%H:%M:%S"),
self.this_trial.stimulus.name
))
self.panel.speaker.queue(self.this_trial.stimulus.file_origin)
self.panel.speaker.play()
# Wait for stimulus to finish
utils.wait(self.this_trial.stimulus.duration)
# Stop the sound
self.panel.speaker.stop()
开发者ID:siriuslee,项目名称:pyoperant,代码行数:17,代码来源:simple_stimulus_playback.py
注:本文中的pyoperant.utils.wait函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论