Skip to content

Instantly share code, notes, and snippets.

View smathot's full-sized avatar

Sebastiaan Mathot smathot

View GitHub Profile
@smathot
smathot / snippets.py
Created November 12, 2011 18:02
OpenSesame code snippets
# ***
# * Continuously poll the keyboard
# ***
from openexp.keyboard import keyboard
my_keyboard = keyboard(self.experiment, timeout=20)
start_time = self.time()
while True:
# Perform some task here
key, end_time = my_keyboard.get_key()
@smathot
smathot / correction_trials.opensesame
Created December 15, 2011 10:08
OpenSesame correction trials example
# Generated by OpenSesame 0.25 (Dashy Darwin)
# Thu Dec 15 11:06:26 2011 (posix)
#
# Copyright Sebastiaan Mathot (2010-2011)
# <http://www.cogsci.nl>
#
set foreground "white"
set subject_parity "even"
set description "A template containing a practice and an experimental phase"
set title "Repeat trials"
@smathot
smathot / pygame-vlc.py
Created December 26, 2011 12:26
Use VLC to play videos on a PyGame surface
import os
import sys
import vlc
import pygame
def callback(self, player):
print
print 'FPS =', player.get_fps()
print 'time =', player.get_time(), '(ms)'
@smathot
smathot / timestamp.py
Created December 30, 2011 00:18
A simple timing checker for OpenSesame (paste in inline_script)
from openexp.canvas import canvas
c1 = canvas(self.experiment)
c2 = canvas(self.experiment)
c3 = canvas(self.experiment)
soa = 0 # The desired SOA. 0 = fastest possible
N = 10 # Nr of repetitions
w = self.get('width')
h = self.get('height')
@smathot
smathot / backlight.sh
Created January 1, 2012 15:23
Script to fix backlight issue (dark screen) for HP g62 laptop on Ubuntu 11.10
#!/bin/bash
# Fix the backlight issue on Ubuntu 11.10 for
# a HP G62 laptop. Add this script to the startup
# applications. In addition, make sure to make
# /sys/class/backlight/intel_backlight
# world-writable (chmod 777), for example
# in /etc/rc.local
#
# Examples:
@smathot
smathot / psycho_timing_check.opensesame
Created January 25, 2012 10:28
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"
@smathot
smathot / legacy_timing_check.opensesame
Created February 8, 2012 09:56
Timing check for OpenSesame Legacy Backend
# Generated by OpenSesame 0.25 (Dashy Darwin)
# Wed Feb 8 10:55:36 2012 (posix)
#
# Copyright Sebastiaan Mathot (2010-2011)
# <http://www.cogsci.nl>
#
set foreground "white"
set subject_parity "even"
set description "Default description"
set title "Legacy timing check"
@smathot
smathot / subplotexample.py
Created March 5, 2012 16:08
Matplotlib subplot example
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from matplotlib import pyplot
import numpy as np
fig = pyplot.figure()
xData = np.linspace(0, 4*np.pi)
yData = np.sin(xData)
@smathot
smathot / clickplot.py
Created March 10, 2012 13:31
Clickable interactive matplotlib figure
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from matplotlib import pyplot
import numpy as np
class ClickPlot:
"""
A clickable matplotlib figure
@smathot
smathot / bigsmallloop
Created April 16, 2012 08:44
Big and Small Loops
# Generated by OpenSesame 0.26 (Earnest Einstein)
# Mon Apr 16 10:43:50 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"