本文整理汇总了Python中psychopy.data.getDateStr函数的典型用法代码示例。如果您正苦于以下问题:Python getDateStr函数的具体用法?Python getDateStr怎么用?Python getDateStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDateStr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: enterSubjInfo
def enterSubjInfo(expName,optionList):
""" Brings up a GUI in which to enter all the subject info."""
def inputsOK(optionList,expInfo):
for curOption in sorted(optionList.items()):
if curOption[1]['options'] != 'any' and expInfo[curOption[1]['name']] not in curOption[1]['options']:
return [False,"The option you entered for " + curOption[1]['name'] + " is not in the allowable list of options: " + str(curOption[1]['options'])]
print "inputsOK passed"
return [True,'']
try:
expInfo = misc.fromFile(expName+'_lastParams.pickle')
except:
expInfo={} #make the kind of dictionary that this gui can understand
for curOption in sorted(optionList.items()):
expInfo[curOption[1]['name']]=curOption[1]['default']
#load the tips
tips={}
for curOption in sorted(optionList.items()):
tips[curOption[1]['name']]=curOption[1]['prompt']
expInfo['dateStr']= data.getDateStr()
expInfo['expName']= expName
dlg = gui.DlgFromDict(expInfo, title=expName, fixed=['dateStr','expName'],order=[optionName[1]['name'] for optionName in sorted(optionList.items())],tip=tips)
if dlg.OK:
misc.toFile(expName+'_lastParams.pickle', expInfo)
[success,error] = inputsOK(optionList,expInfo)
if success:
return [True,expInfo]
else:
return [False,error]
else:
core.quit()
开发者ID:bastienboutonnet,项目名称:AccPred,代码行数:32,代码来源:auditorySentence.py
示例2: writeScript
def writeScript(self, expPath=None):
"""Write a PsychoPy script for the experiment
"""
self.expPath = expPath
script = IndentingBuffer(u"") # a string buffer object
script.write(
"#!/usr/bin/env python\n"
+ "# -*- coding: utf-8 -*-\n"
+ '"""\nThis experiment was created using PsychoPy2 Experiment Builder (v%s), %s\n'
% (self.psychopyVersion, data.getDateStr(format="%B %d, %Y, at %H:%M"))
+ "If you publish work using this script please cite the relevant PsychoPy publications\n"
+ " Peirce, JW (2007) PsychoPy - Psychophysics software in Python. Journal of Neuroscience Methods, 162(1-2), 8-13.\n"
+ ' Peirce, JW (2009) Generating stimuli for neuroscience using PsychoPy. Frontiers in Neuroinformatics, 2:10. doi: 10.3389/neuro.11.010.2008\n"""\n'
)
script.write(
"from numpy import * #many different maths functions\n"
+ "from numpy.random import * #maths randomisation functions\n"
+ "import os #handy system and path functions\n"
+ "from psychopy import %s\n" % ", ".join(self.psychopyLibs)
+ "import psychopy.log #import like this so it doesn't interfere with numpy.log\n\n"
)
self.namespace.user.sort()
script.write(
"#User-defined variables = %s\n" % str(self.namespace.user)
+ "known_name_collisions = %s #(collisions are bad)\n\n" % str(self.namespace.get_collisions())
)
self.settings.writeStartCode(script) # present info dlg, make logfile, Window
# delegate rest of the code-writing to Flow
self.flow.writeCode(script)
self.settings.writeEndCode(script) # close log file
return script
开发者ID:LotusEcho,项目名称:psychopy,代码行数:33,代码来源:experiment.py
示例3: _setExperimentInfo
def _setExperimentInfo(self, author, version, verbose):
# try to auto-detect __author__ and __version__ in sys.argv[0] (= the users's script)
if not author or not version:
if os.path.isfile(sys.argv[0]):
f = open(sys.argv[0], 'r')
lines = f.read()
f.close()
if not author and '__author__' in lines:
linespl = lines.splitlines()
while linespl[0].find('__author__') == -1:
linespl.pop(0)
auth = linespl[0]
if len(auth) and '=' in auth:
try:
author = str(eval(auth[auth.find('=')+1 :]))
except:
pass
if not version and '__version__' in lines:
linespl = lines.splitlines()
while linespl[0].find('__version__') == -1:
linespl.pop(0)
ver = linespl[0]
if len(ver) and ver.find('=') > 0:
try:
version = str(eval(ver[ver.find('=')+1 :]))
except:
pass
if author or verbose:
self['experimentAuthor'] = author
if version or verbose:
self['experimentAuthVersion'] = version
# script identity & integrity information:
self['experimentScript'] = os.path.basename(sys.argv[0]) # file name
scriptDir = os.path.dirname(os.path.abspath(sys.argv[0]))
self['experimentScript.directory'] = scriptDir
# sha1 digest, text-format compatibility
self['experimentScript.digestSHA1'] = _getSha1hexDigest(os.path.abspath(sys.argv[0]), isfile=True)
# subversion revision?
try:
svnrev, last, url = _getSvnVersion(os.path.abspath(sys.argv[0])) # svn revision
if svnrev: # or verbose:
self['experimentScript.svnRevision'] = svnrev
self['experimentScript.svnRevLast'] = last
self['experimentScript.svnRevURL'] = url
except:
pass
# mercurical revision?
try:
hgChangeSet = _getHgVersion(os.path.abspath(sys.argv[0]))
if hgChangeSet: # or verbose:
self['experimentScript.hgChangeSet'] = hgChangeSet
except:
pass
# when was this run?
self['experimentRunTime.epoch'] = core.getAbsTime()
self['experimentRunTime'] = data.getDateStr(format="%Y_%m_%d %H:%M (Year_Month_Day Hour:Min)")
开发者ID:alexholcombe,项目名称:psychopy,代码行数:59,代码来源:info.py
示例4: get_subject_info
def get_subject_info():
try:
expInfo = fromFile('../data/lastParams.pickle') # check existence of previous parameter file
except:
expInfo = {'pseudo':'pseudo'}
expInfo['date']= data.getDateStr() #add current time
#present a dialog box to get user info
dlg = gui.DlgFromDict(expInfo, title='Experiment', fixed=['date'])
if dlg.OK:
toFile('../data/lastParams.pickle', expInfo)#save params to file for next time
else:
core.quit()#cancel -> exit
return expInfo
开发者ID:vincentadam87,项目名称:pitch_experiment,代码行数:13,代码来源:run_experimentAXB.py
示例5: experimentInfo
def experimentInfo(self, expName = "SET EXPERIMENT NAME"):
self.expName = expName
self.expInfo = {'Subject Id':'', 'Age':'', 'Experiment Version': 0.1,
'Sex': ['Male', 'Female', 'Other']}
self.expInfo[u'date'] = data.getDateStr(format="%Y-%m-%d_%H:%M")
self.infoDlg = gui.DlgFromDict(dictionary=self.expInfo,
title=self.expName,
fixed=['Experiment Version'])
self.expInfo[u'DataFile'] = u'Data' + os.path.sep + u'DATA_Local-Global_Task.csv'
if self.infoDlg.OK:
return self.expInfo
else:
return 'Cancelled'
开发者ID:marsja,项目名称:psypy,代码行数:13,代码来源:local-global_task.py
示例6: callDialog
def callDialog(self):
"""Fire up the dialog instance and return the data"""
# Set up dialog data
for item in self.dialog_data:
self.info[item] = ""
dlg = gui.DlgFromDict(dictionary=self.info, title=self.expName)
if not dlg.OK:
core.quit()
# Tack on date
self.info["dateStr"] = data.getDateStr() # will create str of current date/time
return self.info
开发者ID:uokpsytech,项目名称:psychopy_training,代码行数:14,代码来源:psych_lib.py
示例7: info_gui
def info_gui(expName, expInfo):
infoDlg = gui.DlgFromDict(expInfo, title = '%s Subject details:'%(expName)) #set the name of the pop up window
expInfo['date'] = data.getDateStr() # add a simple timestamp to the experiment
expInfo['expName'] = expName
datalog_fn = 'data_' + expName + os.sep + '%s_%s_%s_%s' %(expInfo['subject'], expInfo['session'], expName, expInfo['date'])
def make_sure_path_exists(path):
try:
os.makedirs(path)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
make_sure_path_exists('data_' + expName)
timelog(datalog_fn)
if infoDlg.OK == False: #stop experiment if press cancel
print 'User Cancelled'
core.quit() # user pressed cancel
return expInfo, datalog_fn
开发者ID:htwangtw,项目名称:mindwanderinglabYork,代码行数:17,代码来源:baseDef.py
示例8:
import matplotlib.pyplot as plt
from psychopy import visual, core, event, gui, data
from sklearn import linear_model
nSessions = 5
# Grab user info and set up output files for analysis
_thisDir = os.path.dirname(os.path.abspath(__file__))
print _thisDir
os.chdir(_thisDir)
expName = 'standardFlashlag'
expInfo = {u'User': u''}
dlg = gui.DlgFromDict(dictionary=expInfo, title=expName)
if dlg.OK == False: core.quit()
expInfo['date'] = data.getDateStr()
expInfo['expName'] = expName
dataOut = pd.DataFrame(columns = ('response','correct','rotation'))
grabMeans = pd.DataFrame()
deg_sign= u'\N{DEGREE SIGN}'
'''
Initalize stimuli parameters
all units are in pixels to show correctly on any sized screen
user may wish to modify for optimality on small or larger screens
tested on 1920x1080 (widescreen) display
'''
dotRad = (55,55)
flashRad = (55,55)
circleRadius = 125
开发者ID:CoAxLab,项目名称:flashlag,代码行数:31,代码来源:flashlag.py
示例9: the
EXP_NAME = "AMP China Dorm" # name of experiment
### store info about experiment session ---------------------------------------
# set up info we need to get
exp_info = {"Participant ID": ""}
# create a dialog box to get info
dialog = gui.DlgFromDict(dictionary=exp_info, title=EXP_NAME)
if dialog.OK == False: # quit dialog box if "canceled" is pressed
core.quit()
# add experiment title and date
exp_info["Experiment Name"] = EXP_NAME
exp_info["Date"] = data.getDateStr()
### set up stimuli ------------------------------------------------------------
## create a window
win = visual.Window(size=SCREENSIZE, color="black", units="pix", fullscr=False)
## display instructions at the beginning of trial
instruction_1 = "What you are about to see will involve two kinds of images: pictures of people, and of geometric shapes.\n\n\nPress SPACE to continue"
instruction_2 = "The pictures of people will be either pictures of Han people doing daily activities, or pictures of minority people such as Tibetan or Uyghur doing similar activities.\n\nYou do not need to do anything with these pictures.\n\n\nPress SPACE to continue"
instruction_3 = "Your job is to judge the visual pleasantness of the geometric shape.\n\nIf the geometric shape is less visually pleasing than average, press the (E) key.\n\nIf the geometric shape is more visually pleasing than average, press the (I) key.\n\n\nPress SPACE to BEGIN"
instruction_text = visual.TextStim(win, text=instruction_1, color="red", height=20)
## display "Pleasant" and "Unpleasant" commands throughout trials
pleasant_text = visual.TextStim(win, text="Pleasant", color="green", height=0.07, pos=(-0.8, 0.85), units="norm")
开发者ID:tyson-ni,项目名称:psychopy-china-dorm,代码行数:31,代码来源:prototype.py
示例10: fails
from numpy import * # many different maths functions
from numpy.random import * # maths randomisation functions
import os # handy system and path functions
from psychopy import core, data, event, visual, gui
import psychopy.log # import like this so it doesn't interfere with numpy.log
# User-defined variables = [u'Gabor', 'Instructions', 'Intro', 'key_resp', 'key_resp_2', 'trial', u'trials']
known_name_collisions = None # (collisions are bad)
# store info about the experiment
expName = "StairTest" # 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
# setup files for saving
if not os.path.isdir("data"):
os.makedirs("data") # if this fails (e.g. permissions) we will get error
filename = "data" + os.path.sep + "%s_%s" % (expInfo["participant"], expInfo["date"])
psychopy.log.console.setLevel(psychopy.log.warning) # this outputs to the screen, not a file
logFile = psychopy.log.LogFile(filename + ".log", level=psychopy.log.EXP)
# setup the Window
win = visual.Window(
size=[1024, 768],
fullscr=True,
screen=0,
allowGUI=False,
allowStencil=False,
开发者ID:RSharman,项目名称:Experiments,代码行数:31,代码来源:StairTest_lastrun.py
示例11: handleKeys
depth=-4.0)
def handleKeys(key):
'''Function for handling keys from the handles and using with
ratingScale...'''
if key != 191:
key = str(key)
event._onPygletKey(symbol=key, modifiers=None, emulated=True)#Buffers the input
last_state = True # Return true if down
port.setData(0)
core.wait(.15)
# Store info about the experiment session
expName = u'Cross-Modality Matching' #
expInfo = {'Subject_Id':'', 'Age':'', 'ExpVersion': 2.0,'Sex': ['Male', 'Female']}
expInfo[u'date'] = data.getDateStr(format="%Y-%m-%d_%H:%M") # add a simple timestamp
infoDlg = gui.DlgFromDict(dictionary=expInfo, title=expName, fixed=['ExpVersion'])
if infoDlg.OK:
print expInfo
else: print 'User Cancelled'
#Soundlevels to choose from...
sndlvls = numpy.linspace(0.1, 1.0, 21)#This can be removed later!!!!!!!!!!!!!!!
#List of sound levels to start from
sint = [0.1, 1.0]
#List of vibration intensities
vlvl = [5,5,5,5,10,10,10,10,15,15,15,15]
#List of the tasks
task = ['Attention', 'Attention', 'Attention', 'Intensity', 'Intensity', 'Intensity']
#Sounds
开发者ID:marsja,项目名称:psypy,代码行数:31,代码来源:CMM_exp_V2_VT15_ENG.py
示例12:
from infant_eeg.facial_movement_exp import FacialMovementExperiment
from infant_eeg.gaze_following_exp import GazeFollowingExperiment
import os
from psychopy import data, gui
from infant_eeg.config import CONF_DIR
from infant_eeg.nine_month_facial_movement_exp import NineMonthFacialMovementExperiment
if __name__ == '__main__':
# experiment parameters
expInfo = {
'child_id': '',
'date': data.getDateStr(),
'session': '',
'diagnosis': '',
'age': '',
'gender': '',
'experimenter_id': '',
'monitor': ['viewsonic','tobii'],
'monitor distance': '65',
'experiment': ['FacialMovement','GazeFollowing','9mo FacialMovement'],
'congruent actor': ['CG', 'FO'],
'incongruent actor': ['CG', 'FO'],
'preferential gaze': False,
'eeg': True,
'eyetracking source': ['tobii', 'mouse', 'none'],
'debug mode': False
}
#present a dialogue to change params
dlg = gui.DlgFromDict(
expInfo,
开发者ID:jbonaiuto,项目名称:infant_eeg,代码行数:31,代码来源:main.py
示例13:
#ntrials3 = 100
#nblocks3 = 2
#blockSize3 = 100
# uncomment for debug run
#ntrials = 4
#nblocks = 4
#blockSize = 4
#create a window to draw in
myWin =visual.Window((1280,1024), allowGUI=True,
bitsMode=None, units='norm', winType='pyglet', color=(-1,-1,-1))
# Admin
expInfo = {'subject':'test','date':data.getDateStr(),'practice':True,'speed time':speedTime,'trial time':1500}
#expInfo['dateStr']= data.getDateStr() #add the current time
#expInfo['practice'] = True
#present a dialogue to change params
ok = False
while(not ok):
dlg = gui.DlgFromDict(expInfo, title='Moving Dots', fixed=['dateStr'],order=['date','subject','practice','speed time','trial time'])
if dlg.OK:
misc.toFile('lastParams.pickle', expInfo)#save params to file for next time
ok = True
else:
core.quit()#the user hit cancel so exit
# setup data file
开发者ID:mspeekenbrink,项目名称:SpeedAccuracyMovingDots,代码行数:31,代码来源:Dots.py
示例14: print
)
if dialogue_box.OK:
print(dialogue_content)
else:
print('User Cancelled')
core.quit()
# Ensure that relative paths start from the same directory as this script
# current_dir = os.path.dirname(os.path.abspath(__file__))
# os.chdir(current_dir)
# Store info about the experiment session
experiment_name = 'CFS popping time' # from the Builder filename that created this script
experiment_info = {u'session': u'001', u'participant': u''}
experiment_info['date'] = data.getDateStr() # add a simple timestamp
experiment_info['experiment_name'] = experiment_name
# Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc
filename = 'data/'+ str(dialogue_box.data[0])
# An ExperimentHandler isn't essential but helps with data saving
current_experiment = data.ExperimentHandler(
name=experiment_name,
extraInfo=experiment_info,
runtimeInfo=None,
#originPath=u'/Users/alex/Documents/Popping Time/',
savePickle=True,
saveWideText=False,
dataFileName=filename)
开发者ID:hughrabagliati,项目名称:CFS_Compositionality,代码行数:30,代码来源:experiment1.py
示例15: conditions
# real session - 24. divided to 18 (go or nogo) and 6 (the opposite). stimulus display for 1,2 or 3s. intertrial was 1.5s
# attched is a .odt document with the conditions (as suggested by Prof. Andrea Berger).
from psychopy import core, visual, gui, data, misc, event, sound
import time, os, random, numpy
# now turn to right folder
directory=os.getcwd() # get folder
os.chdir(directory) # use it
#folder='/home/ord/Experiments_BP_Clinic/PCT/' #specify the folder of result files to be saved in
# savine last experiment data
try:#try to get a previous parameters file
expInfo = misc.fromFile('gonogo.pickle')
except:#if not there then use a default set
expInfo = {'subject no':''}
expInfo['dateStr']= data.getDateStr() #add the current time
# dialouge box for name of subject and file
dlg = gui.DlgFromDict(expInfo, title='Go/NoGo Task', fixed=['dateStr'])
if dlg.OK:
misc.toFile('gonogo.pickle', expInfo)#save params to file for next time
else:
core.quit()#the user hit cancel so exit
# check if folder exist and if not, create it
if not os.path.exists('results'):
os.makedirs('results')
fileName = expInfo['subject no'] + expInfo['dateStr']
dataFile = open(directory+'/results/'+fileName+'.csv', 'w')#a simple text file with 'comma-separated-values'
dataFile.write('trialNo,trial,RT,press,answer\n')
开发者ID:orduek,项目名称:TBI_Research,代码行数:30,代码来源:gonogo_mouse.py
示例16: _setExperimentInfo
def _setExperimentInfo(self, author, version, verbose, randomSeedFlag=None):
# try to auto-detect __author__ and __version__ in sys.argv[0] (= the users's script)
if not author or not version:
f = open(sys.argv[0],'r')
lines = f.read()
f.close()
if not author and lines.find('__author__')>-1:
linespl = lines.splitlines()
while linespl[0].find('__author__') == -1:
linespl.pop(0)
auth = linespl[0]
if len(auth) and auth.find('=') > 0:
try:
author = str(eval(auth[auth.find('=')+1 :]))
except:
pass
if not version and lines.find('__version__')>-1:
linespl = lines.splitlines()
while linespl[0].find('__version__') == -1:
linespl.pop(0)
ver = linespl[0]
if len(ver) and ver.find('=') > 0:
try:
version = str(eval(ver[ver.find('=')+1 :]))
except:
pass
if author or verbose:
self['experimentAuthor'] = author
if version or verbose:
self['experimentAuthVersion'] = version
# script identity & integrity information:
self['experimentScript'] = os.path.basename(sys.argv[0]) # file name
scriptDir = os.path.dirname(os.path.abspath(sys.argv[0]))
self['experimentScript.directory'] = scriptDir
# sha1 digest, text-format compatibility
self['experimentScript.digestSHA1'] = _getSha1hexDigest(os.path.abspath(sys.argv[0]), file=True)
# subversion revision?
try:
svnrev, last, url = _getSvnVersion(os.path.abspath(sys.argv[0])) # svn revision
if svnrev: # or verbose:
self['experimentScript.svnRevision'] = svnrev
self['experimentScript.svnRevLast'] = last
self['experimentScript.svnRevURL'] = url
except:
pass
# mercurical revision?
try:
hgChangeSet = _getHgVersion(os.path.abspath(sys.argv[0]))
if hgChangeSet: # or verbose:
self['experimentScript.hgChangeSet'] = hgChangeSet
except:
pass
# when was this run?
self['experimentRunTime.epoch'] = core.getAbsTime() # basis for default random.seed()
self['experimentRunTime'] = data.getDateStr(format="%Y_%m_%d %H:%M (Year_Month_Day Hour:Min)")
# random.seed -- record the value, and initialize random.seed() if 'set:'
if randomSeedFlag:
randomSeedFlag = str(randomSeedFlag)
while randomSeedFlag.find('set: ') == 0:
randomSeedFlag = randomSeedFlag.replace('set: ','set:',1) # spaces between set: and value could be confusing after deleting 'set:'
randomSeed = randomSeedFlag.replace('set:','',1).strip()
if randomSeed in ['time']:
randomSeed = self['experimentRunTime.epoch']
self['experimentRandomSeed.string'] = randomSeed
if randomSeedFlag.find('set:') == 0:
random.seed(self['experimentRandomSeed.string']) # seed it
self['experimentRandomSeed.isSet'] = True
else:
self['experimentRandomSeed.isSet'] = False
else:
self['experimentRandomSeed.string'] = None
self['experimentRandomSeed.isSet'] = False
开发者ID:del82,项目名称:psychopy,代码行数:76,代码来源:info.py
示例17: len
from os.path import expanduser
import sys
sys.dont_write_bytecode = True
import cPickle as pickle
# import relevant classes and dicts for condition names + targets/distractors per condition
from vwmClasses import VWMObj, VWMTrial, conds, nTotalObjsPerCond, nDistractorsInCond, nTargetsInCond
### Assign Random Seed ###
assert len(sys.argv) == 3, "Too many inputs"
assert sys.argv[1].isdigit() and sys.argv[2].isdigit(), "Integers necessary"
subjHash = (int(sys.argv[1]), int(sys.argv[2]))
np.random.seed(seed=subjHash)
### Path and Filename Information based on terminal input###
behavRun = 'behav5'
date = data.getDateStr()
homeDirectory = expanduser("~")
saveDirectory = homeDirectory + os.sep + 'Google Drive/tACS_VWM_ALPHA/data'
filename = saveDirectory + os.sep + behavRun + os.sep + 's' + sys.argv[1] + os.sep + 'setupData/setup-run' + sys.argv[2] + "_" + date
pickleFilename = saveDirectory + os.sep + behavRun + os.sep + 's' + sys.argv[1] + os.sep + 'setupData/subj' + sys.argv[1] + 'run' + sys.argv[2] + '.p'
# ExperimentHandler conducts data saving
thisExp = data.ExperimentHandler(name='setup', version='', runtimeInfo=None,
originPath=None,
savePickle=False, saveWideText=True,
dataFileName=filename)
############# Object Location Rules ########################
# maxNumObjsPerQuadrant = 2
# maxNumTargersPerQuadrant = 1
# maxNumObjsPerRadix = 4
开发者ID:alexgonzl,项目名称:tacs_vmw_alpha,代码行数:31,代码来源:conditionSetup.py
示例18:
globalClock = core.Clock()
respClock = core.Clock()
#initialise experiment information
info = {} #a dictionary
#present dialog to collect info
info['participant'] = ''
dlg = gui.DlgFromDict(info)
if not dlg.OK:
core.quit()
#add additional info after the dialog has gone
info['fixFrames'] = 30 #0.5s at 60Hz
info['cueFrames'] = 12 #200ms at 60Hz
info['probeFrames'] = 12
info['dateStr'] = data.getDateStr() #will create str of current date/time
#set up logging
#create a clock to synchronise with our experiment
globalClock = core.Clock()
logging.setDefaultClock(globalClock)
logging.console.setLevel(logging.WARNING)#set the console to receive warnings and errors
#create the base filename for our data files
filename = "data/{participant}_{dateStr}".format(**info)
DEBUG = False # set debug
if DEBUG:
fullscr = False
logging.console.setLevel(logging.INFO)
else:
开发者ID:smithdanielle,项目名称:posner,代码行数:31,代码来源:posner.py
示例19: print
info = {'Session': 1, 'Subject':'', 'gender':['male','female']}
dialog = gui.DlgFromDict(dictionary= info, title='MPRR with Joystick')
if dialog.OK:
infoUser = dialog.data
#Subject's data is saved in infoUser and are ready to print them on each file
else:
print('user cancelled')
core.quit()
#Date is saved on each trial
info['dateStr'] = data.getDateStr()
#We create a screen on which our program will run
#We also set up the internal clock meanwhile the remaining functions are ready to use
mywin = visual.Window([1366,768], fullscr = False, monitor='testMonitor', color='black',units='deg', allowGUI = False)
respClock = core.Clock()
joystick.backend='pyglet'
nJoysticks=joystick.getNumJoysticks()
if nJoysticks>0:
joy = joystick.Joystick(0)
开发者ID:adribaena,项目名称:MPRR,代码行数:30,代码来源:MPRROxford.py
示例20: writeScript
def writeScript(self, expPath=None, target="PsychoPy"):
"""Write a PsychoPy script for the experiment
"""
self.flow._prescreenValues()
self.expPath = expPath
script = IndentingBuffer(u'') # a string buffer object
# get date info, in format preferred by current locale as set by app:
if hasattr(locale, 'nl_langinfo'):
fmt = locale.nl_langinfo(locale.D_T_FMT)
localDateTime = data.getDateStr(format=fmt)
else:
localDateTime = data.getDateStr(format="%B %d, %Y, at %H:%M")
if target == "PsychoPy":
self.settings.writeInitCode(script,
self.psychopyVersion, localDateTime)
self.settings.writeStartCode(script) # present info, make logfile
# writes any components with a writeStartCode()
self.flow.writeStartCode(script)
self.settings.writeWindowCode(script) # create our visual.Window()
# for JS the routine begin/frame/end code are funcs so write here
# write the rest of the code for the components
self.flow.writeBody(script)
self.settings.writeEndCode(script) # close log file
elif target == "PsychoJS":
script.oneIndent = " " # use 2 spaces rather than python 4
self.settings.writeInitCodeJS(script,
self.psychopyVersion, localDateTime)
self.settings.writeWindowCodeJS(script)
# initialise the components for all Routines in a single function
script.writeIndentedLines("\nfunction experimentInit() {")
script.setIndentLevel(1, relative=True)
# routine init sections
for entry in self.flow:
# NB each entry is a routine or LoopInitiator/Terminator
self._currentRoutine = entry
if hasattr(entry, 'writeInitCodeJS'):
entry.writeInitCodeJS(script)
# create globalClock etc
code = ("\n// Create some handy timers\n"
"globalClock = new psychoJS.core.Clock();"
" // to track the time since experiment started\n"
"routineTimer = new psychoJS.core.CountdownTimer();"
" // to track time remaining of each (non-slip) routine\n"
"\nreturn psychoJS.NEXT;")
script.writeIndentedLines(code)
script.setIndentLevel(-1, relative=True)
script.writeIndentedLines("}")
# This differs to the Python script. We can loop through all
# Routines once (whether or not they get used) because we're using
# functions that may or may not get called later.
# Do the Routines of the experiment first
for thisRoutine in list(self.routines.values()):
self._currentRoutine = thisRoutine
thisRoutine.writeRoutineBeginCodeJS(script)
thisRoutine.writeEachFrameCodeJS(script)
thisRoutine.writeRoutineEndCodeJS(script)
# loao resources files (images, csv files etc
self.flow.writeResourcesCodeJS(script)
# create the run() function and schedulers
self.flow.writeBodyJS(script) # functions for loops and for scheduler
self.settings.writeEndCodeJS(script)
return script
开发者ID:flipphillips,项目名称:psychopy,代码行数:72,代码来源:_experiment.py
注:本文中的psychopy.data.getDateStr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论