Skip to content

Instantly share code, notes, and snippets.

View smathot's full-sized avatar

Sebastiaan Mathot smathot

View GitHub Profile
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from exparser.DataMatrix import DataMatrix
from generate import edgeDetect
import os
import numpy as np
from matplotlib import pyplot as plt
from scipy import ndimage, interpolate, misc
from exparser import TraceKit as tk
@smathot
smathot / generate.py
Created October 1, 2014 12:47
Generate artificial shapes
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os
import numpy as np
from matplotlib import pyplot as plt
from scipy import ndimage, interpolate, misc
from exparser import TraceKit as tk
from skimage import draw
@smathot
smathot / gist:5353595
Created April 10, 2013 10:46
UnicodeError fix for _stimulus.py
def __init__(self, log_comment=None):
"""Create a stimulus.
Keyword arguments:
log_comment -- the comment for the event log file (str) (optional)
"""
self._id = Stimulus._id_counter
Stimulus._id_counter += 1
@smathot
smathot / counterbalancing.opensesame
Created November 30, 2012 16:58
OpenSesame counterbalancing example
# Generated by OpenSesame 0.25-pre1 (Dashy Darwin)
# Thu Sep 15 16:39:04 2011 (posix)
#
# Copyright Sebastiaan Mathot (2010-2011)
# <http://www.cogsci.nl>
#
set foreground "white"
set subject_parity "even"
set description "Default description"
set title "Counterbalancing example"
@smathot
smathot / xpyriment_timing_check.opensesame
Created November 30, 2012 16:43
Expyriment timing check
# 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"
@smathot
smathot / gist:3840902
Created October 5, 2012 16:40
Expyriment presentation time test
from expyriment import stimuli, control, design
import time
from random import randint
control.defaults.initialize_delay = 0
control.defaults.open_gl = True
exp = design.Experiment()
control.initialize(exp)
l = []
@smathot
smathot / forum_script.py
Created September 18, 2012 15:00
Forum help script
# Ref: <http://forum.cogsci.nl/discussion/198>
# This script should be placed in the prepare phase of an inline_script, before
# the open_question item.
#
# First retrieve the full path to a file called 'question.txt' in the file pool
path = exp.get_file('question.txt')
# Read the entire contents of the file.
question = open(path).read()
# Set the variable, so that the open_question item can use it.
exp.set('_question', question)
@smathot
smathot / text_formatting.html
Created September 3, 2012 17:05
Text formatting in OpenSesame
OpenSesame supports a sub-set of HTML tags:
- <b>Bold face</b>
- <i>Italic</i>
- <u>Underline</u>
In addition, you can pass 'color', 'size', and 'style' as keywords to a 'span' tag:
- <span color="red">Color</span>
- <span size="32">Font size</span>
- <span style="serif" mce_style="serif">Font style</span>
@smathot
smathot / trigger_test.py
Created September 2, 2012 11:59
Trigger test
# Create a canvas to show info on screen
from openexp.canvas import canvas
canvas = canvas(self.experiment)
from ctypes import windll, c_ubyte
io = windll.dlportio # requires dlportio.dll !!!
# Define port:
port = 0x4cf8
# Execute the script below twice, once in the old way, once in the
# newly-suggested way:
for change_to_ubyte in (False, True):
@smathot
smathot / opensesame_form_rating_scales.txt
Created August 31, 2012 16:28
OpenSesame form rating scales example
set rows "1;1;1;1;1"
set cols "1;1"
widget 0 0 2 1 label text="Indicate how much you agree with the following statements"
widget 0 1 1 1 label center="no" text="Forms are easy"
widget 1 1 1 1 rating_scale var="question1" nodes="Agree;Don't know;Disagree"
widget 0 2 1 1 label center="no" text="I like data"
widget 1 2 1 1 rating_scale var="question2" nodes="Agree;Don't know;Disagree"
widget 0 3 1 1 label center="no" text="I like questionnaires"
widget 1 3 1 1 rating_scale var="question3" nodes="Agree;Don't know;Disagree"
widget 0 4 2 1 button text="Next"