Hello! I’m having trouble running an experiment in PsychoPy (version 1.83.04).
If you could help me, I would be very greatful!
Lines and scales are displayed instead of words.
The experiment was made in this version and new version do not support it. Along with PsychoPy, I also use SV-1 (Smart Voice Key, Cedrus).
How to fix it?
Thank you!
Please could you clarify the issue? What do you mean by lines and scales? Perhaps you could add a screenshot and upload your Builder file?
50ms_last1_1.py (14.6 KB)
I am sending a screenshot, the lines and scales being displayed and the words to be displayed and file.
Regardless of the lines and scales, the data is well saved in Excel.
Thank you very much. This is important to me for my master’s thesis.
So you are seeing the top right image instead of, for example, pu___?
What font is the text component?
Please could you upload the psyexp file instead of the py file since it was created in Builder?
That’s right. I see the upper right picture instead of pu___.
The font is Arial, I am sending an attached stimulus file in Excel.
last1_1.xlsx (10.9 KB)
#!/usr/bin/env python2
-- coding: utf-8 --
“”"
This experiment was created using PsychoPy2 Experiment Builder (v1.83.04), Mai 23, 2016, at 11:59
If you publish work using this script please cite the relevant 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 division # so that 1/3=0.333 instead of 1/3=0
from psychopy import locale_setup, visual, core, data, event, logging, sound, gui
from psychopy.visual.textbox import TextBox
from psychopy.constants import * # things like STARTED, FINISHED
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 = ‘bbTest’ # from the Builder filename that created this script
expInfo = {u’participant’: u’’}
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’ %(expInfo[‘participant’])
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.WARNING)
logging.console.setLevel(logging.WARNING) # this outputs to the screen, not a file
endExpNow = False # flag for ‘escape’ or other condition => quit the exp
Start Code - component code to be run before the window creation
Setup the Window
win = visual.Window(size=(1366, 768), fullscr=True, screen=0, allowGUI=False, allowStencil=False,
monitor=‘testMonitor’, color=[1.000,1.000,1.000], colorSpace=‘rgb’,
blendMode=‘avg’, useFBO=True,
)
#window = visual.Window(size=(1920, 1080), fullscr=True, screen=0, allowGUI=False, allowStencil=False,
monitor=‘testMonitor’, color=[1.000,1.000,1.000], colorSpace=‘rgb’,
blendMode=‘avg’, useFBO=True,
)
#window=visual.Window((1920, 1080),
units=‘norm’,
fullscr=False, allowGUI=True,
screen=0
)
#window=visual.Window((800,600),
units=‘norm’,
fullscr=False, allowGUI=True,
screen=0
)
store frame rate of monitor if we can measure it successfully
expInfo[‘frameRate’]=win.getActualFrameRate()
if expInfo[‘frameRate’]!=None:
frameDur = 1.0/round(expInfo[‘frameRate’])
else:
frameDur = 1.0/60.0 # couldn’t get a reliable measure so guess
Initialize components for Routine “testBB”
testBBClock = core.Clock()
import pyxid
devices = pyxid.get_xid_devices()
buttonBox = devices[0]
hashtags = visual.TextStim(win=win, ori=0, name=‘hashtags’,
text=’######’, font=‘Arial’,
pos=[0, 0], height=0.25, wrapWidth=None,
color=‘black’, colorSpace=‘rgb’, opacity=1,
depth=-1.0)
Prime = visual.TextBox(window=win, name=‘Target’,
text=‘default text’,
font_size=100,
font_name=‘Courier New’, bold = True,
font_color=‘black’,
background_color=‘white’,
border_color=‘white’,
border_stroke_width=4,
textgrid_shape=[9,1], # 20 cols (20 chars wide)
# by 4 rows (4 lines of text)
pos=(0.28,0),) # 20 cols (20 chars wide)
# by 4 rows (4 lines of text))
Target = visual.TextBox(window=win, name=‘Target’,
text=‘default text’,
font_size=100,
font_name=‘Courier New’, bold = True,
#font=1,
font_color=‘black’,
background_color=‘white’,
border_color=‘white’,
border_stroke_width=4,
textgrid_shape=[9,1], # 20 cols (20 chars wide)
# by 4 rows (4 lines of text)
pos=(0.28,0),) # 20 cols (20 chars wide)
# by 4 rows (4 lines of text))
#Target = visual.TextStim(win=win, ori=0, name=‘Target’,
text=‘default text’, font=‘Arial’,
pos=[0, 0], height=0.2, wrapWidth=None,
color=[-1.000,-1.000,-1.000], colorSpace=‘rgb’, opacity=1,
depth=-3.0)
jitter = visual.TextStim(win=win, ori=0, name=‘jitter’,
text=’’, font=‘Arial’,
pos=[0, 0], height=0.1, wrapWidth=None,
color=‘black’, colorSpace=‘rgb’, opacity=1,
depth=-4.0)
jitter2 = visual.TextBox(window=win, name=‘Target’,
text=’’,
font_size=100,
font_name=‘Courier New’, bold = True,
#font=1,
font_color=‘black’,
background_color=‘white’,
border_color=‘white’,
border_stroke_width=4,
textgrid_shape=[9,1], # 20 cols (20 chars wide)
# by 4 rows (4 lines of text)
pos=(0.18,0),) # 20 cols (20 chars wide)
# by 4 rows (4 lines of text))
Initialize components for Routine “testJitter”
testJitterClock = core.Clock()
Jitter = visual.TextStim(win=win, ori=0, name=‘Jitter’,
text=’’, font=‘Arial’,
pos=[0, 0], height=0.1, wrapWidth=None,
color=‘black’, colorSpace=‘rgb’, opacity=1,
depth=0.0)
Create some handy timers
globalClock = core.Clock() # to track the time since experiment started
routineTimer = core.CountdownTimer() # to track time remaining of each (non-slip) routine
set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=1, method=‘sequential’,
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions(‘Stimuli\last1_1.xlsx’),
seed=None, name=‘trials’)
thisExp.addLoop(trials) # add the loop to the experiment
thisTrial = trials.trialList[0] # so we can initialise stimuli with some values
abbreviate parameter names if possible (e.g. rgb=thisTrial.rgb)
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + ‘= thisTrial.’ + paramName)
for thisTrial in trials:
currentLoop = trials
# abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + ‘= thisTrial.’ + paramName)
#------Prepare to start Routine "testBB"-------
t = 0
testBBClock.reset() # clock
frameN = -1
routineTimer.add(4.580000)
# update component parameters for each repeat
bb_rt = []
bb_timer = core.Clock()
bb_status = NOT_STARTED
gotResponse = False
theseKeys=[]
theseRTs=[]
Prime.setText(prime)
Target.setText(target)
# keep track of which components have finished
testBBComponents = []
testBBComponents.append(hashtags)
testBBComponents.append(Prime)
testBBComponents.append(Target)
testBBComponents.append(jitter)
for thisComponent in testBBComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#-------Start Routine "testBB"-------
continueRoutine = True
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = testBBClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
if frameN == 34 and buttonBox.is_response_device() and bb_status == NOT_STARTED:
bb_timer.reset()
bb_status = STARTED
buttonBox.poll_for_response()
while len(buttonBox.response_queue):
buttonBox.clear_response_queue()
buttonBox.poll_for_response()
if bb_status == STARTED and frameN >= 154: # 35+120=156
bb_status = STOPPED
if bb_status == STARTED:
theseKeys=[]
theseRTs=[]
buttonBox.poll_for_response()
while len(buttonBox.response_queue):
evt = buttonBox.get_next_response()
if evt['pressed']:
theseRTs.append(bb_timer.getTime())
bb_rt = theseRTs[0]
gotResponse = True
bb_status = STOPPED
#continueRoutine=False
buttonBox.poll_for_response()
buttonBox.clear_response_queue()
# *hashtags* updates
if frameN >= 0 and hashtags.status == NOT_STARTED:
# keep track of start time/frame for later
hashtags.tStart = t # underestimates by a little under one frame
hashtags.frameNStart = frameN # exact frame index
hashtags.setAutoDraw(True)
if hashtags.status == STARTED and frameN >= (hashtags.frameNStart + 30):
hashtags.setAutoDraw(False)
# *Prime* updates
if frameN >= 31: #and Prime.status == NOT_STARTED:
# keep track of start time/frame for later
Prime.tStart = t # underestimates by a little under one frame
Prime.frameNStart = frameN # exact frame index
#Prime.setAutoDraw(True)
Prime.draw()
if Prime.status == STARTED and frameN >= (Prime.frameNStart + 50):
Prime.setAutoDraw(False)
# *Target* updates
if frameN >= 34:
# keep track of start time/frame for later
Target.tStart = t # underestimates by a little under one frame
Target.frameNStart = frameN # exact frame index
Target.draw()
#if Target.status == STARTED and frameN >= (Target.frameNStart + 180):
# Target.setAutoDraw(False)
# *jitter* updates
if frameN >= 153 and jitter.status == NOT_STARTED:
# keep track of start time/frame for later
jitter.tStart = t # underestimates by a little under one frame
jitter.frameNStart = frameN # exact frame index
jitter.setAutoDraw(True)
if jitter.status == STARTED and frameN >= (jitter.frameNStart + 1):
jitter.setAutoDraw(False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in testBBComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# check for quit (the Esc key)
if endExpNow or event.getKeys(keyList=["escape"]):
core.quit()
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
#-------Ending Routine “testBB”-------
for thisComponent in testBBComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
if gotResponse:
thisExp.addData('bb_rt',bb_rt)
reactionTime = round(bb_rt,10)
else:
thisExp.addData('bb_rt','None')
reactionTime = 0.0
#------Prepare to start Routine "testJitter"-------
t = 0
testJitterClock.reset() # clock
frameN = -1
routineTimer.add(2.000000)
# update component parameters for each repeat
#Jitter.setText(reactionTime)
# keep track of which components have finished
testJitterComponents = []
testJitterComponents.append(Jitter)
for thisComponent in testJitterComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#-------Start Routine "testJitter"-------
continueRoutine = True
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = testJitterClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *Jitter* updates
if t >= 0 and Jitter.status == NOT_STARTED:
# keep track of start time/frame for later
Jitter.tStart = t # underestimates by a little under one frame
Jitter.frameNStart = frameN # exact frame index
Jitter.setAutoDraw(True)
if Jitter.status == STARTED and t >= (0 + (2-win.monitorFramePeriod*0.75)): #most of one frame period left
Jitter.setAutoDraw(False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in testJitterComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# check for quit (the Esc key)
if endExpNow or event.getKeys(keyList=["escape"]):
core.quit()
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
#-------Ending Routine "testJitter"-------
for thisComponent in testJitterComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
thisExp.nextEntry()
completed 1 repeats of ‘trials’
these shouldn’t be strictly necessary (should auto-save)
thisExp.saveAsWideText(filename+’.csv’)
thisExp.saveAsPickle(filename)
logging.flush()
make sure everything is closed down
thisExp.abort() # or data files will save again on exit
win.close()
core.quit()
Does anyone have any idea what I need to do?
I think we’d need to try it. Please could you make the repository public or upload the psyexp file,
Is the issue that more recent versions don’t support the SV-1?
50ms last 1.psyexp (1.7 KB)
50ms_last1_1.py (14.6 KB)
You can open the PY file in PsychoPy Coder version 1.83.04.
The SV-1 supports this version with a downloaded USB driver. That’s what I did.
What confuses me the most is that the data is well saved in Excel after the experiment as if the words were displayed.
Thanks for the support.