Skip to content

Instantly share code, notes, and snippets.

@mmagnuski
Created May 22, 2016 18:14
Show Gist options
  • Save mmagnuski/506004df8b47fb3142e5c0a14cdc58b8 to your computer and use it in GitHub Desktop.
Save mmagnuski/506004df8b47fb3142e5c0a14cdc58b8 to your computer and use it in GitHub Desktop.
Short script that glues together three experimental procedures. Two of the three procedures are presented in random order, same key-mappings are ensured across procedures.
# -*- encoding: utf-8 -*-
from __future__ import print_function
import random
from psychopy import core, visual, event
from OpenClose import run_baseline as bsln
import TurboSternberg as strn
import LinOrd as lin
# TODO
# - [ ] add more precise instructions to baseline
def make_img(win, im):
return visual.ImageStim(win, image=im,
size=[1169, 826], units='pix', interpolate=True)
# get subject_id and run baseline
subject_id = bsln.get_subject_id()
window = bsln.run(segment_time=60)
core.wait(2)
# prepare mid and fin slides:
lin.go_to_file_dir(__file__)
img = [make_img(window, im) for im in
[u'POŁOWA.png', u'KONIEC.png']]
# select proc order
procs = [strn, lin]
proc_ind = random.sample([0, 1], 1)[0]
first_proc = procs[proc_ind]
second_proc = procs[1 - proc_ind]
# select true key
true_key = random.sample(['f', 'j'], 1)[0]
# run fist proc
first_proc.run(window=window, subject_id=subject_id, true_key=true_key)
# show mid slide
img[0].draw(); window.flip()
event.waitKeys(); window.flip()
# run second proc
second_proc.run(window=window, subject_id=subject_id, true_key=true_key)
# show final info
img[1].draw(); window.flip()
event.waitKeys(); core.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment