before giving up, here my code. please could you check it on your machine? just put e.g. 3 jpgs in your path = "/home/christoph/work/programming/my_ve_projects/load_picture/data/" ..change the path thanks christoph ------- #!/usr/bin/env python """Load a picture from a file.""" ############################ # Import various modules # ############################ #remark 17.12.2002: with the latest cvs release, texture.orig.size had to be changed to texture.size from random import * import os from VisionEgg import * from VisionEgg.Core import * from VisionEgg.Textures import * from math import * import pygame #to get the mouse button responses import types #to check if a variable is of type float from VisionEgg.DaqLPT import raw_lpt_module #for parallel port polling path = "/home/christoph/work/programming/my_ve_projects/load_picture/data/" #the path the images are in photo = [] photoX = [] # present them in random order for filename in os.listdir(path): photo.append(filename) length = len(photo) for i in range(0, length): ran = randint(0, len(photo)-1) file = photo[ran] photoX.append(file) photo.pop(ran) os.chdir(path) screen = get_default_screen() duration_per_image = 1 # seconds num_images = len(photoX) # Create list of stimuli preloaded_stimulus_list = [] # empty at first for i in range(num_images): # Read the texture file texture = TextureFromFile(photoX[i]) x = screen.size[0]/2 - texture.size[0]/2 y = screen.size[1]/2 - texture.size[1]/2 # Load the texture to OpenGL, prepare for display stimulus = TextureStimulus(texture = texture, size = texture.size, lowerleft=(x,y)) # Add to list of stimuli preloaded_stimulus_list.append( stimulus ) log_list = [] log = [] last_image = -1 first_stim_flag = 1 #def image_selector( t ): # global last_image, start_time, timestamp, last_timestamp, first_stim_flag, log # time.sleep(0.0001) #purposefully yield the processor, so that during max priority mode, mouse can be tracked # i = int(t/duration_per_image) # if first_stim_flag == 1: # start_time = VisionEgg.timing_func() # timestamp = start_time # log = (timestamp - start_time, photoX[i], -1, -1) #create next new log # first_stim_flag = 0 # elif i <> last_image: # log_list.append(log) #append last log # timestamp = VisionEgg.timing_func() # log = (timestamp - start_time, photoX[i], -1, -1) #create next new log # last_image = i # return [ preloaded_stimulus_list[i] ] my_debug_msg = [] start_wait_for_trig = 0.1 #0.1 sec before the duration_per_image has been spend, start waiting for trigger (start polling the LPT) def image_selector( t ): global last_image, start_time, timestamp, last_timestamp, first_stim_flag, log, start_wait_for_trig time.sleep(0.0001) #purposefully yield the processor, so that during max priority mode, mouse can be tracked i = int(t/duration_per_image) #i = int(t/((last_image-1)*duration_per_image + duration_per_image - start_wait_for_trig)) if first_stim_flag == 1: start_time = VisionEgg.timing_func() timestamp = start_time log = (timestamp - start_time, photoX[i], -1, -1) #create next new log first_stim_flag = 0 elif i <> last_image: #time reached, where we start waiting for the MR trigger # poll the LPT for the TTL trigger, sent by the MR scanner input_value = 0 while (input_value == 0): my_debug_msg.append('before<' + str(input_value) + '>lastimage <' + str(last_image) + '>') input_value = raw_lpt_module.inp(0x379) & 0x20 my_debug_msg.append('after<' + str(input_value) + '>lastimage <' + str(last_image) + '>') log_list.append(log) #append last log timestamp = VisionEgg.timing_func() log = (timestamp - start_time, photoX[i], -1, -1) #create next new log last_image = i return [ preloaded_stimulus_list[i] ] viewport = Viewport(screen=screen) ############################################# # Create event handler callback functions # ############################################# def mousebuttondown(event): global log, timestamp if event.button == 1: log = (timestamp - start_time, photoX[last_image], VisionEgg.timing_func() - timestamp, 'left') #overwrite actual log elif event.button == 3: log = (timestamp - start_time, photoX[last_image], VisionEgg.timing_func() - timestamp, 'right') #overwrite actual log handle_event_callbacks = [(pygame.locals.MOUSEBUTTONDOWN, mousebuttondown)] p = Presentation(go_duration=(duration_per_image * num_images,'seconds'), viewports=[viewport], check_events=1, handle_event_callbacks=handle_event_callbacks) ############################################################# # Connect the controllers with the variables they control # ############################################################# p.add_controller(viewport,'stimuli', FunctionController(during_go_func=image_selector) ) ####################### # Run the stimulus! # ####################### p.go() log_list.append(log) #append last log ############################################ # write the button press times to a file # ############################################ f=open('/home/christoph/work/programming/my_ve_projects/load_picture/my_debug_msg.txt', 'w') f.write('_______________________________________________________' + '\n') for x in my_debug_msg: if (type(x) == types.FloatType): f.write("%010.2f " % x) else: f.write(str(x) + " ") f.write('\n') f.write('_______________________________________________________' + '\n') f.close() f=open('/home/christoph/work/programming/my_ve_projects/load_picture/exp_log_file.txt', 'w') f.write('index onset stim RT response' + '\n') f.write('_______________________________________________________' + '\n') cnt = 1 for x in log_list: f.write("%04.0f " % cnt) for y in x: if (type(y) == types.FloatType): f.write("%010.2f " % (y * 1000)) else: f.write(str(y) + " ") f.write('\n') cnt = cnt + 1 f.write('_______________________________________________________' + '\n') f.close() last_onset = 0 last_diff = 0 f=open('/home/christoph/work/programming/my_ve_projects/load_picture/exp_log_file_verb.txt', 'w') f.write('index onset_t diff_t stim RT response' + '\n') f.write('___________________________________________________________________________________' + '\n') x = 0 while x < len(log_list): y = 0 while y < len(log_list[x]): if (type(log_list[x][y]) == types.FloatType): if y == 0: # y = 0: onset_time of the stimulus f.write("%04.0f " % x) #index f.write("%010.2f " % (log_list[x][y] * 1000)) #onset time of the stimulus diff = (1000 * ( log_list[x][y] - x * duration_per_image ) ) f.write("%010.2f " % diff) #difference between should and is onset else: f.write("%010.2f " % (log_list[x][y] * 1000)) #RT else: f.write(str(log_list[x][y]) + " ") #mouse response (left/right) y = y + 1 last_onset = log_list[x][0] f.write('\n') x = x + 1 f.write('___________________________________________________________________________________' + '\n') f.close() ------- ====================================== The Vision Egg mailing list Archives: //www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html