[visionegg] Re: simple RSVP scripts

Hi, andrew...

This version works... however, does calling the Viewport() method instantiate a *new* viewport object or simply reassign an existing one (preferrable)? In other words, what's the simplest way to designate the next texture in the "preloaded_stimulus_list[]" for presentation without allocating more resources (and, consequently, adding delays)?

Here is the guilty code snippet:

    viewport = Viewport(screen=screen,
                        stimuli = [preloaded_stimulus_list[image_counter]]) #


cheers, gabe

p.s. Below is the fully "functional" code... yes, it's REALLY ugly (thereby emphasizing, by contrast, the elegance of the Presentation object)

*********************************

#!usr/bin/pythonw
# based on Andrew Straw's demo code
# http://www.freelists.org/archives/visionegg/11-2002/msg00001.html

from VisionEgg import *
start_default_logging(); watch_exceptions()

from VisionEgg.Core import *
from VisionEgg.FlowControl import Presentation, FunctionController
from VisionEgg.Textures import *
from pygame.time import *
import OpenGL.GL as gl

photoX = ("crate.bmp", "glass.bmp", "mud.bmp", "nehe.bmp", "star.bmp")

duration_per_image = 0.1 # seconds
num_images = len(photoX)

screen = get_default_screen()

# Create list of stimuli
preloaded_stimulus_list = [] # empty at first

for i in range(num_images):
     # Read the texture file
     texture = TextureFromFile(photoX[i])

     # Load the texture to OpenGL, prepare for display
     stimulus = TextureStimulus(texture = texture,
                                size    = texture.size,
                                texture_min_filter=gl.GL_LINEAR,

position=(screen.size[0]/2.0,screen.size[1]/2.0),
                                shrink_texture_ok=1)

     # Add to list of stimuli
     preloaded_stimulus_list.append( stimulus )

     #<debug>
     print "preloaded_stimulus_list = "
     print preloaded_stimulus_list
     #</debug>


def image_selector( t ): i = int(t/duration_per_image) return [ preloaded_stimulus_list[i] ]

###############################################
#
# <controller_version>
    #uncomment this section this section for original, working version
"""

p = Presentation(go_duration=(duration_per_image *
                              num_images,'seconds'),viewports=[viewport])
p.add_controller(viewport,'stimuli',
                 FunctionController(during_go_func=image_selector) )

p.go()

"""
# </controller_version>

###############################################
# comment this section for "controller" version
#
# <procedural_version>

frame_timer = FrameTimer()
msec_timer = get_ticks()


done = False

# show image 1

for trialcounter in range(1000):

# code to modify for loading file as appropriate image_counter = 0
viewport = Viewport(screen=screen,
stimuli = [preloaded_stimulus_list[image_counter]]) # doesn't work


    screen.clear()
    viewport.draw()
    swap_buffers()
    frame_timer.tick()

    image_counter = image_counter + 1


#delay(1000) # show image 2


viewport = Viewport(screen=screen,
stimuli = [preloaded_stimulus_list[image_counter]]) # doesn't work


    screen.clear()
    viewport.draw()
    swap_buffers()
    frame_timer.tick()
    image_counter = image_counter + 1

    #delay(1000)

# show image 3
viewport = Viewport(screen=screen,
stimuli = [preloaded_stimulus_list[image_counter]]) # doesn't work


    screen.clear()
    viewport.draw()
    swap_buffers()
    frame_timer.tick()
    image_counter = image_counter + 1


#delay(1000)
#show image 4
viewport = Viewport(screen=screen,
stimuli = [preloaded_stimulus_list[image_counter]]) # doesn't work


    screen.clear()
    viewport.draw()
    swap_buffers()
    frame_timer.tick()
    image_counter = image_counter + 1


#delay(1000)
#show image 5
viewport = Viewport(screen=screen,
stimuli = [preloaded_stimulus_list[image_counter]]) # doesn't work


    screen.clear()
    viewport.draw()
    swap_buffers()
    frame_timer.tick()
    #image_counter = image_counter + 1

# </procedural_version>
#
########################################

frame_timer.print_histogram()





Hi, Andrew,

I'm writing a simple RSVP script to pre-load several bitmaps and display them at the appropriate time, while getting user RT.

As this program will need to be modified by undergrads with no programming experience, I want to modify the demo you posted some time ago (in response to another post... http://www.freelists.org/archives/visionegg/11-2002/msg00001.html ) to do away with the Presentation object and controllers until they feel more comfortable with them.

I've included the code at the end of this email.
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: