[visionegg] M-sequences and timing
- From: Angelique <acp1@xxxxxxxxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Wed, 8 Aug 2007 18:16:08 -0700
Hello, Vision Egg masters,
I have two questions regarding Vision Egg and timing. I would greatly
appreciate any help you could offer.
First, Iseem to be having trouble with the timing of basic flicker stimuli. The
duration of the stimulus should be 100 ms, but I find that the photodiode is
showing the duration of the stimulus is at around 150 ms. Is there a
particularly stupid thing I am doing to get this discrepancy?
Second, I am trying to put together an m-sequence stimulus set to test receptive
fields of individual cells in the fly brain. I generated a set of m-sequences
(1000 frames) in Matlab and converted this information into .txt files. Then,
I have Vision Egg load these files one by one and reproduce the m-sequence in
order. Now, because it's in flies, I have to use a screen refresh rate of 160
Hz. In addition, I am trying to display each m-sequence frame at 64 Hz (0.016
ms per frame). Basically, as the program runs, it gets slower and slower, as
if the buffer is getting overloaded. Is there some more efficient way of doing
this and maintaining speed? (I included the program below). I would greatly
appreciate any help on this.
Thank you very much,
Angelique Paulk
from VisionEgg import *
start_default_logging(); watch_exceptions()
from VisionEgg.Core import *
from VisionEgg.FlowControl import Presentation, FunctionController
from VisionEgg.Textures import *
import Image, ImageDraw # Python Imaging Library (PIL)
import OpenGL.GL as gl # PyOpenGL
import RandomArray # from Numeric package
import csv
import glob, os
from Numeric import *
import Numeric
import array
from array import array
num_images=100 #Number of images
duration_per_image = 0.016
dynamic_time = 10.0 # seconds
static_time = 1.0 # seconds
dynamic_checkerboard_size = (18,24) # width, height in texture elements
static_checkerboard_size = (18,24) # width, height in texture elements
scale = 40 # magification of checkerboard (this many pixels per texture element)
screen = get_default_screen()
# allocate temporary texture in grayscale mode for dynamic texture
temp_grayscale_image = Image.new("L",dynamic_checkerboard_size,0)
temp_texture = Texture(temp_grayscale_image)
# create TextureStimulus for dynamic stimulus
scaled_dynamic_size =
(scale*dynamic_checkerboard_size[0],scale*dynamic_checkerboard_size[1])
# find center of screen
x = screen.size[0]/2.0
y = screen.size[1]/2.0
dynamic_checkerboard = TextureStimulus(texture=temp_texture,
position=(x,y),
anchor="center",
mipmaps_enabled=0,
size=scaled_dynamic_size,
texture_min_filter=gl.GL_NEAREST,
texture_mag_filter=gl.GL_NEAREST)
viewport = Viewport(screen=screen,
stimuli=[dynamic_checkerboard])
p = Presentation(go_duration=(duration_per_image,'seconds'),
viewports=[viewport])
# Use a controller to hook into go loop, but control texture buffer
# through direct manipulation.
dynamic_texture_object =
dynamic_checkerboard.parameters.texture.get_texture_object()
width,height = dynamic_checkerboard_size
# (Note: Numeric arrays have indices flipped from images, thus the re-ordering)
flipped_shape = (height,width)
# This is where we load the individual .txt files with the m-sequence data in a
# 'for' loop after finding all the .txt files in the folder with the .py file.
test_filename = glob.glob("*.txt") #Finding all the .txt files in the folder
with the .py file
preloaded_stimulus_list = []
for i in range(0,num_images):
reader = csv.reader(open(test_filename[i], "rb")) #Reading the files
List = []
for row in reader:
for z in range(24):
List.append( int(row[z]) ) #Concatenating each m-sequence to a
single row (to read the csv files)
preloaded_stimulus_list.append(List) #creating a m-sequence list of the rows
of m-sequences
#This loop is to restructure the m-sequences into the python 'array' form, which
is needed
#for loading into the dynamic control sequence
a = [];
xx = zeros([18,24], Float) #Creating an array for the m-sequences
for g in range(0,len(preloaded_stimulus_list)):
V = preloaded_stimulus_list[g]
w = 0
for r in range(0,18):
for c in range(0,24):
xx[r][c]= V[w] #Placing the entries in the right spots
#Here, r means rows, c means columns for an array, xx
#and V[w] is the individual values from the concatenated
m-sequences
w = w+1
def control_dynamic(t): #This is the function that allows you to change the
image
## if t <= dynamic_time:
i = int(t/duration_per_image)
dynamic_texture_object.put_sub_image( xx )
## print g
#The controller here is altering the image using that function:
p.add_controller(None,None,FunctionController(during_go_func=control_dynamic))
p.go()
-------------------
409 Gould-Simpson
University of Arizona
Arizona Research Division of Neurobiology
Phone: (520) 626-2894
E-mail: acp1@xxxxxxxxxxxxxxxxx
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
Other related posts:
- » [visionegg] M-sequences and timing