Skip to content

Commit

Permalink
Revert: remove code intended for another branch
Browse files Browse the repository at this point in the history
thought I was getting all slick with git and stuff. sheesh.
  • Loading branch information
jeremygray committed Nov 24, 2015
1 parent eb0a9f0 commit aaf6a78
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
10 changes: 3 additions & 7 deletions psychopy/app/builder/components/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,10 @@ def writeStopTestCode(self,buff):
"""Test whether we need to stop
"""
if self.params['stopType'].val=='time (s)':
frameVal = "frameRemains = %(stopVal)s - win.monitorFramePeriod * 0.75 # most of one frame period left\n" % self.params
buff.writeIndented(frameVal)
buff.writeIndented("if %(name)s.status == STARTED and t >= frameRemains:\n" % self.params)
buff.writeIndented("if %(name)s.status == STARTED and t >= (%(stopVal)s-win.monitorFramePeriod*0.75): #most of one frame period left\n" %(self.params))
#duration in time (s)
elif self.params['stopType'].val=='duration (s)' and self.params['startType'].val=='time (s)':
frameVal = "frameRemains = %(startVal)s + %(stopVal)s - win.monitorFramePeriod * 0.75 # most of one frame period left\n" % self.params
buff.writeIndented(frameVal)
buff.writeIndented("if %(name)s.status == STARTED and t >= frameRemains:\n" % self.params)
buff.writeIndented("if %(name)s.status == STARTED and t >= (%(startVal)s + (%(stopVal)s-win.monitorFramePeriod*0.75)): #most of one frame period left\n" %(self.params))
elif self.params['stopType'].val=='duration (s)':#start at frame and end with duratio (need to use approximate)
buff.writeIndented("if %(name)s.status == STARTED and t >= (%(name)s.tStart + %(stopVal)s):\n" %(self.params))
#duration in frames
Expand All @@ -131,7 +127,7 @@ def writeStopTestCode(self,buff):
buff.writeIndented("if %(name)s.status == STARTED and frameN >= %(stopVal)s:\n" %(self.params))
#end according to a condition
elif self.params['stopType'].val=='condition':
buff.writeIndented("if %(name)s.status == STARTED and bool(%(stopVal)s):\n" %(self.params))
buff.writeIndented("if %(name)s.status == STARTED and (%(stopVal)s):\n" %(self.params))
else:
raise "Didn't write any stop line for startType=%(startType)s, stopType=%(stopType)s" %(self.params)
buff.setIndentLevel(+1,relative=True)
Expand Down
14 changes: 7 additions & 7 deletions psychopy/app/builder/components/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, parentName, exp, expName='', fullScr=True, winSize=[1024,768]
saveLogFile=True, showExpInfo=True, expInfo="{'participant':'', 'session':'001'}",units='use prefs',
logging='exp', color='$[0,0,0]', colorSpace='rgb', enableEscape=True, blendMode='avg',
saveXLSXFile=False, saveCSVFile=False, saveWideCSVFile=True, savePsydatFile=True,
savedDataFolder='', filename="u'xxxx/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date'])"):
savedDataFolder='', filename="u'xxxx/%s_%s_%s' %(expInfo['participant'], expName, expInfo['date'])"):
self.type='Settings'
self.exp=exp#so we can access the experiment if necess
self.exp.requirePsychopyLibs(['visual', 'gui'])
Expand Down Expand Up @@ -169,7 +169,7 @@ def writeStartCode(self,buff):
buff.writeIndented("expInfo = %s\n" % expInfo)
if self.params['Show info dlg'].val:
buff.writeIndented("dlg = gui.DlgFromDict(dictionary=expInfo, title=expName)\n")
buff.writeIndentedLines("if dlg.OK == False:\n core.quit() # user pressed cancel\n")
buff.writeIndented("if dlg.OK == False: core.quit() # user pressed cancel\n")
buff.writeIndented("expInfo['date'] = data.getDateStr() # add a simple timestamp\n")
buff.writeIndented("expInfo['expName'] = expName\n")
level=self.params['logging level'].val.upper()
Expand All @@ -183,7 +183,7 @@ def writeStartCode(self,buff):
if field in expInfoDict:
participantField=field
self.params['Data filename'].val = repr(saveToDir) + \
" + os.sep + '%s_%s' % (expInfo['" + field + "'], expInfo['date'])"
" + os.sep + '%s_%s' %(expInfo['" + field + "'], expInfo['date'])"
break
if not participantField: #we didn't find a participant-type field so skip that part of filename
self.params['Data filename'].val = repr(saveToDir) + " + os.path.sep + expInfo['date']"
Expand Down Expand Up @@ -260,11 +260,11 @@ def writeWindowCode(self,buff):
"microphone.switchOn()\n")

