audio_visual_congruence_lastrun.py 150 KB
Newer Older
1 2 3 4
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This experiment was created using PsychoPy3 Experiment Builder (v2020.1.3),
5
    on June 19, 2020, at 14:05
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
If you publish work using this script the most relevant publication is:

    Peirce J, Gray JR, Simpson S, MacAskill M, Höchenberger R, Sogo H, Kastman E, Lindeløv JK. (2019) 
        PsychoPy2: Experiments in behavior made easy Behav Res 51: 195. 
        https://doi.org/10.3758/s13428-018-01193-y

"""

from __future__ import absolute_import, division

from psychopy import locale_setup
from psychopy import prefs
prefs.hardware['audioLib'] = 'ptb'
from psychopy import sound, gui, visual, core, data, event, logging, clock
from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED,
                                STOPPED, FINISHED, PRESSED, RELEASED, FOREVER)

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

from psychopy.hardware import keyboard



# Ensure that relative paths start from the same directory as this script
_thisDir = os.path.dirname(os.path.abspath(__file__))
os.chdir(_thisDir)

# Store info about the experiment session
psychopyVersion = '2020.1.3'
expName = 'audio_visual_congruence'  # from the Builder filename that created this script
expInfo = {'participant': '', 'session': '001'}
dlg = gui.DlgFromDict(dictionary=expInfo, sortKeys=False, title=expName)
if dlg.OK == False:
    core.quit()  # user pressed cancel
expInfo['date'] = data.getDateStr()  # add a simple timestamp
expInfo['expName'] = expName
expInfo['psychopyVersion'] = psychopyVersion

# Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc
filename = _thisDir + os.sep + u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date'])

# An ExperimentHandler isn't essential but helps with data saving
thisExp = data.ExperimentHandler(name=expName, version='',
    extraInfo=expInfo, runtimeInfo=None,
    originPath='C:\\Users\\HP\\Documents\\Experiment_Pau\\audio_visual_congruence_lastrun.py',
    savePickle=True, saveWideText=True,
    dataFileName=filename)
# save a log file for detail verbose info
logFile = logging.LogFile(filename+'.log', level=logging.EXP)
logging.console.setLevel(logging.WARNING)  # this outputs to the screen, not a file

endExpNow = False  # flag for 'escape' or other condition => quit the exp
frameTolerance = 0.001  # how close to onset before 'same' frame

# Start Code - component code to be run before the window creation

# Setup the Window
win = visual.Window(
    size=[1536, 864], fullscr=True, screen=0, 
    winType='pyglet', allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=True, 
    units='height')
# store frame rate of monitor if we can measure it
expInfo['frameRate'] = win.getActualFrameRate()
if expInfo['frameRate'] != None:
    frameDur = 1.0 / round(expInfo['frameRate'])
else:
    frameDur = 1.0 / 60.0  # could not measure, so guess

# create a default keyboard (e.g. to check for escape)
defaultKeyboard = keyboard.Keyboard()

# Initialize components for Routine "Description_Consent"
Description_ConsentClock = core.Clock()
text_description_consent = visual.TextStim(win=win, name='text_description_consent',
    text='default text',
    font='Arial',
    pos=(0, 0), height=0.03, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
key_resp_description_consent = keyboard.Keyboard()

95 96 97
# Initialize components for Routine "EncodingInstructions"
EncodingInstructionsClock = core.Clock()
EncodinginstructionsText = visual.TextStim(win=win, name='EncodinginstructionsText',
Pau Alexander's avatar
Pau Alexander committed
98
    text="Step 1: Sound image pairs (Part 1/3)\n\nPlease set your volume up to at least 70%. Rate how well the sound and image pairs match together.\nPlease respond before the next image appears.\n\nRemember:\n1= Doesn't match at all.\n2= Doesn't match.\n3= More or less.\n4= Matches.\n5= Matches very well.\n\nPress any key to continue.\n",
99
    font='Arial',
100
    pos=(0, 0), height=0.04, wrapWidth=None, ori=0, 
101 102 103
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
104
key_respInstructions = keyboard.Keyboard()
105

106 107 108 109
# Initialize components for Routine "ISIEncoding"
ISIEncodingClock = core.Clock()
polygonIsiEncoding = visual.ShapeStim(
    win=win, name='polygonIsiEncoding', vertices='cross',
110 111 112 113 114 115
    size=(0.1, 0.1),
    ori=0, pos=(0, 0),
    lineWidth=0.25, lineColor=[1,1,1], lineColorSpace='rgb',
    fillColor=[1,1,1], fillColorSpace='rgb',
    opacity=1, depth=0.0, interpolate=True)

116 117 118 119
# Initialize components for Routine "trialEncoding"
trialEncodingClock = core.Clock()
responseEncoding = keyboard.Keyboard()
imageEncoding = visual.ImageStim(
120
    win=win,
121
    name='imageEncoding', 
122 123 124 125 126
    image='sin', mask=None,
    ori=0, pos=(0, 0), size=(0.5, 0.5),
    color=[1,1,1], colorSpace='rgb', opacity=1,
    flipHoriz=False, flipVert=False,
    texRes=128, interpolate=True, depth=-1.0)
127 128 129
sound_1Encoding = sound.Sound('A', secs=-1, stereo=True, hamming=True,
    name='sound_1Encoding')
sound_1Encoding.setVolume(1)
130 131 132 133

# Initialize components for Routine "feedback_in_loop_encodingpractice"
feedback_in_loop_encodingpracticeClock = core.Clock()
msg='doh!'#if this comes up we forgot to update the msg!
134
text_10EncodingPracticeFeedback = visual.TextStim(win=win, name='text_10EncodingPracticeFeedback',
135 136 137 138 139 140 141 142 143
    text='default text',
    font='Arial',
    pos=(0, 0), height=0.1, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-1.0);

# Initialize components for Routine "EncodingInstructionsReminder"
EncodingInstructionsReminderClock = core.Clock()
144
text_EncodingInstructionsReminder = visual.TextStim(win=win, name='text_EncodingInstructionsReminder',
145
    text="Did you hear the sounds well? If necessary, please adjust your volume to atleast 70%, and close any background aplications.\n\nRemember the instructions:\nRate how well the sound and image pairs match together.\nPlease respond before the next image appears.\n\n1= Doesn't match at all.\n2= Doesn't match.\n3= More or less.\n4= Matches.\n5= Matches very well.\n\nPress any key to continue.\n",
146
    font='Arial',
Pau Alexander's avatar
Pau Alexander committed
147
    pos=(0, 0), height=0.04, wrapWidth=None, ori=0, 
148 149 150
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
151
key_resp_EncodingInstructionsReminder = keyboard.Keyboard()
152

153 154 155 156
# Initialize components for Routine "ISIEncoding"
ISIEncodingClock = core.Clock()
polygonIsiEncoding = visual.ShapeStim(
    win=win, name='polygonIsiEncoding', vertices='cross',
157 158 159 160 161 162
    size=(0.1, 0.1),
    ori=0, pos=(0, 0),
    lineWidth=0.25, lineColor=[1,1,1], lineColorSpace='rgb',
    fillColor=[1,1,1], fillColorSpace='rgb',
    opacity=1, depth=0.0, interpolate=True)

163 164 165 166
# Initialize components for Routine "trialEncoding"
trialEncodingClock = core.Clock()
responseEncoding = keyboard.Keyboard()
imageEncoding = visual.ImageStim(
167
    win=win,
168
    name='imageEncoding', 
169 170 171 172 173
    image='sin', mask=None,
    ori=0, pos=(0, 0), size=(0.5, 0.5),
    color=[1,1,1], colorSpace='rgb', opacity=1,
    flipHoriz=False, flipVert=False,
    texRes=128, interpolate=True, depth=-1.0)
174 175 176
sound_1Encoding = sound.Sound('A', secs=-1, stereo=True, hamming=True,
    name='sound_1Encoding')
sound_1Encoding.setVolume(1)
177

178 179 180 181 182 183 184 185 186 187
# Initialize components for Routine "RespondFasterEncoding"
RespondFasterEncodingClock = core.Clock()
textRespondFasterEncoding = visual.TextStim(win=win, name='textRespondFasterEncoding',
    text='Respond faster please!',
    font='Arial',
    pos=(0, 0), height=0.1, wrapWidth=None, ori=0, 
    color='red', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-1.0);

Pau Alexander's avatar
Pau Alexander committed
188 189 190 191 192 193 194 195 196 197 198
# Initialize components for Routine "EncodingPause"
EncodingPauseClock = core.Clock()
TextBreakEncoding = visual.TextStim(win=win, name='TextBreakEncoding',
    text="Take a short break. \n\nRemember the instructions:\nRate how well the sound and image pairs match together.\nPlease respond before the next image appears.\n\n1= Doesn't match at all.\n2= Doesn't match.\n3= More or less.\n4= Matches.\n5= Matches very well.\n\nPlease press the 'space' bar when you are ready to continue.\n\n",
    font='Arial',
    pos=(0, 0), height=0.03, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-1.0);
key_resp_EncodingBreak = keyboard.Keyboard()

199 200
# Initialize components for Routine "Interval_task_instructions"
Interval_task_instructionsClock = core.Clock()
201
text_IntervalTaskInstructions = visual.TextStim(win=win, name='text_IntervalTaskInstructions',
202 203
    text='Step 2: Math Task (part 2/3)\n\nLook at the two numbers that appear.\nYou have three seconds to choose,\nwith the left or right arrow buttons,\nwhich is bigger.\n\nThe correct answer is flashed after each trial.\n\nPress any key to continue.\n',
    font='Arial',
204
    pos=(0, 0), height=0.04, wrapWidth=None, ori=0, 
205 206 207
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
208
key_resp_IntervalTaskInstructions = keyboard.Keyboard()
209 210 211

# Initialize components for Routine "interval_task"
interval_taskClock = core.Clock()
212
text_IntervalTask = visual.TextStim(win=win, name='text_IntervalTask',
213 214 215 216 217 218
    text='default text',
    font='Arial',
    pos=(0, 0), height=0.05, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
219
key_resp_IntervalTask = keyboard.Keyboard()
220 221 222 223

# Initialize components for Routine "interval_feedback"
interval_feedbackClock = core.Clock()
msg='doh!'#if this comes up we forgot to update the msg!
224
text_IntervalTaskFeedback = visual.TextStim(win=win, name='text_IntervalTaskFeedback',
225 226 227 228 229 230
    text='default text',
    font='Arial',
    pos=(0, 0), height=0.1, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-1.0);
231
key_resp_IntervalTaskFeedback = keyboard.Keyboard()
232 233 234

# Initialize components for Routine "DistractionInstructionsReminder"
DistractionInstructionsReminderClock = core.Clock()
235
text_IntervalInstructionsReminder = visual.TextStim(win=win, name='text_IntervalInstructionsReminder',
236 237
    text='Remember the instructions:\n\nLook at the two numbers that appear.\nYou have three seconds to choose,\nwith the left or right arrow buttons,\nwhich is bigger.\n\nThe correct answer is flashed after each trial.\n\nPress any key to continue.\n',
    font='Arial',
238
    pos=(0, 0), height=0.04, wrapWidth=None, ori=0, 
239 240 241
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
242
key_resp_IntervalInstructionsReminder = keyboard.Keyboard()
243 244 245

# Initialize components for Routine "interval_task"
interval_taskClock = core.Clock()
246
text_IntervalTask = visual.TextStim(win=win, name='text_IntervalTask',
247 248 249 250 251 252
    text='default text',
    font='Arial',
    pos=(0, 0), height=0.05, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
253
key_resp_IntervalTask = keyboard.Keyboard()
254 255 256 257

# Initialize components for Routine "interval_feedback"
interval_feedbackClock = core.Clock()
msg='doh!'#if this comes up we forgot to update the msg!
258
text_IntervalTaskFeedback = visual.TextStim(win=win, name='text_IntervalTaskFeedback',
259 260 261 262 263 264
    text='default text',
    font='Arial',
    pos=(0, 0), height=0.1, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-1.0);
265
key_resp_IntervalTaskFeedback = keyboard.Keyboard()
266

Pau Alexander's avatar
Pau Alexander committed
267 268
# Initialize components for Routine "TestInstructions"
TestInstructionsClock = core.Clock()
269
textTestInstructions = visual.TextStim(win=win, name='textTestInstructions',
Pau Alexander's avatar
Pau Alexander committed
270 271
    text='Step 3: Memory Test (part 3/3)\n\nNow you will see a series of images, for each image try to remember whether it appeared before during the first \nhalf of the experiment (old) or not (new).\n\nUsing a using a 6-point confidence scale with a keypress on 1 meaning you are sure it did not appear before (new), and 6 meaning you are sure it did appear during the first phase (old): \n1= sure new, 2= maybe new, 3= guess new,\n4= guess old, 5= maybe old, 6= sure old.\n\n\nPress any key to continue.',
    font='Arial',
272
    pos=(0, 0), height=0.04, wrapWidth=None, ori=0, 
Pau Alexander's avatar
Pau Alexander committed
273 274 275
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
276
key_resp_TestInstructions = keyboard.Keyboard()
Pau Alexander's avatar
Pau Alexander committed
277

278 279
# Initialize components for Routine "testtrial"
testtrialClock = core.Clock()
280 281
key_resp_TestTrial = keyboard.Keyboard()
image_TestTrial = visual.ImageStim(
282
    win=win,
283
    name='image_TestTrial', 
284 285 286 287 288 289 290 291 292
    image='sin', mask=None,
    ori=0, pos=(0, 0), size=(0.5, 0.5),
    color=[1,1,1], colorSpace='rgb', opacity=1,
    flipHoriz=False, flipVert=False,
    texRes=128, interpolate=True, depth=-1.0)

# Initialize components for Routine "test_feedback"
test_feedbackClock = core.Clock()
msg='doh!'#if this comes up we forgot to update the msg!
293
text_TestFeedback = visual.TextStim(win=win, name='text_TestFeedback',
294 295 296 297 298 299 300
    text='default text',
    font='Arial',
    pos=(0, 0), height=0.1, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-1.0);

Pau Alexander's avatar
Pau Alexander committed
301 302
# Initialize components for Routine "TestInstructionsReminder"
TestInstructionsReminderClock = core.Clock()
303
text_TestInstructionsReminder = visual.TextStim(win=win, name='text_TestInstructionsReminder',
Pau Alexander's avatar
Pau Alexander committed
304 305
    text='Remember the instructions:\n\nNow you will see a series of images, for each image try to remember whether it appeared before during the first \nhalf of the experiment (old) or not (new).\n\nUsing a using a 6-point confidence scale with a keypress on 1 meaning you are sure it did not appear before (new), and 6 meaning you are sure it did appear during the first phase (old): \n1= sure new, 2= maybe new, 3= guess new,\n4= guess old, 5= maybe old, 6= sure old.\n\n\nPress any key to continue.',
    font='Arial',
306
    pos=(0, 0), height=0.04, wrapWidth=None, ori=0, 
Pau Alexander's avatar
Pau Alexander committed
307 308 309
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
310
key_resp_TestInstructionsReminder = keyboard.Keyboard()
Pau Alexander's avatar
Pau Alexander committed
311

312 313
# Initialize components for Routine "testtrial"
testtrialClock = core.Clock()
314 315
key_resp_TestTrial = keyboard.Keyboard()
image_TestTrial = visual.ImageStim(
316
    win=win,
317
    name='image_TestTrial', 
318 319 320 321 322 323
    image='sin', mask=None,
    ori=0, pos=(0, 0), size=(0.5, 0.5),
    color=[1,1,1], colorSpace='rgb', opacity=1,
    flipHoriz=False, flipVert=False,
    texRes=128, interpolate=True, depth=-1.0)

324 325 326 327 328 329 330 331 332 333 334
# Initialize components for Routine "TestPause"
TestPauseClock = core.Clock()
text_TestPause = visual.TextStim(win=win, name='text_TestPause',
    text="Take a short break. \n\nRemember the instructions:\n\nNow you will see a series of images, for each image try to remember whether it appeared before during the first \nhalf of the experiment (old) or not (new).\n\nUsing a using a 6-point confidence scale with a keypress on 1 meaning you are sure it did not appear before (new), and 6 meaning you are sure it did appear during the first phase (old): \n1= sure new, 2= maybe new, 3= guess new,\n4= guess old, 5= maybe old, 6= sure old.\n\nPlease press the 'space' bar when you are ready to continue.\n\n",
    font='Arial',
    pos=(0, 0), height=0.03, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-1.0);
key_resp_TestPause = keyboard.Keyboard()

335 336
# Initialize components for Routine "Thanks"
ThanksClock = core.Clock()
337 338
text_Thanks = visual.TextStim(win=win, name='text_Thanks',
    text='Thank you very much for participating!\n\nThis was an experimental memory test, \ndesigned to see how congruency,\nbetween sound-images pairs,\ninfluences subsequent long-term memory.\n\nPress any key to end.',
339 340 341 342 343
    font='Arial',
    pos=(0, 0), height=0.05, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
344
key_resp_Thanks = keyboard.Keyboard()
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468

# 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('Consent_instructions.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:
        exec('{} = thisTrial[paramName]'.format(paramName))

for thisTrial in trials:
    currentLoop = trials
    # abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
    if thisTrial != None:
        for paramName in thisTrial:
            exec('{} = thisTrial[paramName]'.format(paramName))
    
    # ------Prepare to start Routine "Description_Consent"-------
    continueRoutine = True
    # update component parameters for each repeat
    text_description_consent.setText(Description_Consent)
    key_resp_description_consent.keys = []
    key_resp_description_consent.rt = []
    _key_resp_description_consent_allKeys = []
    # keep track of which components have finished
    Description_ConsentComponents = [text_description_consent, key_resp_description_consent]
    for thisComponent in Description_ConsentComponents:
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
    Description_ConsentClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
    frameN = -1
    
    # -------Run Routine "Description_Consent"-------
    while continueRoutine:
        # get current time
        t = Description_ConsentClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=Description_ConsentClock)
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
        
        # *text_description_consent* updates
        if text_description_consent.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
            # keep track of start time/frame for later
            text_description_consent.frameNStart = frameN  # exact frame index
            text_description_consent.tStart = t  # local t and not account for scr refresh
            text_description_consent.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(text_description_consent, 'tStartRefresh')  # time at next scr refresh
            text_description_consent.setAutoDraw(True)
        
        # *key_resp_description_consent* updates
        waitOnFlip = False
        if key_resp_description_consent.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
            # keep track of start time/frame for later
            key_resp_description_consent.frameNStart = frameN  # exact frame index
            key_resp_description_consent.tStart = t  # local t and not account for scr refresh
            key_resp_description_consent.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(key_resp_description_consent, 'tStartRefresh')  # time at next scr refresh
            key_resp_description_consent.status = STARTED
            # keyboard checking is just starting
            waitOnFlip = True
            win.callOnFlip(key_resp_description_consent.clock.reset)  # t=0 on next screen flip
            win.callOnFlip(key_resp_description_consent.clearEvents, eventType='keyboard')  # clear events on next screen flip
        if key_resp_description_consent.status == STARTED and not waitOnFlip:
            theseKeys = key_resp_description_consent.getKeys(keyList=['space'], waitRelease=False)
            _key_resp_description_consent_allKeys.extend(theseKeys)
            if len(_key_resp_description_consent_allKeys):
                key_resp_description_consent.keys = _key_resp_description_consent_allKeys[-1].name  # just the last key pressed
                key_resp_description_consent.rt = _key_resp_description_consent_allKeys[-1].rt
                # a response ends the routine
                continueRoutine = False
        
        # check for quit (typically the Esc key)
        if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
            core.quit()
        
        # 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 Description_ConsentComponents:
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished
        
        # refresh the screen
        if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
            win.flip()
    
    # -------Ending Routine "Description_Consent"-------
    for thisComponent in Description_ConsentComponents:
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
    trials.addData('text_description_consent.started', text_description_consent.tStartRefresh)
    trials.addData('text_description_consent.stopped', text_description_consent.tStopRefresh)
    # check responses
    if key_resp_description_consent.keys in ['', [], None]:  # No response was made
        key_resp_description_consent.keys = None
    trials.addData('key_resp_description_consent.keys',key_resp_description_consent.keys)
    if key_resp_description_consent.keys != None:  # we had a response
        trials.addData('key_resp_description_consent.rt', key_resp_description_consent.rt)
    trials.addData('key_resp_description_consent.started', key_resp_description_consent.tStartRefresh)
    trials.addData('key_resp_description_consent.stopped', key_resp_description_consent.tStopRefresh)
    # the Routine "Description_Consent" was not non-slip safe, so reset the non-slip timer
    routineTimer.reset()
    thisExp.nextEntry()
    
# completed 1 repeats of 'trials'


469
# ------Prepare to start Routine "EncodingInstructions"-------
470 471
continueRoutine = True
# update component parameters for each repeat
472 473 474
key_respInstructions.keys = []
key_respInstructions.rt = []
_key_respInstructions_allKeys = []
475
# keep track of which components have finished
476 477
EncodingInstructionsComponents = [EncodinginstructionsText, key_respInstructions]
for thisComponent in EncodingInstructionsComponents:
478 479 480 481 482 483 484 485 486
    thisComponent.tStart = None
    thisComponent.tStop = None
    thisComponent.tStartRefresh = None
    thisComponent.tStopRefresh = None
    if hasattr(thisComponent, 'status'):
        thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
487
EncodingInstructionsClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
488 489
frameN = -1

490
# -------Run Routine "EncodingInstructions"-------
491 492
while continueRoutine:
    # get current time
493 494
    t = EncodingInstructionsClock.getTime()
    tThisFlip = win.getFutureFlipTime(clock=EncodingInstructionsClock)
495 496 497 498
    tThisFlipGlobal = win.getFutureFlipTime(clock=None)
    frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
    # update/draw components on each frame
    
499 500
    # *EncodinginstructionsText* updates
    if EncodinginstructionsText.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
501
        # keep track of start time/frame for later
502 503 504 505 506
        EncodinginstructionsText.frameNStart = frameN  # exact frame index
        EncodinginstructionsText.tStart = t  # local t and not account for scr refresh
        EncodinginstructionsText.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(EncodinginstructionsText, 'tStartRefresh')  # time at next scr refresh
        EncodinginstructionsText.setAutoDraw(True)
507
    
508
    # *key_respInstructions* updates
509
    waitOnFlip = False
510
    if key_respInstructions.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
511
        # keep track of start time/frame for later
512 513 514 515 516
        key_respInstructions.frameNStart = frameN  # exact frame index
        key_respInstructions.tStart = t  # local t and not account for scr refresh
        key_respInstructions.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(key_respInstructions, 'tStartRefresh')  # time at next scr refresh
        key_respInstructions.status = STARTED
517 518
        # keyboard checking is just starting
        waitOnFlip = True
519 520 521 522 523 524 525 526
        win.callOnFlip(key_respInstructions.clock.reset)  # t=0 on next screen flip
        win.callOnFlip(key_respInstructions.clearEvents, eventType='keyboard')  # clear events on next screen flip
    if key_respInstructions.status == STARTED and not waitOnFlip:
        theseKeys = key_respInstructions.getKeys(keyList=None, waitRelease=False)
        _key_respInstructions_allKeys.extend(theseKeys)
        if len(_key_respInstructions_allKeys):
            key_respInstructions.keys = _key_respInstructions_allKeys[-1].name  # just the last key pressed
            key_respInstructions.rt = _key_respInstructions_allKeys[-1].rt
527 528 529 530 531 532 533 534 535 536 537
            # a response ends the routine
            continueRoutine = False
    
    # check for quit (typically the Esc key)
    if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
        core.quit()
    
    # 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
538
    for thisComponent in EncodingInstructionsComponents:
539 540 541 542 543 544 545 546
        if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
            continueRoutine = True
            break  # at least one component has not yet finished
    
    # refresh the screen
    if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
        win.flip()

547 548
# -------Ending Routine "EncodingInstructions"-------
for thisComponent in EncodingInstructionsComponents:
549 550
    if hasattr(thisComponent, "setAutoDraw"):
        thisComponent.setAutoDraw(False)
551 552
thisExp.addData('EncodinginstructionsText.started', EncodinginstructionsText.tStartRefresh)
thisExp.addData('EncodinginstructionsText.stopped', EncodinginstructionsText.tStopRefresh)
553
# check responses
554 555 556 557 558 559 560
if key_respInstructions.keys in ['', [], None]:  # No response was made
    key_respInstructions.keys = None
thisExp.addData('key_respInstructions.keys',key_respInstructions.keys)
if key_respInstructions.keys != None:  # we had a response
    thisExp.addData('key_respInstructions.rt', key_respInstructions.rt)
thisExp.addData('key_respInstructions.started', key_respInstructions.tStartRefresh)
thisExp.addData('key_respInstructions.stopped', key_respInstructions.tStopRefresh)
561
thisExp.nextEntry()
562
# the Routine "EncodingInstructions" was not non-slip safe, so reset the non-slip timer
563 564 565 566 567
routineTimer.reset()

# set up handler to look after randomisation of conditions etc
Encodingpractice = data.TrialHandler(nReps=1, method='random', 
    extraInfo=expInfo, originPath=-1,
568
    trialList=data.importConditions('AVCongConditionsEncodingA.xlsx', selection='0,147,95'),
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
    seed=None, name='Encodingpractice')
thisExp.addLoop(Encodingpractice)  # add the loop to the experiment
thisEncodingpractice = Encodingpractice.trialList[0]  # so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb = thisEncodingpractice.rgb)
if thisEncodingpractice != None:
    for paramName in thisEncodingpractice:
        exec('{} = thisEncodingpractice[paramName]'.format(paramName))

for thisEncodingpractice in Encodingpractice:
    currentLoop = Encodingpractice
    # abbreviate parameter names if possible (e.g. rgb = thisEncodingpractice.rgb)
    if thisEncodingpractice != None:
        for paramName in thisEncodingpractice:
            exec('{} = thisEncodingpractice[paramName]'.format(paramName))
    
584
    # ------Prepare to start Routine "ISIEncoding"-------
585 586 587 588
    continueRoutine = True
    routineTimer.add(1.000000)
    # update component parameters for each repeat
    # keep track of which components have finished
589 590
    ISIEncodingComponents = [polygonIsiEncoding]
    for thisComponent in ISIEncodingComponents:
591 592 593 594 595 596 597 598 599
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
600
    ISIEncodingClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
601 602
    frameN = -1
    
603
    # -------Run Routine "ISIEncoding"-------
604 605
    while continueRoutine and routineTimer.getTime() > 0:
        # get current time
606 607
        t = ISIEncodingClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=ISIEncodingClock)
608 609 610 611
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
        
612 613
        # *polygonIsiEncoding* updates
        if polygonIsiEncoding.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
614
            # keep track of start time/frame for later
615 616 617 618 619 620
            polygonIsiEncoding.frameNStart = frameN  # exact frame index
            polygonIsiEncoding.tStart = t  # local t and not account for scr refresh
            polygonIsiEncoding.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(polygonIsiEncoding, 'tStartRefresh')  # time at next scr refresh
            polygonIsiEncoding.setAutoDraw(True)
        if polygonIsiEncoding.status == STARTED:
621
            # is it time to stop? (based on global clock, using actual start)
622
            if tThisFlipGlobal > polygonIsiEncoding.tStartRefresh + 1-frameTolerance:
623
                # keep track of stop time/frame for later
624 625 626 627
                polygonIsiEncoding.tStop = t  # not accounting for scr refresh
                polygonIsiEncoding.frameNStop = frameN  # exact frame index
                win.timeOnFlip(polygonIsiEncoding, 'tStopRefresh')  # time at next scr refresh
                polygonIsiEncoding.setAutoDraw(False)
628 629 630 631 632 633 634 635 636
        
        # check for quit (typically the Esc key)
        if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
            core.quit()
        
        # 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
637
        for thisComponent in ISIEncodingComponents:
638 639 640 641 642 643 644 645
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished
        
        # refresh the screen
        if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
            win.flip()
    
646 647
    # -------Ending Routine "ISIEncoding"-------
    for thisComponent in ISIEncodingComponents:
648 649
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
650 651
    Encodingpractice.addData('polygonIsiEncoding.started', polygonIsiEncoding.tStartRefresh)
    Encodingpractice.addData('polygonIsiEncoding.stopped', polygonIsiEncoding.tStopRefresh)
652
    
653
    # ------Prepare to start Routine "trialEncoding"-------
654 655
    continueRoutine = True
    # update component parameters for each repeat
656 657 658 659 660 661
    responseEncoding.keys = []
    responseEncoding.rt = []
    _responseEncoding_allKeys = []
    imageEncoding.setImage(learning_image_1)
    sound_1Encoding.setSound(learning_sound_file, hamming=True)
    sound_1Encoding.setVolume(1, log=False)
662
    # keep track of which components have finished
663 664
    trialEncodingComponents = [responseEncoding, imageEncoding, sound_1Encoding]
    for thisComponent in trialEncodingComponents:
665 666 667 668 669 670 671 672 673
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
674
    trialEncodingClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
675 676
    frameN = -1
    
677
    # -------Run Routine "trialEncoding"-------
678 679
    while continueRoutine:
        # get current time
680 681
        t = trialEncodingClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=trialEncodingClock)
682 683 684 685
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
        
686
        # *responseEncoding* updates
687
        waitOnFlip = False
688
        if responseEncoding.status == NOT_STARTED and tThisFlip >= 0-frameTolerance:
689
            # keep track of start time/frame for later
690 691 692 693 694
            responseEncoding.frameNStart = frameN  # exact frame index
            responseEncoding.tStart = t  # local t and not account for scr refresh
            responseEncoding.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(responseEncoding, 'tStartRefresh')  # time at next scr refresh
            responseEncoding.status = STARTED
695 696
            # keyboard checking is just starting
            waitOnFlip = True
697 698 699
            win.callOnFlip(responseEncoding.clock.reset)  # t=0 on next screen flip
            win.callOnFlip(responseEncoding.clearEvents, eventType='keyboard')  # clear events on next screen flip
        if responseEncoding.status == STARTED:
700
            # is it time to stop? (based on global clock, using actual start)
701
            if tThisFlipGlobal > responseEncoding.tStartRefresh + 4-frameTolerance:
702
                # keep track of stop time/frame for later
703 704 705 706 707 708 709 710 711 712
                responseEncoding.tStop = t  # not accounting for scr refresh
                responseEncoding.frameNStop = frameN  # exact frame index
                win.timeOnFlip(responseEncoding, 'tStopRefresh')  # time at next scr refresh
                responseEncoding.status = FINISHED
        if responseEncoding.status == STARTED and not waitOnFlip:
            theseKeys = responseEncoding.getKeys(keyList=['1', '2', '3', '4', '5'], waitRelease=False)
            _responseEncoding_allKeys.extend(theseKeys)
            if len(_responseEncoding_allKeys):
                responseEncoding.keys = _responseEncoding_allKeys[-1].name  # just the last key pressed
                responseEncoding.rt = _responseEncoding_allKeys[-1].rt
713
                # was this correct?
714 715
                if (responseEncoding.keys == str(learning_condition)) or (responseEncoding.keys == learning_condition):
                    responseEncoding.corr = 1
716
                else:
717
                    responseEncoding.corr = 0
718
        
719 720
        # *imageEncoding* updates
        if imageEncoding.status == NOT_STARTED and tThisFlip >= 0.-frameTolerance:
721
            # keep track of start time/frame for later
722 723 724 725 726 727
            imageEncoding.frameNStart = frameN  # exact frame index
            imageEncoding.tStart = t  # local t and not account for scr refresh
            imageEncoding.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(imageEncoding, 'tStartRefresh')  # time at next scr refresh
            imageEncoding.setAutoDraw(True)
        if imageEncoding.status == STARTED:
728
            # is it time to stop? (based on global clock, using actual start)
729
            if tThisFlipGlobal > imageEncoding.tStartRefresh + 4-frameTolerance:
730
                # keep track of stop time/frame for later
731 732 733 734 735 736
                imageEncoding.tStop = t  # not accounting for scr refresh
                imageEncoding.frameNStop = frameN  # exact frame index
                win.timeOnFlip(imageEncoding, 'tStopRefresh')  # time at next scr refresh
                imageEncoding.setAutoDraw(False)
        # start/stop sound_1Encoding
        if sound_1Encoding.status == NOT_STARTED and tThisFlip >= 0-frameTolerance:
737
            # keep track of start time/frame for later
738 739 740 741
            sound_1Encoding.frameNStart = frameN  # exact frame index
            sound_1Encoding.tStart = t  # local t and not account for scr refresh
            sound_1Encoding.tStartRefresh = tThisFlipGlobal  # on global time
            sound_1Encoding.play(when=win)  # sync with win flip
742 743 744 745 746 747 748 749 750
        
        # check for quit (typically the Esc key)
        if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
            core.quit()
        
        # 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
751
        for thisComponent in trialEncodingComponents:
752 753 754 755 756 757 758 759
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished
        
        # refresh the screen
        if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
            win.flip()
    
760 761
    # -------Ending Routine "trialEncoding"-------
    for thisComponent in trialEncodingComponents:
762 763 764
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
    # check responses
765 766
    if responseEncoding.keys in ['', [], None]:  # No response was made
        responseEncoding.keys = None
767 768
        # was no response the correct answer?!
        if str(learning_condition).lower() == 'none':
769
           responseEncoding.corr = 1;  # correct non-response
770
        else:
771
           responseEncoding.corr = 0;  # failed to respond (incorrectly)
772
    # store data for Encodingpractice (TrialHandler)
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793
    Encodingpractice.addData('responseEncoding.keys',responseEncoding.keys)
    Encodingpractice.addData('responseEncoding.corr', responseEncoding.corr)
    if responseEncoding.keys != None:  # we had a response
        Encodingpractice.addData('responseEncoding.rt', responseEncoding.rt)
    Encodingpractice.addData('responseEncoding.started', responseEncoding.tStartRefresh)
    Encodingpractice.addData('responseEncoding.stopped', responseEncoding.tStopRefresh)
    Encodingpractice.addData('imageEncoding.started', imageEncoding.tStartRefresh)
    Encodingpractice.addData('imageEncoding.stopped', imageEncoding.tStopRefresh)
    sound_1Encoding.stop()  # ensure sound has stopped at end of routine
    Encodingpractice.addData('sound_1Encoding.started', sound_1Encoding.tStartRefresh)
    Encodingpractice.addData('sound_1Encoding.stopped', sound_1Encoding.tStopRefresh)
    # END OF ROUTINE 
    if responseEncoding.keys != None:
        if responseEncoding.keys[0] in correct_responseEncoding:
            thisExp.addData('correctEncoding', '1')
            print("response OK")
        else:
            thisExp.addData('correctEncoding', '0')
            print("response NOK") 
        
    # the Routine "trialEncoding" was not non-slip safe, so reset the non-slip timer
794 795 796 797 798 799
    routineTimer.reset()
    
    # ------Prepare to start Routine "feedback_in_loop_encodingpractice"-------
    continueRoutine = True
    routineTimer.add(1.000000)
    # update component parameters for each repeat
800
    if not responseEncoding.keys :
801
        msg="Respond faster please!"
802 803 804 805 806
        msgcolor='red'
    else: #stored on last run routine
        msg="You responded" 
        msgcolor='green'   
    
807 808
    text_10EncodingPracticeFeedback.setColor(msgcolor, colorSpace='rgb')
    text_10EncodingPracticeFeedback.setText(msg)
809
    # keep track of which components have finished
810
    feedback_in_loop_encodingpracticeComponents = [text_10EncodingPracticeFeedback]
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832
    for thisComponent in feedback_in_loop_encodingpracticeComponents:
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
    feedback_in_loop_encodingpracticeClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
    frameN = -1
    
    # -------Run Routine "feedback_in_loop_encodingpractice"-------
    while continueRoutine and routineTimer.getTime() > 0:
        # get current time
        t = feedback_in_loop_encodingpracticeClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=feedback_in_loop_encodingpracticeClock)
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
        
833 834
        # *text_10EncodingPracticeFeedback* updates
        if text_10EncodingPracticeFeedback.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
835
            # keep track of start time/frame for later
836 837 838 839 840 841
            text_10EncodingPracticeFeedback.frameNStart = frameN  # exact frame index
            text_10EncodingPracticeFeedback.tStart = t  # local t and not account for scr refresh
            text_10EncodingPracticeFeedback.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(text_10EncodingPracticeFeedback, 'tStartRefresh')  # time at next scr refresh
            text_10EncodingPracticeFeedback.setAutoDraw(True)
        if text_10EncodingPracticeFeedback.status == STARTED:
842
            # is it time to stop? (based on global clock, using actual start)
843
            if tThisFlipGlobal > text_10EncodingPracticeFeedback.tStartRefresh + 1.0-frameTolerance:
844
                # keep track of stop time/frame for later
845 846 847 848
                text_10EncodingPracticeFeedback.tStop = t  # not accounting for scr refresh
                text_10EncodingPracticeFeedback.frameNStop = frameN  # exact frame index
                win.timeOnFlip(text_10EncodingPracticeFeedback, 'tStopRefresh')  # time at next scr refresh
                text_10EncodingPracticeFeedback.setAutoDraw(False)
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870
        
        # check for quit (typically the Esc key)
        if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
            core.quit()
        
        # 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 feedback_in_loop_encodingpracticeComponents:
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished
        
        # refresh the screen
        if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
            win.flip()
    
    # -------Ending Routine "feedback_in_loop_encodingpractice"-------
    for thisComponent in feedback_in_loop_encodingpracticeComponents:
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
871 872
    Encodingpractice.addData('text_10EncodingPracticeFeedback.started', text_10EncodingPracticeFeedback.tStartRefresh)
    Encodingpractice.addData('text_10EncodingPracticeFeedback.stopped', text_10EncodingPracticeFeedback.tStopRefresh)
873 874 875 876 877 878 879 880
    thisExp.nextEntry()
    
# completed 1 repeats of 'Encodingpractice'


# ------Prepare to start Routine "EncodingInstructionsReminder"-------
continueRoutine = True
# update component parameters for each repeat
881 882 883
key_resp_EncodingInstructionsReminder.keys = []
key_resp_EncodingInstructionsReminder.rt = []
_key_resp_EncodingInstructionsReminder_allKeys = []
884
# keep track of which components have finished
885
EncodingInstructionsReminderComponents = [text_EncodingInstructionsReminder, key_resp_EncodingInstructionsReminder]
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907
for thisComponent in EncodingInstructionsReminderComponents:
    thisComponent.tStart = None
    thisComponent.tStop = None
    thisComponent.tStartRefresh = None
    thisComponent.tStopRefresh = None
    if hasattr(thisComponent, 'status'):
        thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
EncodingInstructionsReminderClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
frameN = -1

# -------Run Routine "EncodingInstructionsReminder"-------
while continueRoutine:
    # get current time
    t = EncodingInstructionsReminderClock.getTime()
    tThisFlip = win.getFutureFlipTime(clock=EncodingInstructionsReminderClock)
    tThisFlipGlobal = win.getFutureFlipTime(clock=None)
    frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
    # update/draw components on each frame
    
908 909
    # *text_EncodingInstructionsReminder* updates
    if text_EncodingInstructionsReminder.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
910
        # keep track of start time/frame for later
911 912 913 914 915
        text_EncodingInstructionsReminder.frameNStart = frameN  # exact frame index
        text_EncodingInstructionsReminder.tStart = t  # local t and not account for scr refresh
        text_EncodingInstructionsReminder.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(text_EncodingInstructionsReminder, 'tStartRefresh')  # time at next scr refresh
        text_EncodingInstructionsReminder.setAutoDraw(True)
916
    
917
    # *key_resp_EncodingInstructionsReminder* updates
918
    waitOnFlip = False
919
    if key_resp_EncodingInstructionsReminder.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
920
        # keep track of start time/frame for later
921 922 923 924 925
        key_resp_EncodingInstructionsReminder.frameNStart = frameN  # exact frame index
        key_resp_EncodingInstructionsReminder.tStart = t  # local t and not account for scr refresh
        key_resp_EncodingInstructionsReminder.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(key_resp_EncodingInstructionsReminder, 'tStartRefresh')  # time at next scr refresh
        key_resp_EncodingInstructionsReminder.status = STARTED
926 927
        # keyboard checking is just starting
        waitOnFlip = True
928 929 930 931 932 933 934 935
        win.callOnFlip(key_resp_EncodingInstructionsReminder.clock.reset)  # t=0 on next screen flip
        win.callOnFlip(key_resp_EncodingInstructionsReminder.clearEvents, eventType='keyboard')  # clear events on next screen flip
    if key_resp_EncodingInstructionsReminder.status == STARTED and not waitOnFlip:
        theseKeys = key_resp_EncodingInstructionsReminder.getKeys(keyList=None, waitRelease=False)
        _key_resp_EncodingInstructionsReminder_allKeys.extend(theseKeys)
        if len(_key_resp_EncodingInstructionsReminder_allKeys):
            key_resp_EncodingInstructionsReminder.keys = _key_resp_EncodingInstructionsReminder_allKeys[-1].name  # just the last key pressed
            key_resp_EncodingInstructionsReminder.rt = _key_resp_EncodingInstructionsReminder_allKeys[-1].rt
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
            # a response ends the routine
            continueRoutine = False
    
    # check for quit (typically the Esc key)
    if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
        core.quit()
    
    # 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 EncodingInstructionsReminderComponents:
        if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
            continueRoutine = True
            break  # at least one component has not yet finished
    
    # refresh the screen
    if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
        win.flip()

# -------Ending Routine "EncodingInstructionsReminder"-------
for thisComponent in EncodingInstructionsReminderComponents:
    if hasattr(thisComponent, "setAutoDraw"):
        thisComponent.setAutoDraw(False)
960 961
thisExp.addData('text_EncodingInstructionsReminder.started', text_EncodingInstructionsReminder.tStartRefresh)
thisExp.addData('text_EncodingInstructionsReminder.stopped', text_EncodingInstructionsReminder.tStopRefresh)
962
# check responses
963 964 965 966 967 968 969
if key_resp_EncodingInstructionsReminder.keys in ['', [], None]:  # No response was made
    key_resp_EncodingInstructionsReminder.keys = None
thisExp.addData('key_resp_EncodingInstructionsReminder.keys',key_resp_EncodingInstructionsReminder.keys)
if key_resp_EncodingInstructionsReminder.keys != None:  # we had a response
    thisExp.addData('key_resp_EncodingInstructionsReminder.rt', key_resp_EncodingInstructionsReminder.rt)
thisExp.addData('key_resp_EncodingInstructionsReminder.started', key_resp_EncodingInstructionsReminder.tStartRefresh)
thisExp.addData('key_resp_EncodingInstructionsReminder.stopped', key_resp_EncodingInstructionsReminder.tStopRefresh)
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992
thisExp.nextEntry()
# the Routine "EncodingInstructionsReminder" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()

# set up handler to look after randomisation of conditions etc
Encoding = data.TrialHandler(nReps=1, method='random', 
    extraInfo=expInfo, originPath=-1,
    trialList=data.importConditions('AVCongConditionsEncodingA.xlsx'),
    seed=None, name='Encoding')
thisExp.addLoop(Encoding)  # add the loop to the experiment
thisEncoding = Encoding.trialList[0]  # so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb = thisEncoding.rgb)
if thisEncoding != None:
    for paramName in thisEncoding:
        exec('{} = thisEncoding[paramName]'.format(paramName))

for thisEncoding in Encoding:
    currentLoop = Encoding
    # abbreviate parameter names if possible (e.g. rgb = thisEncoding.rgb)
    if thisEncoding != None:
        for paramName in thisEncoding:
            exec('{} = thisEncoding[paramName]'.format(paramName))
    
993
    # ------Prepare to start Routine "ISIEncoding"-------
994 995 996 997
    continueRoutine = True
    routineTimer.add(1.000000)
    # update component parameters for each repeat
    # keep track of which components have finished
998 999
    ISIEncodingComponents = [polygonIsiEncoding]
    for thisComponent in ISIEncodingComponents:
1000 1001 1002 1003 1004 1005 1006 1007 1008
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
1009
    ISIEncodingClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
1010 1011
    frameN = -1
    
1012
    # -------Run Routine "ISIEncoding"-------
1013 1014
    while continueRoutine and routineTimer.getTime() > 0:
        # get current time
1015 1016
        t = ISIEncodingClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=ISIEncodingClock)
1017 1018 1019 1020
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
        
1021 1022
        # *polygonIsiEncoding* updates
        if polygonIsiEncoding.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
1023
            # keep track of start time/frame for later
1024 1025 1026 1027 1028 1029
            polygonIsiEncoding.frameNStart = frameN  # exact frame index
            polygonIsiEncoding.tStart = t  # local t and not account for scr refresh
            polygonIsiEncoding.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(polygonIsiEncoding, 'tStartRefresh')  # time at next scr refresh
            polygonIsiEncoding.setAutoDraw(True)
        if polygonIsiEncoding.status == STARTED:
1030
            # is it time to stop? (based on global clock, using actual start)
1031
            if tThisFlipGlobal > polygonIsiEncoding.tStartRefresh + 1-frameTolerance:
1032
                # keep track of stop time/frame for later
1033 1034 1035 1036
                polygonIsiEncoding.tStop = t  # not accounting for scr refresh
                polygonIsiEncoding.frameNStop = frameN  # exact frame index
                win.timeOnFlip(polygonIsiEncoding, 'tStopRefresh')  # time at next scr refresh
                polygonIsiEncoding.setAutoDraw(False)
1037 1038 1039 1040 1041 1042 1043 1044 1045
        
        # check for quit (typically the Esc key)
        if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
            core.quit()
        
        # 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
1046
        for thisComponent in ISIEncodingComponents:
1047 1048 1049 1050 1051 1052 1053 1054
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished
        
        # refresh the screen
        if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
            win.flip()
    
1055 1056
    # -------Ending Routine "ISIEncoding"-------
    for thisComponent in ISIEncodingComponents:
1057 1058
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
1059 1060
    Encoding.addData('polygonIsiEncoding.started', polygonIsiEncoding.tStartRefresh)
    Encoding.addData('polygonIsiEncoding.stopped', polygonIsiEncoding.tStopRefresh)
1061
    
1062
    # ------Prepare to start Routine "trialEncoding"-------
1063 1064
    continueRoutine = True
    # update component parameters for each repeat
1065 1066 1067 1068 1069 1070
    responseEncoding.keys = []
    responseEncoding.rt = []
    _responseEncoding_allKeys = []
    imageEncoding.setImage(learning_image_1)
    sound_1Encoding.setSound(learning_sound_file, hamming=True)
    sound_1Encoding.setVolume(1, log=False)
1071
    # keep track of which components have finished
1072 1073
    trialEncodingComponents = [responseEncoding, imageEncoding, sound_1Encoding]
    for thisComponent in trialEncodingComponents:
1074 1075 1076 1077 1078 1079 1080 1081 1082
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
1083
    trialEncodingClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
1084 1085
    frameN = -1
    
1086
    # -------Run Routine "trialEncoding"-------
1087 1088
    while continueRoutine:
        # get current time
1089 1090
        t = trialEncodingClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=trialEncodingClock)
1091 1092 1093 1094
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
        
1095
        # *responseEncoding* updates
1096
        waitOnFlip = False
1097
        if responseEncoding.status == NOT_STARTED and tThisFlip >= 0-frameTolerance:
1098
            # keep track of start time/frame for later
1099 1100 1101 1102 1103
            responseEncoding.frameNStart = frameN  # exact frame index
            responseEncoding.tStart = t  # local t and not account for scr refresh
            responseEncoding.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(responseEncoding, 'tStartRefresh')  # time at next scr refresh
            responseEncoding.status = STARTED
1104 1105
            # keyboard checking is just starting
            waitOnFlip = True
1106 1107 1108
            win.callOnFlip(responseEncoding.clock.reset)  # t=0 on next screen flip
            win.callOnFlip(responseEncoding.clearEvents, eventType='keyboard')  # clear events on next screen flip
        if responseEncoding.status == STARTED:
1109
            # is it time to stop? (based on global clock, using actual start)
1110
            if tThisFlipGlobal > responseEncoding.tStartRefresh + 4-frameTolerance:
1111
                # keep track of stop time/frame for later
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121
                responseEncoding.tStop = t  # not accounting for scr refresh
                responseEncoding.frameNStop = frameN  # exact frame index
                win.timeOnFlip(responseEncoding, 'tStopRefresh')  # time at next scr refresh
                responseEncoding.status = FINISHED
        if responseEncoding.status == STARTED and not waitOnFlip:
            theseKeys = responseEncoding.getKeys(keyList=['1', '2', '3', '4', '5'], waitRelease=False)
            _responseEncoding_allKeys.extend(theseKeys)
            if len(_responseEncoding_allKeys):
                responseEncoding.keys = _responseEncoding_allKeys[-1].name  # just the last key pressed
                responseEncoding.rt = _responseEncoding_allKeys[-1].rt
1122
                # was this correct?
1123 1124
                if (responseEncoding.keys == str(learning_condition)) or (responseEncoding.keys == learning_condition):
                    responseEncoding.corr = 1
1125
                else:
1126
                    responseEncoding.corr = 0
1127
        
1128 1129
        # *imageEncoding* updates
        if imageEncoding.status == NOT_STARTED and tThisFlip >= 0.-frameTolerance:
1130
            # keep track of start time/frame for later
1131 1132 1133 1134 1135 1136
            imageEncoding.frameNStart = frameN  # exact frame index
            imageEncoding.tStart = t  # local t and not account for scr refresh
            imageEncoding.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(imageEncoding, 'tStartRefresh')  # time at next scr refresh
            imageEncoding.setAutoDraw(True)
        if imageEncoding.status == STARTED:
1137
            # is it time to stop? (based on global clock, using actual start)
1138
            if tThisFlipGlobal > imageEncoding.tStartRefresh + 4-frameTolerance:
1139
                # keep track of stop time/frame for later
1140 1141 1142 1143 1144 1145
                imageEncoding.tStop = t  # not accounting for scr refresh
                imageEncoding.frameNStop = frameN  # exact frame index
                win.timeOnFlip(imageEncoding, 'tStopRefresh')  # time at next scr refresh
                imageEncoding.setAutoDraw(False)
        # start/stop sound_1Encoding
        if sound_1Encoding.status == NOT_STARTED and tThisFlip >= 0-frameTolerance:
1146
            # keep track of start time/frame for later
1147 1148 1149 1150
            sound_1Encoding.frameNStart = frameN  # exact frame index
            sound_1Encoding.tStart = t  # local t and not account for scr refresh
            sound_1Encoding.tStartRefresh = tThisFlipGlobal  # on global time
            sound_1Encoding.play(when=win)  # sync with win flip
1151 1152 1153 1154 1155 1156 1157 1158 1159
        
        # check for quit (typically the Esc key)
        if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
            core.quit()
        
        # 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
1160
        for thisComponent in trialEncodingComponents:
1161 1162 1163 1164 1165 1166 1167 1168
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished
        
        # refresh the screen
        if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
            win.flip()
    
1169 1170
    # -------Ending Routine "trialEncoding"-------
    for thisComponent in trialEncodingComponents:
1171 1172 1173
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
    # check responses
1174 1175
    if responseEncoding.keys in ['', [], None]:  # No response was made
        responseEncoding.keys = None
1176 1177
        # was no response the correct answer?!
        if str(learning_condition).lower() == 'none':
1178
           responseEncoding.corr = 1;  # correct non-response
1179
        else:
1180
           responseEncoding.corr = 0;  # failed to respond (incorrectly)
1181
    # store data for Encoding (TrialHandler)
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202
    Encoding.addData('responseEncoding.keys',responseEncoding.keys)
    Encoding.addData('responseEncoding.corr', responseEncoding.corr)
    if responseEncoding.keys != None:  # we had a response
        Encoding.addData('responseEncoding.rt', responseEncoding.rt)
    Encoding.addData('responseEncoding.started', responseEncoding.tStartRefresh)
    Encoding.addData('responseEncoding.stopped', responseEncoding.tStopRefresh)
    Encoding.addData('imageEncoding.started', imageEncoding.tStartRefresh)
    Encoding.addData('imageEncoding.stopped', imageEncoding.tStopRefresh)
    sound_1Encoding.stop()  # ensure sound has stopped at end of routine
    Encoding.addData('sound_1Encoding.started', sound_1Encoding.tStartRefresh)
    Encoding.addData('sound_1Encoding.stopped', sound_1Encoding.tStopRefresh)
    # END OF ROUTINE 
    if responseEncoding.keys != None:
        if responseEncoding.keys[0] in correct_responseEncoding:
            thisExp.addData('correctEncoding', '1')
            print("response OK")
        else:
            thisExp.addData('correctEncoding', '0')
            print("response NOK") 
        
    # the Routine "trialEncoding" was not non-slip safe, so reset the non-slip timer
1203
    routineTimer.reset()
Pau Alexander's avatar
Pau Alexander committed
1204
    
1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
    # ------Prepare to start Routine "RespondFasterEncoding"-------
    continueRoutine = True
    routineTimer.add(1.000000)
    # update component parameters for each repeat
    if not responseEncoding.keys :
        msg="Respond faster please!"
    else: #stored on last run routine
        continueRoutine = False
    # keep track of which components have finished
    RespondFasterEncodingComponents = [textRespondFasterEncoding]
    for thisComponent in RespondFasterEncodingComponents:
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
    RespondFasterEncodingClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
    frameN = -1
    
    # -------Run Routine "RespondFasterEncoding"-------
    while continueRoutine and routineTimer.getTime() > 0:
        # get current time
        t = RespondFasterEncodingClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=RespondFasterEncodingClock)
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
        
        # *textRespondFasterEncoding* updates
        if textRespondFasterEncoding.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
            # keep track of start time/frame for later
            textRespondFasterEncoding.frameNStart = frameN  # exact frame index
            textRespondFasterEncoding.tStart = t  # local t and not account for scr refresh
            textRespondFasterEncoding.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(textRespondFasterEncoding, 'tStartRefresh')  # time at next scr refresh
            textRespondFasterEncoding.setAutoDraw(True)
        if textRespondFasterEncoding.status == STARTED:
            # is it time to stop? (based on global clock, using actual start)
            if tThisFlipGlobal > textRespondFasterEncoding.tStartRefresh + 1.0-frameTolerance:
                # keep track of stop time/frame for later
                textRespondFasterEncoding.tStop = t  # not accounting for scr refresh
                textRespondFasterEncoding.frameNStop = frameN  # exact frame index
                win.timeOnFlip(textRespondFasterEncoding, 'tStopRefresh')  # time at next scr refresh
                textRespondFasterEncoding.setAutoDraw(False)
        
        # check for quit (typically the Esc key)
        if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
            core.quit()
        
        # 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 RespondFasterEncodingComponents:
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished
        
        # refresh the screen
        if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
            win.flip()
    
    # -------Ending Routine "RespondFasterEncoding"-------
    for thisComponent in RespondFasterEncodingComponents:
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
    Encoding.addData('textRespondFasterEncoding.started', textRespondFasterEncoding.tStartRefresh)
    Encoding.addData('textRespondFasterEncoding.stopped', textRespondFasterEncoding.tStopRefresh)
    
Pau Alexander's avatar
Pau Alexander committed
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306
    # ------Prepare to start Routine "EncodingPause"-------
    continueRoutine = True
    # update component parameters for each repeat
    key_resp_EncodingBreak.keys = []
    key_resp_EncodingBreak.rt = []
    _key_resp_EncodingBreak_allKeys = []
    # keep track of which components have finished
    EncodingPauseComponents = [TextBreakEncoding, key_resp_EncodingBreak]
    for thisComponent in EncodingPauseComponents:
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
    EncodingPauseClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
    frameN = -1
    
    # -------Run Routine "EncodingPause"-------
    while continueRoutine:
        # get current time
        t = EncodingPauseClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=EncodingPauseClock)
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
1307
        if Encoding.thisTrialN != 100:
Pau Alexander's avatar
Pau Alexander committed
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373
                continueRoutine = False
        
        # *TextBreakEncoding* updates
        if TextBreakEncoding.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
            # keep track of start time/frame for later
            TextBreakEncoding.frameNStart = frameN  # exact frame index
            TextBreakEncoding.tStart = t  # local t and not account for scr refresh
            TextBreakEncoding.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(TextBreakEncoding, 'tStartRefresh')  # time at next scr refresh
            TextBreakEncoding.setAutoDraw(True)
        
        # *key_resp_EncodingBreak* updates
        waitOnFlip = False
        if key_resp_EncodingBreak.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
            # keep track of start time/frame for later
            key_resp_EncodingBreak.frameNStart = frameN  # exact frame index
            key_resp_EncodingBreak.tStart = t  # local t and not account for scr refresh
            key_resp_EncodingBreak.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(key_resp_EncodingBreak, 'tStartRefresh')  # time at next scr refresh
            key_resp_EncodingBreak.status = STARTED
            # keyboard checking is just starting
            waitOnFlip = True
            win.callOnFlip(key_resp_EncodingBreak.clock.reset)  # t=0 on next screen flip
            win.callOnFlip(key_resp_EncodingBreak.clearEvents, eventType='keyboard')  # clear events on next screen flip
        if key_resp_EncodingBreak.status == STARTED and not waitOnFlip:
            theseKeys = key_resp_EncodingBreak.getKeys(keyList=['space'], waitRelease=False)
            _key_resp_EncodingBreak_allKeys.extend(theseKeys)
            if len(_key_resp_EncodingBreak_allKeys):
                key_resp_EncodingBreak.keys = _key_resp_EncodingBreak_allKeys[-1].name  # just the last key pressed
                key_resp_EncodingBreak.rt = _key_resp_EncodingBreak_allKeys[-1].rt
                # a response ends the routine
                continueRoutine = False
        
        # check for quit (typically the Esc key)
        if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
            core.quit()
        
        # 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 EncodingPauseComponents:
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished
        
        # refresh the screen
        if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
            win.flip()
    
    # -------Ending Routine "EncodingPause"-------
    for thisComponent in EncodingPauseComponents:
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
    Encoding.addData('TextBreakEncoding.started', TextBreakEncoding.tStartRefresh)
    Encoding.addData('TextBreakEncoding.stopped', TextBreakEncoding.tStopRefresh)
    # check responses
    if key_resp_EncodingBreak.keys in ['', [], None]:  # No response was made
        key_resp_EncodingBreak.keys = None
    Encoding.addData('key_resp_EncodingBreak.keys',key_resp_EncodingBreak.keys)
    if key_resp_EncodingBreak.keys != None:  # we had a response
        Encoding.addData('key_resp_EncodingBreak.rt', key_resp_EncodingBreak.rt)
    Encoding.addData('key_resp_EncodingBreak.started', key_resp_EncodingBreak.tStartRefresh)
    Encoding.addData('key_resp_EncodingBreak.stopped', key_resp_EncodingBreak.tStopRefresh)
    # the Routine "EncodingPause" was not non-slip safe, so reset the non-slip timer
    routineTimer.reset()
1374 1375 1376 1377 1378 1379 1380 1381
    thisExp.nextEntry()
    
# completed 1 repeats of 'Encoding'


# ------Prepare to start Routine "Interval_task_instructions"-------
continueRoutine = True
# update component parameters for each repeat
1382 1383 1384
key_resp_IntervalTaskInstructions.keys = []
key_resp_IntervalTaskInstructions.rt = []
_key_resp_IntervalTaskInstructions_allKeys = []
1385
# keep track of which components have finished
1386
Interval_task_instructionsComponents = [text_IntervalTaskInstructions, key_resp_IntervalTaskInstructions]
1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408
for thisComponent in Interval_task_instructionsComponents:
    thisComponent.tStart = None
    thisComponent.tStop = None
    thisComponent.tStartRefresh = None
    thisComponent.tStopRefresh = None
    if hasattr(thisComponent, 'status'):
        thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
Interval_task_instructionsClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
frameN = -1

# -------Run Routine "Interval_task_instructions"-------
while continueRoutine:
    # get current time
    t = Interval_task_instructionsClock.getTime()
    tThisFlip = win.getFutureFlipTime(clock=Interval_task_instructionsClock)
    tThisFlipGlobal = win.getFutureFlipTime(clock=None)
    frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
    # update/draw components on each frame
    
1409 1410
    # *text_IntervalTaskInstructions* updates
    if text_IntervalTaskInstructions.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
1411
        # keep track of start time/frame for later
1412 1413 1414 1415 1416
        text_IntervalTaskInstructions.frameNStart = frameN  # exact frame index
        text_IntervalTaskInstructions.tStart = t  # local t and not account for scr refresh
        text_IntervalTaskInstructions.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(text_IntervalTaskInstructions, 'tStartRefresh')  # time at next scr refresh
        text_IntervalTaskInstructions.setAutoDraw(True)
1417
    
1418
    # *key_resp_IntervalTaskInstructions* updates
1419
    waitOnFlip = False
1420
    if key_resp_IntervalTaskInstructions.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
1421
        # keep track of start time/frame for later
1422 1423 1424 1425 1426
        key_resp_IntervalTaskInstructions.frameNStart = frameN  # exact frame index
        key_resp_IntervalTaskInstructions.tStart = t  # local t and not account for scr refresh
        key_resp_IntervalTaskInstructions.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(key_resp_IntervalTaskInstructions, 'tStartRefresh')  # time at next scr refresh
        key_resp_IntervalTaskInstructions.status = STARTED
1427 1428
        # keyboard checking is just starting
        waitOnFlip = True
1429 1430 1431 1432 1433 1434 1435 1436
        win.callOnFlip(key_resp_IntervalTaskInstructions.clock.reset)  # t=0 on next screen flip
        win.callOnFlip(key_resp_IntervalTaskInstructions.clearEvents, eventType='keyboard')  # clear events on next screen flip
    if key_resp_IntervalTaskInstructions.status == STARTED and not waitOnFlip:
        theseKeys = key_resp_IntervalTaskInstructions.getKeys(keyList=None, waitRelease=False)
        _key_resp_IntervalTaskInstructions_allKeys.extend(theseKeys)
        if len(_key_resp_IntervalTaskInstructions_allKeys):
            key_resp_IntervalTaskInstructions.keys = _key_resp_IntervalTaskInstructions_allKeys[-1].name  # just the last key pressed
            key_resp_IntervalTaskInstructions.rt = _key_resp_IntervalTaskInstructions_allKeys[-1].rt
1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460
            # a response ends the routine
            continueRoutine = False
    
    # check for quit (typically the Esc key)
    if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
        core.quit()
    
    # 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 Interval_task_instructionsComponents:
        if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
            continueRoutine = True
            break  # at least one component has not yet finished
    
    # refresh the screen
    if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
        win.flip()

# -------Ending Routine "Interval_task_instructions"-------
for thisComponent in Interval_task_instructionsComponents:
    if hasattr(thisComponent, "setAutoDraw"):
        thisComponent.setAutoDraw(False)
1461 1462
thisExp.addData('text_IntervalTaskInstructions.started', text_IntervalTaskInstructions.tStartRefresh)
thisExp.addData('text_IntervalTaskInstructions.stopped', text_IntervalTaskInstructions.tStopRefresh)
1463
# check responses
1464 1465 1466 1467 1468 1469 1470
if key_resp_IntervalTaskInstructions.keys in ['', [], None]:  # No response was made
    key_resp_IntervalTaskInstructions.keys = None
thisExp.addData('key_resp_IntervalTaskInstructions.keys',key_resp_IntervalTaskInstructions.keys)
if key_resp_IntervalTaskInstructions.keys != None:  # we had a response
    thisExp.addData('key_resp_IntervalTaskInstructions.rt', key_resp_IntervalTaskInstructions.rt)
thisExp.addData('key_resp_IntervalTaskInstructions.started', key_resp_IntervalTaskInstructions.tStartRefresh)
thisExp.addData('key_resp_IntervalTaskInstructions.stopped', key_resp_IntervalTaskInstructions.tStopRefresh)
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497
thisExp.nextEntry()
# the Routine "Interval_task_instructions" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()

# set up handler to look after randomisation of conditions etc
DistractionTaskPractice = data.TrialHandler(nReps=1, method='random', 
    extraInfo=expInfo, originPath=-1,
    trialList=data.importConditions('AVDistractionTask.xlsx', selection='0:3'),
    seed=None, name='DistractionTaskPractice')
thisExp.addLoop(DistractionTaskPractice)  # add the loop to the experiment
thisDistractionTaskPractice = DistractionTaskPractice.trialList[0]  # so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb = thisDistractionTaskPractice.rgb)
if thisDistractionTaskPractice != None:
    for paramName in thisDistractionTaskPractice:
        exec('{} = thisDistractionTaskPractice[paramName]'.format(paramName))

for thisDistractionTaskPractice in DistractionTaskPractice:
    currentLoop = DistractionTaskPractice
    # abbreviate parameter names if possible (e.g. rgb = thisDistractionTaskPractice.rgb)
    if thisDistractionTaskPractice != None:
        for paramName in thisDistractionTaskPractice:
            exec('{} = thisDistractionTaskPractice[paramName]'.format(paramName))
    
    # ------Prepare to start Routine "interval_task"-------
    continueRoutine = True
    routineTimer.add(4.000000)
    # update component parameters for each repeat
1498
    text_IntervalTask.setText(math_test
1499 1500

)
1501 1502 1503
    key_resp_IntervalTask.keys = []
    key_resp_IntervalTask.rt = []
    _key_resp_IntervalTask_allKeys = []
1504
    # keep track of which components have finished
1505
    interval_taskComponents = [text_IntervalTask, key_resp_IntervalTask]
1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527
    for thisComponent in interval_taskComponents:
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
    interval_taskClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
    frameN = -1
    
    # -------Run Routine "interval_task"-------
    while continueRoutine and routineTimer.getTime() > 0:
        # get current time
        t = interval_taskClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=interval_taskClock)
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
        
1528 1529
        # *text_IntervalTask* updates
        if text_IntervalTask.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
1530
            # keep track of start time/frame for later
1531 1532 1533 1534 1535 1536
            text_IntervalTask.frameNStart = frameN  # exact frame index
            text_IntervalTask.tStart = t  # local t and not account for scr refresh
            text_IntervalTask.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(text_IntervalTask, 'tStartRefresh')  # time at next scr refresh
            text_IntervalTask.setAutoDraw(True)
        if text_IntervalTask.status == STARTED:
1537
            # is it time to stop? (based on global clock, using actual start)
1538
            if tThisFlipGlobal > text_IntervalTask.tStartRefresh + 4.0-frameTolerance:
1539
                # keep track of stop time/frame for later
1540 1541 1542 1543
                text_IntervalTask.tStop = t  # not accounting for scr refresh
                text_IntervalTask.frameNStop = frameN  # exact frame index
                win.timeOnFlip(text_IntervalTask, 'tStopRefresh')  # time at next scr refresh
                text_IntervalTask.setAutoDraw(False)
1544
        
1545
        # *key_resp_IntervalTask* updates
1546
        waitOnFlip = False
1547
        if key_resp_IntervalTask.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
1548
            # keep track of start time/frame for later
1549 1550 1551 1552 1553
            key_resp_IntervalTask.frameNStart = frameN  # exact frame index
            key_resp_IntervalTask.tStart = t  # local t and not account for scr refresh
            key_resp_IntervalTask.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(key_resp_IntervalTask, 'tStartRefresh')  # time at next scr refresh
            key_resp_IntervalTask.status = STARTED
1554 1555
            # keyboard checking is just starting
            waitOnFlip = True
1556 1557 1558
            win.callOnFlip(key_resp_IntervalTask.clock.reset)  # t=0 on next screen flip
            win.callOnFlip(key_resp_IntervalTask.clearEvents, eventType='keyboard')  # clear events on next screen flip
        if key_resp_IntervalTask.status == STARTED:
1559
            # is it time to stop? (based on global clock, using actual start)
1560
            if tThisFlipGlobal > key_resp_IntervalTask.tStartRefresh + 4-frameTolerance: