demo_eye_tracking2.psyexp 40.7 KB
Newer Older
Thomas Pronk's avatar
_  
Thomas Pronk committed
1
<?xml version="1.0" ?>
RebeccaHirst's avatar
RebeccaHirst committed
2
<PsychoPy2experiment encoding="utf-8" version="2021.2.3">
Thomas Pronk's avatar
_  
Thomas Pronk committed
3 4 5 6 7 8 9
  <Settings>
    <Param name="Audio latency priority" updates="None" val="use prefs" valType="str"/>
    <Param name="Audio lib" updates="None" val="use prefs" valType="str"/>
    <Param name="Completed URL" updates="None" val="" valType="str"/>
    <Param name="Data file delimiter" updates="None" val="auto" valType="str"/>
    <Param name="Data filename" updates="None" val="u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date'])" valType="code"/>
    <Param name="Enable Escape" updates="None" val="True" valType="bool"/>
10
    <Param name="Experiment info" updates="None" val="{'participant': '', 'session': '001'}" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
11 12 13 14 15
    <Param name="Force stereo" updates="None" val="True" valType="bool"/>
    <Param name="Full-screen window" updates="None" val="True" valType="bool"/>
    <Param name="HTML path" updates="None" val="" valType="str"/>
    <Param name="Incomplete URL" updates="None" val="" valType="str"/>
    <Param name="Monitor" updates="None" val="testMonitor" valType="str"/>
16
    <Param name="Resources" updates="None" val="['webgazer-2.0.1.tp.js']" valType="fileList"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
17 18
    <Param name="Save csv file" updates="None" val="False" valType="bool"/>
    <Param name="Save excel file" updates="None" val="False" valType="bool"/>
RebeccaHirst's avatar
RebeccaHirst committed
19
    <Param name="Save hdf5 file" updates="None" val="False" valType="bool"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
20 21 22 23 24 25 26 27
    <Param name="Save log file" updates="None" val="True" valType="bool"/>
    <Param name="Save psydat file" updates="None" val="True" valType="bool"/>
    <Param name="Save wide csv file" updates="None" val="True" valType="bool"/>
    <Param name="Screen" updates="None" val="1" valType="num"/>
    <Param name="Show info dlg" updates="None" val="True" valType="bool"/>
    <Param name="Show mouse" updates="None" val="False" valType="bool"/>
    <Param name="Units" updates="None" val="height" valType="str"/>
    <Param name="Use version" updates="None" val="" valType="str"/>
28
    <Param name="Window size (pixels)" updates="None" val="[1536, 960]" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
29
    <Param name="blendMode" updates="None" val="avg" valType="str"/>
30
    <Param name="color" updates="None" val="$[-1,-1,-1]" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
31
    <Param name="colorSpace" updates="None" val="rgb" valType="str"/>
RebeccaHirst's avatar
RebeccaHirst committed
32 33 34 35 36 37 38 39 40 41
    <Param name="elAddress" updates="None" val="100.1.1.1" valType="str"/>
    <Param name="elDataFiltering" updates="None" val="FILTER_LEVEL_2" valType="str"/>
    <Param name="elLiveFiltering" updates="None" val="FILTER_LEVEL_OFF" valType="str"/>
    <Param name="elModel" updates="None" val="EYELINK 1000 DESKTOP" valType="str"/>
    <Param name="elPupilAlgorithm" updates="None" val="ELLIPSE_FIT" valType="str"/>
    <Param name="elPupilMeasure" updates="None" val="PUPIL_AREA" valType="str"/>
    <Param name="elSampleRate" updates="None" val="1000" valType="num"/>
    <Param name="elSimMode" updates="None" val="False" valType="bool"/>
    <Param name="elTrackEyes" updates="None" val="RIGHT_EYE" valType="str"/>
    <Param name="elTrackingMode" updates="None" val="PUPIL_CR_TRACKING" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
42 43
    <Param name="expName" updates="None" val="demo_eye_tracking" valType="str"/>
    <Param name="exportHTML" updates="None" val="on Sync" valType="str"/>
RebeccaHirst's avatar
RebeccaHirst committed
44 45 46
    <Param name="eyetracker" updates="None" val="None" valType="str"/>
    <Param name="gpAddress" updates="None" val="127.0.0.1" valType="str"/>
    <Param name="gpPort" updates="None" val="4242" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
47
    <Param name="logging level" updates="None" val="exp" valType="code"/>
48
    <Param name="mgBlink" updates="None" val="('MIDDLE_BUTTON',)" valType="list"/>
RebeccaHirst's avatar
RebeccaHirst committed
49 50 51 52 53 54
    <Param name="mgMove" updates="None" val="CONTINUOUS" valType="str"/>
    <Param name="mgSaccade" updates="None" val="0.5" valType="num"/>
    <Param name="tbLicenseFile" updates="None" val="" valType="str"/>
    <Param name="tbModel" updates="None" val="" valType="str"/>
    <Param name="tbSampleRate" updates="None" val="60" valType="num"/>
    <Param name="tbSerialNo" updates="None" val="" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
55 56
  </Settings>
  <Routines>
Thomas Pronk's avatar
_  
Thomas Pronk committed
57
    <Routine name="webcam_trial">
Thomas Pronk's avatar
_  
Thomas Pronk committed
58 59 60
      <TextComponent name="intro_text">
        <Param name="color" updates="constant" val="white" valType="str"/>
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
61
        <Param name="contrast" updates="constant" val="1" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="flip" updates="constant" val="" valType="str"/>
        <Param name="font" updates="constant" val="Arial" valType="str"/>
        <Param name="languageStyle" updates="None" val="LTR" valType="str"/>
        <Param name="letterHeight" updates="constant" val="0.04" valType="code"/>
        <Param name="name" updates="None" val="intro_text" valType="code"/>
        <Param name="opacity" updates="constant" val="1" valType="code"/>
        <Param name="ori" updates="constant" val="0" valType="code"/>
        <Param name="pos" updates="constant" val="(0, 0)" valType="code"/>
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
        <Param name="startVal" updates="None" val="0.0" valType="code"/>
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
        <Param name="stopVal" updates="constant" val="" valType="code"/>
        <Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
79
        <Param name="text" updates="constant" val="demo_eye_tracking: starting webcam&amp;#10;&amp;#10;This experiment demonstrates eye tracking via the webgazer library. &amp;#10;&amp;#10;You should see your web-browser request access to your webcam. You might need to click on this text to make that happen. Please permit access, and wait a little while. Your webcam video should appear in the top-left of the screen." valType="extendedStr"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
80 81 82
        <Param name="units" updates="None" val="from exp settings" valType="str"/>
        <Param name="wrapWidth" updates="constant" val="" valType="code"/>
      </TextComponent>
Thomas Pronk's avatar
_  
Thomas Pronk committed
83
      <CodeComponent name="start_webgazer">
Thomas Pronk's avatar
_  
Thomas Pronk committed
84 85 86 87
        <Param name="Before Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Before JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Experiment" updates="constant" val="" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
88
        <Param name="Begin JS Routine" updates="constant" val="// Show webcam thumbnail and face feedback box, but not face overlay and gaze dot&amp;#10;window.webgazer.params.showVideoPreview = true;&amp;#10;window.webgazer.params.showFaceFeedbackBox = true;&amp;#10;window.webgazer.params.showFaceOverlay = false;&amp;#10;window.webgazer.params.showGazeDot = false&amp;#10;// Start eye tracking&amp;#10;window.webgazer&amp;#10;    // Called on each eye tracking update&amp;#10;    .setGazeListener(function(data, clock) {&amp;#10;      if (data !== null) {&amp;#10;        // Remove first element from gazes array, add current gaze at the end&amp;#10;        window.xGazes.shift();&amp;#10;        window.xGazes.push(data.x);&amp;#10;        window.yGazes.shift();&amp;#10;        window.yGazes.push(data.y);&amp;#10;       }&amp;#10;    })&amp;#10;    .begin();&amp;#10;    //.showPredictionPoints(true); &amp;#10;" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
89 90 91
        <Param name="Begin Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="Code Type" updates="None" val="JS" valType="str"/>
        <Param name="Each Frame" updates="constant" val="" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
92
        <Param name="Each JS Frame" updates="constant" val="// Finish routine once everything is ready&amp;#10;continueRoutine = &amp;#10;  !window.webgazer.isReady() || &amp;#10;  document.getElementById('webgazerFaceFeedbackBox') === null ||&amp;#10;  document.getElementById('webgazerVideoFeed') === null;" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
93 94 95 96 97
        <Param name="End Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="End Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
