Dear all,
I created a program in psychopy that includes several routines in which e.g. pictures and rating scales are presented. In addition, I use this psychpy program to control an external device for applying heat stimuli to the subject's skin. All works fine for a couple of trials but after around 5 trials the program freezes and can only be escaped by pressing alt + cmd + esc. The program not always freezes in the same trial or at the same time/routine. However, it seems to be somehow time dependent. That means if I speed up the program be answering the rating scales (two per trial) quickly instead of waiting for the maximum time allowed, the program runs through some more trials. For me it sounds possibly like a memory or buffer problem, but I have no idea where to look. In order to find the problem, I removed all parts from the program, which were in my opinion most likely causing this (i.e. some movies and an interval with quiet a lot of communication via the serial port). But unfortunately the problem persist. As I have no idea what might cause the freezing of the program, I copied the whole scripted compiled with the builder below. I'm using the builder in psychopy v1.78.01 on mac os x v10.6.8.
Any help would be highly appreciated as I'm stuck...
Susanne
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This experiment was created using PsychoPy2 Experiment Builder (v1.78.01), Tue Feb 4 22:00:26 2014
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 visual, core, data, event, logging, sound, gui
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
# Store info about the experiment session
expName = u'WOWPainRelief_7woMovies' # from the Builder filename that created this script
expInfo = {u'session': u'', 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
# 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'])
logFile = logging.LogFile(filename+'.log', level=logging.EXP)
logging.console.setLevel(logging.WARNING) # this outputs to the screen, not a file
# 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)
# Setup the Window
win = visual.Window(size=(1280, 800), fullscr=True, screen=0, allowGUI=True, allowStencil=False,
monitor='testMonitor', color=[255,255,255], colorSpace='rgb')
# 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 "thermode_ini"
thermode_iniClock = core.Clock()
import serial
serPort = serialPort = serial.Serial('/dev/tty.PL2303-00001004', baudrate=9600, bytesize=8, parity='N',stopbits=1, timeout=0.0001, xonxoff = True)
# Thermode calibration presets assessed with the Cal4 program - UPDATE FOR CURRENT THERMODE!!!
# Thermode 25 x 50 - No. xxx
# *** DO NOT USE CAPS for hex values!!! ***
Gcal = 'G194' # Offset DA temp - G 404 = 194
Hcal = 'H1bb' # Scale DA temp - H 44.3 = 1bb
Ocal = 'O003' # Offset DA Slope- O 3 = 003
Ncal = 'N1ae' # Scale DA Slope- N 430 = 1ae
Kcal = 'K261' # Offset AD temp - K 609 = 261
Lcal = 'L1c7' # Scale AD temp - L 45.5 = 1c7
#start settinggs Thermode
baselinetemp = 'B17c'
stimulustemp = 'T1cc' #46°C
stimulustemp_dec = 460 # = 46.0 * 100 for convertion to hex
rtc_stimulus = 'S05a' # = 9deg/sec
rtc_baseline = 'R05a' # = 9deg/sec
thermode_delay = 0.05 #Delay between sequential polling
thermal_stim_delay = 0.1 # Delay for fine-tuning the time course of thermal stimulus
# Thermode control codes
getT = 'M000' #Get temperature from MSA
goB = 'C000' # Goto baseline B with slope R
goT = 'C002' # Goto stimulus T with slope S
goTB = 'C003' # Goto stimulus T wait and return to baseline
getV1 = 'M006' # Get VAS1 from MSA
get2 = 'M007' # Get VAS2 from MSA
stimulustemp_dec = 460 # = 46.0 * 100 for convertion to hex
outcome_temp_win = 'T'+hex(stimulustemp_dec - 30)[2:]
outcome_temp_lose = 'T'+hex(stimulustemp_dec + 20)[2:]
up = 3
down = 3
start = visual.TextStim(win=win, ori=0, name='start',
text=None, font='Arial',
pos=[0, 0], height=0.1, wrapWidth=None,
color='black', colorSpace='rgb', opacity=1,
depth=-1.0)
# Initialize components for Routine "trial"
trialClock = core.Clock()
wait = visual.TextStim(win=win, ori=0, name='wait',
text='Bereit machen...', font='Calibri',
pos=[0, 0], height=0.3, wrapWidth=None,
color='black', colorSpace='rgb', opacity=1,
depth=-1.0)
memorize = visual.TextStim(win=win, ori=0, name='memorize',
text='Jetzt Temperatur einpraegen', font='Calibri',
pos=[0, 0], height=0.1, wrapWidth=None,
color='black', colorSpace='rgb', opacity=1,
depth=-2.0)
chose = visual.TextStim(win=win, ori=0, name='chose',
text='Farbe waehlen: pink <1> blau <2>', font='Calibri',
pos=[0,0.9], height=0.1, wrapWidth=None,
color='black', colorSpace='rgb', opacity=1,
depth=-4.0)
button_pink = visual.Rect(win=win, name='button_pink',
width=[0.1, 0.15][0], height=[0.1, 0.15][1],
ori=0, pos=[-0.2, -0.8],
lineWidth=3, lineColor=[-1,-1,-1], lineColorSpace='rgb',
fillColor='Fuchsia', fillColorSpace='rgb',
opacity=1.0,interpolate=True)
button_blue = visual.Rect(win=win, name='button_blue',
width=[0.1, 0.15][0], height=[0.1, 0.15][1],
ori=0, pos=[0.2,-0.8],
lineWidth=3, lineColor=[-1,-1,-1], lineColorSpace='rgb',
fillColor='DodgerBlue', fillColorSpace='rgb',
opacity=1.0,interpolate=True)
button_black = visual.Rect(win=win, name='button_black',
width=[0.1, 0.15][0], height=[0.1, 0.15][1],
ori=0, pos=[0, -0.8],
lineWidth=1, lineColor='black', lineColorSpace='rgb',
fillColor='black', fillColorSpace='rgb',
opacity=1.0,interpolate=True)
image = visual.ImageStim(win=win, name='image',
image='/Users/experiment/Documents/WOWPainRelief_newZI/WheelDisplay.JPG', mask=None,
ori=0, pos=[0, 0], size=None,
color=[1,1,1], colorSpace='rgb', opacity=1,
texRes=128, interpolate=True, depth=-8.0)
showselection_pink = visual.Rect(win=win, name='showselection_pink',
width=[0.1, 0.15][0], height=[0.1, 0.15][1],
ori=0, pos=[-0.2, -0.8],
lineWidth=10, lineColor='Gold', lineColorSpace='rgb',
fillColor='Fuchsia', fillColorSpace='rgb',
opacity=1.0,interpolate=True)
showselection_blue = visual.Rect(win=win, name='showselection_blue',
width=[0.1, 0.15][0], height=[0.1, 0.15][1],
ori=0, pos=[0.2, -0.8],
lineWidth=10, lineColor='Gold', lineColorSpace='rgb',
fillColor='DodgerBlue', fillColorSpace='rgb',
opacity=1.0,interpolate=True)
showselection_black = visual.Rect(win=win, name='showselection_black',
width=[0.1, 0.15][0], height=[0.1, 0.15][1],
ori=0, pos=[0, -0.8],
lineWidth=10, lineColor='Gold', lineColorSpace='rgb',
fillColor='black', fillColorSpace='rgb',
opacity=1.0,interpolate=True)
# Initialize components for Routine "outcome"
outcomeClock = core.Clock()
outcome_win = visual.TextStim(win=win, ori=0, name='outcome_win',
text='Gewonnen!', font='Calibri',
pos=[0, 0], height=0.2, wrapWidth=None,
color='black', colorSpace='rgb', opacity=1.0,
depth=-1.0)
outcome_loss = visual.TextStim(win=win, ori=0, name='outcome_loss',
text='Verloren!', font='Calibri',
pos=[0, 0], height=0.2, wrapWidth=None,
color='black', colorSpace='rgb', opacity=1.0,
depth=-2.0)
outcome_neut = visual.TextStim(win=win, ori=0, name='outcome_neut',
text=None, font='calibri',
pos=[0, 0], height=0.1, wrapWidth=None,
color='black', colorSpace='rgb', opacity=1.0,
depth=-3.0)
# Initialize components for Routine "VAS_intensity_2"
VAS_intensity_2Clock = core.Clock()
VASIntensity = visual.RatingScale(win=win, name='VASIntensity', scale='Reizintensitaet',
low=0,
high=10,
showAnchors=True,
tickMarks=[0,5,10],
labels=['keine Empfindung', 'Schmerzschwelle','staerkster vorstellebarer Schmerz'],
precision =1,
showValue=False,
showAccept=False,
acceptKeys=['space'],
leftKeys=['1'],
rightKeys=['2'],
lineColor='black',
ticksAboveLine=False,
markerStyle='slider',
markerColor='DarkRed',
markerStart=5,
pos=(0,0),
stretchHoriz=2,
disappear=True)
# Initialize components for Routine "VAS_UnAngenehm"
VAS_UnAngenehmClock = core.Clock()
VASUnangenehm = visual.RatingScale(win=win, name='VASUnangenehm', scale='unangenehm/angenehm',
low=-5,
high=5,
showAnchors=True,
tickMarks=[-5,0,5],
labels=['extrem unangenehm', 'neutral','extrem angenehm'],
precision =1,
showValue=False,
showAccept=False,
acceptKeys=['space'],
leftKeys=['1'],
rightKeys=['2'],
lineColor='black',
ticksAboveLine=False,
markerStyle='slider',
markerColor='DarkRed',
markerStart=0,
pos=(0,0),
stretchHoriz=2,
disappear=True)
# Initialize components for Routine "end_trial"
end_trialClock = core.Clock()
end = visual.TextStim(win=win, ori=0, name='end',
text='warten...\r\n', font='Calibri',
pos=[0, 0], height=0.1, wrapWidth=None,
color='black', colorSpace='rgb', opacity=1,
depth=-1.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
#------Prepare to start Routine "thermode_ini"-------
t = 0
thermode_iniClock.reset() # clock
frameN = -1
routineTimer.add(0.500000)
# update component parameters for each repeat
serPort.write(Gcal)
print serPort.readline()
core.wait(thermode_delay)
serPort.write(Hcal)
core.wait(thermode_delay)
print serPort.readline()
serPort.write(Ocal)
core.wait(thermode_delay)
print serPort.readline()
serPort.write(Ncal)
core.wait(thermode_delay)
print serPort.readline()
serPort.write(Kcal)
core.wait(thermode_delay)
print serPort.readline()
serPort.write(Lcal)
print serPort.readline()
core.wait(thermode_delay)
serPort.write(baselinetemp)
print serPort.readline()
core.wait(thermode_delay)
serPort.write(stimulustemp)
print serPort.readline()
core.wait(thermode_delay)
serPort.write(rtc_stimulus)
print serPort.readline()
core.wait(thermode_delay)
serPort.write(rtc_baseline)
print serPort.readline()
core.wait(thermode_delay)
serPort.write(goB)
core.wait(thermode_delay)
print serPort.readline()
# keep track of which components have finished
thermode_iniComponents = []
thermode_iniComponents.append(start)
for thisComponent in thermode_iniComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#-------Start Routine "thermode_ini"-------
continueRoutine = True
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = thermode_iniClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
lastCall = 0
if t>(lastCall+1.5):
serPort.write(getT)
lastCall = t
# *start* updates
if t >= 0.0 and start.status == NOT_STARTED:
# keep track of start time/frame for later
start.tStart = t # underestimates by a little under one frame
start.frameNStart = frameN # exact frame index
start.setAutoDraw(True)
elif start.status == STARTED and t >= (0.0 + 0.5):
start.setAutoDraw(False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineTimer.reset() # if we abort early the non-slip timer needs reset
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in thermode_iniComponents:
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 event.getKeys(["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 "thermode_ini"-------
for thisComponent in thermode_iniComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
# set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=24, method='sequential',
extraInfo=expInfo, originPath=None,
trialList=data.importConditions('trialorder.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 "trial"-------
t = 0
trialClock.reset() # clock
frameN = -1
routineTimer.add(3.500000)
# update component parameters for each repeat
serPort.write(getT)
print serPort.readline()
core.wait(thermal_stim_delay)
serPort.write(goT)
print serPort.readline()
button_pink.setOpacity(0)
button_blue.setOpacity(0)
button_black.setOpacity(0)
button_choice = event.BuilderKeyResponse() # create an object of type KeyResponse
button_choice.status = NOT_STARTED
showselection_pink.setOpacity(0)
showselection_blue.setOpacity(0)
showselection_black.setOpacity(0)
# keep track of which components have finished
trialComponents = []
trialComponents.append(wait)
trialComponents.append(memorize)
trialComponents.append(chose)
trialComponents.append(button_pink)
trialComponents.append(button_blue)
trialComponents.append(button_black)
trialComponents.append(image)
trialComponents.append(button_choice)
trialComponents.append(showselection_pink)
trialComponents.append(showselection_blue)
trialComponents.append(showselection_black)
for thisComponent in trialComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#-------Start Routine "trial"-------
continueRoutine = True
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = trialClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
lastCall = 0
if t>(lastCall+1.0):
serPort.write(getT)
lastCall = t
# *wait* updates
if t >= 0.0 and wait.status == NOT_STARTED:
# keep track of start time/frame for later
wait.tStart = t # underestimates by a little under one frame
wait.frameNStart = frameN # exact frame index
wait.setAutoDraw(True)
elif wait.status == STARTED and t >= (0.0 + 0.5):
wait.setAutoDraw(False)
# *memorize* updates
if t >= 0.5 and memorize.status == NOT_STARTED:
# keep track of start time/frame for later
memorize.tStart = t # underestimates by a little under one frame
memorize.frameNStart = frameN # exact frame index
memorize.setAutoDraw(True)
elif memorize.status == STARTED and t >= (0.5 + 0.5):
memorize.setAutoDraw(False)
if condition=='test':
button_pink.setOpacity(1)
button_blue.setOpacity(1)
elif condition=='control':
button_black.setOpacity(1)
# *chose* updates
if t >= 1 and chose.status == NOT_STARTED:
# keep track of start time/frame for later
chose.tStart = t # underestimates by a little under one frame
chose.frameNStart = frameN # exact frame index
chose.setAutoDraw(True)
elif chose.status == STARTED and t >= (1 + 2.0):
chose.setAutoDraw(False)
# *button_pink* updates
if t >= 1 and button_pink.status == NOT_STARTED:
# keep track of start time/frame for later
button_pink.tStart = t # underestimates by a little under one frame
button_pink.frameNStart = frameN # exact frame index
button_pink.setAutoDraw(True)
elif button_pink.status == STARTED and t >= (1 + 2.0):
button_pink.setAutoDraw(False)
# *button_blue* updates
if t >= 1 and button_blue.status == NOT_STARTED:
# keep track of start time/frame for later
button_blue.tStart = t # underestimates by a little under one frame
button_blue.frameNStart = frameN # exact frame index
button_blue.setAutoDraw(True)
elif button_blue.status == STARTED and t >= (1 + 2.0):
button_blue.setAutoDraw(False)
# *button_black* updates
if t >= 1 and button_black.status == NOT_STARTED:
# keep track of start time/frame for later
button_black.tStart = t # underestimates by a little under one frame
button_black.frameNStart = frameN # exact frame index
button_black.setAutoDraw(True)
elif button_black.status == STARTED and t >= (1 + 2):
button_black.setAutoDraw(False)
# *image* updates
if t >= 1 and image.status == NOT_STARTED:
# keep track of start time/frame for later
image.tStart = t # underestimates by a little under one frame
image.frameNStart = frameN # exact frame index
image.setAutoDraw(True)
elif image.status == STARTED and t >= (1 + 2.5):
image.setAutoDraw(False)
# *button_choice* updates
if t >= 1.0 and button_choice.status == NOT_STARTED:
# keep track of start time/frame for later
button_choice.tStart = t # underestimates by a little under one frame
button_choice.frameNStart = frameN # exact frame index
button_choice.status = STARTED
# keyboard checking is just starting
button_choice.clock.reset() # now t=0
event.clearEvents()
elif button_choice.status == STARTED and t >= (1.0 + 2.0):
button_choice.status = STOPPED
if button_choice.status == STARTED:
theseKeys = event.getKeys(keyList=['1', '2', '3'])
if len(theseKeys) > 0: # at least one key was pressed
button_choice.keys = theseKeys[-1] # just the last key pressed
button_choice.rt = button_choice.clock.getTime()
if button_choice.keys=='1': showselection_pink.setOpacity(1)
elif button_choice.keys=='2': showselection_blue.setOpacity(1)
elif button_choice.keys=='3': showselection_black.setOpacity(1)
# *showselection_pink* updates
if t >= 3.0 and showselection_pink.status == NOT_STARTED:
# keep track of start time/frame for later
showselection_pink.tStart = t # underestimates by a little under one frame
showselection_pink.frameNStart = frameN # exact frame index
showselection_pink.setAutoDraw(True)
elif showselection_pink.status == STARTED and t >= (3.0 + 0.5):
showselection_pink.setAutoDraw(False)
# *showselection_blue* updates
if t >= 3.0 and showselection_blue.status == NOT_STARTED:
# keep track of start time/frame for later
showselection_blue.tStart = t # underestimates by a little under one frame
showselection_blue.frameNStart = frameN # exact frame index
showselection_blue.setAutoDraw(True)
elif showselection_blue.status == STARTED and t >= (3.0 + 0.5):
showselection_blue.setAutoDraw(False)
# *showselection_black* updates
if t >= 3.0 and showselection_black.status == NOT_STARTED:
# keep track of start time/frame for later
showselection_black.tStart = t # underestimates by a little under one frame
showselection_black.frameNStart = frameN # exact frame index
showselection_black.setAutoDraw(True)
elif showselection_black.status == STARTED and t >= (3.0 + 0.5):
showselection_black.setAutoDraw(False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineTimer.reset() # if we abort early the non-slip timer needs reset
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in trialComponents:
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 event.getKeys(["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 "trial"-------
for thisComponent in trialComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
serPort.write(getT)
# check responses
if len(button_choice.keys) == 0: # No response was made
button_choice.keys=None
# store data for trials (TrialHandler)
trials.addData('button_choice.keys',button_choice.keys)
if button_choice.keys != None: # we had a response
trials.addData('button_choice.rt', button_choice.rt)
#------Prepare to start Routine "outcome"-------
t = 0
outcomeClock.reset() # clock
frameN = -1
routineTimer.add(4.000000)
# update component parameters for each repeat
serPort.write(getT)
core.wait(thermode_delay)
if outcome=='win':
serPort.write(outcome_temp_win)
#core.wait(thermode_delay)
print serPort.readline()
if outcome=='lose':
serPort.write(outcome_temp_lose)
#core.wait(thermode_delay)
print serPort.readline()
if button_choice.keys=='1':
if outcome=='win':
outcome_win.setOpacity(1)
outcome_win.setText(outcome_win.text)
outcome_loss.setOpacity(0)
outcome_loss.setText(outcome_loss.text)
elif outcome=='lose':
outcome_loss.setOpacity(1)
outcome_loss.setText(outcome_loss.text)
outcome_win.setOpacity(0)
outcome_win.setText(outcome_win.text)
elif outcome=='neut':
outcome_loss.setOpacity(0)
outcome_loss.setText(outcome_loss.text)
outcome_win.setOpacity(0)
outcome_win.setText(outcome_win.text)
elif button_choice.keys=='2':
if outcome=='win':
outcome_win.setOpacity(1)
outcome_win.setText(outcome_win.text)
outcome_loss.setOpacity(0)
outcome_loss.setText(outcome_win.text)
elif outcome=='lose':
outcome_loss.setOpacity(1)
outcome_loss.setText(outcome_loss.text)
outcome_win.setOpacity(0)
outcome_win.setText(outcome_win.text)
elif outcome=='neut':
outcome_loss.setOpacity(0)
outcome_loss.setText(outcome_loss.text)
outcome_win.setOpacity(0)
outcome_win.setText(outcome_win.text)
else:
outcome_win.setOpacity(0)
outcome_win.setText(outcome_win.text)
outcome_loss.setOpacity(0)
outcome_loss.setText(outcome_loss.text)
serPort.write(goT)
print serPort.readline()
outcome_win.setOpacity(0)
outcome_loss.setOpacity(0)
outcome_neut.setOpacity(1)
# keep track of which components have finished
outcomeComponents = []
outcomeComponents.append(outcome_win)
outcomeComponents.append(outcome_loss)
outcomeComponents.append(outcome_neut)
for thisComponent in outcomeComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#-------Start Routine "outcome"-------
continueRoutine = True
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = outcomeClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
lastCall = 0
if t>(lastCall+1.0):
serPort.write(getT)
lastCall = t
# *outcome_win* updates
if t >= 0.0 and outcome_win.status == NOT_STARTED:
# keep track of start time/frame for later
outcome_win.tStart = t # underestimates by a little under one frame
outcome_win.frameNStart = frameN # exact frame index
outcome_win.setAutoDraw(True)
elif outcome_win.status == STARTED and t >= (0.0 + 4):
outcome_win.setAutoDraw(False)
# *outcome_loss* updates
if t >= 0.0 and outcome_loss.status == NOT_STARTED:
# keep track of start time/frame for later
outcome_loss.tStart = t # underestimates by a little under one frame
outcome_loss.frameNStart = frameN # exact frame index
outcome_loss.setAutoDraw(True)
elif outcome_loss.status == STARTED and t >= (0.0 + 4):
outcome_loss.setAutoDraw(False)
# *outcome_neut* updates
if t >= 0.0 and outcome_neut.status == NOT_STARTED:
# keep track of start time/frame for later
outcome_neut.tStart = t # underestimates by a little under one frame
outcome_neut.frameNStart = frameN # exact frame index
outcome_neut.setAutoDraw(True)
elif outcome_neut.status == STARTED and t >= (0.0 + 4):
outcome_neut.setAutoDraw(False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineTimer.reset() # if we abort early the non-slip timer needs reset
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in outcomeComponents:
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 event.getKeys(["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 "outcome"-------
for thisComponent in outcomeComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
print serPort.readline()
serPort.write(getT)
#------Prepare to start Routine "VAS_intensity_2"-------
t = 0
VAS_intensity_2Clock.reset() # clock
frameN = -1
routineTimer.add(5.000000)
# update component parameters for each repeat
serPort.write(getT)
VASIntensity.reset()
# keep track of which components have finished
VAS_intensity_2Components = []
VAS_intensity_2Components.append(VASIntensity)
for thisComponent in VAS_intensity_2Components:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#-------Start Routine "VAS_intensity_2"-------
continueRoutine = True
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = VAS_intensity_2Clock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
lastCall = 0
if t>(lastCall+1.0):
serPort.write(getT)
lastCall = t
# *VASIntensity* updates
if t > 0.0:
VASIntensity.draw()
continueRoutine = VASIntensity.noResponse
if VASIntensity.noResponse == False:
VASIntensity.response = VASIntensity.getRating()
VASIntensity.rt = VASIntensity.getRT()
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineTimer.reset() # if we abort early the non-slip timer needs reset
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in VAS_intensity_2Components:
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 event.getKeys(["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 "VAS_intensity_2"-------
for thisComponent in VAS_intensity_2Components:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
serPort.write(getT)
trials.addData('VASIntensity.response', VASIntensity.getRating())
trials.addData('VASIntensity.rt', VASIntensity.getRT())
#------Prepare to start Routine "VAS_UnAngenehm"-------
t = 0
VAS_UnAngenehmClock.reset() # clock
frameN = -1
routineTimer.add(5.000000)
# update component parameters for each repeat
serPort.write(getT)
VASUnangenehm.reset()
# keep track of which components have finished
VAS_UnAngenehmComponents = []
VAS_UnAngenehmComponents.append(VASUnangenehm)
for thisComponent in VAS_UnAngenehmComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#-------Start Routine "VAS_UnAngenehm"-------
continueRoutine = True
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = VAS_UnAngenehmClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
lastCall = 0
if t>(lastCall+1.0):
serPort.write(getT)
lastCall = t
# *VASUnangenehm* updates
if t > 0.0:
VASUnangenehm.draw()
continueRoutine = VASUnangenehm.noResponse
if VASUnangenehm.noResponse == False:
VASUnangenehm.response = VASUnangenehm.getRating()
VASUnangenehm.rt = VASUnangenehm.getRT()
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineTimer.reset() # if we abort early the non-slip timer needs reset
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in VAS_UnAngenehmComponents:
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 event.getKeys(["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 "VAS_UnAngenehm"-------
for thisComponent in VAS_UnAngenehmComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
serPort.write(getT)
trials.addData('VASUnangenehm.response', VASUnangenehm.getRating())
trials.addData('VASUnangenehm.rt', VASUnangenehm.getRT())
#------Prepare to start Routine "end_trial"-------
t = 0
end_trialClock.reset() # clock
frameN = -1
routineTimer.add(5.000000)
# update component parameters for each repeat
serPort.write(getT)
core.wait(thermode_delay)
print serPort.readline()
serPort.write(stimulustemp)
print serPort.readline()
core.wait(thermode_delay)
# keep track of which components have finished
end_trialComponents = []
end_trialComponents.append(end)
for thisComponent in end_trialComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#-------Start Routine "end_trial"-------
continueRoutine = True
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = end_trialClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
lastCall = 0
if t>(lastCall+1.0):
serPort.write(getT)
lastCall = t
# *end* updates
if t >= 0.0 and end.status == NOT_STARTED:
# keep track of start time/frame for later
end.tStart = t # underestimates by a little under one frame
end.frameNStart = frameN # exact frame index
end.setAutoDraw(True)
elif end.status == STARTED and t >= (0.0 + 5.0):
end.setAutoDraw(False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineTimer.reset() # if we abort early the non-slip timer needs reset
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in end_trialComponents:
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 event.getKeys(["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 "end_trial"-------
for thisComponent in end_trialComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
serPort.write(getT)
serPort.flushInput()
serPort.flushOutput()
serPort.write(getT)
thisExp.nextEntry()
# completed 24 repeats of 'trials'
win.close()
core.quit()