Reply To: inserting getEyetracker start and stop into the code

PennController for IBEX Forums Support inserting getEyetracker start and stop into the code Reply To: inserting getEyetracker start and stop into the code

#10360
multanip
Participant

THis is an eyetracking script and study.
I went back and added and moved the eyetracker start in different part of the script and all the items run with audio but no logging in server. Below is the newer script.

Template( "eng_01_geo_List_tense_old.csv", row=>  // all newText commands will automatically print the text centered when run
    newTrial("eyetracking",
        defaultImage.center().print(),    // all newImage commands will automatically print the image centered when run
        defaultImage.size(1280,720).print()//,
        .print("center at 50vw", "center at 50vh")
        //defaultText.center().print()
    ,
    newEyeTracker("tracker",1).callback( function (x,y) {
        if (this != getEyeTracker("tracker")._element.elements[0]) return; // The callback commands lets us log the X and Y coordinates of the estimated gaze-locations at each recorded moment in time
        getEyeTracker("tracker")._element.counts._Xs.push(x);
        getEyeTracker("tracker")._element.counts._Ys.push(y);
        })
    ,
    newFunction(()=>{
        getEyeTracker("tracker")._element.counts._Xs = [];
        getEyeTracker("tracker")._element.counts._Ys = [];
    }).call()
    ,
        getEyeTracker("tracker")
            .calibrate(5)  // Make sure that the tracker is still calibrated
            .log() // log the calibration test.index
        //,
        //getEyeTracker("tracker")
           // .log()  // If this line is missing, the eye-tracking data won't be sent to the server
            //.start()
       ,
    newTimer("pre-trial0", 500).start().wait()
    ,
    newImage("image0", row.Static_image1),// we always use middleImage.png as the middle image
    newTimer("displayTime0", 2000).start().wait(), //.start(),//.wait() //wait 400ms befoere moving to the iamge
    //getTimer("last-image"),
    getImage("image0").remove()
    .log()
    ,
    newTimer("pre-trial1", 500).start().wait()
    ,
    newImage("image1", row.action_image), // the first image is set in design.csv
    newTimer("displayTime1", 2500).start().wait(), //.start().wait() // wait 400ms before moving on to the next image
    //getTimer("mid-image"),
    getImage("image1").remove()
    .log()
    ,
    newTimer("pre-trial2", 500).start().wait()
    ,
    newImage("image2", row.Static_image2),
// we always use middleImage.png as the middle image
    newAudio("audio", row.wav_file).play(), // the audio file is set in design.csv
    getAudio("audio").wait("first"), // wait until the Audio element has finished playing back
    //getImage("image2").remove(), //getText("AudioSpace").remove(),
    //newKey("stop", "FJ").callback(getTimer("last-image").stop()),
    newTimer("displayTime2", 400).start().wait(), //.start(),//.wait() //wait 400ms befoere moving to the last iamge
    //getTimer("last-image"),
    getImage("image2").remove()
    .log()
    ,
    newTimer("pre-trial3", 500).start().wait()//remain for 1000 ms on screen
    ,
    newImage("image3", row.action_image2), // the third image is set in design.csv
    newTimer("displayTime3", 2500).start().wait(),
    getImage("image3").remove()
    .log()
    ,
    getEyeTracker("tracker")
        .add(   
            getImage("image0"),
            getImage("image1"),
            getImage("image2"),
            getImage("image3")
        )
        .log()  // If this line is missing, the eye-tracking data won't be sent to the server
        .start(),
    // Stop now to prevent collecting unnecessary data
    getEyeTracker("tracker")
        .stop()
    )
.noHeader()
  .log("Subject"              , getVar("Subject")  )
  .log("Static_image1"          ,row.Static_image1)
  .log("action1_image"          ,row.action_image)
  .log("ID_No"                  ,row.random)
  .log("Static_image2"          ,row.Static_image2)
  .log("wav_file"               ,row.wav_file)
  .log("action_image2"          ,row.action_image2)
  .log("ViewportWidth" 	    	,window.innerWidth	 		) // Screensize: width
  .log("ViewportHeight"	    	,window.innerHeight 		) // Screensize: heigth
)

SendResults("Send")