98
        <Param name="name" updates="None" val="start_webgazer" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
99
      </CodeComponent>
Thomas Pronk's avatar
_  
Thomas Pronk committed
100
    </Routine>
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
    <Routine name="inst1">
      <CodeComponent name="hide_thumbnail">
        <Param name="Before Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Before JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Routine" updates="constant" val="document.getElementById('webgazerFaceFeedbackBox').style.display = 'none';&amp;#10;document.getElementById('webgazerVideoFeed').style.display = 'none';" valType="extendedCode"/>
        <Param name="Begin Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="Code Type" updates="None" val="JS" valType="str"/>
        <Param name="Each Frame" updates="constant" val="" valType="extendedCode"/>
        <Param name="Each JS Frame" updates="constant" val="" valType="extendedCode"/>
        <Param name="End Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="End Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="name" updates="None" val="hide_thumbnail" valType="code"/>
      </CodeComponent>
      <TextComponent name="instruction1Txt">
        <Param name="color" updates="constant" val="white" valType="color"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
121
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
122
        <Param name="contrast" updates="constant" val="1" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
123 124
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
125
        <Param name="flip" updates="constant" val="None" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
126 127
        <Param name="font" updates="constant" val="Arial" valType="str"/>
        <Param name="languageStyle" updates="None" val="LTR" valType="str"/>
128 129 130 131 132
        <Param name="letterHeight" updates="constant" val="0.05" valType="num"/>
        <Param name="name" updates="None" val="instruction1Txt" valType="code"/>
        <Param name="opacity" updates="constant" val="" valType="num"/>
        <Param name="ori" updates="constant" val="0" valType="num"/>
        <Param name="pos" updates="constant" val="(0, 0)" valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
133 134 135 136 137
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
        <Param name="startVal" updates="None" val="0.0" valType="code"/>
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
138
        <Param name="stopVal" updates="constant" val="" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
139
        <Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
140
        <Param name="text" updates="constant" val="Webgazer initialized. &amp;#10;Press space to move on" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
141
        <Param name="units" updates="None" val="from exp settings" valType="str"/>
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
        <Param name="wrapWidth" updates="constant" val="" valType="num"/>
      </TextComponent>
      <KeyboardComponent name="inst1_resp">
        <Param name="allowedKeys" updates="constant" val="'space'" valType="list"/>
        <Param name="correctAns" updates="constant" val="" valType="str"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="discard previous" updates="constant" val="True" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="forceEndRoutine" updates="constant" val="True" valType="bool"/>
        <Param name="name" updates="None" val="inst1_resp" valType="code"/>
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
        <Param name="startVal" updates="None" val="0.0" valType="code"/>
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
        <Param name="stopVal" updates="constant" val="" valType="code"/>
        <Param name="store" updates="constant" val="last key" valType="str"/>
        <Param name="storeCorrect" updates="constant" val="False" valType="bool"/>
        <Param name="syncScreenRefresh" updates="constant" val="True" valType="bool"/>
      </KeyboardComponent>
    </Routine>
    <Routine name="calibrationIntro">
      <TextComponent name="calibrationTxt">
        <Param name="color" updates="constant" val="white" valType="color"/>
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
        <Param name="contrast" updates="constant" val="1" valType="num"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="flip" updates="constant" val="None" valType="str"/>
        <Param name="font" updates="constant" val="Arial" valType="str"/>
        <Param name="languageStyle" updates="None" val="LTR" valType="str"/>
        <Param name="letterHeight" updates="constant" val="0.05" valType="num"/>
        <Param name="name" updates="None" val="calibrationTxt" valType="code"/>
        <Param name="opacity" updates="constant" val="" valType="num"/>
        <Param name="ori" updates="constant" val="0" valType="num"/>
        <Param name="pos" updates="constant" val="(0, 0)" valType="list"/>
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
        <Param name="startVal" updates="None" val="0.0" valType="code"/>
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
        <Param name="stopVal" updates="constant" val="" valType="code"/>
        <Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
        <Param name="text" updates="constant" val="OK great! we are almost ready to get started. &amp;#10;&amp;#10;First we need to calibrate the eye tracker. Please try to keep your head still. If you move your head too far away, you'r webcam will appear in the top left corner. If this happens, please move back into view. &amp;#10;&amp;#10;White squares will appear at different locations on the screen. Please click each square with your mouse.&amp;#10;&amp;#10;Click anywhere with the mouse to continue..." valType="str"/>
        <Param name="units" updates="None" val="from exp settings" valType="str"/>
        <Param name="wrapWidth" updates="constant" val="" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
188
      </TextComponent>
189 190
      <MouseComponent name="calibrationMouse">
        <Param name="clickable" updates="constant" val="" valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
191 192 193
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="forceEndRoutineOnPress" updates="constant" val="any click" valType="str"/>
194
        <Param name="name" updates="None" val="calibrationMouse" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
195 196
        <Param name="newClicksOnly" updates="constant" val="True" valType="bool"/>
        <Param name="saveMouseState" updates="None" val="final" valType="str"/>
197
        <Param name="saveParamsClickable" updates="constant" val="name," valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
198 199 200 201 202 203 204 205 206 207
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
        <Param name="startVal" updates="None" val="0.0" valType="code"/>
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
        <Param name="stopVal" updates="constant" val="" valType="code"/>
        <Param name="syncScreenRefresh" updates="None" val="False" valType="bool"/>
        <Param name="timeRelativeTo" updates="constant" val="mouse onset" valType="str"/>
      </MouseComponent>
    </Routine>
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
    <Routine name="calibration">
      <CodeComponent name="calibrationCode">
        <Param name="Before Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Before JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Routine" updates="constant" val="// Position calibration_square using width and height of window&amp;#10;var canvas = psychoJS.window.size;&amp;#10;var scaling = [&amp;#10;  canvas[0] &lt;= canvas[1]? 1: canvas[0] / canvas[1],&amp;#10;  canvas[1] &lt;= canvas[0]? 1: canvas[1] / canvas[0]&amp;#10;];&amp;#10;var newPos = [&amp;#10;    calibration_x * scaling[0],&amp;#10;    calibration_y * scaling[1]&amp;#10;];&amp;#10;console.log(newPos);&amp;#10;//calibration_square.setPos(newPos);&amp;#10;callib_color = 'white';" valType="extendedCode"/>
        <Param name="Begin Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="Code Type" updates="None" val="JS" valType="str"/>
        <Param name="Each Frame" updates="constant" val="" valType="extendedCode"/>
        <Param name="Each JS Frame" updates="constant" val="// returns type error - checking fix &amp;#10;&amp;#10;// Hide webcam thumbnail if eyes are in validation box&amp;#10;if (webgazer.checkEyesInValidationBox() === true) {&amp;#10;  // If last time that eyes were outside of validation box was longer than &amp;#10;  // window.eyesReturnedDelay ago, hide thumbnail&amp;#10;  if (&amp;#10;    document.getElementById('webgazerFaceFeedbackBox').style.display != 'none' &amp;&amp;&amp;#10;    (new Date).getTime() &gt; window.eyesExitedTimestamp + window.eyesReturnedDelay&amp;#10;  ) {   &amp;#10;    document.getElementById('webgazerFaceFeedbackBox').style.display = 'none';&amp;#10;    document.getElementById('webgazerVideoFeed').style.display = 'none';&amp;#10;  }&amp;#10;} else {&amp;#10;    // Eyes outside of validation box; show thumbnail&amp;#10;    window.eyesExitedTimestamp = (new Date).getTime();&amp;#10;    document.getElementById('webgazerFaceFeedbackBox').style.display = 'block';&amp;#10;    document.getElementById('webgazerVideoFeed').style.display = 'block';&amp;#10;}&amp;#10;&amp;#10;&amp;#10;if (&amp;#10;  document.getElementById('webgazerFaceFeedbackBox').style.display != 'none' &amp;&amp;&amp;#10;  (new Date).getTime() &gt; window.eyesExitedTimestamp + window.eyesReturnedDelay&amp;#10;) {   &amp;#10;  document.getElementById('webgazerFaceFeedbackBox').style.display = 'none';&amp;#10;  document.getElementById('webgazerVideoFeed').style.display = 'none';&amp;#10;}&amp;#10;" valType="extendedCode"/>
        <Param name="End Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="End Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="name" updates="None" val="calibrationCode" valType="code"/>
      </CodeComponent>
Thomas Pronk's avatar
_  
Thomas Pronk committed
226
      <PolygonComponent name="calibration_square">
Thomas Pronk's avatar
_  
Thomas Pronk committed
227 228
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
        <Param name="contrast" updates="constant" val="1" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
