Dear Andrew, thank you so much, it works great!!! I'm sorry to bother you, but I have several questions to ask you: every time I run a script I obtain this message in the vision-egg log file: ----------------------------------------------------------------------------------- 2004-12-06 12:28:03,190 (3480) INFO: Script C:\Documents and settings\Alessandra\Documenti\esperimento shift visionegg\programmi python per exp shifting\in progress\un solo trigger_prova senza tgt.py started Vision Egg 1.0-cvs with process id 3480. 2004-12-06 12:28:09,628 (3480) INFO: Requesting window 1280 x 1024 32 bpp (8 8 8 0 RGBA). 2004-12-06 12:28:09,736 (3480) INFO: OpenGL 1.3.0 - Build 4.14.10.3691, Intel Springdale-G, Intel 2004-12-06 12:28:09,736 (3480) INFO: Video system reports 32 bpp (8 8 8 8 RGBA). 2004-12-06 12:29:09,721 (3480) WARNING: Calculated frames per second was 85.560, while the VISIONEGG_MONITOR_REFRESH_HZ variable is 70.0. 2004-12-06 12:29:09,721 (3480) WARNING: One or more frames took 36.8 msec, which is signficantly longer than the expected inter frame interval of 14.3 msec for your frame rate (70.0 Hz). 2004-12-06 12:29:09,721 (3480) INFO: 5135 frames were drawn. Mean frame was 11.69 msec (85.56 fps), longest frame was 36.82 msec. histogram: 3686 * 3277 * 2867 * 2458 * 2048 * 1638 * 1229 * 819 * 410 * * 0 * * * * * * * * * * Time: 0 2 4 6 8 10 12 14 16 18 20 22 24 +(msec) Total: 5 4 0 0 256 +++ 719 33 3 3 2 0 13 ----------------------------------------------------------------------------------- Can this have something to do with the synchrony of swap buffers with the vertical blanking period? When I check "attempt to synchronize swap buffers" in the dialog box of Vision Egg, the program doesn't start (but It works perfectly if I don't check this option) and I got an error printed in the console, which I can read just a first part, because it closes immediately the program and there's no trace of this in the vision egg log file. The error is the following: ------------------------------------------------------------------------------------ 2004-12-06 14:30:17,486 (3220) INFO: Script C:\Documents and Settings\Alessandra \Documenti\esperimento shift visionegg\programmi python per exp shifting\in progress\prova trigger cue.py started Vision Egg 1.0-cvs with process id 3220. 2004-12-06 14:30:20,956 (3220) INFO: Requesting window 1280 x 1024 32 bpp (8 8 8 0 RGBA). 2004-12-06 14:30:21,019 (3220) INFO: OpenGL 1.3.0 - Build 4.14.10.3691, Intel Springdale-G, Intel 2004-12-06 14:30:21,019 (3220) INFO: Video system reports 32 bpp (8 8 8 8 RGBA). Pygame Parachute Traceback: File "C:\Python23\lib\site-packages\VisionEgg\PlatformDependent.py", line 187, in sync_swap_with_vbl_post_gl_init (?) ---------------------------------------------------------------------------------------- Must I synchronize swap buffers, also in order to have correct trigger timing? Another question is about the triggers (again, I know!): now I have the triggers for the Gabors (thank you!). I need also to trigger, to the computer recording EEG, when other two stimuli (two small arrows, one on the left and one on the right) appear, alternately, on the screen. I tried to add a controller to presentation like I the one I saw in the demo DAQ\ trigger_out but the output are several triggers that last the duration the stimulus is on; I just need a pulse that triggers the first moment (frame?) that the stimulus appears on the screen. Also, I can?t ?name? the trigger to understand which trigger belongs to which arrow. I tried to use the simple_lpt_out, too, but I guess I should add it to Presentation at some point (?), and I don?t know how to do that. I attached the script below. Thank you so much for your precious help! Alessandra
import os import VisionEgg import VisionEgg.Daq import random VisionEgg.start_default_logging(); VisionEgg.watch_exceptions() from VisionEgg.Core import * from VisionEgg.FlowControl import Presentation from VisionEgg.Gratings import * from VisionEgg.Textures import * from VisionEgg.MoreStimuli import * from math import * from VisionEgg.DaqLPT import * from VisionEgg.DaqLPT import raw_lpt_module LPT1 = 0x378 BIT0 = 0x01 # pin 2 on DB25 connector BIT1 = 0x02 # pin 3 on DB25 connector screen = get_default_screen() screen.parameters.bgcolor = (0.5,0.5,0.5,1.0) """ fix cross """ fixation_p = FixationCross(position= (screen.size[0]/2,screen.size[1]/2), size=(20,20), texture_size=(32,32)) """ right and left cue """ filename_cue_sx = os.path.join(VisionEgg.config.VISIONEGG_SYSTEM_DIR,"data","cue_v_quadr.png") texture_cue_sx = Texture(filename_cue_sx) cue_sx = TextureStimulus(texture=texture_cue_sx, position = ((screen.size[0]/2)-20,screen.size[1]/2), anchor = 'center', size = (10.0,10.0), shrink_texture_ok = 1) filename_cue_ds = os.path.join(VisionEgg.config.VISIONEGG_SYSTEM_DIR,"data","cue_v_quadr.png") texture_cue_ds = Texture(filename_cue_ds) cue_ds = TextureStimulus(texture=texture_cue_ds, position = ((screen.size[0]/2)+20,screen.size[1]/2), anchor = 'center', size = (10.0,10.0), shrink_texture_ok = 1) filename_quad = os.path.join(VisionEgg.config.VISIONEGG_SYSTEM_DIR,"data","quadrato.png") texture_quad = Texture(filename_quad) quad = TextureStimulus(texture=texture_quad, position = ((screen.size[0]/2)-20,screen.size[1]/2), anchor = 'center', size = (10.0,10.0), shrink_texture_ok = 1) filename_quad1 = os.path.join(VisionEgg.config.VISIONEGG_SYSTEM_DIR,"data","quadrato.png") texture_quad1 = Texture(filename_quad1) quad1 = TextureStimulus(texture=texture_quad1, position = ((screen.size[0]/2)+20,screen.size[1]/2), anchor = 'center', size = (10.0,10.0), shrink_texture_ok = 1) """gabor standard""" mask = Mask2D(function='gaussian', radius_parameter=25, num_samples=(256,256)) g_std_ds = SinGrating2D(mask = mask, bit_depth = 8, position=((screen.size[0]/2)+300,(screen.size[1]/2)+300 ), size = ( 400 , 400 ), spatial_freq = 0.05, temporal_freq_hz = 0.0, orientation = 90.0 ) g_std_sx = SinGrating2D(mask = mask, bit_depth = 8, position=((screen.size[0]/2)-300,(screen.size[1]/2)+300 ), size = ( 400, 400 ), spatial_freq = 0.05, temporal_freq_hz = 0.0, orientation = 90.0 ) """gabors target""" g_tgt_ds = SinGrating2D(mask = mask, bit_depth = 8, position=((screen.size[0]/2)+300,(screen.size[1]/2)+300 ), size = ( 400 , 400 ), spatial_freq = 0.05, temporal_freq_hz = 0.0, orientation = 45.0 ) g_tgt_sx = SinGrating2D(mask = mask, bit_depth = 8, position=((screen.size[0]/2)-300,(screen.size[1]/2)+300 ), size = ( 400, 400 ), spatial_freq = 0.05, temporal_freq_hz = 0.0, orientation = 45.0 ) """gabors NON target""" g_nontgt_ds = SinGrating2D(mask = mask, bit_depth = 8, position=((screen.size[0]/2)+300,(screen.size[1]/2)+300 ), size = ( 400 , 400 ), spatial_freq = 0.05, temporal_freq_hz = 0.0, orientation = 0.0 ) g_nontgt_sx = SinGrating2D(mask = mask, bit_depth = 8, position=((screen.size[0]/2)-300,(screen.size[1]/2)+300 ), size = ( 400, 400 ), spatial_freq = 0.05, temporal_freq_hz = 0.0, orientation = 0.0 ) """ screen: fix point """ viewport_uno = Viewport( screen=screen, stimuli=[fixation_p] ) """ screen: fix point+gabors standard+ cue-placeholders """ viewport_due = Viewport( screen=screen, stimuli=[fixation_p, quad, quad1, g_std_ds, g_std_sx] ) """ screen: fix point+ standard gabors + left cue """ viewport_cue_sx = Viewport( screen=screen, stimuli=[fixation_p, cue_sx, quad1, g_std_ds, g_std_sx] ) """ screen: fix point+ standard gabors + right cue""" viewport_cue_ds = Viewport( screen=screen, stimuli=[fixation_p, quad, cue_ds, g_std_ds, g_std_sx] ) """ Left Cue""" """A_V """ viewport_A_v = Viewport( screen=screen, stimuli=[fixation_p, cue_sx, quad1, g_tgt_sx, g_std_ds] ) """ B_V """ viewport_B_v = Viewport( screen=screen, stimuli=[fixation_p, cue_sx, quad1, g_nontgt_sx, g_std_ds] ) """ C_V """ viewport_C_v = Viewport( screen=screen, stimuli=[fixation_p, cue_sx, quad1, g_std_sx, g_tgt_ds] ) """ D_V """ viewport_D_v = Viewport( screen=screen, stimuli=[fixation_p, cue_sx, quad1, g_std_sx, g_nontgt_ds] ) """ Right Cue""" """ E_R """ viewport_E_r = Viewport( screen=screen, stimuli=[fixation_p, quad, cue_ds, g_std_sx, g_tgt_ds] ) """ F_R """ viewport_F_r = Viewport( screen=screen, stimuli=[fixation_p, quad, cue_ds, g_nontgt_ds, g_std_sx] ) """ G_R """ viewport_G_r = Viewport( screen=screen, stimuli=[fixation_p, quad, cue_ds, g_tgt_sx, g_std_ds] ) """ H_R """ viewport_H_r = Viewport( screen=screen, stimuli=[fixation_p, quad, cue_ds, g_nontgt_sx, g_std_ds] ) bit0_set = False bit1_set = False Hz_g_ds = 7.5 Hz_g_sx = 6.0 duration_ds = 1/Hz_g_ds duration_sx = 1/Hz_g_sx initial1 = 1.5 initial2 = 1.3 SOA1 = 0.4 SOA2 = 0.7+0.00000000000000001 lista_sx = [viewport_A_v, viewport_B_v, viewport_C_v, viewport_D_v] lista_ds = [viewport_E_r, viewport_F_r, viewport_G_r, viewport_H_r] """definisco funzione per contrasto: pattern reversal a 5 e 8 Hz""" def contrast_controllerds( t ): contrast_ds = sin(Hz_g_ds*2.0*pi*t) bit0_set = contrast_ds > 0 out_value = (bit0_set and BIT0) | (bit1_set and BIT1) raw_lpt_module.out(LPT1,out_value) return contrast_ds def contrast_controllersx( t ): contrast_sx = sin(Hz_g_sx*2.0*pi*t) bit1_set = contrast_sx > 0 out_value = (bit0_set and BIT0) | (bit1_set and BIT1) raw_lpt_module.out(LPT1,out_value) return contrast_sx """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" for i in range (10): scelta = random.randint(0,1) duration = random.uniform(SOA1,SOA2) duration_tot = 0 if scelta < 1 : a = Presentation(go_duration=(initial1,'seconds'), viewports=[viewport_uno]) a.go() b = Presentation(go_duration=(initial2,'seconds'), viewports=[viewport_due]) b.add_controller(g_std_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) b.add_controller(g_std_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) b.go() while duration_tot<3: c = Presentation(go_duration=(duration,'seconds'), viewports=[viewport_cue_sx]) c.add_controller(g_std_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) c.add_controller(g_std_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) c.go() duration_tot = duration_tot + duration e = Presentation(go_duration=(0.2,'seconds'), viewports=[random.choice(lista_sx)]) e.add_controller(g_std_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) e.add_controller(g_std_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) e.add_controller(g_tgt_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) e.add_controller(g_tgt_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) e.add_controller(g_nontgt_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) e.add_controller(g_nontgt_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) e.go() print duration_tot else: a = Presentation(go_duration=(initial1,'seconds'), trigger_armed=(1), trigger_go_if_armed=(1), viewports=[viewport_uno]) a.go() b = Presentation(go_duration=(initial2,'seconds'), viewports=[viewport_due]) b.add_controller(g_std_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) b.add_controller(g_std_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) b.go() while duration_tot<3: d = Presentation(go_duration=(duration,'seconds'), viewports=[viewport_cue_ds]) d.add_controller(g_std_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) d.add_controller(g_std_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) d.go() duration_tot = duration_tot + duration f = Presentation(go_duration=(0.2,'seconds'), viewports=[random.choice(lista_ds)]) f.add_controller(g_std_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) f.add_controller(g_std_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) f.add_controller(g_tgt_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) f.add_controller(g_tgt_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) f.add_controller(g_nontgt_ds,'contrast',FunctionController(during_go_func=contrast_controllerds)) f.add_controller(g_nontgt_sx,'contrast',FunctionController(during_go_func=contrast_controllersx)) f.go() print duration_tot