buff.writeIndented("# store frame rate of monitor if we can measure it successfully\n")
buff.writeIndented("expInfo['frameRate'] = win.getActualFrameRate()\n")
buff.writeIndented("if expInfo['frameRate'] != None:\n")
buff.writeIndented(" frameDur = 1.0 / round(expInfo['frameRate'])\n")
buff.writeIndented("expInfo['frameRate']=win.getActualFrameRate()\n")
buff.writeIndented("if expInfo['frameRate']!=None:\n")
buff.writeIndented(" frameDur = 1.0/round(expInfo['frameRate'])\n")
buff.writeIndented("else:\n")
buff.writeIndented(" frameDur = 1.0 / 60.0 # couldn't get a reliable measure so guess\n")
buff.writeIndented(" frameDur = 1.0/60.0 # couldn't get a reliable measure so guess\n")

def writeEndCode(self,buff):
"""write code for end of experiment (e.g. close log file)
Expand Down
4 changes: 2 additions & 2 deletions psychopy/app/builder/components/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def writeStartTestCode(self,buff):
def writeStopTestCode(self,buff):
"""Test whether we need to stop
"""
buff.writeIndented("elif %(name)s.status == STARTED: # one frame should pass before updating params and completing\n" %(self.params))
buff.writeIndented("elif %(name)s.status == STARTED: #one frame should pass before updating params and completing\n" %(self.params))
buff.setIndentLevel(+1, relative=True)#entered an if statement
self.writeParamUpdates(buff)
buff.writeIndented("%(name)s.complete() # finish the static period\n" %(self.params))
buff.writeIndented("%(name)s.complete() #finish the static period\n" %(self.params))
buff.setIndentLevel(-1, relative=True)#to get out of the if statement

pass #the clock.StaticPeriod class handles its own stopping
Expand Down
19 changes: 9 additions & 10 deletions psychopy/app/builder/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,19 @@ def writeScript(self, expPath=None):

script.write('#!/usr/bin/env python2\n' +
'# -*- coding: utf-8 -*-\n' +
'"""\nThis experiment was created using PsychoPy2 Experiment Builder (v%s),\n'
' on %s\n' % (self.psychopyVersion, localDateTime ) +
'If you publish work using this script please cite the PsychoPy publications:\n'
' Peirce, JW (2007) PsychoPy - Psychophysics software in Python.\n'
' Journal of Neuroscience Methods, 162(1-2), 8-13.\n'
' Peirce, JW (2009) Generating stimuli for neuroscience using PsychoPy.\n'
' Frontiers in Neuroinformatics, 2:10. doi: 10.3389/neuro.11.010.2008\n"""\n')
'"""\nThis experiment was created using PsychoPy2 Experiment Builder (v%s), %s\n' % (
self.psychopyVersion, localDateTime ) +
'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("\nfrom __future__ import division # so that 1/3=0.333 instead of 1/3=0\n")
script.write("from psychopy import locale_setup, %s\n" % ', '.join(self.psychopyLibs) +
"from psychopy.constants import * # things like STARTED, FINISHED\n"
"import numpy as np # whole numpy lib is available, prepend 'np.'\n"
"from psychopy.constants import * # things like STARTED, FINISHED\n" +
"import numpy as np # whole numpy lib is available, prepend 'np.'\n" +
"from numpy import %s\n" % ', '.join(_numpyImports) +
"from numpy.random import %s\n" % ', '.join(_numpyRandomImports) +
"import os, sys # handy system and path functions\n")
"import os # handy system and path functions\n" +
"import sys # to get file system encoding\n")
script.write("\n")
self.settings.writeStartCode(script) #present info dlg, make logfile
self.flow.writeStartCode(script) #writes any components with a writeStartCode()
Expand Down

0 comments on commit aaf6a78

Please sign in to comment.