229 230
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
231
        <Param name="fillColor" updates="set every frame" val="$callib_color" valType="color"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
232
        <Param name="interpolate" updates="constant" val="linear" valType="str"/>
233 234
        <Param name="lineColor" updates="constant" val="white" valType="color"/>
        <Param name="lineWidth" updates="constant" val="1" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
235 236
        <Param name="nVertices" updates="constant" val="4" valType="int"/>
        <Param name="name" updates="None" val="calibration_square" valType="code"/>
237 238 239
        <Param name="opacity" updates="constant" val="" valType="num"/>
        <Param name="ori" updates="constant" val="0" valType="num"/>
        <Param name="pos" updates="set every repeat" val="(calibration_x, calibration_y)" valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
240
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
241 242
        <Param name="shape" updates="None" val="rectangle" valType="str"/>
        <Param name="size" updates="constant" val="(0.02, 0.02)" valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
243 244
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
245
        <Param name="startVal" updates="None" val="0.5" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
246
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
247
        <Param name="stopVal" updates="constant" val="3" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
248 249
        <Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
        <Param name="units" updates="None" val="from exp settings" valType="str"/>
RebeccaHirst's avatar
RebeccaHirst committed
250
        <Param name="vertices" updates="constant" val="" valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
251
      </PolygonComponent>
252 253
      <MouseComponent name="calibrationClick">
        <Param name="clickable" updates="constant" val="calibration_square" valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
254 255
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
256 257
        <Param name="forceEndRoutineOnPress" updates="constant" val="any click" valType="str"/>
        <Param name="name" updates="None" val="calibrationClick" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
258 259
        <Param name="newClicksOnly" updates="constant" val="True" valType="bool"/>
        <Param name="saveMouseState" updates="None" val="final" valType="str"/>
260
        <Param name="saveParamsClickable" updates="constant" val="name," valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
261 262 263
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
264
        <Param name="startVal" updates="None" val="0.5" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
265
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
266
        <Param name="stopVal" updates="constant" val="3" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
267 268 269
        <Param name="syncScreenRefresh" updates="None" val="False" valType="bool"/>
        <Param name="timeRelativeTo" updates="constant" val="mouse onset" valType="str"/>
      </MouseComponent>
270
      <CodeComponent name="code">
Thomas Pronk's avatar
_  
Thomas Pronk committed
271 272 273 274
        <Param name="Before Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Before JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Experiment" updates="constant" val="" valType="extendedCode"/>
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
        <Param name="Begin JS Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="Code Type" updates="None" val="Auto-&gt;JS" valType="str"/>
        <Param name="Each Frame" updates="constant" val="if calibrationClick.getPressed()[0]:&amp;#10;    callib_color = 'green'&amp;#10;" valType="extendedCode"/>
        <Param name="Each JS Frame" updates="constant" val="if (calibrationClick.getPressed()[0]) {&amp;#10;    callib_color = &quot;green&quot;;&amp;#10;}&amp;#10;" valType="extendedCode"/>
        <Param name="End Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="End Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="disabled" updates="None" val="True" valType="bool"/>
        <Param name="name" updates="None" val="code" valType="code"/>
      </CodeComponent>
    </Routine>
    <Routine name="initializeEyetracking">
      <CodeComponent name="initWebgazer">
        <Param name="Before Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Before JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Experiment" updates="constant" val="//initialize params of the webgazer package (used for eye tracking)&amp;#10;&amp;#10;// Initialize x and y arrays; we use these to calculate running averages of &amp;#10;// current gaze position; the longer the window, the slower, but more fluent&amp;#10;// the updates&amp;#10;let averagingWindow = 10;&amp;#10;window.xGazes = new Array(averagingWindow ).fill(0);&amp;#10;window.yGazes = new Array(averagingWindow ).fill(0);&amp;#10;" valType="extendedCode"/>
        <Param name="Begin JS Routine" updates="constant" val="// Show webcam thumbnail and face feedback box, but not face overlay and gaze dot&amp;#10;window.webgazer.params.showVideoPreview = true;&amp;#10;window.webgazer.params.showFaceFeedbackBox = true;&amp;#10;window.webgazer.params.showFaceOverlay = false;&amp;#10;window.webgazer.params.showGazeDot = false&amp;#10;// Start eye tracking&amp;#10;window.webgazer&amp;#10;    // Called on each eye tracking update&amp;#10;    .setGazeListener(function(data, clock) {&amp;#10;      if (data !== null) {&amp;#10;        // Remove first element from gazes array, add current gaze at the end&amp;#10;        window.xGazes.shift();&amp;#10;        window.xGazes.push(data.x);&amp;#10;        window.yGazes.shift();&amp;#10;        window.yGazes.push(data.y);&amp;#10;       }&amp;#10;    })&amp;#10;    .begin();&amp;#10;    //.showPredictionPoints(true); &amp;#10;&amp;#10;" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
