Skip to content

Save eye tracking and video data periodically in multiple files #3222

Answered by derekalbert
derekalbert asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks Shaobin,

The solution I ended up with was to include this timeline item at the end of each block:

    timeline.push({
        type: jsPsychCallFunction,
        func: function () {
            var dataToSave = jsPsych.data.get().csv();
            saveData(dataToSave, SONAID, task, blockType, currentBlockNumber);
            jsPsych.data.reset();
        }
    });

function saveData(data, sona, task, type, block) {
    var xhr = new XMLHttpRequest();
    xhr.open('POST', 'php/write_data.php'); // 'write_data.php' is the path to the php file described above.
    xhr.setRequestHeader('Content-Type', 'application/json');
    xhr.send(JSON.stringify({ filedata: data, sona: sona, task: …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@derekalbert
Comment options

Answer selected by derekalbert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants