demo_eye_tracking2.psyexp 28.7 KB
Newer Older
Thomas Pronk's avatar
_  
Thomas Pronk committed
1
<?xml version="1.0" ?>
2
<PsychoPy2experiment encoding="utf-8" version="2021.1.4">
Thomas Pronk's avatar
_  
Thomas Pronk committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  <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"/>
    <Param name="Experiment info" updates="None" val="{'participant':'', 'session':'001'}" valType="code"/>
    <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"/>
    <Param name="Resources" updates="None" val="[]" valType="fileList"/>
    <Param name="Save csv file" updates="None" val="False" valType="bool"/>
    <Param name="Save excel file" updates="None" val="False" valType="bool"/>
    <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"/>
    <Param name="Window size (pixels)" updates="None" val="(1024, 768)" valType="code"/>
    <Param name="blendMode" updates="None" val="avg" valType="str"/>
    <Param name="color" updates="None" val="$[0,0,0]" valType="str"/>
    <Param name="colorSpace" updates="None" val="rgb" valType="str"/>
    <Param name="expName" updates="None" val="demo_eye_tracking" valType="str"/>
    <Param name="exportHTML" updates="None" val="on Sync" valType="str"/>
    <Param name="logging level" updates="None" val="exp" valType="code"/>
  </Settings>
  <Routines>
Thomas Pronk's avatar
_  
Thomas Pronk committed
36
    <Routine name="loading_trial">
Thomas Pronk's avatar
_  
Thomas Pronk committed
37
      <CodeComponent name="configuration_code">
Thomas Pronk's avatar
_  
Thomas Pronk committed
38 39 40
        <Param name="Before Experiment" updates="constant" val="ale" valType="extendedCode"/>
        <Param name="Before JS Experiment" updates="constant" val="" valType="extendedCode"/>
        <Param name="Begin Experiment" updates="constant" val="" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
41
        <Param name="Begin JS Experiment" updates="constant" val="// Download the webgazer library and re-download seedrandom.js (since webgazer&amp;#10;// overrides it with a version that conflicts with PsychoJS)&amp;#10;psychoJS.downloadResources([&amp;#10;  { name: 'webgazer.js', path: 'js/webgazer-2.0.1.tp.js' },&amp;#10;  { name: 'seedrandom.js', path: 'https://cdnjs.cloudflare.com/ajax/libs/seedrandom/3.0.1/seedrandom.min.js' }&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;// Timestamp for last time eyes exited validation box&amp;#10;window.eyesExitedTimestamp= (new Date).getTime();&amp;#10;// No. of ms to keep webcam thumbnail visible after eyes returned into validation box&amp;#10;window.eyesReturnedDelay = 3000;&amp;#10;// DEBUG&amp;#10;window.psychoJS = psychoJS;" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
42 43 44 45
        <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="JS" valType="str"/>
        <Param name="Each Frame" updates="constant" val="" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
46
        <Param name="Each JS Frame" updates="constant" val="// Continue once the webgazer global is available&amp;#10;continueRoutine = !window.hasOwnProperty('webgazer');" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
47 48 49 50 51
        <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
52
        <Param name="name" updates="None" val="configuration_code" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
53
      </CodeComponent>
Thomas Pronk's avatar
_  
Thomas Pronk committed
54
      <TextComponent name="loading_text">
Thomas Pronk's avatar
_  
Thomas Pronk committed
55 56
        <Param name="color" updates="constant" val="white" valType="str"/>
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
57
        <Param name="contrast" updates="constant" val="1" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
58 59 60 61 62 63
        <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.1" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
64
        <Param name="name" updates="None" val="loading_text" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
        <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"/>
        <Param name="text" updates="constant" val="Downloading additional resources. &amp;#10;&amp;#10;One moment please..." valType="extendedStr"/>
        <Param name="units" updates="None" val="from exp settings" valType="str"/>
        <Param name="wrapWidth" updates="constant" val="" valType="code"/>
      </TextComponent>
    </Routine>
    <Routine name="webcam_trial">
Thomas Pronk's avatar
_  
Thomas Pronk committed
81 82 83
      <TextComponent name="intro_text">
        <Param name="color" updates="constant" val="white" valType="str"/>
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
84
        <Param name="contrast" updates="constant" val="1" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
        <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
102
        <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
103 104 105
        <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
106
      <CodeComponent name="start_webgazer">
Thomas Pronk's avatar
_  
Thomas Pronk committed
107 108 109 110
        <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"/>
111
        <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
112 113 114
        <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
115
        <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
116 117 118 119 120
        <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