295 296 297
        <Param name="Begin Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="Code Type" updates="None" val="JS" valType="str"/>
        <Param name="Each Frame" updates="constant" val="" valType="extendedCode"/>
298
        <Param name="Each JS Frame" updates="constant" val="// Finish routine once everything is ready&amp;#10;continueRoutine = &amp;#10;  !window.webgazer.isReady() || &amp;#10;  document.getElementById('webgazerFaceFeedbackBox') === null ||&amp;#10;  document.getElementById('webgazerVideoFeed') === null;" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
299 300 301 302 303
        <Param name="End Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="End Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
304
        <Param name="name" updates="None" val="initWebgazer" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
305
      </CodeComponent>
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
      <TextComponent name="webcamWarning">
        <Param name="color" updates="constant" val="white" valType="color"/>
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
        <Param name="contrast" updates="constant" val="1" valType="num"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="flip" updates="constant" val="None" valType="str"/>
        <Param name="font" updates="constant" val="Arial" valType="str"/>
        <Param name="languageStyle" updates="None" val="LTR" valType="str"/>
        <Param name="letterHeight" updates="constant" val="0.05" valType="num"/>
        <Param name="name" updates="None" val="webcamWarning" valType="code"/>
        <Param name="opacity" updates="constant" val="" valType="num"/>
        <Param name="ori" updates="constant" val="0" valType="num"/>
        <Param name="pos" updates="constant" val="(0, 0)" valType="list"/>
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
        <Param name="startVal" updates="None" val="0.0" valType="code"/>
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
        <Param name="stopVal" updates="constant" val="" valType="code"/>
        <Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
        <Param name="text" updates="constant" val="This experiment uses eye tracking. &amp;#10;&amp;#10;You should see your web-browser request access to your webcam. You might need to click on this text to make that happen. Please permit access, and wait a little while. Your webcam video should appear in the top-left of the screen." valType="str"/>
        <Param name="units" updates="None" val="from exp settings" valType="str"/>
        <Param name="wrapWidth" updates="constant" val="" valType="num"/>
      </TextComponent>
Thomas Pronk's avatar
_  
Thomas Pronk committed
331
    </Routine>
332
    <Routine name="trackingTrial">
Thomas Pronk's avatar
_  
Thomas Pronk committed
333
      <PolygonComponent name="tracking_square">
Thomas Pronk's avatar
_  
Thomas Pronk committed
334 335
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
        <Param name="contrast" updates="constant" val="1" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
336 337
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
338
        <Param name="fillColor" updates="constant" val="white" valType="color"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
339
        <Param name="interpolate" updates="constant" val="linear" valType="str"/>
340 341
        <Param name="lineColor" updates="constant" val="white" valType="color"/>
        <Param name="lineWidth" updates="constant" val="1" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
342 343
        <Param name="nVertices" updates="constant" val="4" valType="int"/>
        <Param name="name" updates="None" val="tracking_square" valType="code"/>
344 345 346
        <Param name="opacity" updates="constant" val="" valType="num"/>
        <Param name="ori" updates="constant" val="0" valType="num"/>
        <Param name="pos" updates="constant" val="(0, 0)" valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
347
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
348 349
        <Param name="shape" updates="None" val="rectangle" valType="str"/>
        <Param name="size" updates="constant" val="(0.02, 0.02)" valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
350 351 352 353 354 355 356
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
        <Param name="startVal" updates="None" val="0.0" valType="code"/>
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
        <Param name="stopVal" updates="constant" val="" valType="code"/>
        <Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
        <Param name="units" updates="None" val="from exp settings" valType="str"/>
RebeccaHirst's avatar
RebeccaHirst committed
357
        <Param name="vertices" updates="constant" val="" valType="list"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
