From 9cec1551c3880a21d690e71114f2710f6c0b2abf Mon Sep 17 00:00:00 2001 From: Jon Roberts Date: Wed, 31 May 2017 14:10:22 -0600 Subject: [PATCH] nReps and sequential/random/fullRandom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add psychoJS support for nReps and sequential/random/fullRandom trial sequences. Add columns from conditions files to data output. Make loops marked as “isTrials” cause a data line to be written each iteration. Add an “eventName” column to the data file to identify whether a data line was caused by a keyboard event or a loop iteration. write out experiment data when quitPsychoJS() is called. This commit goes with the one with the same name in the psychopy project --- js/psychojs/data.js | 85 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 10 deletions(-) mode change 100644 => 100755 js/psychojs/data.js diff --git a/js/psychojs/data.js b/js/psychojs/data.js old mode 100644 new mode 100755 index f3b8850..b8de2ad --- a/js/psychojs/data.js +++ b/js/psychojs/data.js @@ -131,6 +131,64 @@ psychoJS.data.TrialHandler = function(attribs) { this.finished = false; this._experimentHandler = null; + this.sequenceIndices = psychoJS.data.makeIndices(this.trialList.length,this.nReps); + this.trialSequence = psychoJS.data.makeSequence(this.sequenceIndices, this.method); +} + +psychoJS.data.makeIndices = function(nt,nr){ +/* + make a 2 dimensional array nReps x trialList.length + of indices into the trialList array +*/ + var seq, temp, r, n + seq = []; + for (r=0;r 0) csv = csv + ', '; @@ -340,9 +405,9 @@ psychoJS.data.ExperimentHandler.prototype.save = function(attribs) { // (b) build the records: for (var r = 0; r < this._trialsData.length; r++) { for (var h = 0; h < header.length; h++) { - if (h > 0) - csv = csv + ', '; - csv = csv + this._trialsData[r][header[h]]; + if (h > 0) csv = csv + ', '; + // leave 'undefined' values blank in the data file + if (typeof(this._trialsData[r][header[h]]) != 'undefined') csv = csv + this._trialsData[r][header[h]]; } csv = csv + '\n'; }