Skip to content

Instantly share code, notes, and snippets.

@smathot
Created January 25, 2012 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smathot/1675762 to your computer and use it in GitHub Desktop.
Save smathot/1675762 to your computer and use it in GitHub Desktop.
Timing check for OpenSesame Psycho Backend
# Generated by OpenSesame 0.25 (Dashy Darwin)
# Wed Jan 25 11:28:24 2012 (posix)
#
# Copyright Sebastiaan Mathot (2010-2011)
# <http://www.cogsci.nl>
#
set foreground "white"
set subject_parity "even"
set description "Default description"
set title "New experiment"
set sampler_backend "legacy"
set coordinates "relative"
set height "768"
set mouse_backend "psycho"
set width "1024"
set compensation "0"
set keyboard_backend "psycho"
set background "black"
set subject_nr "0"
set canvas_backend "psycho"
set start "experiment"
set synth_backend "legacy"
define keyboard_response keyboard_response
set description "Collects keyboard responses"
set timeout "infinite"
set flush "yes"
define sequence experiment
set flush_keyboard "yes"
set description "Runs a number of items in sequence"
run timing_check "always"
run keyboard_response "always"
define inline_script timing_check
___run__
from openexp.canvas import canvas
from psychopy import visual
import numpy as np
speed = 2 # Rotation speed
soa = 50 # SOA
# Create a canvas with a simple sinusoid grating
stim = visual.PatchStim(self.experiment.window, sf=.05, size=100)
my_canvas = canvas(self.experiment)
my_canvas.stim_list.append(stim)
# Rotate the canvas and record timestamps
l = []
for ori in range(0, 360, speed):
stim.setOri(ori)
my_canvas.show()
self.sleep(soa)
l.append(self.time())
# Determine the actual SOA
_l = []
for i in range(len(l)-1):
_l.append(l[i+1]-l[i])
# Calculate the mean SOA and the standard deviation
a = np.array(_l)
m = a.mean()
std = a.std()
# Report the results
txt = visual.TextStim(self.experiment.window, 'M=%.2f, STD=%.2f' % (m, std))
txt.draw()
self.experiment.window.flip()
__end__
set _prepare ""
set description "Executes Python code"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment