本文整理汇总了Python中VisionEgg.FlowControl.Presentation.set方法的典型用法代码示例。如果您正苦于以下问题:Python Presentation.set方法的具体用法?Python Presentation.set怎么用?Python Presentation.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisionEgg.FlowControl.Presentation
的用法示例。
在下文中一共展示了Presentation.set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import set [as 别名]
class SimpleVisionEgg:
keyboard_controller = None
trigger_controller = None
screen = None
presentation = None
keys = None
presses = None
releases = None
def __init__(self):
"""We break up initialization a bit as we need to go back and forth with
some information. In this case, we need screen size before specifying
the stimuli"""
# pasted in from where it used to be at the beginning of the script
# used to be outside of any methods...
VisionEgg.start_default_logging()
VisionEgg.watch_exceptions()
# get screen size for setting fullscreen resolution
# comment this block out if you don't want to use full-screen.
screen = pygame.display.set_mode((0,0))
WIDTH, HEIGHT = screen.get_size()
pygame.quit()
VisionEgg.config.VISIONEGG_SCREEN_W = WIDTH
VisionEgg.config.VISIONEGG_SCREEN_H = HEIGHT
self.screen = get_default_screen()
self.keys = []
self.presses = []
self.releases = []
def set_stimuli(self, stimuli, trigger=None, kb_controller=False):
"""Now that we have our stimuli, we initialize everything we can"""
viewport = Viewport(screen=self.screen, size=self.screen.size,
stimuli=stimuli)
# We disable "check_events" so that we don't lose "instantaneous" key
# presses and can check these in our Response classes
self.presentation = Presentation(viewports=[viewport],
check_events=False)
if trigger:
trigger_controller = KeyboardTriggerInController(trigger)
self.presentation.add_controller(self.presentation,
'trigger_go_if_armed', trigger_controller)
self.presentation.set(trigger_go_if_armed=0)
if kb_controller:
self.keyboard_controller = KeyboardResponseController()
self.presentation.add_controller(None, None, self.keyboard_controller)
def set_functions(self, update=None, pause_update=None):
"""Interface for cognac.StimulusController or similar"""
self.presentation.add_controller(None, None,
FunctionController(during_go_func=update,
between_go_func=pause_update,
return_type=NoneType) )
def go(self, go_duration=('forever',)):
self.presentation.parameters.go_duration = go_duration
self.presentation.go()
def pause(self):
self.presentation.parameters.go_duration = (0, 'frames')
def get_new_response(self, t, min_interval=2.0 / 60, releases=False):
"""(key, press) = get_new_response(self, t, min_interval=2.0 / 60)
DEPRECATED!
Use this function to get responses from the keyboard controller in real
time.
Returns (None, None) if no new response is available.
Maintains three instance variables - keys, presses and releases, which
you can also access directly (but they won't be updated during loops
where you don't call this function)
This function makes a number of assumptions and is a little brittle
right now. By not hard-coding the min_interval and maybe using key
presses and release events directly, we'd have a much better function.
But I don't really care right now.
DJC
"""
raise DeprecationWarning("please use pygame directly, as in" +
"StimController.Response")
# Note - this is deprecated anyway, but it'd probably make more sense to
# use the keyboard_controller.get_responses() to simply get the keys
# that are down _right_now_
press_time = self.keyboard_controller.get_time_last_response_since_go()
key = self.keyboard_controller.get_last_response_since_go()
# Our first response!
if len(self.keys) == 0:
if key:
self.keys.append(key)
self.presses.append(press_time)
#.........这里部分代码省略.........
示例2: VisualSpellerVE
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import set [as 别名]
class VisualSpellerVE(MainloopFeedback):
"""
Visual Speller with six circles like the classical HexOSpell.
"""
# Triggers: look in Marker
END_LEVEL1, END_LEVEL2 = 244, 245 # end of hex levels
COPYSPELLING_FINISHED = 246
STIMULUS = [[11, 12, 13, 14, 15, 16], [21, 22, 23, 24, 25, 26]]
RESPONSE = [[51, 52, 53, 54, 55, 56], [61, 62, 63, 64, 65, 66]]
TARGET_ADD = 20
ERROR_ADD = 100
COUNTDOWN_STIMULI = 239
ERROR_POTENTIAL = 96 # send if error potential is classified
def init(self):
"""
initialize parameters
"""
self.log_filename = "VisualSpellerVE.log"
self.geometry = [0, 0, 1280, 800] ## size
self.letterbox_size = (60, 60)
self.osc_size = 40
self.font_size_phrase = 60 # the spelled phrase at the top
self.font_size_current_letter = 80 # the spelled phrase at the top
self.font_size_countdown = 150 # number during countdown
self.desired_phrase = ""
## colors:
self.bg_color = (0.0, 0.0, 0.0)
self.phrase_color = (0.2, 0.0, 1.0)
self.current_letter_color = (1.0, 0.0, 0.0)
self.countdown_color = (0.2, 0.0, 1.0)
self.osc_color = (1, 1, 1)
self.letter_set = [
["A", "B", "C", "D", "E"],
["F", "G", "H", "I", "J"],
["K", "L", "M", "N", "O"],
["P", "Q", "R", "S", "T"],
["U", "V", "W", "X", "Y"],
["Z", "_", ".", ",", "<"],
]
self.fullscreen = False
self.use_oscillator = True
self.offline = True
self.copy_spelling = True # in copy-spelling mode, selection of the target symbol is forced
self.debug = False
self.nCountdown = 5
self.nr_sequences = 6
self.randomize_sequence = True # set to False to present a fixed stimulus sequence
self.min_dist = 2 # Min number of intermediate flashes bef. a flash is repeated twice
self.stimulus_duration = 0.083 # 5 frames @60 Hz = 83ms flash
self.interstimulus_duration = 0.1
self.animation_time = 1
self.wait_before_classify = 1.0
self.feedback_duration = 1.0
self.feedback_ErrP_duration = 1.0
self.wait_after_start = 0.0
# Countdown options
self.do_animation = True
self.synchronized_countdown = True
if self.synchronized_countdown:
self.do_animation = False
self.countdown_level1 = True
self.countdown_level2 = True
self.countdown_shapes = {"circle": FilledCircle, "hexagon": FilledHexagon}
self.countdown_shape_select = "hexagon"
self.countdown_shape_color = (0.7, 0.7, 0.7)
self.countdown_shape_on = True
self.countdown_blinking_nr = 5 # number of pre-sequence stimuli(1 sec is approx. 5 frames at 60 Hz)
self.wait_after_early_stopping = 3 # sec
self.abort_trial = False
self.output_per_stimulus = True
self.use_ErrP_detection = False
self.serialtrigger = False
self.serialport = serialport.SerialPort(13)
self.send_parallel_bak = self.send_parallel
if self.debug:
msg = "!!! YOU'RE IN DEBUG MODE! CLASSIFICATION WILL BE RANDOM OR KEYBOARD CONTROLLED !!!"
self.logger.warning(msg)
def pre_mainloop(self):
## logging
assert len(self.log_filename) != 0 # 'log_filename' must not be empty string!
logger.setLevel(logging.ERROR)
handler = logging.FileHandler(self.log_filename, "w")
handler.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s: %(message)s")
handler.setFormatter(formatter)
#.........这里部分代码省略.........
示例3: VisionEggView
# 需要导入模块: from VisionEgg.FlowControl import Presentation [as 别名]
# 或者: from VisionEgg.FlowControl.Presentation import set [as 别名]
class VisionEggView(object):
""" This class handles VisionEgg internals and the creation of
common/standard stimuli like centered words, a fixation cross or
a countdown. Inherit this and pass the type to VisionEggFeedback
for customization.
"""
def __init__(self):
self.__init_attributes()
def __init_attributes(self):
""" Setup internal attributes. """
self._logger = logging.getLogger('VisionEggView')
self._logger.addHandler(logging.FileHandler('log'))
self._screen_acquired = False
self._viewports = []
def set_trigger_function(self, trigger):
self._trigger = trigger
def set_event_handlers(self, event_handlers):
""" Set pygame/VisionEgg event handler function. """
self._event_handlers = event_handlers
def set_iterator_semaphore(self, flag):
""" Specify the object to be used as semaphore for iterators.
See L{Switcherator} for more.
"""
self._iter = lambda it: Switcherator(flag, it)
def update_parameters(self, **kwargs):
""" Apply new parameters set from pyff. """
for k, v in kwargs.iteritems():
setattr(self, '_' + k, v)
if self._screen_acquired:
self.reinit()
def acquire(self):
""" Allow L{update_parameters} initialize VisionEgg. """
self._screen_acquired = True
def reinit(self):
""" Initialize VisionEgg objects. """
self.__init_screen()
self.__init_presentation()
self.__init_viewports()
self.init()
self.__init_text()
def init(self):
""" Overload this for additional custom VisionEgg
initialization.
"""
pass
def __init_screen(self):
""" Create the VisionEgg Screen object using the pyff
configuration parameters 'fullscreen' and 'geometry' and the
font and background colors according to parameters
'font_color_name' and 'bg_color'.
"""
params = { 'fullscreen': self._fullscreen, 'sync_swap': True }
if not self._fullscreen:
os.environ['SDL_VIDEO_WINDOW_POS'] = '%d, %d' % (self._geometry[0],
self._geometry[1])
params['size'] = self._geometry[2:]
self.screen = Screen(**params)
self._set_bg_color()
self._set_font_color()
def __init_presentation(self):
""" Provide a standard presentation object. """
self.presentation = Presentation(handle_event_callbacks=
self._event_handlers)
def __init_viewports(self):
""" Provide a standard viewport. """
self._standard_viewport = Viewport(screen=self.screen)
self.add_viewport(self._standard_viewport)
def __init_text(self):
""" Provide a text in the screen center for standard stimuli and
fixation cross etc.
"""
sz = self.screen.size
self._center_text = self.add_color_word(position=(sz[0] / 2.,
sz[1] / 2.),
font_size=self._font_size)
def add_viewport(self, viewport):
""" Add an additional custom viewport object to the list of
viewports.
"""
self._viewports.append(viewport)
self.presentation.set(viewports=self._viewports)
def clear_stimuli(self):
""" Remove all existing stimuli in the standard viewport. """
self.set_stimuli()
def add_stimuli(self, *stimuli):
#.........这里部分代码省略.........