#!/usr/bin/env python # -*- coding: utf-8 -*- """ This experiment was created using PsychoPy3 Experiment Builder (v2020.2.3), on Fri Jan 15 18:07:21 2021 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 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.2.3' expName = 'Pilot' # from the Builder filename that created this script expInfo = {'ID (same as survey)': '', 'session': '001'} dlg = gui.DlgFromDict(dictionary=expInfo, sort_keys=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='/Users/benedettalarosa/Documents/Jobmotion2020/PsychoPy/PILOT/Pilot_lastrun.py', savePickle=True, saveWideText=True, dataFileName=filename) # save a log file for detail verbose info logFile = logging.LogFile(filename+'.log', level=logging.DEBUG) 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=[1440, 900], fullscr=True, screen=0, winType='pyglet', allowGUI=True, allowStencil=False, monitor='testMonitor', color=[1,1,1], colorSpace='rgb', blendMode='avg', useFBO=True, units='norm') # 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 "beginning" beginningClock = core.Clock() text_beginning = visual.TextStim(win=win, name='text_beginning', text='Hello.\n\nBefore the beginning of this experiment, you should have filled in a survey online.\n\nIf you haven’t, please do so first.\n\nIf you have, please write down the code you generated in the survey.\n\n(Remember, the code should be made by your birthday + the date in which you completed the survey)\n\nPress ENTER to continue.', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_beginning = keyboard.Keyboard() # Initialize components for Routine "typedresponse" typedresponseClock = core.Clock() ID = visual.TextBox2( win, text='default text', font='Arial', pos=(0, 0), letterHeight=0.05, size=None, borderWidth=2.0, color='white', colorSpace='rgb', opacity=1, bold=False, italic=False, lineSpacing=1.0, padding=None, anchor='center', fillColor=None, borderColor=None, flipHoriz=False, flipVert=False, editable=True, name='ID', autoLog=True, ) endbutton = visual.TextStim(win=win, name='endbutton', text='Click here to continue', font='Arial', pos=(0, -.4), height=0.1, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); mouse_2 = event.Mouse(win=win) x, y = [None, None] mouse_2.mouseClock = core.Clock() # Initialize components for Routine "introduction" introductionClock = core.Clock() text_intro = visual.TextStim(win=win, name='text_intro', text='Welcome to the experiment.\n\nBefore proceeding with the instructions of the task, we would like you to answer some questions.\n\nPlease choose for each question a score from 0 (not present) to 10 (very strong).\n\n\nPlease press ENTER to proceed.', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp_intro = keyboard.Keyboard() # Initialize components for Routine "blank_1500" blank_1500Clock = core.Clock() blank_screen = visual.TextStim(win=win, name='blank_screen', text=None, font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); # Initialize components for Routine "stress_pre" stress_preClock = core.Clock() text_stress = visual.TextStim(win=win, name='text_stress', text='Please rate your current distress on the scale below:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating_stress = visual.RatingScale(win=win, name='rating_stress', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "body_pre" body_preClock = core.Clock() text_body = visual.TextStim(win=win, name='text_body', text='I have the impression that my body does not belong to me:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating_body = visual.RatingScale(win=win, name='rating_body', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "hearing_pre" hearing_preClock = core.Clock() text_hearing = visual.TextStim(win=win, name='text_hearing', text='I have problems hearing, e.g. I hear sounds from nearby as if they come from far away:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating_hearing = visual.RatingScale(win=win, name='rating_hearing', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "unreal_pre" unreal_preClock = core.Clock() text_unreal = visual.TextStim(win=win, name='text_unreal', text='I have the impression other people or things around me are unreal:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating_unreal = visual.RatingScale(win=win, name='rating_unreal', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "pain_pre" pain_preClock = core.Clock() text_pain = visual.TextStim(win=win, name='text_pain', text='I have the impression that my body or parts of it are insensitive to pain:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating_pain = visual.RatingScale(win=win, name='rating_pain', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "instructions" instructionsClock = core.Clock() text_instructions = visual.TextStim(win=win, name='text_instructions', text='This test includes several trials, which are separated by a white screen.\nAt the beginning of each trial, a set of three uppercase letters is presented. \nPlease memorize this set of letters as good as possible!\n\nAfter a delay interval (1.5 seconds), you will again see a set of three uppercase letters.\nEither one of these letters has been presented before, or all letters are new. \n\nPlease press ENTER to proceed with the instructions. ', font='Arial', pos=(0, 0), height=0.07, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_instructions = keyboard.Keyboard() # Initialize components for Routine "instructions2" instructions2Clock = core.Clock() text_instructions2 = visual.TextStim(win=win, name='text_instructions2', text='Your task is to indicate AS SOON AND ACCURATELY AS POSSIBLE whether you recognize one of the letters (as shown before) or not. \nIF YES: Press the LEFT key!\nIF NO: Press the RIGHT key! \n\nIn the delay interval between the two sets of letters, you will either see a CROSS (in front of a white screen) or pictures of faces. \nPlease don’t close your eyes and focus on the screen, but try to ignore the pictures and concentrate on the task! \n\nYou have now the opportunity to practice the task. \n\nPlease press ENTER when you are ready to start with the practice trials.\n', font='Arial', pos=(0, 0), height=0.07, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_instructions2 = keyboard.Keyboard() # Initialize components for Routine "blank_1500" blank_1500Clock = core.Clock() blank_screen = visual.TextStim(win=win, name='blank_screen', text=None, font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); # Initialize components for Routine "memoranda" memorandaClock = core.Clock() text_memoranda = visual.TextStim(win=win, name='text_memoranda', text='default text', font='Arial', pos=(0, 0), height=0.3, wrapWidth=0.1, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); # Initialize components for Routine "distractor" distractorClock = core.Clock() image_distractor = visual.ImageStim( win=win, name='image_distractor', image='sin', mask=None, ori=0, pos=(0, 0), size=(0.8,1.5), color=[1,1,1], colorSpace='rgb', opacity=1, flipHoriz=False, flipVert=False, texRes=512, interpolate=True, depth=0.0) # Initialize components for Routine "target" targetClock = core.Clock() text_target = visual.TextStim(win=win, name='text_target', text='default text', font='Arial', pos=(0, 0), height=0.3, wrapWidth=0.1, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_practice = keyboard.Keyboard() # Initialize components for Routine "blank_1500" blank_1500Clock = core.Clock() blank_screen = visual.TextStim(win=win, name='blank_screen', text=None, font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); # Initialize components for Routine "finish_practice" finish_practiceClock = core.Clock() text_finishpractice = visual.TextStim(win=win, name='text_finishpractice', text='This was the end of the practice trials.\n\nNow, you will start with the actual experiment.\n\nPress ENTER when you are ready to continue.', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_finishpractice = keyboard.Keyboard() # Initialize components for Routine "blank_1500" blank_1500Clock = core.Clock() blank_screen = visual.TextStim(win=win, name='blank_screen', text=None, font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); # Initialize components for Routine "memoranda" memorandaClock = core.Clock() text_memoranda = visual.TextStim(win=win, name='text_memoranda', text='default text', font='Arial', pos=(0, 0), height=0.3, wrapWidth=0.1, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); # Initialize components for Routine "distractor" distractorClock = core.Clock() image_distractor = visual.ImageStim( win=win, name='image_distractor', image='sin', mask=None, ori=0, pos=(0, 0), size=(0.8,1.5), color=[1,1,1], colorSpace='rgb', opacity=1, flipHoriz=False, flipVert=False, texRes=512, interpolate=True, depth=0.0) # Initialize components for Routine "target" targetClock = core.Clock() text_target = visual.TextStim(win=win, name='text_target', text='default text', font='Arial', pos=(0, 0), height=0.3, wrapWidth=0.1, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_practice = keyboard.Keyboard() # Initialize components for Routine "blank_1500" blank_1500Clock = core.Clock() blank_screen = visual.TextStim(win=win, name='blank_screen', text=None, font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); # Initialize components for Routine "finish_trials" finish_trialsClock = core.Clock() text_finishtrials = visual.TextStim(win=win, name='text_finishtrials', text='You are now finished with the trials.\n\nYou can now proceed to the last part.\n\n\nPress ENTER to continue.', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_finishtrials = keyboard.Keyboard() # Initialize components for Routine "introduction2" introduction2Clock = core.Clock() text_introduction2 = visual.TextStim(win=win, name='text_introduction2', text='Before the end of the experiment, we would like you to answer the same questions you answered at the beginning of the experiment.\n\nPlease choose for each question a score from 0 (not present) to 10 (very strong).\n\n\nPlease press ENTER to proceed.', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_introduction2 = keyboard.Keyboard() # Initialize components for Routine "blank_1500" blank_1500Clock = core.Clock() blank_screen = visual.TextStim(win=win, name='blank_screen', text=None, font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); # Initialize components for Routine "stress_post" stress_postClock = core.Clock() text_stress2 = visual.TextStim(win=win, name='text_stress2', text='Please rate your current distress on the scale below:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating_stress2 = visual.RatingScale(win=win, name='rating_stress2', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "body_post" body_postClock = core.Clock() text_body2 = visual.TextStim(win=win, name='text_body2', text='I have the impression that my body does not belong to me:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating_body2 = visual.RatingScale(win=win, name='rating_body2', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "hearing_post" hearing_postClock = core.Clock() text_hearing2 = visual.TextStim(win=win, name='text_hearing2', text='I have problems hearing, e.g. I hear sounds from nearby as if they come from far away:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating = visual.RatingScale(win=win, name='rating', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "unreal_post" unreal_postClock = core.Clock() text_unreal2 = visual.TextStim(win=win, name='text_unreal2', text='I have the impression other people or things around me are unreal:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating_2 = visual.RatingScale(win=win, name='rating_2', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "pain_post" pain_postClock = core.Clock() text_pain2 = visual.TextStim(win=win, name='text_pain2', text='I have the impression that my body or parts of it are insensitive to pain:\n0 (not present) - 10 (very strong)\n\n\n(Press ENTER to confirm your response)', font='Arial', pos=(0, 0), height=0.08, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); rating_3 = visual.RatingScale(win=win, name='rating_3', marker='triangle', size=1.0, pos=[0.0, -0.4], low=0, high=10, labels=[''], scale='') # Initialize components for Routine "blank_1500" blank_1500Clock = core.Clock() blank_screen = visual.TextStim(win=win, name='blank_screen', text=None, font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); # Initialize components for Routine "end" endClock = core.Clock() text_end = visual.TextStim(win=win, name='text_end', text='This is the end of the experiment.\n\nThank you for your participation.\n\n\nPlease press ENTER to exit the screen.', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_end = keyboard.Keyboard() # 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 "beginning"------- continueRoutine = True # update component parameters for each repeat key_beginning.keys = [] key_beginning.rt = [] _key_beginning_allKeys = [] # keep track of which components have finished beginningComponents = [text_beginning, key_beginning] for thisComponent in beginningComponents: 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") beginningClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "beginning"------- while continueRoutine: # get current time t = beginningClock.getTime() tThisFlip = win.getFutureFlipTime(clock=beginningClock) 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_beginning* updates if text_beginning.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_beginning.frameNStart = frameN # exact frame index text_beginning.tStart = t # local t and not account for scr refresh text_beginning.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_beginning, 'tStartRefresh') # time at next scr refresh text_beginning.setAutoDraw(True) # *key_beginning* updates waitOnFlip = False if key_beginning.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_beginning.frameNStart = frameN # exact frame index key_beginning.tStart = t # local t and not account for scr refresh key_beginning.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_beginning, 'tStartRefresh') # time at next scr refresh key_beginning.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_beginning.clock.reset) # t=0 on next screen flip win.callOnFlip(key_beginning.clearEvents, eventType='keyboard') # clear events on next screen flip if key_beginning.status == STARTED and not waitOnFlip: theseKeys = key_beginning.getKeys(keyList=['return'], waitRelease=False) _key_beginning_allKeys.extend(theseKeys) if len(_key_beginning_allKeys): key_beginning.keys = _key_beginning_allKeys[-1].name # just the last key pressed key_beginning.rt = _key_beginning_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 beginningComponents: 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 "beginning"------- for thisComponent in beginningComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_beginning.started', text_beginning.tStartRefresh) thisExp.addData('text_beginning.stopped', text_beginning.tStopRefresh) # the Routine "beginning" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "typedresponse"------- continueRoutine = True # update component parameters for each repeat ID.setText('Write your ID here') # setup some python lists for storing info about the mouse_2 mouse_2.x = [] mouse_2.y = [] mouse_2.leftButton = [] mouse_2.midButton = [] mouse_2.rightButton = [] mouse_2.time = [] mouse_2.clicked_name = [] gotValidClick = False # until a click is received # keep track of which components have finished typedresponseComponents = [ID, endbutton, mouse_2] for thisComponent in typedresponseComponents: 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") typedresponseClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "typedresponse"------- while continueRoutine: # get current time t = typedresponseClock.getTime() tThisFlip = win.getFutureFlipTime(clock=typedresponseClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *ID* updates if ID.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later ID.frameNStart = frameN # exact frame index ID.tStart = t # local t and not account for scr refresh ID.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(ID, 'tStartRefresh') # time at next scr refresh ID.setAutoDraw(True) # *endbutton* updates if endbutton.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later endbutton.frameNStart = frameN # exact frame index endbutton.tStart = t # local t and not account for scr refresh endbutton.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(endbutton, 'tStartRefresh') # time at next scr refresh endbutton.setAutoDraw(True) # *mouse_2* updates if mouse_2.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later mouse_2.frameNStart = frameN # exact frame index mouse_2.tStart = t # local t and not account for scr refresh mouse_2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(mouse_2, 'tStartRefresh') # time at next scr refresh mouse_2.status = STARTED mouse_2.mouseClock.reset() prevButtonState = mouse_2.getPressed() # if button is down already this ISN'T a new click if mouse_2.status == STARTED: # only update if started and not finished! buttons = mouse_2.getPressed() if buttons != prevButtonState: # button state changed? prevButtonState = buttons if sum(buttons) > 0: # state changed to a new click # check if the mouse was inside our 'clickable' objects gotValidClick = False for obj in [endbutton]: if obj.contains(mouse_2): gotValidClick = True mouse_2.clicked_name.append(obj.name) x, y = mouse_2.getPos() mouse_2.x.append(x) mouse_2.y.append(y) buttons = mouse_2.getPressed() mouse_2.leftButton.append(buttons[0]) mouse_2.midButton.append(buttons[1]) mouse_2.rightButton.append(buttons[2]) mouse_2.time.append(mouse_2.mouseClock.getTime()) if gotValidClick: # abort routine on response 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 typedresponseComponents: 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 "typedresponse"------- for thisComponent in typedresponseComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('ID.text',ID.text) thisExp.addData('ID.started', ID.tStartRefresh) thisExp.addData('ID.stopped', ID.tStopRefresh) thisExp.addData('endbutton.started', endbutton.tStartRefresh) thisExp.addData('endbutton.stopped', endbutton.tStopRefresh) # store data for thisExp (ExperimentHandler) if len(mouse_2.x): thisExp.addData('mouse_2.x', mouse_2.x[0]) if len(mouse_2.y): thisExp.addData('mouse_2.y', mouse_2.y[0]) if len(mouse_2.leftButton): thisExp.addData('mouse_2.leftButton', mouse_2.leftButton[0]) if len(mouse_2.midButton): thisExp.addData('mouse_2.midButton', mouse_2.midButton[0]) if len(mouse_2.rightButton): thisExp.addData('mouse_2.rightButton', mouse_2.rightButton[0]) if len(mouse_2.time): thisExp.addData('mouse_2.time', mouse_2.time[0]) if len(mouse_2.clicked_name): thisExp.addData('mouse_2.clicked_name', mouse_2.clicked_name[0]) thisExp.addData('mouse_2.started', mouse_2.tStart) thisExp.addData('mouse_2.stopped', mouse_2.tStop) thisExp.nextEntry() # the Routine "typedresponse" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "introduction"------- continueRoutine = True # update component parameters for each repeat key_resp_intro.keys = [] key_resp_intro.rt = [] _key_resp_intro_allKeys = [] # keep track of which components have finished introductionComponents = [text_intro, key_resp_intro] for thisComponent in introductionComponents: 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") introductionClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "introduction"------- while continueRoutine: # get current time t = introductionClock.getTime() tThisFlip = win.getFutureFlipTime(clock=introductionClock) 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_intro* updates if text_intro.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_intro.frameNStart = frameN # exact frame index text_intro.tStart = t # local t and not account for scr refresh text_intro.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_intro, 'tStartRefresh') # time at next scr refresh text_intro.setAutoDraw(True) # *key_resp_intro* updates waitOnFlip = False if key_resp_intro.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_intro.frameNStart = frameN # exact frame index key_resp_intro.tStart = t # local t and not account for scr refresh key_resp_intro.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_intro, 'tStartRefresh') # time at next scr refresh key_resp_intro.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_intro.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_intro.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_intro.status == STARTED and not waitOnFlip: theseKeys = key_resp_intro.getKeys(keyList=['return'], waitRelease=False) _key_resp_intro_allKeys.extend(theseKeys) if len(_key_resp_intro_allKeys): key_resp_intro.keys = _key_resp_intro_allKeys[-1].name # just the last key pressed key_resp_intro.rt = _key_resp_intro_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 introductionComponents: 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 "introduction"------- for thisComponent in introductionComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_intro.started', text_intro.tStartRefresh) thisExp.addData('text_intro.stopped', text_intro.tStopRefresh) # the Routine "introduction" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "blank_1500"------- continueRoutine = True routineTimer.add(1.500000) # update component parameters for each repeat # keep track of which components have finished blank_1500Components = [blank_screen] for thisComponent in blank_1500Components: 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") blank_1500Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "blank_1500"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = blank_1500Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=blank_1500Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *blank_screen* updates if blank_screen.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later blank_screen.frameNStart = frameN # exact frame index blank_screen.tStart = t # local t and not account for scr refresh blank_screen.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(blank_screen, 'tStartRefresh') # time at next scr refresh blank_screen.setAutoDraw(True) if blank_screen.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > blank_screen.tStartRefresh + 1.5-frameTolerance: # keep track of stop time/frame for later blank_screen.tStop = t # not accounting for scr refresh blank_screen.frameNStop = frameN # exact frame index win.timeOnFlip(blank_screen, 'tStopRefresh') # time at next scr refresh blank_screen.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 blank_1500Components: 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 "blank_1500"------- for thisComponent in blank_1500Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('blank_screen.started', blank_screen.tStartRefresh) thisExp.addData('blank_screen.stopped', blank_screen.tStopRefresh) # ------Prepare to start Routine "stress_pre"------- continueRoutine = True # update component parameters for each repeat rating_stress.reset() # keep track of which components have finished stress_preComponents = [text_stress, rating_stress] for thisComponent in stress_preComponents: 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") stress_preClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "stress_pre"------- while continueRoutine: # get current time t = stress_preClock.getTime() tThisFlip = win.getFutureFlipTime(clock=stress_preClock) 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_stress* updates if text_stress.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_stress.frameNStart = frameN # exact frame index text_stress.tStart = t # local t and not account for scr refresh text_stress.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_stress, 'tStartRefresh') # time at next scr refresh text_stress.setAutoDraw(True) # *rating_stress* updates if rating_stress.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating_stress.frameNStart = frameN # exact frame index rating_stress.tStart = t # local t and not account for scr refresh rating_stress.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating_stress, 'tStartRefresh') # time at next scr refresh rating_stress.setAutoDraw(True) continueRoutine &= rating_stress.noResponse # a response ends the trial # 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 stress_preComponents: 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 "stress_pre"------- for thisComponent in stress_preComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_stress.started', text_stress.tStartRefresh) thisExp.addData('text_stress.stopped', text_stress.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating_stress.response', rating_stress.getRating()) thisExp.addData('rating_stress.rt', rating_stress.getRT()) thisExp.nextEntry() thisExp.addData('rating_stress.started', rating_stress.tStart) thisExp.addData('rating_stress.stopped', rating_stress.tStop) # the Routine "stress_pre" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "body_pre"------- continueRoutine = True # update component parameters for each repeat rating_body.reset() # keep track of which components have finished body_preComponents = [text_body, rating_body] for thisComponent in body_preComponents: 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") body_preClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "body_pre"------- while continueRoutine: # get current time t = body_preClock.getTime() tThisFlip = win.getFutureFlipTime(clock=body_preClock) 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_body* updates if text_body.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_body.frameNStart = frameN # exact frame index text_body.tStart = t # local t and not account for scr refresh text_body.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_body, 'tStartRefresh') # time at next scr refresh text_body.setAutoDraw(True) # *rating_body* updates if rating_body.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating_body.frameNStart = frameN # exact frame index rating_body.tStart = t # local t and not account for scr refresh rating_body.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating_body, 'tStartRefresh') # time at next scr refresh rating_body.setAutoDraw(True) continueRoutine &= rating_body.noResponse # a response ends the trial # 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 body_preComponents: 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 "body_pre"------- for thisComponent in body_preComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_body.started', text_body.tStartRefresh) thisExp.addData('text_body.stopped', text_body.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating_body.response', rating_body.getRating()) thisExp.addData('rating_body.rt', rating_body.getRT()) thisExp.nextEntry() thisExp.addData('rating_body.started', rating_body.tStart) thisExp.addData('rating_body.stopped', rating_body.tStop) # the Routine "body_pre" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "hearing_pre"------- continueRoutine = True # update component parameters for each repeat rating_hearing.reset() # keep track of which components have finished hearing_preComponents = [text_hearing, rating_hearing] for thisComponent in hearing_preComponents: 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") hearing_preClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "hearing_pre"------- while continueRoutine: # get current time t = hearing_preClock.getTime() tThisFlip = win.getFutureFlipTime(clock=hearing_preClock) 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_hearing* updates if text_hearing.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_hearing.frameNStart = frameN # exact frame index text_hearing.tStart = t # local t and not account for scr refresh text_hearing.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_hearing, 'tStartRefresh') # time at next scr refresh text_hearing.setAutoDraw(True) # *rating_hearing* updates if rating_hearing.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating_hearing.frameNStart = frameN # exact frame index rating_hearing.tStart = t # local t and not account for scr refresh rating_hearing.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating_hearing, 'tStartRefresh') # time at next scr refresh rating_hearing.setAutoDraw(True) continueRoutine &= rating_hearing.noResponse # a response ends the trial # 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 hearing_preComponents: 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 "hearing_pre"------- for thisComponent in hearing_preComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_hearing.started', text_hearing.tStartRefresh) thisExp.addData('text_hearing.stopped', text_hearing.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating_hearing.response', rating_hearing.getRating()) thisExp.addData('rating_hearing.rt', rating_hearing.getRT()) thisExp.nextEntry() thisExp.addData('rating_hearing.started', rating_hearing.tStart) thisExp.addData('rating_hearing.stopped', rating_hearing.tStop) # the Routine "hearing_pre" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "unreal_pre"------- continueRoutine = True # update component parameters for each repeat rating_unreal.reset() # keep track of which components have finished unreal_preComponents = [text_unreal, rating_unreal] for thisComponent in unreal_preComponents: 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") unreal_preClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "unreal_pre"------- while continueRoutine: # get current time t = unreal_preClock.getTime() tThisFlip = win.getFutureFlipTime(clock=unreal_preClock) 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_unreal* updates if text_unreal.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_unreal.frameNStart = frameN # exact frame index text_unreal.tStart = t # local t and not account for scr refresh text_unreal.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_unreal, 'tStartRefresh') # time at next scr refresh text_unreal.setAutoDraw(True) # *rating_unreal* updates if rating_unreal.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating_unreal.frameNStart = frameN # exact frame index rating_unreal.tStart = t # local t and not account for scr refresh rating_unreal.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating_unreal, 'tStartRefresh') # time at next scr refresh rating_unreal.setAutoDraw(True) continueRoutine &= rating_unreal.noResponse # a response ends the trial # 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 unreal_preComponents: 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 "unreal_pre"------- for thisComponent in unreal_preComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_unreal.started', text_unreal.tStartRefresh) thisExp.addData('text_unreal.stopped', text_unreal.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating_unreal.response', rating_unreal.getRating()) thisExp.addData('rating_unreal.rt', rating_unreal.getRT()) thisExp.nextEntry() thisExp.addData('rating_unreal.started', rating_unreal.tStart) thisExp.addData('rating_unreal.stopped', rating_unreal.tStop) # the Routine "unreal_pre" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "pain_pre"------- continueRoutine = True # update component parameters for each repeat rating_pain.reset() # keep track of which components have finished pain_preComponents = [text_pain, rating_pain] for thisComponent in pain_preComponents: 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") pain_preClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "pain_pre"------- while continueRoutine: # get current time t = pain_preClock.getTime() tThisFlip = win.getFutureFlipTime(clock=pain_preClock) 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_pain* updates if text_pain.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_pain.frameNStart = frameN # exact frame index text_pain.tStart = t # local t and not account for scr refresh text_pain.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_pain, 'tStartRefresh') # time at next scr refresh text_pain.setAutoDraw(True) # *rating_pain* updates if rating_pain.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating_pain.frameNStart = frameN # exact frame index rating_pain.tStart = t # local t and not account for scr refresh rating_pain.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating_pain, 'tStartRefresh') # time at next scr refresh rating_pain.setAutoDraw(True) continueRoutine &= rating_pain.noResponse # a response ends the trial # 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 pain_preComponents: 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 "pain_pre"------- for thisComponent in pain_preComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_pain.started', text_pain.tStartRefresh) thisExp.addData('text_pain.stopped', text_pain.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating_pain.response', rating_pain.getRating()) thisExp.addData('rating_pain.rt', rating_pain.getRT()) thisExp.nextEntry() thisExp.addData('rating_pain.started', rating_pain.tStart) thisExp.addData('rating_pain.stopped', rating_pain.tStop) # the Routine "pain_pre" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "instructions"------- continueRoutine = True # update component parameters for each repeat key_instructions.keys = [] key_instructions.rt = [] _key_instructions_allKeys = [] # keep track of which components have finished instructionsComponents = [text_instructions, key_instructions] for thisComponent in 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") instructionsClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "instructions"------- while continueRoutine: # get current time t = instructionsClock.getTime() tThisFlip = win.getFutureFlipTime(clock=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 # *text_instructions* updates if text_instructions.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_instructions.frameNStart = frameN # exact frame index text_instructions.tStart = t # local t and not account for scr refresh text_instructions.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_instructions, 'tStartRefresh') # time at next scr refresh text_instructions.setAutoDraw(True) # *key_instructions* updates waitOnFlip = False if key_instructions.status == NOT_STARTED and tThisFlip >= 1-frameTolerance: # keep track of start time/frame for later key_instructions.frameNStart = frameN # exact frame index key_instructions.tStart = t # local t and not account for scr refresh key_instructions.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_instructions, 'tStartRefresh') # time at next scr refresh key_instructions.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_instructions.clock.reset) # t=0 on next screen flip win.callOnFlip(key_instructions.clearEvents, eventType='keyboard') # clear events on next screen flip if key_instructions.status == STARTED and not waitOnFlip: theseKeys = key_instructions.getKeys(keyList=['return'], waitRelease=False) _key_instructions_allKeys.extend(theseKeys) if len(_key_instructions_allKeys): key_instructions.keys = _key_instructions_allKeys[-1].name # just the last key pressed key_instructions.rt = _key_instructions_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 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 "instructions"------- for thisComponent in instructionsComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_instructions.started', text_instructions.tStartRefresh) thisExp.addData('text_instructions.stopped', text_instructions.tStopRefresh) # the Routine "instructions" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "instructions2"------- continueRoutine = True # update component parameters for each repeat key_instructions2.keys = [] key_instructions2.rt = [] _key_instructions2_allKeys = [] # keep track of which components have finished instructions2Components = [text_instructions2, key_instructions2] for thisComponent in instructions2Components: 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") instructions2Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "instructions2"------- while continueRoutine: # get current time t = instructions2Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=instructions2Clock) 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_instructions2* updates if text_instructions2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_instructions2.frameNStart = frameN # exact frame index text_instructions2.tStart = t # local t and not account for scr refresh text_instructions2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_instructions2, 'tStartRefresh') # time at next scr refresh text_instructions2.setAutoDraw(True) # *key_instructions2* updates waitOnFlip = False if key_instructions2.status == NOT_STARTED and tThisFlip >= 1-frameTolerance: # keep track of start time/frame for later key_instructions2.frameNStart = frameN # exact frame index key_instructions2.tStart = t # local t and not account for scr refresh key_instructions2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_instructions2, 'tStartRefresh') # time at next scr refresh key_instructions2.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_instructions2.clock.reset) # t=0 on next screen flip win.callOnFlip(key_instructions2.clearEvents, eventType='keyboard') # clear events on next screen flip if key_instructions2.status == STARTED and not waitOnFlip: theseKeys = key_instructions2.getKeys(keyList=['return'], waitRelease=False) _key_instructions2_allKeys.extend(theseKeys) if len(_key_instructions2_allKeys): key_instructions2.keys = _key_instructions2_allKeys[-1].name # just the last key pressed key_instructions2.rt = _key_instructions2_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 instructions2Components: 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 "instructions2"------- for thisComponent in instructions2Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_instructions2.started', text_instructions2.tStartRefresh) thisExp.addData('text_instructions2.stopped', text_instructions2.tStopRefresh) # the Routine "instructions2" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "blank_1500"------- continueRoutine = True routineTimer.add(1.500000) # update component parameters for each repeat # keep track of which components have finished blank_1500Components = [blank_screen] for thisComponent in blank_1500Components: 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") blank_1500Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "blank_1500"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = blank_1500Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=blank_1500Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *blank_screen* updates if blank_screen.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later blank_screen.frameNStart = frameN # exact frame index blank_screen.tStart = t # local t and not account for scr refresh blank_screen.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(blank_screen, 'tStartRefresh') # time at next scr refresh blank_screen.setAutoDraw(True) if blank_screen.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > blank_screen.tStartRefresh + 1.5-frameTolerance: # keep track of stop time/frame for later blank_screen.tStop = t # not accounting for scr refresh blank_screen.frameNStop = frameN # exact frame index win.timeOnFlip(blank_screen, 'tStopRefresh') # time at next scr refresh blank_screen.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 blank_1500Components: 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 "blank_1500"------- for thisComponent in blank_1500Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('blank_screen.started', blank_screen.tStartRefresh) thisExp.addData('blank_screen.stopped', blank_screen.tStopRefresh) # set up handler to look after randomisation of conditions etc trials = data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('PilotAttributes.xlsx', selection='81:85'), 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 "memoranda"------- continueRoutine = True routineTimer.add(1.000000) # update component parameters for each repeat text_memoranda.setText(Memoranda) # keep track of which components have finished memorandaComponents = [text_memoranda] for thisComponent in memorandaComponents: 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") memorandaClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "memoranda"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = memorandaClock.getTime() tThisFlip = win.getFutureFlipTime(clock=memorandaClock) 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_memoranda* updates if text_memoranda.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_memoranda.frameNStart = frameN # exact frame index text_memoranda.tStart = t # local t and not account for scr refresh text_memoranda.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_memoranda, 'tStartRefresh') # time at next scr refresh text_memoranda.setAutoDraw(True) if text_memoranda.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_memoranda.tStartRefresh + 1.0-frameTolerance: # keep track of stop time/frame for later text_memoranda.tStop = t # not accounting for scr refresh text_memoranda.frameNStop = frameN # exact frame index win.timeOnFlip(text_memoranda, 'tStopRefresh') # time at next scr refresh text_memoranda.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 memorandaComponents: 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 "memoranda"------- for thisComponent in memorandaComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) trials.addData('text_memoranda.started', text_memoranda.tStartRefresh) trials.addData('text_memoranda.stopped', text_memoranda.tStopRefresh) # ------Prepare to start Routine "distractor"------- continueRoutine = True routineTimer.add(1.500000) # update component parameters for each repeat image_distractor.setImage(Distractor_jpg) # keep track of which components have finished distractorComponents = [image_distractor] for thisComponent in distractorComponents: 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") distractorClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "distractor"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = distractorClock.getTime() tThisFlip = win.getFutureFlipTime(clock=distractorClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *image_distractor* updates if image_distractor.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later image_distractor.frameNStart = frameN # exact frame index image_distractor.tStart = t # local t and not account for scr refresh image_distractor.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(image_distractor, 'tStartRefresh') # time at next scr refresh image_distractor.setAutoDraw(True) if image_distractor.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > image_distractor.tStartRefresh + 1.5-frameTolerance: # keep track of stop time/frame for later image_distractor.tStop = t # not accounting for scr refresh image_distractor.frameNStop = frameN # exact frame index win.timeOnFlip(image_distractor, 'tStopRefresh') # time at next scr refresh image_distractor.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 distractorComponents: 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 "distractor"------- for thisComponent in distractorComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) trials.addData('image_distractor.started', image_distractor.tStartRefresh) trials.addData('image_distractor.stopped', image_distractor.tStopRefresh) # ------Prepare to start Routine "target"------- continueRoutine = True routineTimer.add(2.500000) # update component parameters for each repeat text_target.setText(Target) key_practice.keys = [] key_practice.rt = [] _key_practice_allKeys = [] # keep track of which components have finished targetComponents = [text_target, key_practice] for thisComponent in targetComponents: 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") targetClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "target"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = targetClock.getTime() tThisFlip = win.getFutureFlipTime(clock=targetClock) 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_target* updates if text_target.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_target.frameNStart = frameN # exact frame index text_target.tStart = t # local t and not account for scr refresh text_target.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_target, 'tStartRefresh') # time at next scr refresh text_target.setAutoDraw(True) if text_target.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_target.tStartRefresh + 1.0-frameTolerance: # keep track of stop time/frame for later text_target.tStop = t # not accounting for scr refresh text_target.frameNStop = frameN # exact frame index win.timeOnFlip(text_target, 'tStopRefresh') # time at next scr refresh text_target.setAutoDraw(False) # *key_practice* updates waitOnFlip = False if key_practice.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_practice.frameNStart = frameN # exact frame index key_practice.tStart = t # local t and not account for scr refresh key_practice.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_practice, 'tStartRefresh') # time at next scr refresh key_practice.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_practice.clock.reset) # t=0 on next screen flip win.callOnFlip(key_practice.clearEvents, eventType='keyboard') # clear events on next screen flip if key_practice.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > key_practice.tStartRefresh + 2.5-frameTolerance: # keep track of stop time/frame for later key_practice.tStop = t # not accounting for scr refresh key_practice.frameNStop = frameN # exact frame index win.timeOnFlip(key_practice, 'tStopRefresh') # time at next scr refresh key_practice.status = FINISHED if key_practice.status == STARTED and not waitOnFlip: theseKeys = key_practice.getKeys(keyList=['left', 'right'], waitRelease=False) _key_practice_allKeys.extend(theseKeys) if len(_key_practice_allKeys): key_practice.keys = _key_practice_allKeys[-1].name # just the last key pressed key_practice.rt = _key_practice_allKeys[-1].rt # was this correct? if (key_practice.keys == str(CorrAns)) or (key_practice.keys == CorrAns): key_practice.corr = 1 else: key_practice.corr = 0 # 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 targetComponents: 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 "target"------- for thisComponent in targetComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) trials.addData('text_target.started', text_target.tStartRefresh) trials.addData('text_target.stopped', text_target.tStopRefresh) # check responses if key_practice.keys in ['', [], None]: # No response was made key_practice.keys = None # was no response the correct answer?! if str(CorrAns).lower() == 'none': key_practice.corr = 1; # correct non-response else: key_practice.corr = 0; # failed to respond (incorrectly) # store data for trials (TrialHandler) trials.addData('key_practice.keys',key_practice.keys) trials.addData('key_practice.corr', key_practice.corr) if key_practice.keys != None: # we had a response trials.addData('key_practice.rt', key_practice.rt) trials.addData('key_practice.started', key_practice.tStartRefresh) trials.addData('key_practice.stopped', key_practice.tStopRefresh) # ------Prepare to start Routine "blank_1500"------- continueRoutine = True routineTimer.add(1.500000) # update component parameters for each repeat # keep track of which components have finished blank_1500Components = [blank_screen] for thisComponent in blank_1500Components: 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") blank_1500Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "blank_1500"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = blank_1500Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=blank_1500Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *blank_screen* updates if blank_screen.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later blank_screen.frameNStart = frameN # exact frame index blank_screen.tStart = t # local t and not account for scr refresh blank_screen.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(blank_screen, 'tStartRefresh') # time at next scr refresh blank_screen.setAutoDraw(True) if blank_screen.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > blank_screen.tStartRefresh + 1.5-frameTolerance: # keep track of stop time/frame for later blank_screen.tStop = t # not accounting for scr refresh blank_screen.frameNStop = frameN # exact frame index win.timeOnFlip(blank_screen, 'tStopRefresh') # time at next scr refresh blank_screen.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 blank_1500Components: 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 "blank_1500"------- for thisComponent in blank_1500Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) trials.addData('blank_screen.started', blank_screen.tStartRefresh) trials.addData('blank_screen.stopped', blank_screen.tStopRefresh) thisExp.nextEntry() # completed 1 repeats of 'trials' # ------Prepare to start Routine "finish_practice"------- continueRoutine = True # update component parameters for each repeat key_finishpractice.keys = [] key_finishpractice.rt = [] _key_finishpractice_allKeys = [] # keep track of which components have finished finish_practiceComponents = [text_finishpractice, key_finishpractice] for thisComponent in finish_practiceComponents: 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") finish_practiceClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "finish_practice"------- while continueRoutine: # get current time t = finish_practiceClock.getTime() tThisFlip = win.getFutureFlipTime(clock=finish_practiceClock) 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_finishpractice* updates if text_finishpractice.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_finishpractice.frameNStart = frameN # exact frame index text_finishpractice.tStart = t # local t and not account for scr refresh text_finishpractice.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_finishpractice, 'tStartRefresh') # time at next scr refresh text_finishpractice.setAutoDraw(True) # *key_finishpractice* updates waitOnFlip = False if key_finishpractice.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_finishpractice.frameNStart = frameN # exact frame index key_finishpractice.tStart = t # local t and not account for scr refresh key_finishpractice.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_finishpractice, 'tStartRefresh') # time at next scr refresh key_finishpractice.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_finishpractice.clock.reset) # t=0 on next screen flip win.callOnFlip(key_finishpractice.clearEvents, eventType='keyboard') # clear events on next screen flip if key_finishpractice.status == STARTED and not waitOnFlip: theseKeys = key_finishpractice.getKeys(keyList=['return'], waitRelease=False) _key_finishpractice_allKeys.extend(theseKeys) if len(_key_finishpractice_allKeys): key_finishpractice.keys = _key_finishpractice_allKeys[-1].name # just the last key pressed key_finishpractice.rt = _key_finishpractice_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 finish_practiceComponents: 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 "finish_practice"------- for thisComponent in finish_practiceComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_finishpractice.started', text_finishpractice.tStartRefresh) thisExp.addData('text_finishpractice.stopped', text_finishpractice.tStopRefresh) # the Routine "finish_practice" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "blank_1500"------- continueRoutine = True routineTimer.add(1.500000) # update component parameters for each repeat # keep track of which components have finished blank_1500Components = [blank_screen] for thisComponent in blank_1500Components: 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") blank_1500Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "blank_1500"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = blank_1500Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=blank_1500Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *blank_screen* updates if blank_screen.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later blank_screen.frameNStart = frameN # exact frame index blank_screen.tStart = t # local t and not account for scr refresh blank_screen.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(blank_screen, 'tStartRefresh') # time at next scr refresh blank_screen.setAutoDraw(True) if blank_screen.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > blank_screen.tStartRefresh + 1.5-frameTolerance: # keep track of stop time/frame for later blank_screen.tStop = t # not accounting for scr refresh blank_screen.frameNStop = frameN # exact frame index win.timeOnFlip(blank_screen, 'tStopRefresh') # time at next scr refresh blank_screen.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 blank_1500Components: 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 "blank_1500"------- for thisComponent in blank_1500Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('blank_screen.started', blank_screen.tStartRefresh) thisExp.addData('blank_screen.stopped', blank_screen.tStopRefresh) # set up handler to look after randomisation of conditions etc trials_2 = data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('PilotAttributes.xlsx', selection='0:3'), seed=None, name='trials_2') thisExp.addLoop(trials_2) # add the loop to the experiment thisTrial_2 = trials_2.trialList[0] # so we can initialise stimuli with some values # abbreviate parameter names if possible (e.g. rgb = thisTrial_2.rgb) if thisTrial_2 != None: for paramName in thisTrial_2: exec('{} = thisTrial_2[paramName]'.format(paramName)) for thisTrial_2 in trials_2: currentLoop = trials_2 # abbreviate parameter names if possible (e.g. rgb = thisTrial_2.rgb) if thisTrial_2 != None: for paramName in thisTrial_2: exec('{} = thisTrial_2[paramName]'.format(paramName)) # ------Prepare to start Routine "memoranda"------- continueRoutine = True routineTimer.add(1.000000) # update component parameters for each repeat text_memoranda.setText(Memoranda) # keep track of which components have finished memorandaComponents = [text_memoranda] for thisComponent in memorandaComponents: 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") memorandaClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "memoranda"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = memorandaClock.getTime() tThisFlip = win.getFutureFlipTime(clock=memorandaClock) 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_memoranda* updates if text_memoranda.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_memoranda.frameNStart = frameN # exact frame index text_memoranda.tStart = t # local t and not account for scr refresh text_memoranda.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_memoranda, 'tStartRefresh') # time at next scr refresh text_memoranda.setAutoDraw(True) if text_memoranda.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_memoranda.tStartRefresh + 1.0-frameTolerance: # keep track of stop time/frame for later text_memoranda.tStop = t # not accounting for scr refresh text_memoranda.frameNStop = frameN # exact frame index win.timeOnFlip(text_memoranda, 'tStopRefresh') # time at next scr refresh text_memoranda.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 memorandaComponents: 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 "memoranda"------- for thisComponent in memorandaComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) trials_2.addData('text_memoranda.started', text_memoranda.tStartRefresh) trials_2.addData('text_memoranda.stopped', text_memoranda.tStopRefresh) # ------Prepare to start Routine "distractor"------- continueRoutine = True routineTimer.add(1.500000) # update component parameters for each repeat image_distractor.setImage(Distractor_jpg) # keep track of which components have finished distractorComponents = [image_distractor] for thisComponent in distractorComponents: 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") distractorClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "distractor"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = distractorClock.getTime() tThisFlip = win.getFutureFlipTime(clock=distractorClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *image_distractor* updates if image_distractor.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later image_distractor.frameNStart = frameN # exact frame index image_distractor.tStart = t # local t and not account for scr refresh image_distractor.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(image_distractor, 'tStartRefresh') # time at next scr refresh image_distractor.setAutoDraw(True) if image_distractor.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > image_distractor.tStartRefresh + 1.5-frameTolerance: # keep track of stop time/frame for later image_distractor.tStop = t # not accounting for scr refresh image_distractor.frameNStop = frameN # exact frame index win.timeOnFlip(image_distractor, 'tStopRefresh') # time at next scr refresh image_distractor.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 distractorComponents: 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 "distractor"------- for thisComponent in distractorComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) trials_2.addData('image_distractor.started', image_distractor.tStartRefresh) trials_2.addData('image_distractor.stopped', image_distractor.tStopRefresh) # ------Prepare to start Routine "target"------- continueRoutine = True routineTimer.add(2.500000) # update component parameters for each repeat text_target.setText(Target) key_practice.keys = [] key_practice.rt = [] _key_practice_allKeys = [] # keep track of which components have finished targetComponents = [text_target, key_practice] for thisComponent in targetComponents: 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") targetClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "target"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = targetClock.getTime() tThisFlip = win.getFutureFlipTime(clock=targetClock) 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_target* updates if text_target.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_target.frameNStart = frameN # exact frame index text_target.tStart = t # local t and not account for scr refresh text_target.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_target, 'tStartRefresh') # time at next scr refresh text_target.setAutoDraw(True) if text_target.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_target.tStartRefresh + 1.0-frameTolerance: # keep track of stop time/frame for later text_target.tStop = t # not accounting for scr refresh text_target.frameNStop = frameN # exact frame index win.timeOnFlip(text_target, 'tStopRefresh') # time at next scr refresh text_target.setAutoDraw(False) # *key_practice* updates waitOnFlip = False if key_practice.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_practice.frameNStart = frameN # exact frame index key_practice.tStart = t # local t and not account for scr refresh key_practice.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_practice, 'tStartRefresh') # time at next scr refresh key_practice.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_practice.clock.reset) # t=0 on next screen flip win.callOnFlip(key_practice.clearEvents, eventType='keyboard') # clear events on next screen flip if key_practice.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > key_practice.tStartRefresh + 2.5-frameTolerance: # keep track of stop time/frame for later key_practice.tStop = t # not accounting for scr refresh key_practice.frameNStop = frameN # exact frame index win.timeOnFlip(key_practice, 'tStopRefresh') # time at next scr refresh key_practice.status = FINISHED if key_practice.status == STARTED and not waitOnFlip: theseKeys = key_practice.getKeys(keyList=['left', 'right'], waitRelease=False) _key_practice_allKeys.extend(theseKeys) if len(_key_practice_allKeys): key_practice.keys = _key_practice_allKeys[-1].name # just the last key pressed key_practice.rt = _key_practice_allKeys[-1].rt # was this correct? if (key_practice.keys == str(CorrAns)) or (key_practice.keys == CorrAns): key_practice.corr = 1 else: key_practice.corr = 0 # 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 targetComponents: 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 "target"------- for thisComponent in targetComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) trials_2.addData('text_target.started', text_target.tStartRefresh) trials_2.addData('text_target.stopped', text_target.tStopRefresh) # check responses if key_practice.keys in ['', [], None]: # No response was made key_practice.keys = None # was no response the correct answer?! if str(CorrAns).lower() == 'none': key_practice.corr = 1; # correct non-response else: key_practice.corr = 0; # failed to respond (incorrectly) # store data for trials_2 (TrialHandler) trials_2.addData('key_practice.keys',key_practice.keys) trials_2.addData('key_practice.corr', key_practice.corr) if key_practice.keys != None: # we had a response trials_2.addData('key_practice.rt', key_practice.rt) trials_2.addData('key_practice.started', key_practice.tStartRefresh) trials_2.addData('key_practice.stopped', key_practice.tStopRefresh) # ------Prepare to start Routine "blank_1500"------- continueRoutine = True routineTimer.add(1.500000) # update component parameters for each repeat # keep track of which components have finished blank_1500Components = [blank_screen] for thisComponent in blank_1500Components: 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") blank_1500Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "blank_1500"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = blank_1500Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=blank_1500Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *blank_screen* updates if blank_screen.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later blank_screen.frameNStart = frameN # exact frame index blank_screen.tStart = t # local t and not account for scr refresh blank_screen.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(blank_screen, 'tStartRefresh') # time at next scr refresh blank_screen.setAutoDraw(True) if blank_screen.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > blank_screen.tStartRefresh + 1.5-frameTolerance: # keep track of stop time/frame for later blank_screen.tStop = t # not accounting for scr refresh blank_screen.frameNStop = frameN # exact frame index win.timeOnFlip(blank_screen, 'tStopRefresh') # time at next scr refresh blank_screen.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 blank_1500Components: 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 "blank_1500"------- for thisComponent in blank_1500Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) trials_2.addData('blank_screen.started', blank_screen.tStartRefresh) trials_2.addData('blank_screen.stopped', blank_screen.tStopRefresh) thisExp.nextEntry() # completed 1 repeats of 'trials_2' # ------Prepare to start Routine "finish_trials"------- continueRoutine = True # update component parameters for each repeat key_finishtrials.keys = [] key_finishtrials.rt = [] _key_finishtrials_allKeys = [] # keep track of which components have finished finish_trialsComponents = [text_finishtrials, key_finishtrials] for thisComponent in finish_trialsComponents: 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") finish_trialsClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "finish_trials"------- while continueRoutine: # get current time t = finish_trialsClock.getTime() tThisFlip = win.getFutureFlipTime(clock=finish_trialsClock) 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_finishtrials* updates if text_finishtrials.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_finishtrials.frameNStart = frameN # exact frame index text_finishtrials.tStart = t # local t and not account for scr refresh text_finishtrials.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_finishtrials, 'tStartRefresh') # time at next scr refresh text_finishtrials.setAutoDraw(True) # *key_finishtrials* updates waitOnFlip = False if key_finishtrials.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_finishtrials.frameNStart = frameN # exact frame index key_finishtrials.tStart = t # local t and not account for scr refresh key_finishtrials.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_finishtrials, 'tStartRefresh') # time at next scr refresh key_finishtrials.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_finishtrials.clock.reset) # t=0 on next screen flip win.callOnFlip(key_finishtrials.clearEvents, eventType='keyboard') # clear events on next screen flip if key_finishtrials.status == STARTED and not waitOnFlip: theseKeys = key_finishtrials.getKeys(keyList=['return'], waitRelease=False) _key_finishtrials_allKeys.extend(theseKeys) if len(_key_finishtrials_allKeys): key_finishtrials.keys = _key_finishtrials_allKeys[-1].name # just the last key pressed key_finishtrials.rt = _key_finishtrials_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 finish_trialsComponents: 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 "finish_trials"------- for thisComponent in finish_trialsComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_finishtrials.started', text_finishtrials.tStartRefresh) thisExp.addData('text_finishtrials.stopped', text_finishtrials.tStopRefresh) # the Routine "finish_trials" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "introduction2"------- continueRoutine = True # update component parameters for each repeat key_introduction2.keys = [] key_introduction2.rt = [] _key_introduction2_allKeys = [] # keep track of which components have finished introduction2Components = [text_introduction2, key_introduction2] for thisComponent in introduction2Components: 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") introduction2Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "introduction2"------- while continueRoutine: # get current time t = introduction2Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=introduction2Clock) 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_introduction2* updates if text_introduction2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_introduction2.frameNStart = frameN # exact frame index text_introduction2.tStart = t # local t and not account for scr refresh text_introduction2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_introduction2, 'tStartRefresh') # time at next scr refresh text_introduction2.setAutoDraw(True) # *key_introduction2* updates waitOnFlip = False if key_introduction2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_introduction2.frameNStart = frameN # exact frame index key_introduction2.tStart = t # local t and not account for scr refresh key_introduction2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_introduction2, 'tStartRefresh') # time at next scr refresh key_introduction2.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_introduction2.clock.reset) # t=0 on next screen flip win.callOnFlip(key_introduction2.clearEvents, eventType='keyboard') # clear events on next screen flip if key_introduction2.status == STARTED and not waitOnFlip: theseKeys = key_introduction2.getKeys(keyList=['return'], waitRelease=False) _key_introduction2_allKeys.extend(theseKeys) if len(_key_introduction2_allKeys): key_introduction2.keys = _key_introduction2_allKeys[-1].name # just the last key pressed key_introduction2.rt = _key_introduction2_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 introduction2Components: 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 "introduction2"------- for thisComponent in introduction2Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_introduction2.started', text_introduction2.tStartRefresh) thisExp.addData('text_introduction2.stopped', text_introduction2.tStopRefresh) # the Routine "introduction2" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "blank_1500"------- continueRoutine = True routineTimer.add(1.500000) # update component parameters for each repeat # keep track of which components have finished blank_1500Components = [blank_screen] for thisComponent in blank_1500Components: 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") blank_1500Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "blank_1500"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = blank_1500Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=blank_1500Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *blank_screen* updates if blank_screen.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later blank_screen.frameNStart = frameN # exact frame index blank_screen.tStart = t # local t and not account for scr refresh blank_screen.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(blank_screen, 'tStartRefresh') # time at next scr refresh blank_screen.setAutoDraw(True) if blank_screen.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > blank_screen.tStartRefresh + 1.5-frameTolerance: # keep track of stop time/frame for later blank_screen.tStop = t # not accounting for scr refresh blank_screen.frameNStop = frameN # exact frame index win.timeOnFlip(blank_screen, 'tStopRefresh') # time at next scr refresh blank_screen.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 blank_1500Components: 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 "blank_1500"------- for thisComponent in blank_1500Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('blank_screen.started', blank_screen.tStartRefresh) thisExp.addData('blank_screen.stopped', blank_screen.tStopRefresh) # ------Prepare to start Routine "stress_post"------- continueRoutine = True # update component parameters for each repeat rating_stress2.reset() # keep track of which components have finished stress_postComponents = [text_stress2, rating_stress2] for thisComponent in stress_postComponents: 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") stress_postClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "stress_post"------- while continueRoutine: # get current time t = stress_postClock.getTime() tThisFlip = win.getFutureFlipTime(clock=stress_postClock) 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_stress2* updates if text_stress2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_stress2.frameNStart = frameN # exact frame index text_stress2.tStart = t # local t and not account for scr refresh text_stress2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_stress2, 'tStartRefresh') # time at next scr refresh text_stress2.setAutoDraw(True) # *rating_stress2* updates if rating_stress2.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating_stress2.frameNStart = frameN # exact frame index rating_stress2.tStart = t # local t and not account for scr refresh rating_stress2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating_stress2, 'tStartRefresh') # time at next scr refresh rating_stress2.setAutoDraw(True) continueRoutine &= rating_stress2.noResponse # a response ends the trial # 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 stress_postComponents: 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 "stress_post"------- for thisComponent in stress_postComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_stress2.started', text_stress2.tStartRefresh) thisExp.addData('text_stress2.stopped', text_stress2.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating_stress2.response', rating_stress2.getRating()) thisExp.addData('rating_stress2.rt', rating_stress2.getRT()) thisExp.nextEntry() thisExp.addData('rating_stress2.started', rating_stress2.tStart) thisExp.addData('rating_stress2.stopped', rating_stress2.tStop) # the Routine "stress_post" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "body_post"------- continueRoutine = True # update component parameters for each repeat rating_body2.reset() # keep track of which components have finished body_postComponents = [text_body2, rating_body2] for thisComponent in body_postComponents: 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") body_postClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "body_post"------- while continueRoutine: # get current time t = body_postClock.getTime() tThisFlip = win.getFutureFlipTime(clock=body_postClock) 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_body2* updates if text_body2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_body2.frameNStart = frameN # exact frame index text_body2.tStart = t # local t and not account for scr refresh text_body2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_body2, 'tStartRefresh') # time at next scr refresh text_body2.setAutoDraw(True) # *rating_body2* updates if rating_body2.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating_body2.frameNStart = frameN # exact frame index rating_body2.tStart = t # local t and not account for scr refresh rating_body2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating_body2, 'tStartRefresh') # time at next scr refresh rating_body2.setAutoDraw(True) continueRoutine &= rating_body2.noResponse # a response ends the trial # 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 body_postComponents: 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 "body_post"------- for thisComponent in body_postComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_body2.started', text_body2.tStartRefresh) thisExp.addData('text_body2.stopped', text_body2.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating_body2.response', rating_body2.getRating()) thisExp.addData('rating_body2.rt', rating_body2.getRT()) thisExp.nextEntry() thisExp.addData('rating_body2.started', rating_body2.tStart) thisExp.addData('rating_body2.stopped', rating_body2.tStop) # the Routine "body_post" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "hearing_post"------- continueRoutine = True # update component parameters for each repeat rating.reset() # keep track of which components have finished hearing_postComponents = [text_hearing2, rating] for thisComponent in hearing_postComponents: 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") hearing_postClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "hearing_post"------- while continueRoutine: # get current time t = hearing_postClock.getTime() tThisFlip = win.getFutureFlipTime(clock=hearing_postClock) 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_hearing2* updates if text_hearing2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_hearing2.frameNStart = frameN # exact frame index text_hearing2.tStart = t # local t and not account for scr refresh text_hearing2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_hearing2, 'tStartRefresh') # time at next scr refresh text_hearing2.setAutoDraw(True) # *rating* updates if rating.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating.frameNStart = frameN # exact frame index rating.tStart = t # local t and not account for scr refresh rating.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating, 'tStartRefresh') # time at next scr refresh rating.setAutoDraw(True) continueRoutine &= rating.noResponse # a response ends the trial # 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 hearing_postComponents: 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 "hearing_post"------- for thisComponent in hearing_postComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_hearing2.started', text_hearing2.tStartRefresh) thisExp.addData('text_hearing2.stopped', text_hearing2.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating.response', rating.getRating()) thisExp.addData('rating.rt', rating.getRT()) thisExp.nextEntry() thisExp.addData('rating.started', rating.tStart) thisExp.addData('rating.stopped', rating.tStop) # the Routine "hearing_post" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "unreal_post"------- continueRoutine = True # update component parameters for each repeat rating_2.reset() # keep track of which components have finished unreal_postComponents = [text_unreal2, rating_2] for thisComponent in unreal_postComponents: 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") unreal_postClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "unreal_post"------- while continueRoutine: # get current time t = unreal_postClock.getTime() tThisFlip = win.getFutureFlipTime(clock=unreal_postClock) 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_unreal2* updates if text_unreal2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_unreal2.frameNStart = frameN # exact frame index text_unreal2.tStart = t # local t and not account for scr refresh text_unreal2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_unreal2, 'tStartRefresh') # time at next scr refresh text_unreal2.setAutoDraw(True) # *rating_2* updates if rating_2.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating_2.frameNStart = frameN # exact frame index rating_2.tStart = t # local t and not account for scr refresh rating_2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating_2, 'tStartRefresh') # time at next scr refresh rating_2.setAutoDraw(True) continueRoutine &= rating_2.noResponse # a response ends the trial # 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 unreal_postComponents: 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 "unreal_post"------- for thisComponent in unreal_postComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_unreal2.started', text_unreal2.tStartRefresh) thisExp.addData('text_unreal2.stopped', text_unreal2.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating_2.response', rating_2.getRating()) thisExp.addData('rating_2.rt', rating_2.getRT()) thisExp.nextEntry() thisExp.addData('rating_2.started', rating_2.tStart) thisExp.addData('rating_2.stopped', rating_2.tStop) # the Routine "unreal_post" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "pain_post"------- continueRoutine = True # update component parameters for each repeat rating_3.reset() # keep track of which components have finished pain_postComponents = [text_pain2, rating_3] for thisComponent in pain_postComponents: 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") pain_postClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "pain_post"------- while continueRoutine: # get current time t = pain_postClock.getTime() tThisFlip = win.getFutureFlipTime(clock=pain_postClock) 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_pain2* updates if text_pain2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_pain2.frameNStart = frameN # exact frame index text_pain2.tStart = t # local t and not account for scr refresh text_pain2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_pain2, 'tStartRefresh') # time at next scr refresh text_pain2.setAutoDraw(True) # *rating_3* updates if rating_3.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later rating_3.frameNStart = frameN # exact frame index rating_3.tStart = t # local t and not account for scr refresh rating_3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(rating_3, 'tStartRefresh') # time at next scr refresh rating_3.setAutoDraw(True) continueRoutine &= rating_3.noResponse # a response ends the trial # 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 pain_postComponents: 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 "pain_post"------- for thisComponent in pain_postComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_pain2.started', text_pain2.tStartRefresh) thisExp.addData('text_pain2.stopped', text_pain2.tStopRefresh) # store data for thisExp (ExperimentHandler) thisExp.addData('rating_3.response', rating_3.getRating()) thisExp.addData('rating_3.rt', rating_3.getRT()) thisExp.nextEntry() thisExp.addData('rating_3.started', rating_3.tStart) thisExp.addData('rating_3.stopped', rating_3.tStop) # the Routine "pain_post" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "blank_1500"------- continueRoutine = True routineTimer.add(1.500000) # update component parameters for each repeat # keep track of which components have finished blank_1500Components = [blank_screen] for thisComponent in blank_1500Components: 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") blank_1500Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "blank_1500"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = blank_1500Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=blank_1500Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *blank_screen* updates if blank_screen.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later blank_screen.frameNStart = frameN # exact frame index blank_screen.tStart = t # local t and not account for scr refresh blank_screen.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(blank_screen, 'tStartRefresh') # time at next scr refresh blank_screen.setAutoDraw(True) if blank_screen.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > blank_screen.tStartRefresh + 1.5-frameTolerance: # keep track of stop time/frame for later blank_screen.tStop = t # not accounting for scr refresh blank_screen.frameNStop = frameN # exact frame index win.timeOnFlip(blank_screen, 'tStopRefresh') # time at next scr refresh blank_screen.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 blank_1500Components: 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 "blank_1500"------- for thisComponent in blank_1500Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('blank_screen.started', blank_screen.tStartRefresh) thisExp.addData('blank_screen.stopped', blank_screen.tStopRefresh) # ------Prepare to start Routine "end"------- continueRoutine = True # update component parameters for each repeat key_end.keys = [] key_end.rt = [] _key_end_allKeys = [] # keep track of which components have finished endComponents = [text_end, key_end] for thisComponent in endComponents: 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") endClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "end"------- while continueRoutine: # get current time t = endClock.getTime() tThisFlip = win.getFutureFlipTime(clock=endClock) 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_end* updates if text_end.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_end.frameNStart = frameN # exact frame index text_end.tStart = t # local t and not account for scr refresh text_end.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_end, 'tStartRefresh') # time at next scr refresh text_end.setAutoDraw(True) # *key_end* updates waitOnFlip = False if key_end.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_end.frameNStart = frameN # exact frame index key_end.tStart = t # local t and not account for scr refresh key_end.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_end, 'tStartRefresh') # time at next scr refresh key_end.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_end.clock.reset) # t=0 on next screen flip win.callOnFlip(key_end.clearEvents, eventType='keyboard') # clear events on next screen flip if key_end.status == STARTED and not waitOnFlip: theseKeys = key_end.getKeys(keyList=['return'], waitRelease=False) _key_end_allKeys.extend(theseKeys) if len(_key_end_allKeys): key_end.keys = _key_end_allKeys[-1].name # just the last key pressed key_end.rt = _key_end_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 endComponents: 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 "end"------- for thisComponent in endComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_end.started', text_end.tStartRefresh) thisExp.addData('text_end.stopped', text_end.tStopRefresh) # the Routine "end" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # Flip one final time so any remaining win.callOnFlip() # and win.timeOnFlip() tasks get executed before quitting win.flip() # these shouldn't be strictly necessary (should auto-save) thisExp.saveAsWideText(filename+'.csv', delim='auto') thisExp.saveAsPickle(filename) logging.flush() # make sure everything is closed down thisExp.abort() # or data files will save again on exit win.close() core.quit()