Created
November 30, 2012 16:43
-
-
Save smathot/4176878 to your computer and use it in GitHub Desktop.
Expyriment timing check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Generated by OpenSesame 0.27~pre31 (Frisky Freud) | |
| # Fri Nov 30 17:42:30 2012 (posix) | |
| # <http://www.cogsci.nl/opensesame> | |
| set foreground "white" | |
| set subject_parity "even" | |
| set font_size "18" | |
| set description "Default description" | |
| set title "Xpyriment timing check" | |
| set font_bold "no" | |
| set sampler_backend "legacy" | |
| set coordinates "relative" | |
| set height "768" | |
| set mouse_backend "xpyriment" | |
| set width "1024" | |
| set compensation "0" | |
| set font_family "mono" | |
| set keyboard_backend "legacy" | |
| set background "black" | |
| set subject_nr "0" | |
| set canvas_backend "xpyriment" | |
| set start "experiment" | |
| set synth_backend "legacy" | |
| set font_italic "no" | |
| 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 | |
| import numpy as np | |
| speed = 2 # Rotation speed | |
| soa = 50 # SOA | |
| my_canvas1 = canvas(self.experiment) | |
| my_canvas1.circle(my_canvas1.xcenter()+100, my_canvas1.ycenter(), 50) | |
| my_canvas2 = canvas(self.experiment) | |
| my_canvas2.circle(my_canvas2.xcenter()-100, my_canvas2.ycenter(), 50) | |
| # Rotate the canvas and record timestamps | |
| l = [] | |
| for i in range(0, 100): | |
| l.append(my_canvas1.show()) | |
| self.sleep(soa) | |
| l.append(my_canvas2.show()) | |
| self.sleep(soa) | |
| # 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 | |
| my_canvas1.clear() | |
| my_canvas1.text('M=%.2f, STD=%.2f' % (m, std)) | |
| my_canvas1.show() | |
| __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