本文整理汇总了Python中psychopy.data.getDateStr函数的典型用法代码示例。如果您正苦于以下问题:Python getDateStr函数的具体用法?Python getDateStr怎么用?Python getDateStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDateStr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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
示例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)")
示例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
示例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'
示例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
示例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
示例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
示例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")
示例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,
示例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
示例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,
示例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
示例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)
示例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')