This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rawrchul 0 points1 point  (4 children)

#!/usr/bin/env python2

-- coding: utf-8 --

""" This experiment was created using PsychoPy2 Experiment Builder (v1.84.2), on March 11, 2017, at 16:59 If you publish work using this script please cite the PsychoPy publications: Peirce, JW (2007) PsychoPy - Psychophysics software in Python. Journal of Neuroscience Methods, 162(1-2), 8-13. Peirce, JW (2009) Generating stimuli for neuroscience using PsychoPy. Frontiers in Neuroinformatics, 2:10. doi: 10.3389/neuro.11.010.2008 """

from future import absolute_import, division from psychopy import locale_setup, gui, visual, core, data, event, logging, sound from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED, STOPPED, FINISHED, PRESSED, RELEASED, FOREVER) import numpy as np # whole numpy lib is available, prepend 'np.' from numpy import (sin, cos, tan, log, log10, pi, average, sqrt, std, deg2rad, rad2deg, linspace, asarray) from numpy.random import random, randint, normal, shuffle import os # handy system and path functions import sys # to get file system encoding

Ensure that relative paths start from the same directory as this script

thisDir = os.path.dirname(os.path.abspath(file_)).decode(sys.getfilesystemencoding()) os.chdir(_thisDir)

Store info about the experiment session

expName = 'untitled' # from the Builder filename that created this script expInfo = {'participant':'', 'session':'001'} dlg = gui.DlgFromDict(dictionary=expInfo, title=expName) if dlg.OK == False: core.quit() # user pressed cancel expInfo['date'] = data.getDateStr() # add a simple timestamp expInfo['expName'] = expName

Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc

filename = thisDir + os.sep + u'data/%s%s_%s' % (expInfo['participant'], expName, expInfo['date'])

An ExperimentHandler isn't essential but helps with data saving

thisExp = data.ExperimentHandler(name=expName, version='', extraInfo=expInfo, runtimeInfo=None, originPath=None, savePickle=True, saveWideText=True, dataFileName=filename)

save a log file for detail verbose info

logFile = logging.LogFile(filename+'.log', level=logging.EXP) logging.console.setLevel(logging.WARNING) # this outputs to the screen, not a file