121
        <Param name="name" updates="None" val="start_webgazer" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
122
      </CodeComponent>
Thomas Pronk's avatar
_  
Thomas Pronk committed
123 124
    </Routine>
    <Routine name="intro_calibatrion_trial">
Thomas Pronk's avatar
_  
Thomas Pronk committed
125
      <TextComponent name="calibration_text">
Thomas Pronk's avatar
_  
Thomas Pronk committed
126 127
        <Param name="color" updates="constant" val="white" valType="str"/>
        <Param name="colorSpace" updates="constant" val="rgb" valType="str"/>
128
        <Param name="contrast" updates="constant" val="1" valType="num"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
129 130 131 132 133
        <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"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
134
        <Param name="letterHeight" updates="constant" val="0.04" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
135
        <Param name="name" updates="None" val="calibration_text" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
136 137 138 139 140 141 142 143
        <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"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
144
        <Param name="stopVal" updates="constant" val="" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
145
        <Param name="syncScreenRefresh" updates="None" val="True" valType="bool"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
146
        <Param name="text" updates="constant" val="demo_eye_tracking: calibration&amp;#10;&amp;#10;Now we'll calibrate the eye tracker. Please try to keep your head still and within the rectangle you see in your webcam video. When you do so, the rectangle turns green.&amp;#10;&amp;#10;In the next part of this experiment, the webcam video disappears. It will reappear when your head is too from the rectangle. If this happens, please move back into view. White squares appears at different locations on the screen. Please click each square with your mouse.&amp;#10;&amp;#10;Click anywhere to continue..." valType="extendedStr"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
147 148 149
        <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
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
      <MouseComponent name="mouse_2">
        <Param name="clickable" updates="constant" val="" valType="code"/>
        <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"/>
        <Param name="name" updates="None" val="mouse_2" valType="code"/>
        <Param name="newClicksOnly" updates="constant" val="True" valType="bool"/>
        <Param name="saveMouseState" updates="None" val="final" valType="str"/>
        <Param name="saveParamsClickable" updates="constant" val="name," 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="False" valType="bool"/>
        <Param name="timeRelativeTo" updates="constant" val="mouse onset" valType="str"/>
      </MouseComponent>
    </Routine>
    <Routine name="calibration_trial">
      <PolygonComponent name="calibration_square">
171 172
        <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
173 174 175 176 177 178 179 180 181 182 183 184
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="fillColor" updates="constant" val="$[1,1,1]" valType="str"/>
        <Param name="fillColorSpace" updates="constant" val="rgb" valType="str"/>
        <Param name="interpolate" updates="constant" val="linear" valType="str"/>
        <Param name="lineColor" updates="constant" val="$[1,1,1]" valType="str"/>
        <Param name="lineColorSpace" updates="constant" val="rgb" valType="str"/>
        <Param name="lineWidth" updates="constant" val="0" valType="code"/>
        <Param name="nVertices" updates="constant" val="4" valType="int"/>
        <Param name="name" updates="None" val="calibration_square" valType="code"/>
        <Param name="opacity" updates="constant" val="1" valType="code"/>
        <Param name="ori" updates="constant" val="0" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
185
        <Param name="pos" updates="constant" val="(0, 0)" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
        <Param name="saveStartStop" updates="None" val="True" valType="bool"/>
        <Param name="shape" updates="constant" val="rectangle" valType="str"/>
        <Param name="size" updates="constant" val="(0.02, 0.02)" valType="code"/>
        <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"/>
      </PolygonComponent>
      <MouseComponent name="mouse_3">
        <Param name="clickable" updates="constant" val="calibration_square" valType="code"/>
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="forceEndRoutineOnPress" updates="constant" val="valid click" valType="str"/>
        <Param name="name" updates="None" val="mouse_3" valType="code"/>
        <Param name="newClicksOnly" updates="constant" val="True" valType="bool"/>
        <Param name="saveMouseState" updates="None" val="final" valType="str"/>
        <Param name="saveParamsClickable" updates="constant" val="name," 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="False" valType="bool"/>
        <Param name="timeRelativeTo" updates="constant" val="mouse onset" valType="str"/>
      </MouseComponent>
Thomas Pronk's avatar
_  
Thomas Pronk committed
215
      <CodeComponent name="calibration_code">
Thomas Pronk's avatar
_  
Thomas Pronk committed
216 217 218 219
        <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
220
        <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);" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
221 222 223
        <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
224
        <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;" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
225 226 227 228 229
        <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
230
        <Param name="name" updates="None" val="calibration_code" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
231
      </CodeComponent>
