Discussion:
Recording frame times
Longden, Kit
2011-09-14 11:00:50 UTC
Permalink
Hi,

I'd like to save the frame times during my code. Would anyone be so kind as to show me the lines I should add to the grating.py demo code (below) to make this happen? I'd be very grateful.

Apologies for such an obvious question, it remains unclear to me after checking the archives and documentation, no doubt because of my lack of Python.

Many thanks,

Kit

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

Kit Longden
The Krapp Lab: Insect vision, sensory
integration, motor control and robotics.
Contact: kit-AQ/***@public.gmane.org, +44 20759 40717
http://www3.imperial.ac.uk/people/c.longden <http://www3.imperial.ac.uk/people/c.longden>
Address: Dr Kit Longden, Department of Bioengineering,
Imperial College London, South Kensington campus, London, SW7 2AZ, U.K.

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

#!/usr/bin/env python
"""Sinusoidal grating calculated in realtime."""

############################
# Import various modules #
############################

import VisionEgg
VisionEgg.start_default_logging(); VisionEgg.watch_exceptions()

from VisionEgg.Core import *
from VisionEgg.FlowControl import Presentation
from VisionEgg.Gratings import *

#####################################
# Initialize OpenGL window/screen #
#####################################

screen = get_default_screen()

######################################
# Create sinusoidal grating object #
######################################

stimulus = SinGrating2D(position = ( screen.size[0]/2.0, screen.size[1]/2.0 ),
anchor = 'center',
size = ( 300.0 , 300.0 ),
spatial_freq = 10.0 / screen.size[0], # units of cycles/pixel
temporal_freq_hz = 1.0,
orientation = 45.0 )

###############################################################
# Create viewport - intermediary between stimuli and screen #
###############################################################

viewport = Viewport( screen=screen, stimuli=[stimulus] )

########################################
# Create presentation object and go! #
########################################

p = Presentation(go_duration=(5.0,'seconds'),viewports=[viewport])
p.go()=====================================The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
Dav Clark
2011-09-14 14:55:19 UTC
Permalink
Check out VisionEgg.Core.FrameTimer

The VisionEgg.FlowControl.Presentation class already uses this. Essentially, you instantiate it, then every time you return from swap_buffers, you do a FrameTimer.tick() call. This class is the one that prints the ascii histogram at the end of the experiment, so you can use that method and a few other helpful ones.

If you are using the VisionEgg.FlowControl.Presentation class with collect_timing_info = True (the default), this is being done for you inside that class (it's what prints the histogram), but unfortunately, the variable is not exposed as a class member. You could change all instances of frame_timer to self.frame_timer in the go() method, and then grab that off your presentation class in the end, but that's a messy solution for staying up to date with Andrew's code.

Cheers,
Dav
Post by Longden, Kit
Hi,
I'd like to save the frame times during my code. Would anyone be so kind as to show me the lines I should add to the grating.py demo code (below) to make this happen? I'd be very grateful.
Apologies for such an obvious question, it remains unclear to me after checking the archives and documentation, no doubt because of my lack of Python.
Many thanks,
Kit
****************************
Kit Longden
The Krapp Lab: Insect vision, sensory
integration, motor control and robotics.
http://www3.imperial.ac.uk/people/c.longden <http://www3.imperial.ac.uk/people/c.longden>
Address: Dr Kit Longden, Department of Bioengineering,
Imperial College London, South Kensington campus, London, SW7 2AZ, U.K.
****************************
#!/usr/bin/env python
"""Sinusoidal grating calculated in realtime."""
############################
# Import various modules #
############################
import VisionEgg
VisionEgg.start_default_logging(); VisionEgg.watch_exceptions()
from VisionEgg.Core import *
from VisionEgg.FlowControl import Presentation
from VisionEgg.Gratings import *
#####################################
# Initialize OpenGL window/screen #
#####################################
screen = get_default_screen()
######################################
# Create sinusoidal grating object #
######################################
stimulus = SinGrating2D(position = ( screen.size[0]/2.0, screen.size[1]/2.0 ),
anchor = 'center',
size = ( 300.0 , 300.0 ),
spatial_freq = 10.0 / screen.size[0], # units of cycles/pixel
temporal_freq_hz = 1.0,
orientation = 45.0 )
###############################################################
# Create viewport - intermediary between stimuli and screen #
###############################################################
viewport = Viewport( screen=screen, stimuli=[stimulus] )
########################################
# Create presentation object and go! #
########################################
p = Presentation(go_duration=(5.0,'seconds'),viewports=[viewport])
p.go()======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
=====================================The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
Jens Peter Lindemann
2011-09-15 08:40:08 UTC
Permalink
Hi Kit,
Post by Longden, Kit
I'd like to save the frame times during my code.
it might be redundant to code inside visionegg, but you can use a
function controller to collect the frame timestamps. See the attached
code example which prints the timestamps of all frames presented.

Best,
Jens.

Loading...