[visionegg] error with latest release:
- From: Christoph Lehmann <lehmann@xxxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Mon, 07 Apr 2003 16:13:22 +0200
Hi Andrew
Running the latest bleeding-edge and lates updated files from cvs I get
the following error with some code, which ran nicely before:
[root@christophl load_picture]# python load_picture_mouse05.py
2003-04-07 16:06:01 (1926) info: Script load_picture_mouse05.py started
Vision Egg 0.9.5a0 with process id 1926.
2003-04-07 16:06:05 (1926) info: Requesting window 640 x 480 24 bpp (8
8 8 0 RGBA).
2003-04-07 16:06:05 (1926) info: OpenGL 1.2 Mesa 3.4.2, Mesa DRI Radeon
20010402 AGP 1x x86/MMX/SSE, VA Linux Systems, Inc.
2003-04-07 16:06:05 (1926) info: Video system reports 32 bpp (8 8 8 8
RGBA).
2003-04-07 16:06:05 (1926) DEPRECATION WARNING: class TextureFromFile
outdated,
use class Texture instead.
2003-04-07 16:06:05 (1926) DEPRECATION WARNING: class TextureFromFile
outdated,
use class Texture instead.
2003-04-07 16:06:05 (1926) DEPRECATION WARNING: class TextureFromFile
outdated,
use class Texture instead.
2003-04-07 16:06:05 (1926) DEPRECATION WARNING: class TextureFromFile
outdated,
use class Texture instead.
Traceback (most recent call last):
File "load_picture_mouse05.py", line 47, in ?
File "/usr/lib/python2.2/site-packages/VisionEgg/Textures.py", line
307, in __
init__
Texture.__init__(self, filename)
File "/usr/lib/python2.2/site-packages/VisionEgg/Textures.py", line
120, in __
init__
texels = Image.open(texels) # Attempt to open as an image stream
File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 975, in
open
prefix = fp.read(16)
IOError: [Errno 21] Is a directory
[root@christophl load_picture]#
==================================================
my code is (the critical passage here; ful code as attachment):
# 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 )
===========================
even if I change from TextureFromFile() to Texture() I get the above
mentioned error.
Thanks a lot
Christoph
--
Christoph Lehmann Phone: ++41 31 930 93 83
Department of Psychiatric Neurophysiology Mobile: ++41 76 570 28 00
University Hospital of Clinical Psychiatry Fax: ++41 31 930 99 61
Waldau lehmann@xxxxxxxxxxxx
CH-3000 Bern 60 http://www.puk.unibe.ch/cl/pn_ni_cv_cl.html
#!/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
# Texture() instead TextureFromFile()
from random import *
import os
from VisionEgg import *
from VisionEgg.Core import *
from VisionEgg.Textures import *
from math import *
import pygame
import types
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 = Texture(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] ]
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/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()
- Follow-Ups:
- [visionegg] Re: error with latest release: SORRY
- From: Christoph Lehmann
Other related posts:
- » [visionegg] error with latest release:
- [visionegg] Re: error with latest release: SORRY
- From: Christoph Lehmann