Thomas Pronk's avatar
_  
Thomas Pronk committed
232
    </Routine>
Thomas Pronk's avatar
_  
Thomas Pronk committed
233 234
    <Routine name="tracking_trial">
      <PolygonComponent name="tracking_square">
235 236
        <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
237 238 239 240 241 242 243
        <Param name="disabled" updates="None" val="False" valType="bool"/>
        <Param name="durationEstim" updates="None" val="" valType="code"/>
        <Param name="fillColor" updates="constant" val="$[-1,-1,-1]" valType="str"/>
        <Param name="fillColorSpace" updates="constant" val="rgb" valType="str"/>
        <Param name="interpolate" updates="constant" val="linear" valType="str"/>
        <Param name="lineColor" updates="constant" val="$[1,1,1]" valType="str"/>
        <Param name="lineColorSpace" updates="constant" val="rgb" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
244
        <Param name="lineWidth" updates="constant" val="" valType="code"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
        <Param name="nVertices" updates="constant" val="4" valType="int"/>
        <Param name="name" updates="None" val="tracking_square" 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="shape" updates="constant" val="rectangle" valType="str"/>
        <Param name="size" updates="constant" val="(0.02, 0.02)" valType="code"/>
        <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"/>
      </PolygonComponent>
      <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"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
266
        <Param name="Begin JS Routine" updates="constant" val="// Remove the click tracker used for calibration&amp;#10;window.webgazer.removeMouseEventListeners();" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
267 268 269
        <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
270
        <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;);&amp;#10;" valType="extendedCode"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
271 272 273 274 275 276 277 278
        <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
279 280
  </Routines>
  <Flow>
Thomas Pronk's avatar
_  
Thomas Pronk committed
281
    <Routine name="loading_trial"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
282 283
    <Routine name="webcam_trial"/>
    <Routine name="intro_calibatrion_trial"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
284 285 286 287 288 289
    <LoopInitiator loopType="TrialHandler" name="trials">
      <Param name="Selected rows" updates="None" val="" valType="str"/>
      <Param name="conditions" updates="None" val="[OrderedDict([('calibration_x', -0.44), ('calibration_y', -0.44)]), OrderedDict([('calibration_x', -0.44), ('calibration_y', -0.22)]), OrderedDict([('calibration_x', -0.44), ('calibration_y', 0.0)]), OrderedDict([('calibration_x', -0.44), ('calibration_y', 0.22)]), OrderedDict([('calibration_x', -0.44), ('calibration_y', 0.44)]), OrderedDict([('calibration_x', -0.22), ('calibration_y', -0.44)]), OrderedDict([('calibration_x', -0.22), ('calibration_y', -0.22)]), OrderedDict([('calibration_x', -0.22), ('calibration_y', 0.0)]), OrderedDict([('calibration_x', -0.22), ('calibration_y', 0.22)]), OrderedDict([('calibration_x', -0.22), ('calibration_y', 0.44)]), OrderedDict([('calibration_x', 0.0), ('calibration_y', -0.44)]), OrderedDict([('calibration_x', 0.0), ('calibration_y', -0.22)]), OrderedDict([('calibration_x', 0.0), ('calibration_y', 0.0)]), OrderedDict([('calibration_x', 0.0), ('calibration_y', 0.22)]), OrderedDict([('calibration_x', 0.0), ('calibration_y', 0.44)]), OrderedDict([('calibration_x', 0.22), ('calibration_y', -0.44)]), OrderedDict([('calibration_x', 0.22), ('calibration_y', -0.22)]), OrderedDict([('calibration_x', 0.22), ('calibration_y', 0.0)]), OrderedDict([('calibration_x', 0.22), ('calibration_y', 0.22)]), OrderedDict([('calibration_x', 0.22), ('calibration_y', 0.44)]), OrderedDict([('calibration_x', 0.44), ('calibration_y', -0.44)]), OrderedDict([('calibration_x', 0.44), ('calibration_y', -0.22)]), OrderedDict([('calibration_x', 0.44), ('calibration_y', 0.0)]), OrderedDict([('calibration_x', 0.44), ('calibration_y', 0.22)]), OrderedDict([('calibration_x', 0.44), ('calibration_y', 0.44)])]" valType="str"/>
      <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
290
      <Param name="loopType" updates="None" val="random" valType="str"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
291 292 293 294 295 296
      <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>
    <Routine name="calibration_trial"/>
    <LoopTerminator name="trials"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
297
    <Routine name="tracking_trial"/>
Thomas Pronk's avatar
_  
Thomas Pronk committed
298 299
  </Flow>
</PsychoPy2experiment>