[visionegg] Re: Recording frame times
- From: Dav Clark <davclark@xxxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Wed, 14 Sep 2011 07:55:19 -0700
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
On Sep 14, 2011, at 4:00 AM, Longden, Kit wrote:
> 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@xxxxxxxxxxxxxx, +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
=====================================The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
Other related posts: