[visionegg] change the texture parameter of a texture object in the main loop
- From: Christoph Lehmann <lehmann@xxxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Tue, 15 Apr 2003 14:22:17 +0200
Hi Andrew
(I know it must be an easy question, but I didn't solve it myself so
far.. :)
------------------------
in the code below:
I have a preloaded_texture_list with textures from files loaded.
The TextureStimulus object, linked to the viewport is called in the main
loop, since there I want to change the texture-parameter after each
received trigger signal.
But I didn't succeed.. (well the code runs,but it doesn't change the
textures..)
before I enter the main loop, I define a TextureStimulus object (for
afterward linking to the viewport): do I need there to specify the
texture-parameter already?
thanks a lot
christoph
Cooooooooooooooooooooooooooooode:
#!/usr/bin/env python
#This bypasses the VisionEgg.Core.Presentation class. It may be easier
#to create simple experiments this way."""
import VisionEgg
from VisionEgg.Core import *
import pygame
from pygame.locals import *
from VisionEgg.Text import *
from random import *
import VisionEgg.Daq
from VisionEgg.DaqLPT import *
from VisionEgg.Textures import *
screen = get_default_screen()
screen.parameters.bgcolor = (0.0,0.0,0.0,0.0) # black (RGBA)
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)
num_images = len(photoX)
# Create list of stimuli
preloaded_texture_list = [] # empty at first
for i in range(num_images):
# Read the texture file
texture = TextureFromFile(photoX[i])
# Add to list of stimuli
preloaded_texture_list.append( texture )
#
x = screen.size[0]/2 - preloaded_texture_list[0].size[0]/2
y = screen.size[1]/2 - preloaded_texture_list[0].size[1]/2
stimulus = TextureStimulus(on = 1,
texture = preloaded_texture_list[0],
size = preloaded_texture_list[0].size,
lowerleft=(x,y))
viewport = Viewport( screen=screen, stimuli=[stimulus] )
# The main loop below is an alternative to using the
# VisionEgg.Core.Presentation class.
i = 1
while not pygame.event.peek((QUIT,KEYDOWN,MOUSEBUTTONDOWN)):
# poll the LPT for the TTL trigger, sent by the MR scanner
input_value = 0
while (input_value == 0):
input_value = raw_lpt_module.inp(0x379) & 0x20 # pin nr 12
stimulus.texture = preloaded_texture_list[i]
screen.clear()
viewport.draw()
swap_buffers()
if i == num_images - 1:
i = 0
else:
i = i + 1
--
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
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- Follow-Ups:
- [visionegg] Re: change the texture parameter of a texture object inthe main loop
- From: Christoph Lehmann
Other related posts:
- » [visionegg] change the texture parameter of a texture object in the main loop
- [visionegg] Re: change the texture parameter of a texture object inthe main loop
- From: Christoph Lehmann