本文整理汇总了Python中VisionEgg.FlowControl.Presentation类的典型用法代码示例。如果您正苦于以下问题:Python Presentation类的具体用法?Python Presentation怎么用?Python Presentation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Presentation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initMe
class CVEggStimText:
# Some are overwritten by the init func. Here for reference
text = "NULL"
font_sz = 50
anchor = "center"
t = 1
tscale = "seconds"
# initme's arguments are : (text,font-sz,time,t-unit,screen)
def initMe(self, arg_text, arg_font_sz, arg_t, arg_tscale, arg_screen, arg_r=1.0, arg_g=1.0, arg_b=1.0):
# member vars init
self.text = arg_text
self.font_sz = arg_font_sz
self.t = arg_t
self.tscale = arg_tscale
self.color = (arg_r, arg_g, arg_b)
# dyn vars
text_vegg = Text(
text=self.text,
color=self.color,
position=(arg_screen.size[0] / 2, arg_screen.size[1] / 2),
font_size=self.font_sz,
anchor=self.anchor,
)
viewport_vegg = Viewport(screen=arg_screen, size=arg_screen.size, stimuli=[text_vegg])
# Set up the pres var
self.pres_vegg = Presentation(go_duration=(arg_t, arg_tscale), viewports=[viewport_vegg])
def show(self):
# print self.text_vegg
self.pres_vegg.go()
示例2: showImage
def showImage(screen, img, duration=1):
def quitKey(event):
if event.key == pygame.locals.K_SPACE:
quit()
def click(event):
quit()
def quit(dummy_arg=None):
image.parameters.go_duration = (0,'frames')
img = Image.open(img)
#create textures
tex = Texture(img)
x = screen.size[0] / 2
y = screen.size[1] / 2
stimulus = TextureStimulus(texture = tex, position = (x, y), anchor = 'center')
#create viewports
viewport = Viewport(screen=screen, stimuli=[stimulus])
if duration:
image = Presentation(go_duration=(duration, 'seconds'), viewports=[viewport])
else:
image = Presentation(go_duration=('forever', ''), viewports=[viewport])
image.parameters.handle_event_callbacks=[(pygame.locals.QUIT, quit),(pygame.locals.KEYDOWN, quitKey), (pygame.locals.MOUSEBUTTONDOWN, click)]
image.go()
示例3: showStimulus
def showStimulus(screen, text, colour):
word, viewport = printWord(screen, text, 200, colour)
p = Presentation(go_duration=(0.5,'seconds'),viewports=[viewport])
p.go()
start = time.clock()
exit = 0
while not exit:
data = raw_lpt_module.inp(0x379) & 0x20
if not data:
RT = time.clock()
p.parameters.go_duration = (0.032, 'seconds')
#dataList.append ([text, colour, start, RT])
exit = 1
else:
pass
示例4: __init__
def __init__(self):
global w, h
self._running = True
# Initialize screen
# TODO
# Set fullscreen
self.screen = get_default_screen()
# Get dimension of the screen
w = self.screen.size[0]
h = self.screen.size[1]
# Initialize Targets
self.TopTarget = Target2D()
self.BotTarget = Target2D()
self.LeftTarget = Target2D()
self.RightTarget = Target2D()
# Message
self.mess = Text(text='Please wait for next trial...',
color=(1.0, 0.5, 0.5),
position=(w/2, h*0.8),
font_size=50,
anchor='center',
on=True)
# Arrows
self.arrow = TextureStimulus()
# Viewports to stick graphical objects to screen
self.viewport1 = Viewport(screen=self.screen,
stimuli=[self.TopTarget, self.BotTarget, self.LeftTarget, self.RightTarget]) # For Targets
self.viewport2 = Viewport(screen=self.screen,
stimuli=[self.arrow]) # For cue (and other things)
self.viewport3 = Viewport(screen=self.screen,
stimuli=[self.mess]) # For cue (and other things)
# Presentations (for controlling timing)
self.initialize = Presentation(go_duration=(duration_init, 'seconds'), viewports=[self.viewport3])
self.targetShow = Presentation(go_duration=(duration_target, 'seconds'), viewports=[self.viewport1])
self.cueShow = Presentation(go_duration=(duration_cue, 'seconds'), viewports=[self.viewport2])
# For result
self.TargetLog = np.zeros((numTrial, 2)) # First column: target code,
示例5: showStimulus
def showStimulus(screen, text, colour, useLPT=True):
word, viewport = printWord(screen, text, 200, colour)
p = Presentation(go_duration=(stroopDuration,'seconds'),viewports=[viewport])
if useLPT:
p.go()
start = time.clock()
exit = 0
while not exit:
data = raw_lpt_module.inp(0x379) & 0x20
#print data
if not data:
#print "hello"
RT = time.clock()
p.parameters.go_duration = (blank, 'seconds')
subject.inputData(trial, "text", text)
subject.inputData(trial, "colour", colour)
subject.inputData(trial, "RT", RT)
exit = 1
else:
pass
示例6: showInstructions
def showInstructions(screen, text, textSize=60, textcolor=(255, 255, 255)):
#create our instruction screen
#load up the instruction text
insStim, insView = printText(screen, text, textSize, textcolor)
instructions = Presentation(go_duration=('forever',), viewports=[insView])
#add a quit function and a handler to go with it
def quitKey(event):
if event.key == pygame.locals.K_SPACE:
quit()
def click(event):
quit()
def quit(dummy_arg=None):
instructions.parameters.go_duration = (0,'frames')
instructions.parameters.handle_event_callbacks=[(pygame.locals.QUIT, quit),(pygame.locals.KEYDOWN, quitKey), (pygame.locals.MOUSEBUTTONDOWN, click)]
#show instructions
instructions.go()
示例7: set_stimuli
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)
示例8: set_stims
def set_stims(self, stim_list, stim_dict, stim_seq_file):
self.stim_list = stim_list
self.stim_dict = stim_dict
self.stim_seq = yaml.load(stim_seq_file)
viewport = Viewport(screen=self.screen,
size=self.screen.size,
stimuli=self.stim_list)
# Need to at least wait for the first trigger if this is going to work.
go_duration = (self.TR * len(self.stim_seq), 'seconds')
self.presentation = Presentation(go_duration=go_duration,
trigger_go_if_armed=0,
viewports=[viewport])
self.presentation.add_controller(None, None,
FunctionController(during_go_func=self.update) )
self.presentation.add_controller(None, None, self.keyboard_controller)
# Adding this so that we can start the stimuli ahead of time
self.presentation.add_controller(self.presentation,'trigger_go_if_armed',
self.firstTTL_trigger)
示例9: aplicacion
def aplicacion():
global p,inten,coord
pos=[0.4,0.5,0.6,0.7,0.8]
pos2=[1.3,1.4,1.5,1.6,1.7,1.8]
rellenar()
shuffle(coord)
i = len(coord)-1
target.parameters.position = coord[i][:2]
(xpos,ypos)=target.parameters.position
x=xpos-screen.size[0]/2
y=ypos-screen.size[1]/2
anrad=math.atan2(y, x)
angrad=math.degrees(anrad)
if angrad>=0:
if angrad<=90:
orientacion=-45
xx=2.0
yy=2.0
else:
orientacion=-135
xx=-2.0
yy=2.0
else:
aux=angrad*(-1)
if aux<=90:
orientacion=45
xx=2.0
yy=-2.0
else:
orientacion=135
xx=-2.0
yy=-2.0
fixpoint.parameters.position=((screen.size[0]/2.0)+xx, (screen.size[1]/2.0)+yy)
fixpoint.parameters.orientation=orientacion
viewport = Viewport(screen=screen, stimuli=[fixpoint,fixcirc])
p = Presentation(go_duration=(1.0,'seconds'),viewports=[viewport])
p.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, keydown),
(pygame.locals.KEYUP, keyup),
(pygame.locals.QUIT, quit_app)]
p.add_controller(None, None, FunctionController(during_go_func=settings))
#winsound.PlaySound('instruccion',winsound.SND_FILENAME)
p.go()
while len(coord)!= 0:
if end:
break
i = len(coord)-1
target.parameters.position = coord[i][:2]
dur=pos[random.randrange(0,4,1)]
(xpos,ypos)=target.parameters.position
x=xpos-screen.size[0]/2
y=ypos-screen.size[1]/2
anrad=math.atan2(y, x)
angrad=math.degrees(anrad)
#fixpoint.parameters.orientation=(-angrad)
if angrad>=0:
if angrad<=90:
orientacion=-45
xx=2.0
yy=2.0
else:
orientacion=-135
xx=-2.0
yy=2.0
else:
aux=angrad*(-1)
if aux<=90:
orientacion=45
xx=2.0
yy=-2.0
else:
orientacion=135
xx=-2.0
yy=-2.0
fixpoint.parameters.position=((screen.size[0]/2.0)+xx, (screen.size[1]/2.0)+yy)
fixpoint.parameters.orientation=orientacion
viewport = Viewport(screen=screen, stimuli=[fixpoint,fixcirc])
p = Presentation(go_duration=(dur,'seconds'),viewports=[viewport])
p.parameters.handle_event_callbacks = [ (pygame.locals.QUIT, quit_app)]
p.add_controller(None, None, FunctionController(during_go_func=settings))
p.go()
inten = coord[i][-1]
target.parameters.color = (1.0,1.0,1.0,inten) #Se muestra el estimulo Duracion 0.3 segundos
viewport = Viewport(screen=screen, stimuli=[target,fixpoint,fixcirc])
p = Presentation(go_duration=(0.3,'seconds'),viewports=[viewport])
p.parameters.handle_event_callbacks = [ (pygame.locals.QUIT, quit_app)]
p.add_controller(None, None, FunctionController(during_go_func=settings))
p.go()
target.parameters.color = (0.0,0.0,0.0,1.0) #Desaparece el estimulo tiempo para registrar
#.........这里部分代码省略.........
示例10: Text
)
instructions_attendSCENE = Text(
text="Attend to SCENES",
font_size=32,
color=(1, 1, 1),
anchor="center",
position=(screen.size[0] / 2, screen.size[1] / 2),
)
cur_time = Text(text="", font_size=15, color=(0.75, 0.75, 0.75), anchor="lowerleft", position=(0, 0))
viewport_instructions = Viewport(screen=screen, stimuli=[instructions, cur_time])
attend_face = Viewport(screen=screen, stimuli=[instructions_attendFACE])
attend_scene = Viewport(screen=screen, stimuli=[instructions_attendSCENE])
p1 = Presentation(go_duration=("forever",), viewports=[viewport_instructions])
p1.add_controller(None, None, FunctionController(during_go_func=displayTime))
p1.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, waitForTrigger)]
# setup main experimental loop
loadStims = 0
wrote_response = 0
stimulus = TextureStimulus(
anchor="center",
size=stimuli_size,
position=(screen.size[0] / 2.0, screen.size[1] / 2.0),
texture_min_filter=gl.GL_LINEAR,
shrink_texture_ok=1,
# PW 2012/11/26
mipmaps_enabled=False,
示例11: DotArea2D
dotStim = DotArea2D( position = ( screen_half_x, screen_half_y ),
anchor = 'center',
size = ( 300.0 , 300.0 ),
signal_fraction = cohLevel,
signal_direction_deg = dirx,
velocity_pixels_per_sec = 100.0,
dot_lifespan_sec = 0.08,
dot_size = 3.0,
num_dots = 200)
# Create a Viewport instance
viewport = Viewport(screen=screen, stimuli=[str_instruct_1, fixation, dotStim, str_instruct_2, sampleFix])
p = Presentation(
go_duration = (exp_length,'seconds'),
trigger_go_if_armed = 0, #wait for trigger
viewports = [viewport])
#initialize log file
logname=time.strftime('_%m-%d-%Y_%Hh-%Mm.csv')
logname='log_'+ss_num+logname
logfile = open(logname, 'w')
logfile.write("# LOGFILE: {0}\n".format(logname))
logfile.write("# Coherence,Direction,Response\n")
#################################
# Main procedure #
#################################
def getState(t):
global fixOn, dotsOn, changeCoh, changeDir, keyPressed, fixOn_start, dotsOn_start, rt, main_curr, block_total, block_curr, practicenum, blocktype, sampleFixOn
示例12: stuff
import VisionEgg
VisionEgg.start_default_logging(); VisionEgg.watch_exceptions()
from VisionEgg.Core import *
from VisionEgg.FlowControl import Presentation
from VisionEgg.Gratings import *
import VisionEgg.Daq
from VisionEgg.DaqLPT import *
# Normal stuff (from grating demo):
screen = get_default_screen()
stimulus = SinGrating2D(position = ( screen.size[0]/2.0, screen.size[1]/2.0 ),
anchor = 'center',
size = ( 300.0 , 300.0 ),
spatial_freq = 10.0 / screen.size[0], # units of cycles/pixel
temporal_freq_hz = 5.0,
orientation = 45.0 )
viewport = Viewport( screen=screen, stimuli=[stimulus] )
p = Presentation(go_duration=(5.0,'seconds'),viewports=[viewport])
# Create a trigger output controller
trigger_out_controller = LPTTriggerOutController()
# Add the trigger output controller to the presentation's list of controllers
p.add_controller(None,None,trigger_out_controller)
# Go!
p.go()
示例13: while
#####################
## RUNTIME CONTROL ##
#####################
count = 0
while (count<len(introTexts)): # DJ CHANGE 4/23/12
# Create a Viewport instance (initialized just to display instructions)
viewport = Viewport(screen=screen, stimuli=[introTexts[count], introTexts_bottomline[count]])
# Create an instance of the Presentation class. (Runtime control)
# note that timeBetweenBlocks/2 is used here to match the time of each between-block frame.
p = Presentation(go_duration=(timeBetweenBlocks/2,'seconds'), viewports=[viewport])
# Register Event Handlers so we can speed things up or quit early if we need to
p.parameters.handle_event_callbacks = \
[(pygame.locals.QUIT, quit), (pygame.locals.KEYDOWN, keydown), (pygame.locals.KEYUP, keyup)]
p.between_presentations()
p.go()
count = count+1
#####################################################################
## Here the intro text is complete, entering the image block loop ##
#####################################################################
示例14: get_default_screen
screen = get_default_screen()
# Set the background color to white (RGBA).
screen.parameters.bgcolor = (1.0,1.0,1.0,1.0)
# Create an instance of the Target2D class with appropriate parameters.
target = Target2D(size = (25.0,10.0),
color = (0.0,0.0,0.0,1.0), # Set the target color (RGBA) black
orientation = -45.0)
# Create a Viewport instance
viewport = Viewport(screen=screen, stimuli=[target])
# Create an instance of the Presentation class. This contains the
# the Vision Egg's runtime control abilities.
p = Presentation(go_duration=(10.0,'seconds'),viewports=[viewport])
#######################
# Define controller #
#######################
# calculate a few variables we need
mid_x = screen.size[0]/2.0
mid_y = screen.size[1]/2.0
max_vel = min(screen.size[0],screen.size[1]) * 0.4
# define position as a function of time
def get_target_position(t):
global mid_x, mid_y, max_vel
return ( max_vel*sin(0.1*2.0*pi*t) + mid_x , # x
max_vel*sin(0.1*2.0*pi*t) + mid_y ) # y
示例15: __init_screen
#.........这里部分代码省略.........
self._ve_letterbox = Target2D(
position=(self._centerPos[0], self.geometry[3] * (1 - 0.01) - self.letterbox_size[1] / 2.0),
size=(self.letterbox_size[0], self.letterbox_size[1]),
color=self.phrase_color,
)
self._ve_innerbox = Target2D(
position=(self._centerPos[0], self.geometry[3] * (1 - 0.01) - self.letterbox_size[1] / 2.0),
size=(self.letterbox_size[0] - 6, self.letterbox_size[1] - 6),
color=self.bg_color,
)
self._current_letter_position = (
self._centerPos[0],
self.geometry[3] * (1 - 0.015) - self.letterbox_size[1] / 2.0,
)
self._ve_current_letter = Text(
position=self._current_letter_position,
text=(len(self._desired_letters[:1]) == 0 and " " or self._desired_letters[:1]),
font_size=self.font_size_current_letter,
color=self.current_letter_color,
anchor="center",
)
self._ve_desired_letters = Text(
position=(self._centerPos[0] + 5 + self.letterbox_size[0] / 2.0, self._current_letter_position[1]),
text=(len(self._desired_letters[1:]) == 0 and " " or self._desired_letters[1:]),
font_size=self.font_size_phrase,
color=self.phrase_color,
anchor="left",
)
self._ve_spelled_phrase = Text(
position=(self._centerPos[0] - 5 - self.letterbox_size[0] / 2.0, self._current_letter_position[1]),
text=(len(self._spelled_phrase) == 0 and " " or self._spelled_phrase),
font_size=self.font_size_phrase,
color=self.phrase_color,
anchor="right",
)
# if we're in free spelling mode, we hide all text fields but
# the _ve_spelled_phrase. we also need a multiline
# _ve_spelled_phrase instead of the single lined one
if self.offline == self.copy_spelling == False:
self._spelled_phrase = " "
self._ve_spelled_phrase = WrappedText(
position=(0, self._current_letter_position[1]),
text=(len(self._spelled_phrase) == 0 and " " or self._spelled_phrase),
font_size=self.font_size_phrase,
color=self.phrase_color,
size=(float(self.geometry[2]), float(self.geometry[3])),
)
for i in self._ve_letterbox, self._ve_innerbox, self._ve_current_letter, self._ve_desired_letters:
i.set(on=False)
## add word box to elementlist:
self._ve_elements.extend(
[
self._ve_letterbox,
self._ve_innerbox,
self._ve_current_letter,
self._ve_desired_letters,
self._ve_spelled_phrase,
]
)
## create countdown:
self._ve_countdown = Text(
position=self._centerPos,
text=" ",
font_size=self.font_size_countdown,
color=self.countdown_color,
anchor="center",
on=False,
)
## create countdown shapes
self._ve_countdown_shape = self.countdown_shapes[self.countdown_shape_select](
radius=90, position=self._centerPos, color=self.countdown_shape_color, on=False
)
## create oscillator circle:
self._ve_oscillator = FilledCircle(
position=(self.osc_size / 2 + 10, self.osc_size / 2 + 10),
radius=self.osc_size / 2,
color=self.osc_color,
on=False,
)
## create shapes and letters:
self.init_screen_elements()
## add remaining elements to element list:
self._ve_elements.extend([self._ve_countdown_shape, self._ve_countdown, self._ve_oscillator])
## add elements to viewport:
self._viewport = Viewport(screen=self._screen, stimuli=self._ve_elements)
self._presentation = Presentation(
viewports=[self._viewport],
handle_event_callbacks=[(pygame.KEYDOWN, self.keyboard_input), (pygame.QUIT, self.__stop)],
)