358
      </PolygonComponent>
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
      <TextComponent name="trackingTxt">
        <Param name="color" updates="constant" val="white" valType="color"/>
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
        <Param name="contrast" updates="constant" val="1" valType="num"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="flip" updates="constant" val="None" valType="str"/>
        <Param name="font" updates="constant" val="Arial" valType="str"/>
        <Param name="languageStyle" updates="None" val="LTR" valType="str"/>
        <Param name="letterHeight" updates="constant" val="0.05" valType="num"/>
        <Param name="name" updates="None" val="trackingTxt" valType="code"/>
        <Param name="opacity" updates="constant" val="" valType="num"/>
        <Param name="ori" updates="constant" val="0" valType="num"/>
        <Param name="pos" updates="constant" val="(0, 0)" valType="list"/>
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
        <Param name="startVal" updates="None" val="0.0" valType="code"/>
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
        <Param name="stopVal" updates="constant" val="" valType="code"/>
        <Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
        <Param name="text" updates="constant" val="Great! we are now tracking your eye movements! look around the screen to see how it works! &amp;#10;&amp;#10;Please remember is important for you to keep your head still during the experiment. &amp;#10;&amp;#10;Press space to start" valType="str"/>
        <Param name="units" updates="None" val="from exp settings" valType="str"/>
        <Param name="wrapWidth" updates="constant" val="" valType="num"/>
      </TextComponent>
      <KeyboardComponent name="tracking_resp">
        <Param name="allowedKeys" updates="constant" val="'space'" valType="list"/>
        <Param name="correctAns" updates="constant" val="" valType="str"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="discard previous" updates="constant" val="True" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="forceEndRoutine" updates="constant" val="True" valType="bool"/>
        <Param name="name" updates="None" val="tracking_resp" valType="code"/>
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="startEstim" updates="None" val="" valType="code"/>
        <Param name="startType" updates="None" val="time (s)" valType="str"/>
        <Param name="startVal" updates="None" val="0.0" valType="code"/>
        <Param name="stopType" updates="None" val="duration (s)" valType="str"/>
        <Param name="stopVal" updates="constant" val="" valType="code"/>
        <Param name="store" updates="constant" val="last key" valType="str"/>
        <Param name="storeCorrect" updates="constant" val="False" valType="bool"/>
        <Param name="syncScreenRefresh" updates="constant" val="True" valType="bool"/>
      </KeyboardComponent>
Thomas Pronk's avatar
_  
Thomas Pronk committed
402 403 404 405 406
      <CodeComponent name="tracking_code">
        <Param name="Before Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Before JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin JS Experiment" updates="constant" val="" valType="extendedCode"/>
407
        <Param name="Begin JS Routine" updates="constant" val="// Remove the click tracker used for calibration&amp;#10;window.webgazer.removeMouseEventListeners();&amp;#10;&amp;#10;//hide the video thumbnail &amp;#10;document.getElementById('webgazerFaceFeedbackBox').style.display = 'none';&amp;#10;document.getElementById('webgazerVideoFeed').style.display = 'none';" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
408 409 410
        <Param name="Begin Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="Code Type" updates="None" val="JS" valType="str"/>
        <Param name="Each Frame" updates="constant" val="" valType="extendedCode"/>
411
        <Param name="Each JS Frame" updates="constant" val="// Hide webcam thumbnail if eyes are in validation box&amp;#10;if (webgazer.checkEyesInValidationBox() === true) {&amp;#10;  // If last time that eyes were outside of validation box was longer than &amp;#10;  // window.eyesReturnedDelay ago, hide thumbnail&amp;#10;  if (&amp;#10;    document.getElementById('webgazerFaceFeedbackBox').style.display != 'none' &amp;&amp;&amp;#10;    (new Date).getTime() &gt; window.eyesExitedTimestamp + window.eyesReturnedDelay&amp;#10;  ) {   &amp;#10;    document.getElementById('webgazerFaceFeedbackBox').style.display = 'none';&amp;#10;    document.getElementById('webgazerVideoFeed').style.display = 'none';&amp;#10;  }&amp;#10;} else {&amp;#10;    // Eyes outside of validation box; show thumbnail&amp;#10;    window.eyesExitedTimestamp = (new Date).getTime();&amp;#10;    document.getElementById('webgazerFaceFeedbackBox').style.display = 'block';&amp;#10;    document.getElementById('webgazerVideoFeed').style.display = 'block';&amp;#10;}&amp;#10;// Update tracking square to the average of last n gazes&amp;#10;let x = util.sum(window.xGazes) / window.xGazes.length;&amp;#10;let y = util.sum(window.yGazes) / window.yGazes.length;&amp;#10;// Set tracking square to x and y, transformed to height units&amp;#10;tracking_square.setPos(&amp;#10;  util.to_height(&amp;#10;    [&amp;#10;      x - psychoJS.window.size[0] / 2,&amp;#10;      -1 * (y - psychoJS.window.size[1] / 2)&amp;#10;    ], &amp;#10;    'pix', &amp;#10;    psychoJS.window&amp;#10;  )&amp;#10;);" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
