#!/usr/bin/env python # -*- coding: utf-8 -*- """ This experiment was created using PsychoPy3 Experiment Builder (v2020.1.3), on June 08, 2020, at 14:02 If you publish work using this script the most relevant publication is: Peirce J, Gray JR, Simpson S, MacAskill M, Höchenberger R, Sogo H, Kastman E, Lindeløv JK. (2019) PsychoPy2: Experiments in behavior made easy Behav Res 51: 195. https://doi.org/10.3758/s13428-018-01193-y """ from __future__ import absolute_import, division from psychopy import locale_setup from psychopy import prefs prefs.hardware['audioLib'] = 'ptb' from psychopy import sound, gui, visual, core, data, event, logging, clock from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED, STOPPED, FINISHED, PRESSED, RELEASED, FOREVER) import numpy as np # whole numpy lib is available, prepend 'np.' from numpy import (sin, cos, tan, log, log10, pi, average, sqrt, std, deg2rad, rad2deg, linspace, asarray) from numpy.random import random, randint, normal, shuffle import os # handy system and path functions import sys # to get file system encoding from psychopy.hardware import keyboard # Ensure that relative paths start from the same directory as this script _thisDir = os.path.dirname(os.path.abspath(__file__)) os.chdir(_thisDir) # Store info about the experiment session psychopyVersion = '2020.1.3' expName = 'audio_visual_congruence' # from the Builder filename that created this script expInfo = {'participant': '', 'session': '001'} dlg = gui.DlgFromDict(dictionary=expInfo, sortKeys=False, title=expName) if dlg.OK == False: core.quit() # user pressed cancel expInfo['date'] = data.getDateStr() # add a simple timestamp expInfo['expName'] = expName expInfo['psychopyVersion'] = psychopyVersion # Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc filename = _thisDir + os.sep + u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date']) # An ExperimentHandler isn't essential but helps with data saving thisExp = data.ExperimentHandler(name=expName, version='', extraInfo=expInfo, runtimeInfo=None, originPath='C:\\Users\\HP\\Documents\\Experiment_Pau\\audio_visual_congruence.py', savePickle=True, saveWideText=True, dataFileName=filename) # save a log file for detail verbose info logFile = logging.LogFile(filename+'.log', level=logging.EXP) logging.console.setLevel(logging.WARNING) # this outputs to the screen, not a file endExpNow = False # flag for 'escape' or other condition => quit the exp frameTolerance = 0.001 # how close to onset before 'same' frame # Start Code - component code to be run before the window creation # Setup the Window win = visual.Window( size=[1536, 864], fullscr=True, screen=0, winType='pyglet', allowGUI=False, allowStencil=False, monitor='testMonitor', color=[0,0,0], colorSpace='rgb', blendMode='avg', useFBO=True, units='height') # store frame rate of monitor if we can measure it expInfo['frameRate'] = win.getActualFrameRate() if expInfo['frameRate'] != None: frameDur = 1.0 / round(expInfo['frameRate']) else: frameDur = 1.0 / 60.0 # could not measure, so guess # create a default keyboard (e.g. to check for escape) defaultKeyboard = keyboard.Keyboard() # Initialize components for Routine "screen_scale" screen_scaleClock = core.Clock() event=psychoJS.eventManager; thisExp=psychoJS.experiment; win=psychoJS.window; round = function (a) { return Math.round(a); } oldt=0 x_size=8.560 y_size=5.398 screen_height=0 if win.units=='norm': x_scale=.05 y_scale=.1 dbase = .0001 unittext=' norm units' vsize=2 elif win.units=='pix': x_scale=60 y_scale=40 dbase = .1 unittext=' pixels' vsize=win.size[1] else: x_scale=.05 y_scale=.05 dbase = .0001 unittext=' height units' vsize=1 text_top_screenscale = visual.TextStim(win=win, name='text_top_screenscale', text='Resize this image to match the size of a credit card\nUp arrow for taller\nDown arrow for shorter\nLeft arrow for narrower\nRight arrow for wider', font='Arial', pos=(0, 0.7), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-2.0); text_bottom_screenscale = visual.TextStim(win=win, name='text_bottom_screenscale', text='Press the space bar when done', font='Arial', pos=(0, -0.6), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-3.0); ccimage_screenscale = visual.ImageStim( win=win, name='ccimage_screenscale', image='bank-1300155_640.png', mask=None, ori=0, pos=(0, 0), size=(x_size*x_scale, y_size*y_scale), color=[1,1,1], colorSpace='rgb', opacity=1, flipHoriz=False, flipVert=False, texRes=128, interpolate=True, depth=-4.0) # Initialize components for Routine "rectangle_screenscale" rectangle_screenscaleClock = core.Clock() text_rectangle_screenscale = visual.TextStim(win=win, name='text_rectangle_screenscale', text='This shape should be a 10 cm square.\n\nPress space to continue', font='Arial', pos=(0, -0.8), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); polygon_screenscale = visual.Rect( win=win, name='polygon_screenscale', width=[1.0, 1.0][0], height=[1.0, 1.0][1], ori=0, pos=(0, 0), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=-1.0, interpolate=True) key_resp_screenscale = keyboard.Keyboard() # Initialize components for Routine "Participant_description1" Participant_description1Clock = core.Clock() polygonDescription = visual.Rect( win=win, name='polygonDescription', width=(2, 2)[0], height=(2, 2)[1], ori=0, pos=(0, 0), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) textDescription1 = visual.TextStim(win=win, name='textDescription1', text='Welcome to the research study!\nPROJECT TITLE: Audiovisual Congruence\n\n\nINVITATION\n\nYou are being asked to voluntarily take part in a research study on audiovisual congruence. Before consenting to participate in this study, please read the following statements and ask as many questions as you need to ensure that you understand what your participation involves. \n\n\nOBJECT OF THIS STUDY\n\nThis study investigates how the brain processes congruence between audio and visual stimuli. \n', font='Arial', pos=(0, 0), height=0.03, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); polygon_continue = visual.ShapeStim( win=win, name='polygon_continue', vertices=[[-(0.6, 0.1)[0]/2.0,-(0.6, 0.1)[1]/2.0], [+(0.6, 0.1)[0]/2.0,-(0.6, 0.1)[1]/2.0], [0,(0.6, 0.1)[1]/2.0]], ori=0, pos=(0, -0.4), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=-2.0, interpolate=True) text_pressbar = visual.TextStim(win=win, name='text_pressbar', text='I read, agree and want to continue', font='Arial', pos=(0, -0.4), height=0.03, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-3.0); mouse_description1 = event.Mouse(win=win) x, y = [None, None] mouse_description1.mouseClock = core.Clock() # Initialize components for Routine "ParticipantDescription2" ParticipantDescription2Clock = core.Clock() polygon_description3 = visual.ShapeStim( win=win, name='polygon_description3', vertices=[[-(2, 2)[0]/2.0,-(2, 2)[1]/2.0], [+(2, 2)[0]/2.0,-(2, 2)[1]/2.0], [0,(2, 2)[1]/2.0]], ori=0, pos=(0, 0), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) text_description2 = visual.TextStim(win=win, name='text_description2', text='THE PROCEDURE YOU WILL PERFORM\n\nThe test in which you will participate includes behavioral measurements. This means that you will be asked to give responses through button press according to your perceptions during the presentation of certain stimuli, in agreement with concrete instructions which will be clearly given at the beginning of the study. \n\n\nPARTICIPANTS’ RIGHTS\n\nDuring the realization of the study, you will be able, at any moment, to exert your right of access, rectification, cancelation or opposition of your data to the responsible researcher, just like establishes the Spanish royal decree 1720/2007, the Spanish law organizing the protection of personal datum 15/1994, and the European directive 2002/58/CE.\n', font='Arial', pos=(0, 0), height=0.03, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); polygon_press2 = visual.ShapeStim( win=win, name='polygon_press2', vertices=[[-(0.6, 0.1)[0]/2.0,-(0.6, 0.1)[1]/2.0], [+(0.6, 0.1)[0]/2.0,-(0.6, 0.1)[1]/2.0], [0,(0.6, 0.1)[1]/2.0]], ori=0, pos=(0, -0.4), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=-2.0, interpolate=True) text_pressbar3 = visual.TextStim(win=win, name='text_pressbar3', text='I have read the above, agree and want to continue', font='Arial', pos=(0, -0.4), height=0.03, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-3.0); mouse_pressbar2 = event.Mouse(win=win) x, y = [None, None] mouse_pressbar2.mouseClock = core.Clock() # Initialize components for Routine "Participant_description3" Participant_description3Clock = core.Clock() polygon_description_3 = visual.ShapeStim( win=win, name='polygon_description_3', vertices=[[-(2,2)[0]/2.0,-(2,2)[1]/2.0], [+(2,2)[0]/2.0,-(2,2)[1]/2.0], [0,(2,2)[1]/2.0]], ori=0, pos=(0, 0), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) text_description3 = visual.TextStim(win=win, name='text_description3', text='INCONVENIENT AND BENEFITS\n\nThe only inconvenient that could happen when participating in the study is the loss of the time needed to carry out the experiment. The study will take up to 45-60 minutes. The participation in the study does not include any evaluation or clinical psychological test of the individual participant, it will only be helpful in the production of scientific information.\n \n\nCOST, REIMBURSEMENT AND COMPENSATION\n\nYour participation in this study is voluntary; there is monetary compensation for your participation in this study.\n', font='Arial', pos=(0, 0), height=0.03, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); polygon_press3 = visual.Rect( win=win, name='polygon_press3', width=(0.6, 0.1)[0], height=(0.6, 0.1)[1], ori=0, pos=(0, -0.4), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=-2.0, interpolate=True) text_pressbar_3 = visual.TextStim(win=win, name='text_pressbar_3', text='I have read the above, agree and want to continue', font='Arial', pos=(0, -0.4), height=0.03, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-3.0); mouse = event.Mouse(win=win) x, y = [None, None] mouse.mouseClock = core.Clock() # Initialize components for Routine "ParticipantDescription4" ParticipantDescription4Clock = core.Clock() polygon_description2 = visual.Rect( win=win, name='polygon_description2', width=(2, 2)[0], height=(2, 2)[1], ori=0, pos=(0, 0), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) text_description4 = visual.TextStim(win=win, name='text_description4', text='CONFIDENTIALITY/ANONYMITY\n\nIn compliance with the Data Protection Act and Freedom of Information Act, the data we collect will not maintain any personally identifiable information about you. No one will link the data you provide to any identifying information you may supply. Data may be used for research outputs such as articles and conference presentations.\n\nIf you have any questions that remain without answers, please ask the person in charge before agreeing to this form.\n\nYou can contact the principal investigator, Prof. Salvador Soto Faraco: TEL.+34.93.542.25.34 or by E-Mail salvador.soto@upf.edu.\n', font='Arial', pos=(0, 0), height=0.03, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); polygon_press4 = visual.Rect( win=win, name='polygon_press4', width=(0.6, 0.1)[0], height=(0.6, 0.1)[1], ori=0, pos=(0, -0.4), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=-2.0, interpolate=True) text_pressbar2 = visual.TextStim(win=win, name='text_pressbar2', text='I have read the above information, agree and want to continue', font='Arial', pos=(0, -0.4), height=0.03, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-3.0); mouse_pressbar4 = event.Mouse(win=win) x, y = [None, None] mouse_pressbar4.mouseClock = core.Clock() # Initialize components for Routine "consent_form" consent_formClock = core.Clock() polygonInformedConsent = visual.ShapeStim( win=win, name='polygonInformedConsent', vertices=[[-(2,2)[0]/2.0,-(2,2)[1]/2.0], [+(2,2)[0]/2.0,-(2,2)[1]/2.0], [0,(2,2)[1]/2.0]], ori=0, pos=(0, 0), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) text_informedconsent = visual.TextStim(win=win, name='text_informedconsent', text='AGREEMENT TO PARTICIPATE IN THE STUDY\n\nBy clicking the button below, you acknowledge that: \n- I have read the page of information that I have been given.\n- I have been given an email address where to ask questions regarding the study.\n- I have received enough information regarding the study. \n', font='Arial', pos=(0, 0), height=0.04, wrapWidth=None, ori=0, color='black', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); polygon_yesconsent = visual.Rect( win=win, name='polygon_yesconsent', width=(0.6, 0.1)[0], height=(0.6, 0.1)[1], ori=0, pos=(-0.5, -0.4), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=-2.0, interpolate=True) text_consentbegin = visual.TextStim(win=win, name='text_consentbegin', text='I consent, begin the study', font='Arial', pos=(-0.5, -0.4), height=0.03, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-3.0); polygon_noconsent = visual.Rect( win=win, name='polygon_noconsent', width=(0.7, 0.1)[0], height=(0.7, 0.1)[1], ori=0, pos=(0.5, -0.4), lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=-4.0, interpolate=True) text_NotConsent = visual.TextStim(win=win, name='text_NotConsent', text='I do not consent, I do not wish to participate', font='Arial', pos=(0.5, -0.4), height=0.03, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-5.0); mouse_consent = event.Mouse(win=win) x, y = [None, None] mouse_consent.mouseClock = core.Clock() # Initialize components for Routine "instructions" instructionsClock = core.Clock() intrText = visual.TextStim(win=win, name='intrText', text="Step 1: Sound image pairs (Part 1/3)\n\nRate how well the sound and image pairs match together.\nPlease respond before the next image appears.\n\nRemember:\n1= Doesn't match at all.\n2= Doesn't match.\n3= More or less.\n4= Matches.\n5= Matches very well.\n\nPress any key to continue.\n", font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp = keyboard.Keyboard() # Initialize components for Routine "ISI" ISIClock = core.Clock() polygon = visual.ShapeStim( win=win, name='polygon', vertices='cross', size=(0.1, 0.1), ori=0, pos=(0, 0), lineWidth=0.25, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) # Initialize components for Routine "trial" trialClock = core.Clock() response = keyboard.Keyboard() image = visual.ImageStim( win=win, name='image', image='sin', mask=None, ori=0, pos=(0, 0), size=(0.5, 0.5), color=[1,1,1], colorSpace='rgb', opacity=1, flipHoriz=False, flipVert=False, texRes=128, interpolate=True, depth=-1.0) sound_1 = sound.Sound('A', secs=-1, stereo=True, hamming=True, name='sound_1') sound_1.setVolume(1) # Initialize components for Routine "feedback_in_loop_encodingpractice" feedback_in_loop_encodingpracticeClock = core.Clock() msg='doh!'#if this comes up we forgot to update the msg! text_10 = visual.TextStim(win=win, name='text_10', text='default text', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); # Initialize components for Routine "EncodingInstructionsReminder" EncodingInstructionsReminderClock = core.Clock() text_6 = visual.TextStim(win=win, name='text_6', text="Remember the instructions:\n\nRate how well the sound and image pairs match together.\nPlease respond before the next image appears.\n\n1= Doesn't match at all.\n2= Doesn't match.\n3= More or less.\n4= Matches.\n5= Matches very well.\n\nPress any key to continue.\n", font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp_8 = keyboard.Keyboard() # Initialize components for Routine "ISI" ISIClock = core.Clock() polygon = visual.ShapeStim( win=win, name='polygon', vertices='cross', size=(0.1, 0.1), ori=0, pos=(0, 0), lineWidth=0.25, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) # Initialize components for Routine "trial" trialClock = core.Clock() response = keyboard.Keyboard() image = visual.ImageStim( win=win, name='image', image='sin', mask=None, ori=0, pos=(0, 0), size=(0.5, 0.5), color=[1,1,1], colorSpace='rgb', opacity=1, flipHoriz=False, flipVert=False, texRes=128, interpolate=True, depth=-1.0) sound_1 = sound.Sound('A', secs=-1, stereo=True, hamming=True, name='sound_1') sound_1.setVolume(1) # Initialize components for Routine "Interval_task_instructions" Interval_task_instructionsClock = core.Clock() text_5 = visual.TextStim(win=win, name='text_5', text='Step 2: Math Task (part 2/3)\n\nLook at the two numbers that appear.\nYou have three seconds to choose,\nwith the left or right arrow buttons,\nwhich is bigger.\n\nThe correct answer is flashed after each trial.\n\nPress any key to continue.\n', font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp_7 = keyboard.Keyboard() # Initialize components for Routine "interval_task" interval_taskClock = core.Clock() text_3 = visual.TextStim(win=win, name='text_3', text='default text', font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp_5 = keyboard.Keyboard() # Initialize components for Routine "interval_feedback" interval_feedbackClock = core.Clock() msg='doh!'#if this comes up we forgot to update the msg! text_4 = visual.TextStim(win=win, name='text_4', text='default text', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); key_resp_6 = keyboard.Keyboard() # Initialize components for Routine "DistractionInstructionsReminder" DistractionInstructionsReminderClock = core.Clock() text_7 = visual.TextStim(win=win, name='text_7', text='Remember the instructions:\n\nLook at the two numbers that appear.\nYou have three seconds to choose,\nwith the left or right arrow buttons,\nwhich is bigger.\n\nThe correct answer is flashed after each trial.\n\nPress any key to continue.\n', font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp_9 = keyboard.Keyboard() # Initialize components for Routine "interval_task" interval_taskClock = core.Clock() text_3 = visual.TextStim(win=win, name='text_3', text='default text', font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp_5 = keyboard.Keyboard() # Initialize components for Routine "interval_feedback" interval_feedbackClock = core.Clock() msg='doh!'#if this comes up we forgot to update the msg! text_4 = visual.TextStim(win=win, name='text_4', text='default text', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); key_resp_6 = keyboard.Keyboard() # Initialize components for Routine "TestInstructions" TestInstructionsClock = core.Clock() text = visual.TextStim(win=win, name='text', text='Step 3: Memory Test (part 3/3)\n\nNow you will see a series of images, for each image try to remember whether it appeared during the first \nhalf of the experiment or not.\nIf it did appear during the first part, press the right arrow key, \nif not, press the left arrow key.\n\nPress any key to continue.\n', font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp_3 = keyboard.Keyboard() # Initialize components for Routine "TestISI" TestISIClock = core.Clock() polygon_2 = visual.ShapeStim( win=win, name='polygon_2', vertices='cross', size=(0.1, 0.1), ori=0, pos=(0, 0), lineWidth=0.25, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) # Initialize components for Routine "testtrial" testtrialClock = core.Clock() key_resp_2 = keyboard.Keyboard() image_2 = visual.ImageStim( win=win, name='image_2', image='sin', mask=None, ori=0, pos=(0, 0), size=(0.5, 0.5), color=[1,1,1], colorSpace='rgb', opacity=1, flipHoriz=False, flipVert=False, texRes=128, interpolate=True, depth=-1.0) # Initialize components for Routine "test_feedback" test_feedbackClock = core.Clock() msg='doh!'#if this comes up we forgot to update the msg! text_11 = visual.TextStim(win=win, name='text_11', text='default text', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); # Initialize components for Routine "TestInstructionsReminder" TestInstructionsReminderClock = core.Clock() text_8 = visual.TextStim(win=win, name='text_8', text='Remember the instructions:\n\nNow you will see a series of images, for each image try to remember whether it appeared during the first \nhalf of the experiment or not.\nIf it did appear during the first part, press the right arrow key, \nif not, press the left arrow key.\n\nPress any key to continue.\n', font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp_10 = keyboard.Keyboard() # Initialize components for Routine "TestISI" TestISIClock = core.Clock() polygon_2 = visual.ShapeStim( win=win, name='polygon_2', vertices='cross', size=(0.1, 0.1), ori=0, pos=(0, 0), lineWidth=0.25, lineColor=[1,1,1], lineColorSpace='rgb', fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=0.0, interpolate=True) # Initialize components for Routine "testtrial" testtrialClock = core.Clock() key_resp_2 = keyboard.Keyboard() image_2 = visual.ImageStim( win=win, name='image_2', image='sin', mask=None, ori=0, pos=(0, 0), size=(0.5, 0.5), color=[1,1,1], colorSpace='rgb', opacity=1, flipHoriz=False, flipVert=False, texRes=128, interpolate=True, depth=-1.0) # Initialize components for Routine "test_feedback" test_feedbackClock = core.Clock() msg='doh!'#if this comes up we forgot to update the msg! text_11 = visual.TextStim(win=win, name='text_11', text='default text', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=-1.0); # Initialize components for Routine "Thanks" ThanksClock = core.Clock() text_2 = visual.TextStim(win=win, name='text_2', text='Thank you very much for participating!\n\nThis was an experimental memory test, \ndesigned to see how congruency,\nbetween sound-images pairs,\ninfluences subsequent long-term memory.', font='Arial', pos=(0, 0), height=0.05, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0); key_resp_4 = 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 "screen_scale"------- continueRoutine = True # update component parameters for each repeat # keep track of which components have finished screen_scaleComponents = [text_top_screenscale, text_bottom_screenscale, ccimage_screenscale] for thisComponent in screen_scaleComponents: 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") screen_scaleClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "screen_scale"------- while continueRoutine: # get current time t = screen_scaleClock.getTime() tThisFlip = win.getFutureFlipTime(clock=screen_scaleClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame keys=event.getKeys() if len(keys): if t-oldt<.5: dscale=5*dbase oldt=t else: dscale=dbase oldt=t if 'space' in keys: continueRoutine=False elif 'up' in keys: y_scale=round((y_scale+dscale)*10000)/10000 elif 'down' in keys: y_scale=round((y_scale-dscale)*10000)/10000 elif 'left' in keys: x_scale=round((x_scale-dscale)*10000)/10000 elif 'right' in keys: x_scale=round((x_scale+dscale)*10000)/10000 screen_height=round(vsize*10/y_scale)/10 text_bottom.text='X Scale = '+str(x_scale)+unittext+' per cm, Y Scale = '+str(y_scale)+unittext+' per cm\nScreen height = '+str(screen_height)+' cm\n\nPress the space bar when done' ccimage.size=[x_size*x_scale, y_size*y_scale] # *text_top_screenscale* updates if text_top_screenscale.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_top_screenscale.frameNStart = frameN # exact frame index text_top_screenscale.tStart = t # local t and not account for scr refresh text_top_screenscale.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_top_screenscale, 'tStartRefresh') # time at next scr refresh text_top_screenscale.setAutoDraw(True) # *text_bottom_screenscale* updates if text_bottom_screenscale.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_bottom_screenscale.frameNStart = frameN # exact frame index text_bottom_screenscale.tStart = t # local t and not account for scr refresh text_bottom_screenscale.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_bottom_screenscale, 'tStartRefresh') # time at next scr refresh text_bottom_screenscale.setAutoDraw(True) # *ccimage_screenscale* updates if ccimage_screenscale.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later ccimage_screenscale.frameNStart = frameN # exact frame index ccimage_screenscale.tStart = t # local t and not account for scr refresh ccimage_screenscale.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(ccimage_screenscale, 'tStartRefresh') # time at next scr refresh ccimage_screenscale.setAutoDraw(True) # 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 screen_scaleComponents: 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 "screen_scale"------- for thisComponent in screen_scaleComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('X Scale',x_scale) thisExp.addData('Y Scale',y_scale) thisExp.addData('text_top_screenscale.started', text_top_screenscale.tStartRefresh) thisExp.addData('text_top_screenscale.stopped', text_top_screenscale.tStopRefresh) thisExp.addData('text_bottom_screenscale.started', text_bottom_screenscale.tStartRefresh) thisExp.addData('text_bottom_screenscale.stopped', text_bottom_screenscale.tStopRefresh) thisExp.addData('ccimage_screenscale.started', ccimage_screenscale.tStartRefresh) thisExp.addData('ccimage_screenscale.stopped', ccimage_screenscale.tStopRefresh) # the Routine "screen_scale" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "rectangle_screenscale"------- continueRoutine = True # update component parameters for each repeat polygon_screenscale.setSize((10*x_scale, 10*y_scale)) key_resp_screenscale.keys = [] key_resp_screenscale.rt = [] _key_resp_screenscale_allKeys = [] # keep track of which components have finished rectangle_screenscaleComponents = [text_rectangle_screenscale, polygon_screenscale, key_resp_screenscale] for thisComponent in rectangle_screenscaleComponents: 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") rectangle_screenscaleClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "rectangle_screenscale"------- while continueRoutine: # get current time t = rectangle_screenscaleClock.getTime() tThisFlip = win.getFutureFlipTime(clock=rectangle_screenscaleClock) 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_rectangle_screenscale* updates if text_rectangle_screenscale.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_rectangle_screenscale.frameNStart = frameN # exact frame index text_rectangle_screenscale.tStart = t # local t and not account for scr refresh text_rectangle_screenscale.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_rectangle_screenscale, 'tStartRefresh') # time at next scr refresh text_rectangle_screenscale.setAutoDraw(True) # *polygon_screenscale* updates if polygon_screenscale.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_screenscale.frameNStart = frameN # exact frame index polygon_screenscale.tStart = t # local t and not account for scr refresh polygon_screenscale.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_screenscale, 'tStartRefresh') # time at next scr refresh polygon_screenscale.setAutoDraw(True) # *key_resp_screenscale* updates waitOnFlip = False if key_resp_screenscale.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_screenscale.frameNStart = frameN # exact frame index key_resp_screenscale.tStart = t # local t and not account for scr refresh key_resp_screenscale.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_screenscale, 'tStartRefresh') # time at next scr refresh key_resp_screenscale.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_screenscale.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_screenscale.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_screenscale.status == STARTED and not waitOnFlip: theseKeys = key_resp_screenscale.getKeys(keyList=['space'], waitRelease=False) _key_resp_screenscale_allKeys.extend(theseKeys) if len(_key_resp_screenscale_allKeys): key_resp_screenscale.keys = _key_resp_screenscale_allKeys[-1].name # just the last key pressed key_resp_screenscale.rt = _key_resp_screenscale_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 rectangle_screenscaleComponents: 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 "rectangle_screenscale"------- for thisComponent in rectangle_screenscaleComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_rectangle_screenscale.started', text_rectangle_screenscale.tStartRefresh) thisExp.addData('text_rectangle_screenscale.stopped', text_rectangle_screenscale.tStopRefresh) thisExp.addData('polygon_screenscale.started', polygon_screenscale.tStartRefresh) thisExp.addData('polygon_screenscale.stopped', polygon_screenscale.tStopRefresh) # the Routine "rectangle_screenscale" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "Participant_description1"------- continueRoutine = True # update component parameters for each repeat # setup some python lists for storing info about the mouse_description1 mouse_description1.clicked_name = [] gotValidClick = False # until a click is received # keep track of which components have finished Participant_description1Components = [polygonDescription, textDescription1, polygon_continue, text_pressbar, mouse_description1] for thisComponent in Participant_description1Components: 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") Participant_description1Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "Participant_description1"------- while continueRoutine: # get current time t = Participant_description1Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=Participant_description1Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *polygonDescription* updates if polygonDescription.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygonDescription.frameNStart = frameN # exact frame index polygonDescription.tStart = t # local t and not account for scr refresh polygonDescription.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygonDescription, 'tStartRefresh') # time at next scr refresh polygonDescription.setAutoDraw(True) # *textDescription1* updates if textDescription1.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later textDescription1.frameNStart = frameN # exact frame index textDescription1.tStart = t # local t and not account for scr refresh textDescription1.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(textDescription1, 'tStartRefresh') # time at next scr refresh textDescription1.setAutoDraw(True) # *polygon_continue* updates if polygon_continue.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_continue.frameNStart = frameN # exact frame index polygon_continue.tStart = t # local t and not account for scr refresh polygon_continue.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_continue, 'tStartRefresh') # time at next scr refresh polygon_continue.setAutoDraw(True) # *text_pressbar* updates if text_pressbar.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_pressbar.frameNStart = frameN # exact frame index text_pressbar.tStart = t # local t and not account for scr refresh text_pressbar.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_pressbar, 'tStartRefresh') # time at next scr refresh text_pressbar.setAutoDraw(True) # *mouse_description1* updates if mouse_description1.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later mouse_description1.frameNStart = frameN # exact frame index mouse_description1.tStart = t # local t and not account for scr refresh mouse_description1.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(mouse_description1, 'tStartRefresh') # time at next scr refresh mouse_description1.status = STARTED mouse_description1.mouseClock.reset() prevButtonState = mouse_description1.getPressed() # if button is down already this ISN'T a new click if mouse_description1.status == STARTED: # only update if started and not finished! buttons = mouse_description1.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 [polygon_continue]: if obj.contains(mouse_description1): gotValidClick = True mouse_description1.clicked_name.append(obj.name) 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 Participant_description1Components: 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 "Participant_description1"------- for thisComponent in Participant_description1Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('polygonDescription.started', polygonDescription.tStartRefresh) thisExp.addData('polygonDescription.stopped', polygonDescription.tStopRefresh) thisExp.addData('textDescription1.started', textDescription1.tStartRefresh) thisExp.addData('textDescription1.stopped', textDescription1.tStopRefresh) thisExp.addData('polygon_continue.started', polygon_continue.tStartRefresh) thisExp.addData('polygon_continue.stopped', polygon_continue.tStopRefresh) thisExp.addData('text_pressbar.started', text_pressbar.tStartRefresh) thisExp.addData('text_pressbar.stopped', text_pressbar.tStopRefresh) # store data for thisExp (ExperimentHandler) x, y = mouse_description1.getPos() buttons = mouse_description1.getPressed() if sum(buttons): # check if the mouse was inside our 'clickable' objects gotValidClick = False for obj in [polygon_continue]: if obj.contains(mouse_description1): gotValidClick = True mouse_description1.clicked_name.append(obj.name) thisExp.addData('mouse_description1.x', x) thisExp.addData('mouse_description1.y', y) thisExp.addData('mouse_description1.leftButton', buttons[0]) thisExp.addData('mouse_description1.midButton', buttons[1]) thisExp.addData('mouse_description1.rightButton', buttons[2]) if len(mouse_description1.clicked_name): thisExp.addData('mouse_description1.clicked_name', mouse_description1.clicked_name[0]) thisExp.addData('mouse_description1.started', mouse_description1.tStart) thisExp.addData('mouse_description1.stopped', mouse_description1.tStop) thisExp.nextEntry() # the Routine "Participant_description1" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "ParticipantDescription2"------- continueRoutine = True # update component parameters for each repeat # setup some python lists for storing info about the mouse_pressbar2 mouse_pressbar2.clicked_name = [] gotValidClick = False # until a click is received # keep track of which components have finished ParticipantDescription2Components = [polygon_description3, text_description2, polygon_press2, text_pressbar3, mouse_pressbar2] for thisComponent in ParticipantDescription2Components: 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") ParticipantDescription2Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "ParticipantDescription2"------- while continueRoutine: # get current time t = ParticipantDescription2Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=ParticipantDescription2Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *polygon_description3* updates if polygon_description3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_description3.frameNStart = frameN # exact frame index polygon_description3.tStart = t # local t and not account for scr refresh polygon_description3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_description3, 'tStartRefresh') # time at next scr refresh polygon_description3.setAutoDraw(True) # *text_description2* updates if text_description2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_description2.frameNStart = frameN # exact frame index text_description2.tStart = t # local t and not account for scr refresh text_description2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_description2, 'tStartRefresh') # time at next scr refresh text_description2.setAutoDraw(True) # *polygon_press2* updates if polygon_press2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_press2.frameNStart = frameN # exact frame index polygon_press2.tStart = t # local t and not account for scr refresh polygon_press2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_press2, 'tStartRefresh') # time at next scr refresh polygon_press2.setAutoDraw(True) # *text_pressbar3* updates if text_pressbar3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_pressbar3.frameNStart = frameN # exact frame index text_pressbar3.tStart = t # local t and not account for scr refresh text_pressbar3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_pressbar3, 'tStartRefresh') # time at next scr refresh text_pressbar3.setAutoDraw(True) # *mouse_pressbar2* updates if mouse_pressbar2.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later mouse_pressbar2.frameNStart = frameN # exact frame index mouse_pressbar2.tStart = t # local t and not account for scr refresh mouse_pressbar2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(mouse_pressbar2, 'tStartRefresh') # time at next scr refresh mouse_pressbar2.status = STARTED mouse_pressbar2.mouseClock.reset() prevButtonState = mouse_pressbar2.getPressed() # if button is down already this ISN'T a new click if mouse_pressbar2.status == STARTED: # only update if started and not finished! buttons = mouse_pressbar2.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 [polygon_press2]: if obj.contains(mouse_pressbar2): gotValidClick = True mouse_pressbar2.clicked_name.append(obj.name) 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 ParticipantDescription2Components: 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 "ParticipantDescription2"------- for thisComponent in ParticipantDescription2Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('polygon_description3.started', polygon_description3.tStartRefresh) thisExp.addData('polygon_description3.stopped', polygon_description3.tStopRefresh) thisExp.addData('text_description2.started', text_description2.tStartRefresh) thisExp.addData('text_description2.stopped', text_description2.tStopRefresh) thisExp.addData('polygon_press2.started', polygon_press2.tStartRefresh) thisExp.addData('polygon_press2.stopped', polygon_press2.tStopRefresh) thisExp.addData('text_pressbar3.started', text_pressbar3.tStartRefresh) thisExp.addData('text_pressbar3.stopped', text_pressbar3.tStopRefresh) # store data for thisExp (ExperimentHandler) x, y = mouse_pressbar2.getPos() buttons = mouse_pressbar2.getPressed() if sum(buttons): # check if the mouse was inside our 'clickable' objects gotValidClick = False for obj in [polygon_press2]: if obj.contains(mouse_pressbar2): gotValidClick = True mouse_pressbar2.clicked_name.append(obj.name) thisExp.addData('mouse_pressbar2.x', x) thisExp.addData('mouse_pressbar2.y', y) thisExp.addData('mouse_pressbar2.leftButton', buttons[0]) thisExp.addData('mouse_pressbar2.midButton', buttons[1]) thisExp.addData('mouse_pressbar2.rightButton', buttons[2]) if len(mouse_pressbar2.clicked_name): thisExp.addData('mouse_pressbar2.clicked_name', mouse_pressbar2.clicked_name[0]) thisExp.addData('mouse_pressbar2.started', mouse_pressbar2.tStart) thisExp.addData('mouse_pressbar2.stopped', mouse_pressbar2.tStop) thisExp.nextEntry() # the Routine "ParticipantDescription2" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "Participant_description3"------- continueRoutine = True # update component parameters for each repeat # setup some python lists for storing info about the mouse mouse.clicked_name = [] gotValidClick = False # until a click is received # keep track of which components have finished Participant_description3Components = [polygon_description_3, text_description3, polygon_press3, text_pressbar_3, mouse] for thisComponent in Participant_description3Components: 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") Participant_description3Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "Participant_description3"------- while continueRoutine: # get current time t = Participant_description3Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=Participant_description3Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *polygon_description_3* updates if polygon_description_3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_description_3.frameNStart = frameN # exact frame index polygon_description_3.tStart = t # local t and not account for scr refresh polygon_description_3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_description_3, 'tStartRefresh') # time at next scr refresh polygon_description_3.setAutoDraw(True) # *text_description3* updates if text_description3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_description3.frameNStart = frameN # exact frame index text_description3.tStart = t # local t and not account for scr refresh text_description3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_description3, 'tStartRefresh') # time at next scr refresh text_description3.setAutoDraw(True) # *polygon_press3* updates if polygon_press3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_press3.frameNStart = frameN # exact frame index polygon_press3.tStart = t # local t and not account for scr refresh polygon_press3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_press3, 'tStartRefresh') # time at next scr refresh polygon_press3.setAutoDraw(True) # *text_pressbar_3* updates if text_pressbar_3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_pressbar_3.frameNStart = frameN # exact frame index text_pressbar_3.tStart = t # local t and not account for scr refresh text_pressbar_3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_pressbar_3, 'tStartRefresh') # time at next scr refresh text_pressbar_3.setAutoDraw(True) # *mouse* updates if mouse.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later mouse.frameNStart = frameN # exact frame index mouse.tStart = t # local t and not account for scr refresh mouse.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(mouse, 'tStartRefresh') # time at next scr refresh mouse.status = STARTED mouse.mouseClock.reset() prevButtonState = mouse.getPressed() # if button is down already this ISN'T a new click if mouse.status == STARTED: # only update if started and not finished! buttons = mouse.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 [polygon_press3]: if obj.contains(mouse): gotValidClick = True mouse.clicked_name.append(obj.name) 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 Participant_description3Components: 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 "Participant_description3"------- for thisComponent in Participant_description3Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('polygon_description_3.started', polygon_description_3.tStartRefresh) thisExp.addData('polygon_description_3.stopped', polygon_description_3.tStopRefresh) thisExp.addData('text_description3.started', text_description3.tStartRefresh) thisExp.addData('text_description3.stopped', text_description3.tStopRefresh) thisExp.addData('polygon_press3.started', polygon_press3.tStartRefresh) thisExp.addData('polygon_press3.stopped', polygon_press3.tStopRefresh) thisExp.addData('text_pressbar_3.started', text_pressbar_3.tStartRefresh) thisExp.addData('text_pressbar_3.stopped', text_pressbar_3.tStopRefresh) # store data for thisExp (ExperimentHandler) x, y = mouse.getPos() buttons = mouse.getPressed() if sum(buttons): # check if the mouse was inside our 'clickable' objects gotValidClick = False for obj in [polygon_press3]: if obj.contains(mouse): gotValidClick = True mouse.clicked_name.append(obj.name) thisExp.addData('mouse.x', x) thisExp.addData('mouse.y', y) thisExp.addData('mouse.leftButton', buttons[0]) thisExp.addData('mouse.midButton', buttons[1]) thisExp.addData('mouse.rightButton', buttons[2]) if len(mouse.clicked_name): thisExp.addData('mouse.clicked_name', mouse.clicked_name[0]) thisExp.addData('mouse.started', mouse.tStart) thisExp.addData('mouse.stopped', mouse.tStop) thisExp.nextEntry() # the Routine "Participant_description3" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "ParticipantDescription4"------- continueRoutine = True # update component parameters for each repeat # setup some python lists for storing info about the mouse_pressbar4 mouse_pressbar4.clicked_name = [] gotValidClick = False # until a click is received # keep track of which components have finished ParticipantDescription4Components = [polygon_description2, text_description4, polygon_press4, text_pressbar2, mouse_pressbar4] for thisComponent in ParticipantDescription4Components: 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") ParticipantDescription4Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "ParticipantDescription4"------- while continueRoutine: # get current time t = ParticipantDescription4Clock.getTime() tThisFlip = win.getFutureFlipTime(clock=ParticipantDescription4Clock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *polygon_description2* updates if polygon_description2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_description2.frameNStart = frameN # exact frame index polygon_description2.tStart = t # local t and not account for scr refresh polygon_description2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_description2, 'tStartRefresh') # time at next scr refresh polygon_description2.setAutoDraw(True) # *text_description4* updates if text_description4.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_description4.frameNStart = frameN # exact frame index text_description4.tStart = t # local t and not account for scr refresh text_description4.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_description4, 'tStartRefresh') # time at next scr refresh text_description4.setAutoDraw(True) # *polygon_press4* updates if polygon_press4.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_press4.frameNStart = frameN # exact frame index polygon_press4.tStart = t # local t and not account for scr refresh polygon_press4.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_press4, 'tStartRefresh') # time at next scr refresh polygon_press4.setAutoDraw(True) # *text_pressbar2* updates if text_pressbar2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_pressbar2.frameNStart = frameN # exact frame index text_pressbar2.tStart = t # local t and not account for scr refresh text_pressbar2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_pressbar2, 'tStartRefresh') # time at next scr refresh text_pressbar2.setAutoDraw(True) # *mouse_pressbar4* updates if mouse_pressbar4.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later mouse_pressbar4.frameNStart = frameN # exact frame index mouse_pressbar4.tStart = t # local t and not account for scr refresh mouse_pressbar4.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(mouse_pressbar4, 'tStartRefresh') # time at next scr refresh mouse_pressbar4.status = STARTED mouse_pressbar4.mouseClock.reset() prevButtonState = mouse_pressbar4.getPressed() # if button is down already this ISN'T a new click if mouse_pressbar4.status == STARTED: # only update if started and not finished! buttons = mouse_pressbar4.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 [polygon_press4]: if obj.contains(mouse_pressbar4): gotValidClick = True mouse_pressbar4.clicked_name.append(obj.name) 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 ParticipantDescription4Components: 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 "ParticipantDescription4"------- for thisComponent in ParticipantDescription4Components: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('polygon_description2.started', polygon_description2.tStartRefresh) thisExp.addData('polygon_description2.stopped', polygon_description2.tStopRefresh) thisExp.addData('text_description4.started', text_description4.tStartRefresh) thisExp.addData('text_description4.stopped', text_description4.tStopRefresh) thisExp.addData('polygon_press4.started', polygon_press4.tStartRefresh) thisExp.addData('polygon_press4.stopped', polygon_press4.tStopRefresh) thisExp.addData('text_pressbar2.started', text_pressbar2.tStartRefresh) thisExp.addData('text_pressbar2.stopped', text_pressbar2.tStopRefresh) # store data for thisExp (ExperimentHandler) x, y = mouse_pressbar4.getPos() buttons = mouse_pressbar4.getPressed() if sum(buttons): # check if the mouse was inside our 'clickable' objects gotValidClick = False for obj in [polygon_press4]: if obj.contains(mouse_pressbar4): gotValidClick = True mouse_pressbar4.clicked_name.append(obj.name) thisExp.addData('mouse_pressbar4.x', x) thisExp.addData('mouse_pressbar4.y', y) thisExp.addData('mouse_pressbar4.leftButton', buttons[0]) thisExp.addData('mouse_pressbar4.midButton', buttons[1]) thisExp.addData('mouse_pressbar4.rightButton', buttons[2]) if len(mouse_pressbar4.clicked_name): thisExp.addData('mouse_pressbar4.clicked_name', mouse_pressbar4.clicked_name[0]) thisExp.addData('mouse_pressbar4.started', mouse_pressbar4.tStart) thisExp.addData('mouse_pressbar4.stopped', mouse_pressbar4.tStop) thisExp.nextEntry() # the Routine "ParticipantDescription4" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "consent_form"------- continueRoutine = True # update component parameters for each repeat # setup some python lists for storing info about the mouse_consent mouse_consent.clicked_name = [] gotValidClick = False # until a click is received # keep track of which components have finished consent_formComponents = [polygonInformedConsent, text_informedconsent, polygon_yesconsent, text_consentbegin, polygon_noconsent, text_NotConsent, mouse_consent] for thisComponent in consent_formComponents: 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") consent_formClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "consent_form"------- while continueRoutine: # get current time t = consent_formClock.getTime() tThisFlip = win.getFutureFlipTime(clock=consent_formClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *polygonInformedConsent* updates if polygonInformedConsent.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygonInformedConsent.frameNStart = frameN # exact frame index polygonInformedConsent.tStart = t # local t and not account for scr refresh polygonInformedConsent.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygonInformedConsent, 'tStartRefresh') # time at next scr refresh polygonInformedConsent.setAutoDraw(True) # *text_informedconsent* updates if text_informedconsent.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_informedconsent.frameNStart = frameN # exact frame index text_informedconsent.tStart = t # local t and not account for scr refresh text_informedconsent.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_informedconsent, 'tStartRefresh') # time at next scr refresh text_informedconsent.setAutoDraw(True) # *polygon_yesconsent* updates if polygon_yesconsent.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_yesconsent.frameNStart = frameN # exact frame index polygon_yesconsent.tStart = t # local t and not account for scr refresh polygon_yesconsent.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_yesconsent, 'tStartRefresh') # time at next scr refresh polygon_yesconsent.setAutoDraw(True) # *text_consentbegin* updates if text_consentbegin.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_consentbegin.frameNStart = frameN # exact frame index text_consentbegin.tStart = t # local t and not account for scr refresh text_consentbegin.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_consentbegin, 'tStartRefresh') # time at next scr refresh text_consentbegin.setAutoDraw(True) # *polygon_noconsent* updates if polygon_noconsent.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_noconsent.frameNStart = frameN # exact frame index polygon_noconsent.tStart = t # local t and not account for scr refresh polygon_noconsent.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_noconsent, 'tStartRefresh') # time at next scr refresh polygon_noconsent.setAutoDraw(True) # *text_NotConsent* updates if text_NotConsent.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_NotConsent.frameNStart = frameN # exact frame index text_NotConsent.tStart = t # local t and not account for scr refresh text_NotConsent.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_NotConsent, 'tStartRefresh') # time at next scr refresh text_NotConsent.setAutoDraw(True) # *mouse_consent* updates if mouse_consent.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later mouse_consent.frameNStart = frameN # exact frame index mouse_consent.tStart = t # local t and not account for scr refresh mouse_consent.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(mouse_consent, 'tStartRefresh') # time at next scr refresh mouse_consent.status = STARTED mouse_consent.mouseClock.reset() prevButtonState = mouse_consent.getPressed() # if button is down already this ISN'T a new click if mouse_consent.status == STARTED: # only update if started and not finished! buttons = mouse_consent.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 [polygon_yesconsent, polygon_noconsent]: if obj.contains(mouse_consent): gotValidClick = True mouse_consent.clicked_name.append(obj.name) 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 consent_formComponents: 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 "consent_form"------- for thisComponent in consent_formComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('polygonInformedConsent.started', polygonInformedConsent.tStartRefresh) thisExp.addData('polygonInformedConsent.stopped', polygonInformedConsent.tStopRefresh) thisExp.addData('text_informedconsent.started', text_informedconsent.tStartRefresh) thisExp.addData('text_informedconsent.stopped', text_informedconsent.tStopRefresh) thisExp.addData('polygon_yesconsent.started', polygon_yesconsent.tStartRefresh) thisExp.addData('polygon_yesconsent.stopped', polygon_yesconsent.tStopRefresh) thisExp.addData('text_consentbegin.started', text_consentbegin.tStartRefresh) thisExp.addData('text_consentbegin.stopped', text_consentbegin.tStopRefresh) thisExp.addData('polygon_noconsent.started', polygon_noconsent.tStartRefresh) thisExp.addData('polygon_noconsent.stopped', polygon_noconsent.tStopRefresh) thisExp.addData('text_NotConsent.started', text_NotConsent.tStartRefresh) thisExp.addData('text_NotConsent.stopped', text_NotConsent.tStopRefresh) # store data for thisExp (ExperimentHandler) x, y = mouse_consent.getPos() buttons = mouse_consent.getPressed() if sum(buttons): # check if the mouse was inside our 'clickable' objects gotValidClick = False for obj in [polygon_yesconsent, polygon_noconsent]: if obj.contains(mouse_consent): gotValidClick = True mouse_consent.clicked_name.append(obj.name) thisExp.addData('mouse_consent.x', x) thisExp.addData('mouse_consent.y', y) thisExp.addData('mouse_consent.leftButton', buttons[0]) thisExp.addData('mouse_consent.midButton', buttons[1]) thisExp.addData('mouse_consent.rightButton', buttons[2]) if len(mouse_consent.clicked_name): thisExp.addData('mouse_consent.clicked_name', mouse_consent.clicked_name[0]) thisExp.addData('mouse_consent.started', mouse_consent.tStart) thisExp.addData('mouse_consent.stopped', mouse_consent.tStop) thisExp.nextEntry() # the Routine "consent_form" 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_resp.keys = [] key_resp.rt = [] _key_resp_allKeys = [] # keep track of which components have finished instructionsComponents = [intrText, key_resp] 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 # *intrText* updates if intrText.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later intrText.frameNStart = frameN # exact frame index intrText.tStart = t # local t and not account for scr refresh intrText.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(intrText, 'tStartRefresh') # time at next scr refresh intrText.setAutoDraw(True) # *key_resp* updates waitOnFlip = False if key_resp.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp.frameNStart = frameN # exact frame index key_resp.tStart = t # local t and not account for scr refresh key_resp.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp, 'tStartRefresh') # time at next scr refresh key_resp.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp.status == STARTED and not waitOnFlip: theseKeys = key_resp.getKeys(keyList=None, waitRelease=False) _key_resp_allKeys.extend(theseKeys) if len(_key_resp_allKeys): key_resp.keys = _key_resp_allKeys[-1].name # just the last key pressed key_resp.rt = _key_resp_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('intrText.started', intrText.tStartRefresh) thisExp.addData('intrText.stopped', intrText.tStopRefresh) # check responses if key_resp.keys in ['', [], None]: # No response was made key_resp.keys = None thisExp.addData('key_resp.keys',key_resp.keys) if key_resp.keys != None: # we had a response thisExp.addData('key_resp.rt', key_resp.rt) thisExp.addData('key_resp.started', key_resp.tStartRefresh) thisExp.addData('key_resp.stopped', key_resp.tStopRefresh) thisExp.nextEntry() # the Routine "instructions" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # set up handler to look after randomisation of conditions etc Encodingpractice = data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('AVCongConditionsEncodingA.xlsx', selection='0,47,95'), seed=None, name='Encodingpractice') thisExp.addLoop(Encodingpractice) # add the loop to the experiment thisEncodingpractice = Encodingpractice.trialList[0] # so we can initialise stimuli with some values # abbreviate parameter names if possible (e.g. rgb = thisEncodingpractice.rgb) if thisEncodingpractice != None: for paramName in thisEncodingpractice: exec('{} = thisEncodingpractice[paramName]'.format(paramName)) for thisEncodingpractice in Encodingpractice: currentLoop = Encodingpractice # abbreviate parameter names if possible (e.g. rgb = thisEncodingpractice.rgb) if thisEncodingpractice != None: for paramName in thisEncodingpractice: exec('{} = thisEncodingpractice[paramName]'.format(paramName)) # ------Prepare to start Routine "ISI"------- continueRoutine = True routineTimer.add(1.000000) # update component parameters for each repeat # keep track of which components have finished ISIComponents = [polygon] for thisComponent in ISIComponents: 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") ISIClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "ISI"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = ISIClock.getTime() tThisFlip = win.getFutureFlipTime(clock=ISIClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *polygon* updates if polygon.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon.frameNStart = frameN # exact frame index polygon.tStart = t # local t and not account for scr refresh polygon.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon, 'tStartRefresh') # time at next scr refresh polygon.setAutoDraw(True) if polygon.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > polygon.tStartRefresh + 1-frameTolerance: # keep track of stop time/frame for later polygon.tStop = t # not accounting for scr refresh polygon.frameNStop = frameN # exact frame index win.timeOnFlip(polygon, 'tStopRefresh') # time at next scr refresh polygon.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 ISIComponents: 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 "ISI"------- for thisComponent in ISIComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) Encodingpractice.addData('polygon.started', polygon.tStartRefresh) Encodingpractice.addData('polygon.stopped', polygon.tStopRefresh) # ------Prepare to start Routine "trial"------- continueRoutine = True # update component parameters for each repeat response.keys = [] response.rt = [] _response_allKeys = [] image.setImage(learning_image_1) sound_1.setSound(learning_sound_file, hamming=True) sound_1.setVolume(1, log=False) # keep track of which components have finished trialComponents = [response, image, sound_1] for thisComponent in trialComponents: 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") trialClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "trial"------- while continueRoutine: # get current time t = trialClock.getTime() tThisFlip = win.getFutureFlipTime(clock=trialClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *response* updates waitOnFlip = False if response.status == NOT_STARTED and tThisFlip >= 0-frameTolerance: # keep track of start time/frame for later response.frameNStart = frameN # exact frame index response.tStart = t # local t and not account for scr refresh response.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(response, 'tStartRefresh') # time at next scr refresh response.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(response.clock.reset) # t=0 on next screen flip win.callOnFlip(response.clearEvents, eventType='keyboard') # clear events on next screen flip if response.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > response.tStartRefresh + 4-frameTolerance: # keep track of stop time/frame for later response.tStop = t # not accounting for scr refresh response.frameNStop = frameN # exact frame index win.timeOnFlip(response, 'tStopRefresh') # time at next scr refresh response.status = FINISHED if response.status == STARTED and not waitOnFlip: theseKeys = response.getKeys(keyList=['1', '2', '3', '4', '5'], waitRelease=False) _response_allKeys.extend(theseKeys) if len(_response_allKeys): response.keys = _response_allKeys[-1].name # just the last key pressed response.rt = _response_allKeys[-1].rt # was this correct? if (response.keys == str(learning_condition)) or (response.keys == learning_condition): response.corr = 1 else: response.corr = 0 # *image* updates if image.status == NOT_STARTED and tThisFlip >= 0.-frameTolerance: # keep track of start time/frame for later image.frameNStart = frameN # exact frame index image.tStart = t # local t and not account for scr refresh image.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(image, 'tStartRefresh') # time at next scr refresh image.setAutoDraw(True) if image.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > image.tStartRefresh + 4-frameTolerance: # keep track of stop time/frame for later image.tStop = t # not accounting for scr refresh image.frameNStop = frameN # exact frame index win.timeOnFlip(image, 'tStopRefresh') # time at next scr refresh image.setAutoDraw(False) # start/stop sound_1 if sound_1.status == NOT_STARTED and tThisFlip >= 0-frameTolerance: # keep track of start time/frame for later sound_1.frameNStart = frameN # exact frame index sound_1.tStart = t # local t and not account for scr refresh sound_1.tStartRefresh = tThisFlipGlobal # on global time sound_1.play(when=win) # sync with win flip # 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 trialComponents: 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 "trial"------- for thisComponent in trialComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) # check responses if response.keys in ['', [], None]: # No response was made response.keys = None # was no response the correct answer?! if str(learning_condition).lower() == 'none': response.corr = 1; # correct non-response else: response.corr = 0; # failed to respond (incorrectly) # store data for Encodingpractice (TrialHandler) Encodingpractice.addData('response.keys',response.keys) Encodingpractice.addData('response.corr', response.corr) if response.keys != None: # we had a response Encodingpractice.addData('response.rt', response.rt) Encodingpractice.addData('response.started', response.tStartRefresh) Encodingpractice.addData('response.stopped', response.tStopRefresh) Encodingpractice.addData('image.started', image.tStartRefresh) Encodingpractice.addData('image.stopped', image.tStopRefresh) sound_1.stop() # ensure sound has stopped at end of routine Encodingpractice.addData('sound_1.started', sound_1.tStartRefresh) Encodingpractice.addData('sound_1.stopped', sound_1.tStopRefresh) # the Routine "trial" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "feedback_in_loop_encodingpractice"------- continueRoutine = True routineTimer.add(1.000000) # update component parameters for each repeat if not response.keys : msg="Failed to respond" msgcolor='red' else: #stored on last run routine msg="You responded" msgcolor='green' text_10.setColor(msgcolor, colorSpace='rgb') text_10.setText(msg) # keep track of which components have finished feedback_in_loop_encodingpracticeComponents = [text_10] for thisComponent in feedback_in_loop_encodingpracticeComponents: thisComponent.tStart = None thisComponent.tStop = None thisComponent.tStartRefresh = None thisComponent.tStopRefresh = None if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # reset timers t = 0 _timeToFirstFrame = win.getFutureFlipTime(clock="now") feedback_in_loop_encodingpracticeClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "feedback_in_loop_encodingpractice"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = feedback_in_loop_encodingpracticeClock.getTime() tThisFlip = win.getFutureFlipTime(clock=feedback_in_loop_encodingpracticeClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *text_10* updates if text_10.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_10.frameNStart = frameN # exact frame index text_10.tStart = t # local t and not account for scr refresh text_10.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_10, 'tStartRefresh') # time at next scr refresh text_10.setAutoDraw(True) if text_10.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_10.tStartRefresh + 1.0-frameTolerance: # keep track of stop time/frame for later text_10.tStop = t # not accounting for scr refresh text_10.frameNStop = frameN # exact frame index win.timeOnFlip(text_10, 'tStopRefresh') # time at next scr refresh text_10.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 feedback_in_loop_encodingpracticeComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "feedback_in_loop_encodingpractice"------- for thisComponent in feedback_in_loop_encodingpracticeComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) Encodingpractice.addData('text_10.started', text_10.tStartRefresh) Encodingpractice.addData('text_10.stopped', text_10.tStopRefresh) thisExp.nextEntry() # completed 1 repeats of 'Encodingpractice' # ------Prepare to start Routine "EncodingInstructionsReminder"------- continueRoutine = True # update component parameters for each repeat key_resp_8.keys = [] key_resp_8.rt = [] _key_resp_8_allKeys = [] # keep track of which components have finished EncodingInstructionsReminderComponents = [text_6, key_resp_8] for thisComponent in EncodingInstructionsReminderComponents: thisComponent.tStart = None thisComponent.tStop = None thisComponent.tStartRefresh = None thisComponent.tStopRefresh = None if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # reset timers t = 0 _timeToFirstFrame = win.getFutureFlipTime(clock="now") EncodingInstructionsReminderClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "EncodingInstructionsReminder"------- while continueRoutine: # get current time t = EncodingInstructionsReminderClock.getTime() tThisFlip = win.getFutureFlipTime(clock=EncodingInstructionsReminderClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *text_6* updates if text_6.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_6.frameNStart = frameN # exact frame index text_6.tStart = t # local t and not account for scr refresh text_6.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_6, 'tStartRefresh') # time at next scr refresh text_6.setAutoDraw(True) # *key_resp_8* updates waitOnFlip = False if key_resp_8.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_8.frameNStart = frameN # exact frame index key_resp_8.tStart = t # local t and not account for scr refresh key_resp_8.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_8, 'tStartRefresh') # time at next scr refresh key_resp_8.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_8.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_8.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_8.status == STARTED and not waitOnFlip: theseKeys = key_resp_8.getKeys(keyList=None, waitRelease=False) _key_resp_8_allKeys.extend(theseKeys) if len(_key_resp_8_allKeys): key_resp_8.keys = _key_resp_8_allKeys[-1].name # just the last key pressed key_resp_8.rt = _key_resp_8_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 EncodingInstructionsReminderComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "EncodingInstructionsReminder"------- for thisComponent in EncodingInstructionsReminderComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_6.started', text_6.tStartRefresh) thisExp.addData('text_6.stopped', text_6.tStopRefresh) # check responses if key_resp_8.keys in ['', [], None]: # No response was made key_resp_8.keys = None thisExp.addData('key_resp_8.keys',key_resp_8.keys) if key_resp_8.keys != None: # we had a response thisExp.addData('key_resp_8.rt', key_resp_8.rt) thisExp.addData('key_resp_8.started', key_resp_8.tStartRefresh) thisExp.addData('key_resp_8.stopped', key_resp_8.tStopRefresh) thisExp.nextEntry() # the Routine "EncodingInstructionsReminder" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # set up handler to look after randomisation of conditions etc Encoding = data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('AVCongConditionsEncodingA.xlsx'), seed=None, name='Encoding') thisExp.addLoop(Encoding) # add the loop to the experiment thisEncoding = Encoding.trialList[0] # so we can initialise stimuli with some values # abbreviate parameter names if possible (e.g. rgb = thisEncoding.rgb) if thisEncoding != None: for paramName in thisEncoding: exec('{} = thisEncoding[paramName]'.format(paramName)) for thisEncoding in Encoding: currentLoop = Encoding # abbreviate parameter names if possible (e.g. rgb = thisEncoding.rgb) if thisEncoding != None: for paramName in thisEncoding: exec('{} = thisEncoding[paramName]'.format(paramName)) # ------Prepare to start Routine "ISI"------- continueRoutine = True routineTimer.add(1.000000) # update component parameters for each repeat # keep track of which components have finished ISIComponents = [polygon] for thisComponent in ISIComponents: 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") ISIClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "ISI"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = ISIClock.getTime() tThisFlip = win.getFutureFlipTime(clock=ISIClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *polygon* updates if polygon.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon.frameNStart = frameN # exact frame index polygon.tStart = t # local t and not account for scr refresh polygon.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon, 'tStartRefresh') # time at next scr refresh polygon.setAutoDraw(True) if polygon.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > polygon.tStartRefresh + 1-frameTolerance: # keep track of stop time/frame for later polygon.tStop = t # not accounting for scr refresh polygon.frameNStop = frameN # exact frame index win.timeOnFlip(polygon, 'tStopRefresh') # time at next scr refresh polygon.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 ISIComponents: 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 "ISI"------- for thisComponent in ISIComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) Encoding.addData('polygon.started', polygon.tStartRefresh) Encoding.addData('polygon.stopped', polygon.tStopRefresh) # ------Prepare to start Routine "trial"------- continueRoutine = True # update component parameters for each repeat response.keys = [] response.rt = [] _response_allKeys = [] image.setImage(learning_image_1) sound_1.setSound(learning_sound_file, hamming=True) sound_1.setVolume(1, log=False) # keep track of which components have finished trialComponents = [response, image, sound_1] for thisComponent in trialComponents: 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") trialClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "trial"------- while continueRoutine: # get current time t = trialClock.getTime() tThisFlip = win.getFutureFlipTime(clock=trialClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *response* updates waitOnFlip = False if response.status == NOT_STARTED and tThisFlip >= 0-frameTolerance: # keep track of start time/frame for later response.frameNStart = frameN # exact frame index response.tStart = t # local t and not account for scr refresh response.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(response, 'tStartRefresh') # time at next scr refresh response.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(response.clock.reset) # t=0 on next screen flip win.callOnFlip(response.clearEvents, eventType='keyboard') # clear events on next screen flip if response.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > response.tStartRefresh + 4-frameTolerance: # keep track of stop time/frame for later response.tStop = t # not accounting for scr refresh response.frameNStop = frameN # exact frame index win.timeOnFlip(response, 'tStopRefresh') # time at next scr refresh response.status = FINISHED if response.status == STARTED and not waitOnFlip: theseKeys = response.getKeys(keyList=['1', '2', '3', '4', '5'], waitRelease=False) _response_allKeys.extend(theseKeys) if len(_response_allKeys): response.keys = _response_allKeys[-1].name # just the last key pressed response.rt = _response_allKeys[-1].rt # was this correct? if (response.keys == str(learning_condition)) or (response.keys == learning_condition): response.corr = 1 else: response.corr = 0 # *image* updates if image.status == NOT_STARTED and tThisFlip >= 0.-frameTolerance: # keep track of start time/frame for later image.frameNStart = frameN # exact frame index image.tStart = t # local t and not account for scr refresh image.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(image, 'tStartRefresh') # time at next scr refresh image.setAutoDraw(True) if image.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > image.tStartRefresh + 4-frameTolerance: # keep track of stop time/frame for later image.tStop = t # not accounting for scr refresh image.frameNStop = frameN # exact frame index win.timeOnFlip(image, 'tStopRefresh') # time at next scr refresh image.setAutoDraw(False) # start/stop sound_1 if sound_1.status == NOT_STARTED and tThisFlip >= 0-frameTolerance: # keep track of start time/frame for later sound_1.frameNStart = frameN # exact frame index sound_1.tStart = t # local t and not account for scr refresh sound_1.tStartRefresh = tThisFlipGlobal # on global time sound_1.play(when=win) # sync with win flip # 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 trialComponents: 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 "trial"------- for thisComponent in trialComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) # check responses if response.keys in ['', [], None]: # No response was made response.keys = None # was no response the correct answer?! if str(learning_condition).lower() == 'none': response.corr = 1; # correct non-response else: response.corr = 0; # failed to respond (incorrectly) # store data for Encoding (TrialHandler) Encoding.addData('response.keys',response.keys) Encoding.addData('response.corr', response.corr) if response.keys != None: # we had a response Encoding.addData('response.rt', response.rt) Encoding.addData('response.started', response.tStartRefresh) Encoding.addData('response.stopped', response.tStopRefresh) Encoding.addData('image.started', image.tStartRefresh) Encoding.addData('image.stopped', image.tStopRefresh) sound_1.stop() # ensure sound has stopped at end of routine Encoding.addData('sound_1.started', sound_1.tStartRefresh) Encoding.addData('sound_1.stopped', sound_1.tStopRefresh) # the Routine "trial" was not non-slip safe, so reset the non-slip timer routineTimer.reset() thisExp.nextEntry() # completed 1 repeats of 'Encoding' # ------Prepare to start Routine "Interval_task_instructions"------- continueRoutine = True # update component parameters for each repeat key_resp_7.keys = [] key_resp_7.rt = [] _key_resp_7_allKeys = [] # keep track of which components have finished Interval_task_instructionsComponents = [text_5, key_resp_7] for thisComponent in Interval_task_instructionsComponents: thisComponent.tStart = None thisComponent.tStop = None thisComponent.tStartRefresh = None thisComponent.tStopRefresh = None if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # reset timers t = 0 _timeToFirstFrame = win.getFutureFlipTime(clock="now") Interval_task_instructionsClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "Interval_task_instructions"------- while continueRoutine: # get current time t = Interval_task_instructionsClock.getTime() tThisFlip = win.getFutureFlipTime(clock=Interval_task_instructionsClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *text_5* updates if text_5.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_5.frameNStart = frameN # exact frame index text_5.tStart = t # local t and not account for scr refresh text_5.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_5, 'tStartRefresh') # time at next scr refresh text_5.setAutoDraw(True) # *key_resp_7* updates waitOnFlip = False if key_resp_7.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_7.frameNStart = frameN # exact frame index key_resp_7.tStart = t # local t and not account for scr refresh key_resp_7.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_7, 'tStartRefresh') # time at next scr refresh key_resp_7.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_7.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_7.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_7.status == STARTED and not waitOnFlip: theseKeys = key_resp_7.getKeys(keyList=None, waitRelease=False) _key_resp_7_allKeys.extend(theseKeys) if len(_key_resp_7_allKeys): key_resp_7.keys = _key_resp_7_allKeys[-1].name # just the last key pressed key_resp_7.rt = _key_resp_7_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 Interval_task_instructionsComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "Interval_task_instructions"------- for thisComponent in Interval_task_instructionsComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_5.started', text_5.tStartRefresh) thisExp.addData('text_5.stopped', text_5.tStopRefresh) # check responses if key_resp_7.keys in ['', [], None]: # No response was made key_resp_7.keys = None thisExp.addData('key_resp_7.keys',key_resp_7.keys) if key_resp_7.keys != None: # we had a response thisExp.addData('key_resp_7.rt', key_resp_7.rt) thisExp.addData('key_resp_7.started', key_resp_7.tStartRefresh) thisExp.addData('key_resp_7.stopped', key_resp_7.tStopRefresh) thisExp.nextEntry() # the Routine "Interval_task_instructions" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # set up handler to look after randomisation of conditions etc DistractionTaskPractice = data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('AVDistractionTask.xlsx', selection='0:3'), seed=None, name='DistractionTaskPractice') thisExp.addLoop(DistractionTaskPractice) # add the loop to the experiment thisDistractionTaskPractice = DistractionTaskPractice.trialList[0] # so we can initialise stimuli with some values # abbreviate parameter names if possible (e.g. rgb = thisDistractionTaskPractice.rgb) if thisDistractionTaskPractice != None: for paramName in thisDistractionTaskPractice: exec('{} = thisDistractionTaskPractice[paramName]'.format(paramName)) for thisDistractionTaskPractice in DistractionTaskPractice: currentLoop = DistractionTaskPractice # abbreviate parameter names if possible (e.g. rgb = thisDistractionTaskPractice.rgb) if thisDistractionTaskPractice != None: for paramName in thisDistractionTaskPractice: exec('{} = thisDistractionTaskPractice[paramName]'.format(paramName)) # ------Prepare to start Routine "interval_task"------- continueRoutine = True routineTimer.add(4.000000) # update component parameters for each repeat text_3.setText(math_test ) key_resp_5.keys = [] key_resp_5.rt = [] _key_resp_5_allKeys = [] # keep track of which components have finished interval_taskComponents = [text_3, key_resp_5] for thisComponent in interval_taskComponents: thisComponent.tStart = None thisComponent.tStop = None thisComponent.tStartRefresh = None thisComponent.tStopRefresh = None if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # reset timers t = 0 _timeToFirstFrame = win.getFutureFlipTime(clock="now") interval_taskClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "interval_task"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = interval_taskClock.getTime() tThisFlip = win.getFutureFlipTime(clock=interval_taskClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *text_3* updates if text_3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_3.frameNStart = frameN # exact frame index text_3.tStart = t # local t and not account for scr refresh text_3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_3, 'tStartRefresh') # time at next scr refresh text_3.setAutoDraw(True) if text_3.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_3.tStartRefresh + 4.0-frameTolerance: # keep track of stop time/frame for later text_3.tStop = t # not accounting for scr refresh text_3.frameNStop = frameN # exact frame index win.timeOnFlip(text_3, 'tStopRefresh') # time at next scr refresh text_3.setAutoDraw(False) # *key_resp_5* updates waitOnFlip = False if key_resp_5.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_5.frameNStart = frameN # exact frame index key_resp_5.tStart = t # local t and not account for scr refresh key_resp_5.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_5, 'tStartRefresh') # time at next scr refresh key_resp_5.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_5.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_5.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_5.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > key_resp_5.tStartRefresh + 4-frameTolerance: # keep track of stop time/frame for later key_resp_5.tStop = t # not accounting for scr refresh key_resp_5.frameNStop = frameN # exact frame index win.timeOnFlip(key_resp_5, 'tStopRefresh') # time at next scr refresh key_resp_5.status = FINISHED if key_resp_5.status == STARTED and not waitOnFlip: theseKeys = key_resp_5.getKeys(keyList=['left', 'right'], waitRelease=False) _key_resp_5_allKeys.extend(theseKeys) if len(_key_resp_5_allKeys): key_resp_5.keys = _key_resp_5_allKeys[-1].name # just the last key pressed key_resp_5.rt = _key_resp_5_allKeys[-1].rt # was this correct? if (key_resp_5.keys == str(math_corrAns)) or (key_resp_5.keys == math_corrAns): key_resp_5.corr = 1 else: key_resp_5.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 interval_taskComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "interval_task"------- for thisComponent in interval_taskComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) DistractionTaskPractice.addData('text_3.started', text_3.tStartRefresh) DistractionTaskPractice.addData('text_3.stopped', text_3.tStopRefresh) # check responses if key_resp_5.keys in ['', [], None]: # No response was made key_resp_5.keys = None # was no response the correct answer?! if str(math_corrAns).lower() == 'none': key_resp_5.corr = 1; # correct non-response else: key_resp_5.corr = 0; # failed to respond (incorrectly) # store data for DistractionTaskPractice (TrialHandler) DistractionTaskPractice.addData('key_resp_5.keys',key_resp_5.keys) DistractionTaskPractice.addData('key_resp_5.corr', key_resp_5.corr) if key_resp_5.keys != None: # we had a response DistractionTaskPractice.addData('key_resp_5.rt', key_resp_5.rt) DistractionTaskPractice.addData('key_resp_5.started', key_resp_5.tStartRefresh) DistractionTaskPractice.addData('key_resp_5.stopped', key_resp_5.tStopRefresh) # ------Prepare to start Routine "interval_feedback"------- continueRoutine = True routineTimer.add(0.500000) # update component parameters for each repeat if not key_resp_5.keys : msg="Failed to respond" msgcolor='red' elif key_resp_5.corr:#stored on last run routine msg="Correct!" msgcolor='green' else: msg="Oops! That was wrong" msgcolor='red' text_4.setColor(msgcolor, colorSpace='rgb') text_4.setText(msg ) key_resp_6.keys = [] key_resp_6.rt = [] _key_resp_6_allKeys = [] # keep track of which components have finished interval_feedbackComponents = [text_4, key_resp_6] for thisComponent in interval_feedbackComponents: thisComponent.tStart = None thisComponent.tStop = None thisComponent.tStartRefresh = None thisComponent.tStopRefresh = None if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # reset timers t = 0 _timeToFirstFrame = win.getFutureFlipTime(clock="now") interval_feedbackClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "interval_feedback"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = interval_feedbackClock.getTime() tThisFlip = win.getFutureFlipTime(clock=interval_feedbackClock) 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_4* updates if text_4.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_4.frameNStart = frameN # exact frame index text_4.tStart = t # local t and not account for scr refresh text_4.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_4, 'tStartRefresh') # time at next scr refresh text_4.setAutoDraw(True) if text_4.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_4.tStartRefresh + 0.5-frameTolerance: # keep track of stop time/frame for later text_4.tStop = t # not accounting for scr refresh text_4.frameNStop = frameN # exact frame index win.timeOnFlip(text_4, 'tStopRefresh') # time at next scr refresh text_4.setAutoDraw(False) # *key_resp_6* updates waitOnFlip = False if key_resp_6.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_6.frameNStart = frameN # exact frame index key_resp_6.tStart = t # local t and not account for scr refresh key_resp_6.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_6, 'tStartRefresh') # time at next scr refresh key_resp_6.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_6.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_6.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_6.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > key_resp_6.tStartRefresh + 0.5-frameTolerance: # keep track of stop time/frame for later key_resp_6.tStop = t # not accounting for scr refresh key_resp_6.frameNStop = frameN # exact frame index win.timeOnFlip(key_resp_6, 'tStopRefresh') # time at next scr refresh key_resp_6.status = FINISHED if key_resp_6.status == STARTED and not waitOnFlip: theseKeys = key_resp_6.getKeys(keyList=None, waitRelease=False) _key_resp_6_allKeys.extend(theseKeys) if len(_key_resp_6_allKeys): key_resp_6.keys = _key_resp_6_allKeys[-1].name # just the last key pressed key_resp_6.rt = _key_resp_6_allKeys[-1].rt # was this correct? if (key_resp_6.keys == str('')) or (key_resp_6.keys == ''): key_resp_6.corr = 1 else: key_resp_6.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 interval_feedbackComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "interval_feedback"------- for thisComponent in interval_feedbackComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) DistractionTaskPractice.addData('text_4.started', text_4.tStartRefresh) DistractionTaskPractice.addData('text_4.stopped', text_4.tStopRefresh) # check responses if key_resp_6.keys in ['', [], None]: # No response was made key_resp_6.keys = None # was no response the correct answer?! if str('').lower() == 'none': key_resp_6.corr = 1; # correct non-response else: key_resp_6.corr = 0; # failed to respond (incorrectly) # store data for DistractionTaskPractice (TrialHandler) DistractionTaskPractice.addData('key_resp_6.keys',key_resp_6.keys) DistractionTaskPractice.addData('key_resp_6.corr', key_resp_6.corr) if key_resp_6.keys != None: # we had a response DistractionTaskPractice.addData('key_resp_6.rt', key_resp_6.rt) DistractionTaskPractice.addData('key_resp_6.started', key_resp_6.tStartRefresh) DistractionTaskPractice.addData('key_resp_6.stopped', key_resp_6.tStopRefresh) thisExp.nextEntry() # completed 1 repeats of 'DistractionTaskPractice' # ------Prepare to start Routine "DistractionInstructionsReminder"------- continueRoutine = True # update component parameters for each repeat key_resp_9.keys = [] key_resp_9.rt = [] _key_resp_9_allKeys = [] # keep track of which components have finished DistractionInstructionsReminderComponents = [text_7, key_resp_9] for thisComponent in DistractionInstructionsReminderComponents: 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") DistractionInstructionsReminderClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "DistractionInstructionsReminder"------- while continueRoutine: # get current time t = DistractionInstructionsReminderClock.getTime() tThisFlip = win.getFutureFlipTime(clock=DistractionInstructionsReminderClock) 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_7* updates if text_7.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_7.frameNStart = frameN # exact frame index text_7.tStart = t # local t and not account for scr refresh text_7.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_7, 'tStartRefresh') # time at next scr refresh text_7.setAutoDraw(True) # *key_resp_9* updates waitOnFlip = False if key_resp_9.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_9.frameNStart = frameN # exact frame index key_resp_9.tStart = t # local t and not account for scr refresh key_resp_9.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_9, 'tStartRefresh') # time at next scr refresh key_resp_9.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_9.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_9.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_9.status == STARTED and not waitOnFlip: theseKeys = key_resp_9.getKeys(keyList=None, waitRelease=False) _key_resp_9_allKeys.extend(theseKeys) if len(_key_resp_9_allKeys): key_resp_9.keys = _key_resp_9_allKeys[-1].name # just the last key pressed key_resp_9.rt = _key_resp_9_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 DistractionInstructionsReminderComponents: 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 "DistractionInstructionsReminder"------- for thisComponent in DistractionInstructionsReminderComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_7.started', text_7.tStartRefresh) thisExp.addData('text_7.stopped', text_7.tStopRefresh) # check responses if key_resp_9.keys in ['', [], None]: # No response was made key_resp_9.keys = None thisExp.addData('key_resp_9.keys',key_resp_9.keys) if key_resp_9.keys != None: # we had a response thisExp.addData('key_resp_9.rt', key_resp_9.rt) thisExp.addData('key_resp_9.started', key_resp_9.tStartRefresh) thisExp.addData('key_resp_9.stopped', key_resp_9.tStopRefresh) thisExp.nextEntry() # the Routine "DistractionInstructionsReminder" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # set up handler to look after randomisation of conditions etc DistractionTask = data.TrialHandler(nReps=6, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('AVDistractionTask.xlsx'), seed=None, name='DistractionTask') thisExp.addLoop(DistractionTask) # add the loop to the experiment thisDistractionTask = DistractionTask.trialList[0] # so we can initialise stimuli with some values # abbreviate parameter names if possible (e.g. rgb = thisDistractionTask.rgb) if thisDistractionTask != None: for paramName in thisDistractionTask: exec('{} = thisDistractionTask[paramName]'.format(paramName)) for thisDistractionTask in DistractionTask: currentLoop = DistractionTask # abbreviate parameter names if possible (e.g. rgb = thisDistractionTask.rgb) if thisDistractionTask != None: for paramName in thisDistractionTask: exec('{} = thisDistractionTask[paramName]'.format(paramName)) # ------Prepare to start Routine "interval_task"------- continueRoutine = True routineTimer.add(4.000000) # update component parameters for each repeat text_3.setText(math_test ) key_resp_5.keys = [] key_resp_5.rt = [] _key_resp_5_allKeys = [] # keep track of which components have finished interval_taskComponents = [text_3, key_resp_5] for thisComponent in interval_taskComponents: thisComponent.tStart = None thisComponent.tStop = None thisComponent.tStartRefresh = None thisComponent.tStopRefresh = None if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # reset timers t = 0 _timeToFirstFrame = win.getFutureFlipTime(clock="now") interval_taskClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "interval_task"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = interval_taskClock.getTime() tThisFlip = win.getFutureFlipTime(clock=interval_taskClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *text_3* updates if text_3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_3.frameNStart = frameN # exact frame index text_3.tStart = t # local t and not account for scr refresh text_3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_3, 'tStartRefresh') # time at next scr refresh text_3.setAutoDraw(True) if text_3.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_3.tStartRefresh + 4.0-frameTolerance: # keep track of stop time/frame for later text_3.tStop = t # not accounting for scr refresh text_3.frameNStop = frameN # exact frame index win.timeOnFlip(text_3, 'tStopRefresh') # time at next scr refresh text_3.setAutoDraw(False) # *key_resp_5* updates waitOnFlip = False if key_resp_5.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_5.frameNStart = frameN # exact frame index key_resp_5.tStart = t # local t and not account for scr refresh key_resp_5.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_5, 'tStartRefresh') # time at next scr refresh key_resp_5.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_5.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_5.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_5.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > key_resp_5.tStartRefresh + 4-frameTolerance: # keep track of stop time/frame for later key_resp_5.tStop = t # not accounting for scr refresh key_resp_5.frameNStop = frameN # exact frame index win.timeOnFlip(key_resp_5, 'tStopRefresh') # time at next scr refresh key_resp_5.status = FINISHED if key_resp_5.status == STARTED and not waitOnFlip: theseKeys = key_resp_5.getKeys(keyList=['left', 'right'], waitRelease=False) _key_resp_5_allKeys.extend(theseKeys) if len(_key_resp_5_allKeys): key_resp_5.keys = _key_resp_5_allKeys[-1].name # just the last key pressed key_resp_5.rt = _key_resp_5_allKeys[-1].rt # was this correct? if (key_resp_5.keys == str(math_corrAns)) or (key_resp_5.keys == math_corrAns): key_resp_5.corr = 1 else: key_resp_5.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 interval_taskComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "interval_task"------- for thisComponent in interval_taskComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) DistractionTask.addData('text_3.started', text_3.tStartRefresh) DistractionTask.addData('text_3.stopped', text_3.tStopRefresh) # check responses if key_resp_5.keys in ['', [], None]: # No response was made key_resp_5.keys = None # was no response the correct answer?! if str(math_corrAns).lower() == 'none': key_resp_5.corr = 1; # correct non-response else: key_resp_5.corr = 0; # failed to respond (incorrectly) # store data for DistractionTask (TrialHandler) DistractionTask.addData('key_resp_5.keys',key_resp_5.keys) DistractionTask.addData('key_resp_5.corr', key_resp_5.corr) if key_resp_5.keys != None: # we had a response DistractionTask.addData('key_resp_5.rt', key_resp_5.rt) DistractionTask.addData('key_resp_5.started', key_resp_5.tStartRefresh) DistractionTask.addData('key_resp_5.stopped', key_resp_5.tStopRefresh) # ------Prepare to start Routine "interval_feedback"------- continueRoutine = True routineTimer.add(0.500000) # update component parameters for each repeat if not key_resp_5.keys : msg="Failed to respond" msgcolor='red' elif key_resp_5.corr:#stored on last run routine msg="Correct!" msgcolor='green' else: msg="Oops! That was wrong" msgcolor='red' text_4.setColor(msgcolor, colorSpace='rgb') text_4.setText(msg ) key_resp_6.keys = [] key_resp_6.rt = [] _key_resp_6_allKeys = [] # keep track of which components have finished interval_feedbackComponents = [text_4, key_resp_6] for thisComponent in interval_feedbackComponents: thisComponent.tStart = None thisComponent.tStop = None thisComponent.tStartRefresh = None thisComponent.tStopRefresh = None if hasattr(thisComponent, 'status'): thisComponent.status = NOT_STARTED # reset timers t = 0 _timeToFirstFrame = win.getFutureFlipTime(clock="now") interval_feedbackClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "interval_feedback"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = interval_feedbackClock.getTime() tThisFlip = win.getFutureFlipTime(clock=interval_feedbackClock) 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_4* updates if text_4.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_4.frameNStart = frameN # exact frame index text_4.tStart = t # local t and not account for scr refresh text_4.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_4, 'tStartRefresh') # time at next scr refresh text_4.setAutoDraw(True) if text_4.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_4.tStartRefresh + 0.5-frameTolerance: # keep track of stop time/frame for later text_4.tStop = t # not accounting for scr refresh text_4.frameNStop = frameN # exact frame index win.timeOnFlip(text_4, 'tStopRefresh') # time at next scr refresh text_4.setAutoDraw(False) # *key_resp_6* updates waitOnFlip = False if key_resp_6.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_6.frameNStart = frameN # exact frame index key_resp_6.tStart = t # local t and not account for scr refresh key_resp_6.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_6, 'tStartRefresh') # time at next scr refresh key_resp_6.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_6.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_6.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_6.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > key_resp_6.tStartRefresh + 0.5-frameTolerance: # keep track of stop time/frame for later key_resp_6.tStop = t # not accounting for scr refresh key_resp_6.frameNStop = frameN # exact frame index win.timeOnFlip(key_resp_6, 'tStopRefresh') # time at next scr refresh key_resp_6.status = FINISHED if key_resp_6.status == STARTED and not waitOnFlip: theseKeys = key_resp_6.getKeys(keyList=None, waitRelease=False) _key_resp_6_allKeys.extend(theseKeys) if len(_key_resp_6_allKeys): key_resp_6.keys = _key_resp_6_allKeys[-1].name # just the last key pressed key_resp_6.rt = _key_resp_6_allKeys[-1].rt # was this correct? if (key_resp_6.keys == str('')) or (key_resp_6.keys == ''): key_resp_6.corr = 1 else: key_resp_6.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 interval_feedbackComponents: if hasattr(thisComponent, "status") and thisComponent.status != FINISHED: continueRoutine = True break # at least one component has not yet finished # refresh the screen if continueRoutine: # don't flip if this routine is over or we'll get a blank screen win.flip() # -------Ending Routine "interval_feedback"------- for thisComponent in interval_feedbackComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) DistractionTask.addData('text_4.started', text_4.tStartRefresh) DistractionTask.addData('text_4.stopped', text_4.tStopRefresh) # check responses if key_resp_6.keys in ['', [], None]: # No response was made key_resp_6.keys = None # was no response the correct answer?! if str('').lower() == 'none': key_resp_6.corr = 1; # correct non-response else: key_resp_6.corr = 0; # failed to respond (incorrectly) # store data for DistractionTask (TrialHandler) DistractionTask.addData('key_resp_6.keys',key_resp_6.keys) DistractionTask.addData('key_resp_6.corr', key_resp_6.corr) if key_resp_6.keys != None: # we had a response DistractionTask.addData('key_resp_6.rt', key_resp_6.rt) DistractionTask.addData('key_resp_6.started', key_resp_6.tStartRefresh) DistractionTask.addData('key_resp_6.stopped', key_resp_6.tStopRefresh) thisExp.nextEntry() # completed 6 repeats of 'DistractionTask' # ------Prepare to start Routine "TestInstructions"------- continueRoutine = True # update component parameters for each repeat key_resp_3.keys = [] key_resp_3.rt = [] _key_resp_3_allKeys = [] # keep track of which components have finished TestInstructionsComponents = [text, key_resp_3] for thisComponent in TestInstructionsComponents: 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") TestInstructionsClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "TestInstructions"------- while continueRoutine: # get current time t = TestInstructionsClock.getTime() tThisFlip = win.getFutureFlipTime(clock=TestInstructionsClock) 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* updates if text.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text.frameNStart = frameN # exact frame index text.tStart = t # local t and not account for scr refresh text.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text, 'tStartRefresh') # time at next scr refresh text.setAutoDraw(True) # *key_resp_3* updates waitOnFlip = False if key_resp_3.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_3.frameNStart = frameN # exact frame index key_resp_3.tStart = t # local t and not account for scr refresh key_resp_3.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_3, 'tStartRefresh') # time at next scr refresh key_resp_3.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_3.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_3.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_3.status == STARTED and not waitOnFlip: theseKeys = key_resp_3.getKeys(keyList=None, waitRelease=False) _key_resp_3_allKeys.extend(theseKeys) if len(_key_resp_3_allKeys): key_resp_3.keys = _key_resp_3_allKeys[-1].name # just the last key pressed key_resp_3.rt = _key_resp_3_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 TestInstructionsComponents: 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 "TestInstructions"------- for thisComponent in TestInstructionsComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text.started', text.tStartRefresh) thisExp.addData('text.stopped', text.tStopRefresh) # check responses if key_resp_3.keys in ['', [], None]: # No response was made key_resp_3.keys = None thisExp.addData('key_resp_3.keys',key_resp_3.keys) if key_resp_3.keys != None: # we had a response thisExp.addData('key_resp_3.rt', key_resp_3.rt) thisExp.addData('key_resp_3.started', key_resp_3.tStartRefresh) thisExp.addData('key_resp_3.stopped', key_resp_3.tStopRefresh) thisExp.nextEntry() # the Routine "TestInstructions" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # set up handler to look after randomisation of conditions etc test_practice = data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('AVCongConditionsTestA.xlsx', selection='0,100,193'), seed=None, name='test_practice') thisExp.addLoop(test_practice) # add the loop to the experiment thisTest_practice = test_practice.trialList[0] # so we can initialise stimuli with some values # abbreviate parameter names if possible (e.g. rgb = thisTest_practice.rgb) if thisTest_practice != None: for paramName in thisTest_practice: exec('{} = thisTest_practice[paramName]'.format(paramName)) for thisTest_practice in test_practice: currentLoop = test_practice # abbreviate parameter names if possible (e.g. rgb = thisTest_practice.rgb) if thisTest_practice != None: for paramName in thisTest_practice: exec('{} = thisTest_practice[paramName]'.format(paramName)) # ------Prepare to start Routine "TestISI"------- continueRoutine = True routineTimer.add(0.500000) # update component parameters for each repeat # keep track of which components have finished TestISIComponents = [polygon_2] for thisComponent in TestISIComponents: 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") TestISIClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "TestISI"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = TestISIClock.getTime() tThisFlip = win.getFutureFlipTime(clock=TestISIClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *polygon_2* updates if polygon_2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_2.frameNStart = frameN # exact frame index polygon_2.tStart = t # local t and not account for scr refresh polygon_2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_2, 'tStartRefresh') # time at next scr refresh polygon_2.setAutoDraw(True) if polygon_2.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > polygon_2.tStartRefresh + 0.5-frameTolerance: # keep track of stop time/frame for later polygon_2.tStop = t # not accounting for scr refresh polygon_2.frameNStop = frameN # exact frame index win.timeOnFlip(polygon_2, 'tStopRefresh') # time at next scr refresh polygon_2.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 TestISIComponents: 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 "TestISI"------- for thisComponent in TestISIComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) test_practice.addData('polygon_2.started', polygon_2.tStartRefresh) test_practice.addData('polygon_2.stopped', polygon_2.tStopRefresh) # ------Prepare to start Routine "testtrial"------- continueRoutine = True # update component parameters for each repeat key_resp_2.keys = [] key_resp_2.rt = [] _key_resp_2_allKeys = [] image_2.setImage(test_image_1) # keep track of which components have finished testtrialComponents = [key_resp_2, image_2] for thisComponent in testtrialComponents: 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") testtrialClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "testtrial"------- while continueRoutine: # get current time t = testtrialClock.getTime() tThisFlip = win.getFutureFlipTime(clock=testtrialClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *key_resp_2* updates if key_resp_2.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_2.frameNStart = frameN # exact frame index key_resp_2.tStart = t # local t and not account for scr refresh key_resp_2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_2, 'tStartRefresh') # time at next scr refresh key_resp_2.status = STARTED # keyboard checking is just starting key_resp_2.clock.reset() # now t=0 key_resp_2.clearEvents(eventType='keyboard') if key_resp_2.status == STARTED: theseKeys = key_resp_2.getKeys(keyList=['1', '2', '3', '4', '5', '6'], waitRelease=False) _key_resp_2_allKeys.extend(theseKeys) if len(_key_resp_2_allKeys): key_resp_2.keys = _key_resp_2_allKeys[-1].name # just the last key pressed key_resp_2.rt = _key_resp_2_allKeys[-1].rt # was this correct? if (key_resp_2.keys == str(corrAnsTest)) or (key_resp_2.keys == corrAnsTest): key_resp_2.corr = 1 else: key_resp_2.corr = 0 # a response ends the routine continueRoutine = False # *image_2* updates if image_2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later image_2.frameNStart = frameN # exact frame index image_2.tStart = t # local t and not account for scr refresh image_2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(image_2, 'tStartRefresh') # time at next scr refresh image_2.setAutoDraw(True) # 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 testtrialComponents: 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 "testtrial"------- for thisComponent in testtrialComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) # check responses if key_resp_2.keys in ['', [], None]: # No response was made key_resp_2.keys = None # was no response the correct answer?! if str(corrAnsTest).lower() == 'none': key_resp_2.corr = 1; # correct non-response else: key_resp_2.corr = 0; # failed to respond (incorrectly) # store data for test_practice (TrialHandler) test_practice.addData('key_resp_2.keys',key_resp_2.keys) test_practice.addData('key_resp_2.corr', key_resp_2.corr) if key_resp_2.keys != None: # we had a response test_practice.addData('key_resp_2.rt', key_resp_2.rt) test_practice.addData('key_resp_2.started', key_resp_2.tStart) test_practice.addData('key_resp_2.stopped', key_resp_2.tStop) test_practice.addData('image_2.started', image_2.tStartRefresh) test_practice.addData('image_2.stopped', image_2.tStopRefresh) # the Routine "testtrial" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "test_feedback"------- continueRoutine = True routineTimer.add(0.500000) # update component parameters for each repeat if not key_resp_2.keys : msg="Failed to respond" msgcolor='red' elif key_resp_2.corr:#stored on last run routine msg="Correct!" msgcolor='green' else: msg="Oops! That was wrong" msgcolor='red' text_11.setColor(msgcolor, colorSpace='rgb') text_11.setText(msg) # keep track of which components have finished test_feedbackComponents = [text_11] for thisComponent in test_feedbackComponents: 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") test_feedbackClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "test_feedback"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = test_feedbackClock.getTime() tThisFlip = win.getFutureFlipTime(clock=test_feedbackClock) 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_11* updates if text_11.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_11.frameNStart = frameN # exact frame index text_11.tStart = t # local t and not account for scr refresh text_11.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_11, 'tStartRefresh') # time at next scr refresh text_11.setAutoDraw(True) if text_11.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_11.tStartRefresh + 0.5-frameTolerance: # keep track of stop time/frame for later text_11.tStop = t # not accounting for scr refresh text_11.frameNStop = frameN # exact frame index win.timeOnFlip(text_11, 'tStopRefresh') # time at next scr refresh text_11.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 test_feedbackComponents: 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 "test_feedback"------- for thisComponent in test_feedbackComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) test_practice.addData('text_11.started', text_11.tStartRefresh) test_practice.addData('text_11.stopped', text_11.tStopRefresh) thisExp.nextEntry() # completed 1 repeats of 'test_practice' # ------Prepare to start Routine "TestInstructionsReminder"------- continueRoutine = True # update component parameters for each repeat key_resp_10.keys = [] key_resp_10.rt = [] _key_resp_10_allKeys = [] # keep track of which components have finished TestInstructionsReminderComponents = [text_8, key_resp_10] for thisComponent in TestInstructionsReminderComponents: 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") TestInstructionsReminderClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "TestInstructionsReminder"------- while continueRoutine: # get current time t = TestInstructionsReminderClock.getTime() tThisFlip = win.getFutureFlipTime(clock=TestInstructionsReminderClock) 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_8* updates if text_8.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_8.frameNStart = frameN # exact frame index text_8.tStart = t # local t and not account for scr refresh text_8.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_8, 'tStartRefresh') # time at next scr refresh text_8.setAutoDraw(True) # *key_resp_10* updates waitOnFlip = False if key_resp_10.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_10.frameNStart = frameN # exact frame index key_resp_10.tStart = t # local t and not account for scr refresh key_resp_10.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_10, 'tStartRefresh') # time at next scr refresh key_resp_10.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_10.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_10.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_10.status == STARTED and not waitOnFlip: theseKeys = key_resp_10.getKeys(keyList=None, waitRelease=False) _key_resp_10_allKeys.extend(theseKeys) if len(_key_resp_10_allKeys): key_resp_10.keys = _key_resp_10_allKeys[-1].name # just the last key pressed key_resp_10.rt = _key_resp_10_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 TestInstructionsReminderComponents: 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 "TestInstructionsReminder"------- for thisComponent in TestInstructionsReminderComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_8.started', text_8.tStartRefresh) thisExp.addData('text_8.stopped', text_8.tStopRefresh) # check responses if key_resp_10.keys in ['', [], None]: # No response was made key_resp_10.keys = None thisExp.addData('key_resp_10.keys',key_resp_10.keys) if key_resp_10.keys != None: # we had a response thisExp.addData('key_resp_10.rt', key_resp_10.rt) thisExp.addData('key_resp_10.started', key_resp_10.tStartRefresh) thisExp.addData('key_resp_10.stopped', key_resp_10.tStopRefresh) thisExp.nextEntry() # the Routine "TestInstructionsReminder" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # set up handler to look after randomisation of conditions etc Test = data.TrialHandler(nReps=1, method='random', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('AVCongConditionsTestA.xlsx'), seed=None, name='Test') thisExp.addLoop(Test) # add the loop to the experiment thisTest = Test.trialList[0] # so we can initialise stimuli with some values # abbreviate parameter names if possible (e.g. rgb = thisTest.rgb) if thisTest != None: for paramName in thisTest: exec('{} = thisTest[paramName]'.format(paramName)) for thisTest in Test: currentLoop = Test # abbreviate parameter names if possible (e.g. rgb = thisTest.rgb) if thisTest != None: for paramName in thisTest: exec('{} = thisTest[paramName]'.format(paramName)) # ------Prepare to start Routine "TestISI"------- continueRoutine = True routineTimer.add(0.500000) # update component parameters for each repeat # keep track of which components have finished TestISIComponents = [polygon_2] for thisComponent in TestISIComponents: 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") TestISIClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "TestISI"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = TestISIClock.getTime() tThisFlip = win.getFutureFlipTime(clock=TestISIClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *polygon_2* updates if polygon_2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later polygon_2.frameNStart = frameN # exact frame index polygon_2.tStart = t # local t and not account for scr refresh polygon_2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(polygon_2, 'tStartRefresh') # time at next scr refresh polygon_2.setAutoDraw(True) if polygon_2.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > polygon_2.tStartRefresh + 0.5-frameTolerance: # keep track of stop time/frame for later polygon_2.tStop = t # not accounting for scr refresh polygon_2.frameNStop = frameN # exact frame index win.timeOnFlip(polygon_2, 'tStopRefresh') # time at next scr refresh polygon_2.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 TestISIComponents: 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 "TestISI"------- for thisComponent in TestISIComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) Test.addData('polygon_2.started', polygon_2.tStartRefresh) Test.addData('polygon_2.stopped', polygon_2.tStopRefresh) # ------Prepare to start Routine "testtrial"------- continueRoutine = True # update component parameters for each repeat key_resp_2.keys = [] key_resp_2.rt = [] _key_resp_2_allKeys = [] image_2.setImage(test_image_1) # keep track of which components have finished testtrialComponents = [key_resp_2, image_2] for thisComponent in testtrialComponents: 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") testtrialClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "testtrial"------- while continueRoutine: # get current time t = testtrialClock.getTime() tThisFlip = win.getFutureFlipTime(clock=testtrialClock) tThisFlipGlobal = win.getFutureFlipTime(clock=None) frameN = frameN + 1 # number of completed frames (so 0 is the first frame) # update/draw components on each frame # *key_resp_2* updates if key_resp_2.status == NOT_STARTED and t >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_2.frameNStart = frameN # exact frame index key_resp_2.tStart = t # local t and not account for scr refresh key_resp_2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_2, 'tStartRefresh') # time at next scr refresh key_resp_2.status = STARTED # keyboard checking is just starting key_resp_2.clock.reset() # now t=0 key_resp_2.clearEvents(eventType='keyboard') if key_resp_2.status == STARTED: theseKeys = key_resp_2.getKeys(keyList=['1', '2', '3', '4', '5', '6'], waitRelease=False) _key_resp_2_allKeys.extend(theseKeys) if len(_key_resp_2_allKeys): key_resp_2.keys = _key_resp_2_allKeys[-1].name # just the last key pressed key_resp_2.rt = _key_resp_2_allKeys[-1].rt # was this correct? if (key_resp_2.keys == str(corrAnsTest)) or (key_resp_2.keys == corrAnsTest): key_resp_2.corr = 1 else: key_resp_2.corr = 0 # a response ends the routine continueRoutine = False # *image_2* updates if image_2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later image_2.frameNStart = frameN # exact frame index image_2.tStart = t # local t and not account for scr refresh image_2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(image_2, 'tStartRefresh') # time at next scr refresh image_2.setAutoDraw(True) # 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 testtrialComponents: 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 "testtrial"------- for thisComponent in testtrialComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) # check responses if key_resp_2.keys in ['', [], None]: # No response was made key_resp_2.keys = None # was no response the correct answer?! if str(corrAnsTest).lower() == 'none': key_resp_2.corr = 1; # correct non-response else: key_resp_2.corr = 0; # failed to respond (incorrectly) # store data for Test (TrialHandler) Test.addData('key_resp_2.keys',key_resp_2.keys) Test.addData('key_resp_2.corr', key_resp_2.corr) if key_resp_2.keys != None: # we had a response Test.addData('key_resp_2.rt', key_resp_2.rt) Test.addData('key_resp_2.started', key_resp_2.tStart) Test.addData('key_resp_2.stopped', key_resp_2.tStop) Test.addData('image_2.started', image_2.tStartRefresh) Test.addData('image_2.stopped', image_2.tStopRefresh) # the Routine "testtrial" was not non-slip safe, so reset the non-slip timer routineTimer.reset() # ------Prepare to start Routine "test_feedback"------- continueRoutine = True routineTimer.add(0.500000) # update component parameters for each repeat if not key_resp_2.keys : msg="Failed to respond" msgcolor='red' elif key_resp_2.corr:#stored on last run routine msg="Correct!" msgcolor='green' else: msg="Oops! That was wrong" msgcolor='red' text_11.setColor(msgcolor, colorSpace='rgb') text_11.setText(msg) # keep track of which components have finished test_feedbackComponents = [text_11] for thisComponent in test_feedbackComponents: 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") test_feedbackClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "test_feedback"------- while continueRoutine and routineTimer.getTime() > 0: # get current time t = test_feedbackClock.getTime() tThisFlip = win.getFutureFlipTime(clock=test_feedbackClock) 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_11* updates if text_11.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_11.frameNStart = frameN # exact frame index text_11.tStart = t # local t and not account for scr refresh text_11.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_11, 'tStartRefresh') # time at next scr refresh text_11.setAutoDraw(True) if text_11.status == STARTED: # is it time to stop? (based on global clock, using actual start) if tThisFlipGlobal > text_11.tStartRefresh + 0.5-frameTolerance: # keep track of stop time/frame for later text_11.tStop = t # not accounting for scr refresh text_11.frameNStop = frameN # exact frame index win.timeOnFlip(text_11, 'tStopRefresh') # time at next scr refresh text_11.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 test_feedbackComponents: 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 "test_feedback"------- for thisComponent in test_feedbackComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) Test.addData('text_11.started', text_11.tStartRefresh) Test.addData('text_11.stopped', text_11.tStopRefresh) thisExp.nextEntry() # completed 1 repeats of 'Test' # ------Prepare to start Routine "Thanks"------- continueRoutine = True # update component parameters for each repeat key_resp_4.keys = [] key_resp_4.rt = [] _key_resp_4_allKeys = [] # keep track of which components have finished ThanksComponents = [text_2, key_resp_4] for thisComponent in ThanksComponents: 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") ThanksClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip frameN = -1 # -------Run Routine "Thanks"------- while continueRoutine: # get current time t = ThanksClock.getTime() tThisFlip = win.getFutureFlipTime(clock=ThanksClock) 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_2* updates if text_2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later text_2.frameNStart = frameN # exact frame index text_2.tStart = t # local t and not account for scr refresh text_2.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(text_2, 'tStartRefresh') # time at next scr refresh text_2.setAutoDraw(True) # *key_resp_4* updates waitOnFlip = False if key_resp_4.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance: # keep track of start time/frame for later key_resp_4.frameNStart = frameN # exact frame index key_resp_4.tStart = t # local t and not account for scr refresh key_resp_4.tStartRefresh = tThisFlipGlobal # on global time win.timeOnFlip(key_resp_4, 'tStartRefresh') # time at next scr refresh key_resp_4.status = STARTED # keyboard checking is just starting waitOnFlip = True win.callOnFlip(key_resp_4.clock.reset) # t=0 on next screen flip win.callOnFlip(key_resp_4.clearEvents, eventType='keyboard') # clear events on next screen flip if key_resp_4.status == STARTED and not waitOnFlip: theseKeys = key_resp_4.getKeys(keyList=None, waitRelease=False) _key_resp_4_allKeys.extend(theseKeys) if len(_key_resp_4_allKeys): key_resp_4.keys = _key_resp_4_allKeys[-1].name # just the last key pressed key_resp_4.rt = _key_resp_4_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 ThanksComponents: 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 "Thanks"------- for thisComponent in ThanksComponents: if hasattr(thisComponent, "setAutoDraw"): thisComponent.setAutoDraw(False) thisExp.addData('text_2.started', text_2.tStartRefresh) thisExp.addData('text_2.stopped', text_2.tStopRefresh) # check responses if key_resp_4.keys in ['', [], None]: # No response was made key_resp_4.keys = None thisExp.addData('key_resp_4.keys',key_resp_4.keys) if key_resp_4.keys != None: # we had a response thisExp.addData('key_resp_4.rt', key_resp_4.rt) thisExp.addData('key_resp_4.started', key_resp_4.tStartRefresh) thisExp.addData('key_resp_4.stopped', key_resp_4.tStopRefresh) thisExp.nextEntry() # the Routine "Thanks" 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') 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()