412 413 414 415 416 417 418 419
        <Param name="End Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="End JS Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="End Routine" updates="constant" val="" valType="extendedCode"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="name" updates="None" val="tracking_code" valType="code"/>
      </CodeComponent>
    </Routine>
Thomas Pronk's avatar
_  
Thomas Pronk committed
420 421
  </Routines>
  <Flow>
422 423 424
    <Routine name="initializeEyetracking"/>
    <Routine name="inst1"/>
    <Routine name="calibrationIntro"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
425 426
    <LoopInitiator loopType="TrialHandler" name="trials">
      <Param name="Selected rows" updates="None" val="" valType="str"/>
427
      <Param name="conditions" updates="None" val="[{'calibration_x': -0.44, 'calibration_y': -0.44}, {'calibration_x': -0.44, 'calibration_y': -0.22}, {'calibration_x': -0.44, 'calibration_y': 0}, {'calibration_x': -0.44, 'calibration_y': 0.22}, {'calibration_x': -0.44, 'calibration_y': 0.44}, {'calibration_x': -0.22, 'calibration_y': -0.44}, {'calibration_x': -0.22, 'calibration_y': -0.22}, {'calibration_x': -0.22, 'calibration_y': 0}, {'calibration_x': -0.22, 'calibration_y': 0.22}, {'calibration_x': -0.22, 'calibration_y': 0.44}, {'calibration_x': 0, 'calibration_y': -0.44}, {'calibration_x': 0, 'calibration_y': -0.22}, {'calibration_x': 0, 'calibration_y': 0}, {'calibration_x': 0, 'calibration_y': 0.22}, {'calibration_x': 0, 'calibration_y': 0.44}, {'calibration_x': 0.22, 'calibration_y': -0.44}, {'calibration_x': 0.22, 'calibration_y': -0.22}, {'calibration_x': 0.22, 'calibration_y': 0}, {'calibration_x': 0.22, 'calibration_y': 0.22}, {'calibration_x': 0.22, 'calibration_y': 0.44}, {'calibration_x': 0.44, 'calibration_y': -0.44}, {'calibration_x': 0.44, 'calibration_y': -0.22}, {'calibration_x': 0.44, 'calibration_y': 0}, {'calibration_x': 0.44, 'calibration_y': 0.22}, {'calibration_x': 0.44, 'calibration_y': 0.44}, {'calibration_x': -0.66, 'calibration_y': -0.44}, {'calibration_x': -0.66, 'calibration_y': -0.22}, {'calibration_x': -0.66, 'calibration_y': 0}, {'calibration_x': -0.66, 'calibration_y': 0.22}, {'calibration_x': 0.66, 'calibration_y': -0.44}, {'calibration_x': 0.66, 'calibration_y': -0.22}, {'calibration_x': 0.66, 'calibration_y': 0}, {'calibration_x': 0.66, 'calibration_y': 0.22}, {'calibration_x': 0.66, 'calibration_y': 0.44}]" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
428 429 430
      <Param name="conditionsFile" updates="None" val="calibration_trials.xlsx" valType="str"/>
      <Param name="endPoints" updates="None" val="[0, 1]" valType="num"/>
      <Param name="isTrials" updates="None" val="True" valType="bool"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
431
      <Param name="loopType" updates="None" val="random" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
432 433 434 435
      <Param name="nReps" updates="None" val="1" valType="code"/>
      <Param name="name" updates="None" val="trials" valType="code"/>
      <Param name="random seed" updates="None" val="" valType="code"/>
    </LoopInitiator>
436
    <Routine name="calibration"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
437
    <LoopTerminator name="trials"/>
438
    <Routine name="trackingTrial"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
439 440
  </Flow>
</PsychoPy2experiment>