From 6f17b2fe15c9484ed723265d8305e51cd9107f45 Mon Sep 17 00:00:00 2001 From: Rashi1997 Date: Thu, 11 Feb 2021 09:12:22 -0500 Subject: [PATCH 1/8] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20rm=20unnecess=20?= =?UTF-8?q?params,=20add=20defaults?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes img/.DS_Store | Bin 0 -> 6148 bytes img/blue.png | Bin 0 -> 5218 bytes tests/countdown.spec.js | 3 +-- tests/fixation.spec.js | 26 ++++---------------------- tests/showImage.spec.js | 29 +++++++++++++++++++++++++++++ tests/showMessage.spec.js | 7 ++++--- trials/countdown.js | 13 ++++++------- trials/fixation.js | 22 +++++++++------------- trials/showImage.js | 38 ++++++++++++++++++-------------------- trials/showMessage.js | 28 +++++++++++++++------------- trials/userId.js | 18 ++++++++---------- 12 files changed, 94 insertions(+), 90 deletions(-) create mode 100644 .DS_Store create mode 100644 img/.DS_Store create mode 100644 img/blue.png create mode 100644 tests/showImage.spec.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2138139aefc9210190b621d1abeead0b5a7fd809 GIT binary patch literal 6148 zcmeHKyKdVs6g`Zc)OjFq(WM;<=m#1gojWLjGIZ#YEZrKv>L!sa!;S-FDYW+wI`kL% z5B;3}M0@TfZIF_hF$fA?gFF;@4|VSmC7J-t>1uoo^a1o(1iO2zT1>{JG;GWDydWB# zV}vD^@AGmr%p2aZBPtLTcxnpByZa0S%=tTl_x_ecj>u=>gyrau8e725#`}8xu5WyQ z)_i-MvBVuFSdcZv#C{vr{^ncFzmJUmBdk!6Gs7)ex42^8jL{VshkT9ghZkFiz6GW= zuS;O-Rnse<9$$>gV$K-W=J-XKWy4&f?0tWie?0&FOH|m5jvpAEe`(Bmh-+rEWG14p zbvij;}wL{MZRU0syy066V`|jeNehXcdF845FjofFfSJ+cR?%86!eT%V< z3Pc5>0viS7`;f2*rVcBM`srY$M*w1%-D+&hp9bM14pWDfMUK#nr4lXGxFd$KboM9C zFLhX1v~(DE_%QCy#+^`%-ktL&>JF1yjCE8XDiA8rv6p?>|Ihw?{trpij@tKr|MiN$-m9%AdjPLx|uY(a@k-X>acK zcJ6djc)b8@eR#YDdH@~W5pO;$&G+3Gc2N-{(s{-WUh#tG`)U8M$UYx%Zif*Q4tV;? zAE*7uz5e~1oj*oVDIf);fE17dQs9>gcfE17dp9=W*q0t?O!Z|TM9UP(s zAg&k=<2-r^V)FoTD4Y`+p;=OiNwsP*Ea{B5${Pyj#H7RGW}Z_wTXiTFw=>=%9X2Ft zlmb%VRDsJ}_Fn(*=s)!TrzEYUfE4&w3fOA1-K_bfs;!I1d97{q9o=(|bT`g}!Xe5r kG0HI)UXHILDf61oxjz)ni9u&P=tTVtxGpj&@Yf1_0E)RJ(EtDd literal 0 HcmV?d00001 diff --git a/img/blue.png b/img/blue.png new file mode 100644 index 0000000000000000000000000000000000000000..820bdce8f886436d9d1f8cc06595e1b55c08ae19 GIT binary patch literal 5218 zcmbVwhf~vA(DpC%aw&pDZv>?ykl+QS7wNr|gb<212to)|5Tr@O1f@xjf*^v@LV!>L zNKuH=6)_M(ks^X9h$vkUdAaX=^ZfzunK^T2_w3H>K4;F(vzzQ_Zy~@3;R66bz{=9p z82~`g|27ZTu_ikH{*B|~?+7zggiFY^h$zf;U%<#G#M@WWDhT7}>+Fm1i4Gg^)dPT& z99E`A@S9WLij4flSdcyi>ByXZPE9n?tD7&6WIt_&&Wvev^k^MfF>d?G#aEYV9Pxew zOp+ZVP7rw`KHf22C~qApAo9N_YMNEL!OKx6Df2M@Pv$)GkJ<)wkDmK6aLSOJSifQI z&4cbGd4qkC<>B4UqoQBKwkJWyG5#MGzHTd&XC8s_@Sq%i%JAMKLpLuMU#wfq7o}EI zbUP838b~HUklNs4jun=5xh&#f_LKjuk6#%HoAd8GqG8b0qlBSeugw+r{TFpnMYle0 z`e+2r$u(-r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I~zwYG$J4Xr?Eh zo5}{)B}=)Ug`S9^TOS0YP4IawiCLdS*Nk|F>_3&)l+;E5T|-Va6UZO&)qu>|Lo&>6OU1cBRv~R4BLY6@!*ozr03~ zdF@IKxC~ir?nq^pe@L)XU}cc|sUYyKw1Db5#vKn47SP6&#R}ZW-+7Zf6PU?Gtpo?! zrTuDfrJkfWFm!rjz+H1qHSQApOY2SY)OY@dQFe>7ZjO*gjS4gYae5z^U2ozp9G;dcG!N)5C& zK^m=%?1cNnVMVJ_LrOO>Zi3%t-Rv^K1gLV+Cnq51TUjvgH2PIabbI8-jhVfnoYBIM z!nu@V=Bnbx8D&Ooq6g%R$II04F%t1Ua#lgGJCs3&Nb{ROzosqF=viaK2FUqTigg}! zDjOL%ZITTpNLD|yP1t>`c5B{}KU0iuj0XDoFgKjg9{L=`K8S+q+dQjsjAQbgZ=ITa zGnChk+Va*d4~^tmb;Ejg#IJ{?2kFgcQ@%w$GGF|e6Ra};u}>ZEzY{Ise~zSYq;=l$ zybkw;_#>-k%}~Hiin5$+6DwpP2m4;ZX;u>MuslynkAGUSF7Qn5n{6seGo<3Bp0?-n z&|fOt9M?^vhL{59pN=0=PUVX}WX(}HUX87;qm+0Ha-?)L>EG^Vj80p0zSD6)B zU8|mAyh_yT;DJ$asdfn+Rao~fE(=b~5)9^PCa!^9J&)xlWs!T|v^<4UWT1YGk{}bG*)Pd{Iqt(*E>KIPAV;*#HUfaE=ObE8#HfZzxK{)Rf { type: "html_keyboard_response", stimulus: "

Countdown10

" }, { prompt: "

9

" }, @@ -19,13 +18,13 @@ describe("Countdown trial", () => { { prompt: "

2

" }, { prompt: "

1

" }, ], + response_ends_trial: false, }; expect( countdown({ duration: 1000, text: "Countdown", time: 10, - responseEndsTrial: false, }) ).toEqual(returnobject); }); diff --git a/tests/fixation.spec.js b/tests/fixation.spec.js index a652488..d78d937 100644 --- a/tests/fixation.spec.js +++ b/tests/fixation.spec.js @@ -5,13 +5,14 @@ const jsPsych = require("jspsych-react"); describe("Fixation trial", () => { it("fixation without photodiode box", () => { const config = init({ USE_PHOTODIODE: false }); + let data = { code: null }; const result = fixation(config, { duration: 100, }); expect(result.stimulus).toContain("fixation-dot"); expect(result.stimulus).not.toContain("photodiode-spot"); - expect(result.on_load()).toEqual(null); - expect(result.on_finish()).toEqual(null); + expect(result.on_load()).toEqual(undefined); + expect(result.on_finish(data)).toEqual(1); }); it("fixation with photodiode box and task code", () => { @@ -24,26 +25,7 @@ describe("Fixation trial", () => { }); expect(result.stimulus).toContain("fixation-dot"); expect(result.stimulus).toContain("photodiode-spot"); - expect(result.on_load()).not.toEqual(null); + expect(result.on_load()).toEqual(undefined); expect(result.on_finish(data)).toEqual(10); }); - - it("fixation with jsPsych.NO_KEYS", () => { - const config = init({ USE_PHOTODIODE: false }); - const result = fixation(config, { - duration: 100, - buttons: jsPsych.NO_KEYS, - }); - expect(result.choices).toEqual(undefined); - }); - - it("fixation with choices", () => { - const config = init({ USE_PHOTODIODE: false }); - const choices = ["p", "q"]; - const result = fixation(config, { - duration: 100, - buttons: choices, - }); - expect(result.choices).toEqual(choices); - }); }); diff --git a/tests/showImage.spec.js b/tests/showImage.spec.js new file mode 100644 index 0000000..22fbd5e --- /dev/null +++ b/tests/showImage.spec.js @@ -0,0 +1,29 @@ +const showImage = require("../trials/showImage.js"); +const { init } = require("../app.js"); + +describe("showImage trial", () => { + it("showImage without photodiode box", () => { + const config = init({ USE_PHOTODIODE: false }); + let data = { code: null }; + const result = showImage(config, { + duration: 100, + }); + expect(result.prompt).not.toContain("photodiode-spot"); + expect(result.on_load()).toEqual(undefined); + result.on_finish(data) + expect(data.code).toEqual(1); + }); + + it("showImage with photodiode box and task code", () => { + const config = init({ USE_PHOTODIODE: true }); + let data = { code: null }; + const result = showImage(config, { + duration: 100, + taskCode: 10, + }); + expect(result.prompt).toContain("photodiode-spot"); + expect(result.on_load()).toEqual(undefined); + result.on_finish(data) + expect(data.code).toEqual(10); + }); +}); diff --git a/tests/showMessage.spec.js b/tests/showMessage.spec.js index 17b78fa..ec776b2 100644 --- a/tests/showMessage.spec.js +++ b/tests/showMessage.spec.js @@ -5,6 +5,7 @@ const jsPsych = require("jspsych-react"); describe("showMessage trial", () => { it("showMessage without photodiode box", () => { const config = init({ USE_PHOTODIODE: false }); + let data = { code: null }; const message = "Experiment Start"; const result = showMessage(config, { responseType: "html_keyboard_response", @@ -13,8 +14,8 @@ describe("showMessage trial", () => { }); expect(result.stimulus).toContain(message); expect(result.stimulus).not.toContain("photodiode-spot"); - expect(result.on_load()).toEqual(null); - expect(result.on_finish()).toEqual(null); + expect(result.on_load()).toEqual(undefined); + expect(result.on_finish(data)).toEqual(1); }); it("showMessage with photodiode box and task code", () => { @@ -30,7 +31,7 @@ describe("showMessage trial", () => { }); expect(result.stimulus).toContain(message); expect(result.stimulus).toContain("photodiode-spot"); - expect(result.on_load()).not.toEqual(null); + expect(result.on_load()).toEqual(undefined); expect(result.on_finish(data)).toEqual(10); }); diff --git a/trials/countdown.js b/trials/countdown.js index b4c8d64..24070a3 100644 --- a/trials/countdown.js +++ b/trials/countdown.js @@ -6,19 +6,18 @@ const _ = require("lodash"); * * @module * @param {Object} options - * @param {number} options.duration - The trial duration. - * @param {string} options.text - Optional text for the countdown. (default: "") - * @param {number} options.time - The number of seconds for the countdown. (default: 10s) - * @param {boolean} options.responseEndsTrial - True if the trial ends on response, false if the trial waits for the duration. (default: false) + * @param {number} options.duration - trial duration in milliseconds. (default: 1000) + * @param {string} options.text - (optional) text for the countdown. (default: "") + * @param {number} options.time - start number for the countdown. (default: 10) */ module.exports = function (options) { const defaults = { + duration: 1000, text: "", time: 10, - responseEndsTrial: false, }; - const { duration, text, time, responseEndsTrial } = { defaults, ...options }; + const { duration, text, time } = { defaults, ...options }; const times = _.range(time, 0, -1); const timeline = times.map((val) => { return { prompt: `

${val}

` }; @@ -28,7 +27,7 @@ module.exports = function (options) { type: "html_keyboard_response", stimulus: `

${text} - taskCode != null ? pdSpotEncode(taskCode, numBlinks, config) : null, - on_finish: (data) => (taskCode != null ? (data.code = taskCode) : null), + on_load: () => pdSpotEncode(taskCode, numBlinks, config), + on_finish: (data) => (data.code = taskCode), }; }; diff --git a/trials/showImage.js b/trials/showImage.js index 15d9859..6ac3f5d 100644 --- a/trials/showImage.js +++ b/trials/showImage.js @@ -7,7 +7,7 @@ const { jitter50 } = require("../lib/utils"); /** * @description - * Builds a trial with a onscreen message, optional buttons and optional photodiode box + * Builds a trial with a onscreen message and optional photodiode box * * @module * @param {Object} config - The configuration object for USE_PHOTODIODE, USE_EEG, USE_ELECTRON and USE_MTURK flags. @@ -16,49 +16,47 @@ const { jitter50 } = require("../lib/utils"); * @param {boolean} config.USE_ELECTRON - USE_ELECTRON flag * @param {boolean} config.USE_MTURK - USE_MTURK flag * @param {Object} options - * @param {string} options.responseType - This tells jsPsych which plugin file to use to run the trial. - * @param {number} options.duration - The trial duration in milliseconds. - * @param {string} options.image - The path of the image file to be displayed. - * @param {number} options.imageHeight - Set the height of the image in pixels. If left null (no value specified), then the image will display at its natural height. - * @param {number} options.imageWidth - Set the width of the image in pixels. If left null (no value specified), then the image will display at its natural width. - * @param {boolean} options.responseEndsTrial - True if the trial ends on response,false if the trial waits for the duration, by default false value. - * @param {number} options.taskCode - Task code to be saved into data log and for pdSpotEncode, which by default is null and is passed when config has USE_PHOTODIODE set true. - * @param {number} options.numBlinks - Number of times the pulse needs to be repeated for photodiode box, when USE_PHOTODIODE is set true. If not set, by default is 1. + * @param {number} options.duration - trial duration in milliseconds. (default: 1000) + * @param {string} options.image - The path of the image file to be displayed. (default: a blue dot image) + * @param {number} options.imageHeight - Set the height of the image in pixels. If left null (no value specified), then the image will display at its natural height. (default: 600) + * @param {number} options.imageWidth - Set the width of the image in pixels. If left null (no value specified), then the image will display at its natural width. (default: 600) + * @param {number} options.taskCode - Task code to be saved into data log (default: 1) + * @param {number} options.numBlinks - Number of times the pulse needs to be repeated for photodiode box, when USE_PHOTODIODE is set true. (default: 1) */ module.exports = function (config, options) { const defaults = { - responseEndsTrial: false, - taskCode: null, + duration: 1000, + image: "../img/blue.png", + imageHeight: 600, + imageWidth: 600, + taskCode: 1, numBlinks: 1, }; const { - responseType, duration, image, imageHeight, imageWidth, - responseEndsTrial, taskCode, numBlinks, } = { ...defaults, ...options }; return { - type: responseType, + type: "image_keyboard_response", stimulus: image, - prompt: config.USE_PHOTODIODE ? photodiodeGhostBox() : null, - response_ends_trial: responseEndsTrial, + prompt: config.USE_PHOTODIODE ? photodiodeGhostBox() : "", + response_ends_trial: false, trial_duration: jitter50(duration), on_load: () => { $("#jspsych-image-keyboard-response-stimulus").addClass("image"); $("#jspsych-image-keyboard-response-stimulus").height(imageHeight); $("#jspsych-image-keyboard-response-stimulus").width(imageWidth); - $("html").css("cursor", "none")(taskCode != null) - ? pdSpotEncode(taskCode, numBlinks, config) - : null; + $("html").css("cursor", "none"); + pdSpotEncode(taskCode, numBlinks, config); }, on_finish: (data) => { - data.code = code; + data.code = taskCode; $("html").css("cursor", "auto"); }, }; diff --git a/trials/showMessage.js b/trials/showMessage.js index e168fda..9bf5bcc 100644 --- a/trials/showMessage.js +++ b/trials/showMessage.js @@ -15,25 +15,28 @@ const { baseStimulus } = require("../lib/markup/stimuli"); * @param {boolean} config.USE_ELECTRON - USE_ELECTRON flag * @param {boolean} config.USE_MTURK - USE_MTURK flag * @param {Object} options - * @param {string} options.responseType - This tells jsPsych which plugin file to use to run the trial. - * @param {number} options.duration - The trial duration in milliseconds. - * @param {string} options.stimulus - Onscreen stimulus in HTML to be shown in the trial, if not set default text is empty. If the stimulus is not provided, message should be provided as a string. - * @param {string} options.message - Onscreen message to be shown in the trial, if not set default text is empty. + * @param {string} options.responseType - This tells jsPsych which plugin file to use to run the trial. (default: 'html_keyboard_response') + * @param {number} options.duration - trial duration in milliseconds. (default: 1000) + * @param {string} options.stimulus - Onscreen stimulus in HTML to be shown in the trial, if not set default text is empty. If the stimulus is not provided, message should be provided as a string. (default: "") + * @param {string} options.message - Onscreen message to be shown in the trial. (default: "") * @param {boolean} options.onstart - True if the message is to be display on start of the trial. False if the message needs to be in the stimulus.(default: false) - * @param {boolean} options.responseEndsTrial - True if the trial ends on response,false if the trial waits for the duration, by default false value. - * @param {number} options.taskCode - Task code to be saved into data log and for pdSpotEncode, which by default is null and is passed when config has USE_PHOTODIODE set true. - * @param {number} options.numBlinks - Number of times the pulse needs to be repeated for photodiode box, when USE_PHOTODIODE is set true. If not set, by default is 1. - * @param {Array} options.buttons - This array contains the keys that the subject is allowed to press in order to respond to the stimulus. Keys can be specified as their numeric key code or as characters (e.g., 'a', 'q'). The default value of jsPsych.ALL_KEYS means that all keys will be accepted as valid responses. Specifying jsPsych.NO_KEYS will mean that no responses are allowed. + * @param {boolean} options.responseEndsTrial - True if the trial ends on response,false if the trial waits for the duration. (default: false) + * @param {number} options.taskCode - Task code to be saved into data log (default: 1) + * @param {number} options.numBlinks - Number of times the pulse needs to be repeated for photodiode box, when USE_PHOTODIODE is set true. (default: 1) + * @param {Array} options.buttons - This array contains the keys that the subject is allowed to press in order to respond to the stimulus. Keys can be specified as their numeric key code or as characters (e.g., 'a', 'q'). The default value of jsPsych.ALL_KEYS means that all keys will be accepted as valid responses. Specifying jsPsych.NO_KEYS will mean that no responses are allowed. (default: ["OK"]) */ module.exports = function (config, options) { const defaults = { - message: "", + responseType: "html_keyboard_response", + duration: 1000, stimulus: "", + message: "", onstart: false, responseEndsTrial: false, - taskCode: null, + taskCode: 1, numBlinks: 1, + buttons: ["OK"], }; const { responseType, @@ -64,8 +67,7 @@ module.exports = function (config, options) { on_start: (trial) => { onstart ? (trial.stimulus = stimulusOrMessage) : ""; }, - on_load: () => - taskCode != null ? pdSpotEncode(taskCode, numBlinks, config) : null, - on_finish: (data) => (taskCode != null ? (data.code = taskCode) : null), + on_load: () => pdSpotEncode(taskCode, numBlinks, config), + on_finish: (data) => (data.code = taskCode), }; }; diff --git a/trials/userId.js b/trials/userId.js index b3324db..cd79339 100644 --- a/trials/userId.js +++ b/trials/userId.js @@ -12,25 +12,23 @@ const { baseStimulus } = require("../lib/markup/stimuli"); * @param {boolean} config.USE_ELECTRON - USE_ELECTRON flag * @param {boolean} config.USE_MTURK - USE_MTURK flag * @param {Object} options - * @param {number} options.duration - The trial duration in milliseconds. - * @param {string} options.stimulus - Onscreen stimulus in HTML to be shown in the trial, if not set default text is empty. If the stimulus is not provided, message should be provided as a string. - * @param {string} options.setIdMessage - Onscreen text for setting user id or for the input box to enter patient id. - * @param {boolean} options.responseEndsTrial - True if the trial ends on response,false if the trial waits for the duration, by default false value. - * @param {boolean} options.defaultPatientId - The patient id to show when requesting a patient ID, if not set default is empty. + * @param {number} options.duration - trial duration in milliseconds. (default: 1000) + * @param {string} options.stimulus - Onscreen stimulus in HTML to be shown in the trial, if not set default text is empty. If the stimulus is not provided, message should be provided as a string. (default: "") + * @param {string} options.setIdMessage - Onscreen text for setting user id or for the input box to enter patient id. (default: "") + * @param {string} options.defaultPatientId - The patient id to show when requesting a patient ID. (default: "") */ module.exports = function (jsPsych, config, options) { const defaults = { - setIdMessage: "", + duration: 1000, stimulus: "", - responseEndsTrial: false, + setIdMessage: "", defaultPatientId: "", }; const { duration, stimulus, setIdMessage, - responseEndsTrial, defaultPatientId, } = { ...defaults, ...options }; @@ -43,9 +41,9 @@ module.exports = function (jsPsych, config, options) { return { type: "html_keyboard_response", stimulus: stimulusOrMessage, - response_ends_trial: responseEndsTrial, + response_ends_trial: false, trial_duration: duration, - on_finish: (data) => { + on_finish: () => { const turkInfo = jsPsych.turk.turkInfo(); const uniqueId = `${turkInfo.workerId}:${turkInfo.assignmentId}`; console.log(uniqueId); From a6251d73c8ed3fc0242c47947dbcf3cee910ef4e Mon Sep 17 00:00:00 2001 From: Rashi1997 Date: Thu, 11 Feb 2021 10:28:33 -0500 Subject: [PATCH 2/8] =?UTF-8?q?fix:=20=F0=9F=90=9B=20PR=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils.js | 6 +++--- trials/countdown.js | 6 +++--- trials/fixation.js | 10 ++++++---- trials/showImage.js | 19 ++++++++++--------- trials/userId.js | 8 ++++---- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 475d6a5..79b6d5d 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -3,10 +3,10 @@ const jitter = (base, offset) => ( base + Math.floor(Math.random() * Math.floor(offset)) ) -// add a random number between 0 and 50 to the base number -const jitter50 = (base) => jitter(base, 50) +// add a random number between 0 and x to the base number +const jitterx = (base, x) => jitter(base, x) module.exports ={ jitter, - jitter50 + jitterx } diff --git a/trials/countdown.js b/trials/countdown.js index 24070a3..20623fe 100644 --- a/trials/countdown.js +++ b/trials/countdown.js @@ -8,16 +8,16 @@ const _ = require("lodash"); * @param {Object} options * @param {number} options.duration - trial duration in milliseconds. (default: 1000) * @param {string} options.text - (optional) text for the countdown. (default: "") - * @param {number} options.time - start number for the countdown. (default: 10) + * @param {number} options.time - start number for the countdown. (default: 3) */ module.exports = function (options) { const defaults = { duration: 1000, text: "", - time: 10, + time: 3, }; - const { duration, text, time } = { defaults, ...options }; + const { duration, text, time } = { ...defaults, ...options }; const times = _.range(time, 0, -1); const timeline = times.map((val) => { return { prompt: `

${val}

` }; diff --git a/trials/fixation.js b/trials/fixation.js index b0ec79f..e32f02c 100644 --- a/trials/fixation.js +++ b/trials/fixation.js @@ -2,7 +2,7 @@ const { pdSpotEncode, photodiodeGhostBox, } = require("../lib/markup/photodiode"); -const { jitter50 } = require("../lib/utils"); +const { jitterx } = require("../lib/utils"); /** * @description @@ -15,7 +15,8 @@ const { jitter50 } = require("../lib/utils"); * @param {boolean} config.USE_ELECTRON - USE_ELECTRON flag * @param {boolean} config.USE_MTURK - USE_MTURK flag * @param {Object} options - * @param {number} options.duration - trial duration in milliseconds. (default: 1000) + * @param {number} options.duration - trial duration in milliseconds jittered with the jitter param. (default: 1000) + * @param {number} options.jitter - jitter range (0-jitter) to add from to the trial duration (default: 50) * @param {number} options.taskCode - Task code to be saved into data log (default: 1) * @param {number} options.numBlinks - Number of times the pulse needs to be repeated for photodiode box, when USE_PHOTODIODE is set true. (default: 1) */ @@ -23,10 +24,11 @@ const { jitter50 } = require("../lib/utils"); module.exports = function (config, options) { const defaults = { duration: 1000, + jitter: 50, taskCode: 1, numBlinks: 1, }; - const { duration, taskCode, numBlinks } = { + const { duration, jitter, taskCode, numBlinks } = { ...defaults, ...options, }; @@ -39,7 +41,7 @@ module.exports = function (config, options) { type: "html_keyboard_response", stimulus: stimulus, response_ends_trial: false, - trial_duration: jitter50(duration), + trial_duration: jitterx(duration, jitter), on_load: () => pdSpotEncode(taskCode, numBlinks, config), on_finish: (data) => (data.code = taskCode), }; diff --git a/trials/showImage.js b/trials/showImage.js index 6ac3f5d..adef61f 100644 --- a/trials/showImage.js +++ b/trials/showImage.js @@ -3,7 +3,7 @@ const { pdSpotEncode, } = require("../lib/markup/photodiode"); const $ = require("jquery"); -const { jitter50 } = require("../lib/utils"); +const { jitterx } = require("../lib/utils"); /** * @description @@ -15,19 +15,20 @@ const { jitter50 } = require("../lib/utils"); * @param {boolean} config.USE_EEG - USE_EEG flag * @param {boolean} config.USE_ELECTRON - USE_ELECTRON flag * @param {boolean} config.USE_MTURK - USE_MTURK flag + * @param {string} image - The path of the image file to be displayed. * @param {Object} options - * @param {number} options.duration - trial duration in milliseconds. (default: 1000) - * @param {string} options.image - The path of the image file to be displayed. (default: a blue dot image) - * @param {number} options.imageHeight - Set the height of the image in pixels. If left null (no value specified), then the image will display at its natural height. (default: 600) - * @param {number} options.imageWidth - Set the width of the image in pixels. If left null (no value specified), then the image will display at its natural width. (default: 600) + * @param {number} options.duration - trial duration in milliseconds jittered with the jitter param. (default: 1000) + * @param {number} options.jitter - jitter range (0-jitter) to add from to the trial duration (default: 50) + * @param {number} options.imageHeight - Set the height of the image in pixels. (default: 600) + * @param {number} options.imageWidth - Set the width of the image in pixels. (default: 600) * @param {number} options.taskCode - Task code to be saved into data log (default: 1) * @param {number} options.numBlinks - Number of times the pulse needs to be repeated for photodiode box, when USE_PHOTODIODE is set true. (default: 1) */ -module.exports = function (config, options) { +module.exports = function (config, image, options) { const defaults = { duration: 1000, - image: "../img/blue.png", + jitter: 50, imageHeight: 600, imageWidth: 600, taskCode: 1, @@ -35,7 +36,7 @@ module.exports = function (config, options) { }; const { duration, - image, + jitter, imageHeight, imageWidth, taskCode, @@ -47,7 +48,7 @@ module.exports = function (config, options) { stimulus: image, prompt: config.USE_PHOTODIODE ? photodiodeGhostBox() : "", response_ends_trial: false, - trial_duration: jitter50(duration), + trial_duration: jitterx(duration, jitter), on_load: () => { $("#jspsych-image-keyboard-response-stimulus").addClass("image"); $("#jspsych-image-keyboard-response-stimulus").height(imageHeight); diff --git a/trials/userId.js b/trials/userId.js index cd79339..673c1a8 100644 --- a/trials/userId.js +++ b/trials/userId.js @@ -15,7 +15,7 @@ const { baseStimulus } = require("../lib/markup/stimuli"); * @param {number} options.duration - trial duration in milliseconds. (default: 1000) * @param {string} options.stimulus - Onscreen stimulus in HTML to be shown in the trial, if not set default text is empty. If the stimulus is not provided, message should be provided as a string. (default: "") * @param {string} options.setIdMessage - Onscreen text for setting user id or for the input box to enter patient id. (default: "") - * @param {string} options.defaultPatientId - The patient id to show when requesting a patient ID. (default: "") + * @param {string} options.defaultId - The patient id to show when requesting a patient ID. (default: "") */ module.exports = function (jsPsych, config, options) { @@ -23,13 +23,13 @@ module.exports = function (jsPsych, config, options) { duration: 1000, stimulus: "", setIdMessage: "", - defaultPatientId: "", + defaultId: "", }; const { duration, stimulus, setIdMessage, - defaultPatientId, + defaultId, } = { ...defaults, ...options }; const stimulusOrMessage = @@ -55,7 +55,7 @@ module.exports = function (jsPsych, config, options) { questions: [ { prompt: baseStimulus(`

${setIdMessage}

`, true), - value: defaultPatientId, + value: defaultId, }, ], on_finish: (data) => { From a488eb247fa11de074ebe8b41594b899c03d0520 Mon Sep 17 00:00:00 2001 From: Rashi1997 Date: Thu, 11 Feb 2021 10:40:19 -0500 Subject: [PATCH 3/8] =?UTF-8?q?test:=20=F0=9F=92=8D=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/showImage.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/showImage.spec.js b/tests/showImage.spec.js index 22fbd5e..403546e 100644 --- a/tests/showImage.spec.js +++ b/tests/showImage.spec.js @@ -5,7 +5,7 @@ describe("showImage trial", () => { it("showImage without photodiode box", () => { const config = init({ USE_PHOTODIODE: false }); let data = { code: null }; - const result = showImage(config, { + const result = showImage(config, "", { duration: 100, }); expect(result.prompt).not.toContain("photodiode-spot"); @@ -17,7 +17,7 @@ describe("showImage trial", () => { it("showImage with photodiode box and task code", () => { const config = init({ USE_PHOTODIODE: true }); let data = { code: null }; - const result = showImage(config, { + const result = showImage(config, "", { duration: 100, taskCode: 10, }); From a0cf96f90c278a47562380a9b3fd0c65f96cc88b Mon Sep 17 00:00:00 2001 From: Rashi1997 Date: Thu, 11 Feb 2021 12:11:09 -0500 Subject: [PATCH 4/8] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20mturk=20alert?= =?UTF-8?q?=20in=20docs=20for=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trials/userId.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/trials/userId.js b/trials/userId.js index 673c1a8..f637321 100644 --- a/trials/userId.js +++ b/trials/userId.js @@ -12,10 +12,10 @@ const { baseStimulus } = require("../lib/markup/stimuli"); * @param {boolean} config.USE_ELECTRON - USE_ELECTRON flag * @param {boolean} config.USE_MTURK - USE_MTURK flag * @param {Object} options - * @param {number} options.duration - trial duration in milliseconds. (default: 1000) - * @param {string} options.stimulus - Onscreen stimulus in HTML to be shown in the trial, if not set default text is empty. If the stimulus is not provided, message should be provided as a string. (default: "") + * @param {number} options.duration - trial duration in milliseconds, when config.USE_MTURK is set to true. (default: 1000) + * @param {string} options.stimulus - Onscreen stimulus in HTML to be shown in the trial. If the stimulus is not provided, message should be provided as a string. (default: "") * @param {string} options.setIdMessage - Onscreen text for setting user id or for the input box to enter patient id. (default: "") - * @param {string} options.defaultId - The patient id to show when requesting a patient ID. (default: "") + * @param {string} options.defaultId - The patient id to show when requesting a patient ID, when config.USE_MTURK is set to false.(default: "") */ module.exports = function (jsPsych, config, options) { @@ -54,7 +54,7 @@ module.exports = function (jsPsych, config, options) { type: "survey_text", questions: [ { - prompt: baseStimulus(`

${setIdMessage}

`, true), + prompt: stimulusOrMessage, value: defaultId, }, ], From c2da46a3cae88afd107b85fbff3389d1e348558c Mon Sep 17 00:00:00 2001 From: Rashi1997 Date: Thu, 11 Feb 2021 12:17:01 -0500 Subject: [PATCH 5/8] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20rm=20img=20and=20ds?= =?UTF-8?q?=5Fstore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- img/.DS_Store | Bin 6148 -> 0 bytes img/blue.png | Bin 5218 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 img/.DS_Store delete mode 100644 img/blue.png diff --git a/img/.DS_Store b/img/.DS_Store deleted file mode 100644 index 8bb921663fcc324e08d86c332dcda6ce4a39d389..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyH3ME5S)b+mS|j3-WMS82UZjc>ij@tKr|MiN$-m9%AdjPLx|uY(a@k-X>acK zcJ6djc)b8@eR#YDdH@~W5pO;$&G+3Gc2N-{(s{-WUh#tG`)U8M$UYx%Zif*Q4tV;? zAE*7uz5e~1oj*oVDIf);fE17dQs9>gcfE17dp9=W*q0t?O!Z|TM9UP(s zAg&k=<2-r^V)FoTD4Y`+p;=OiNwsP*Ea{B5${Pyj#H7RGW}Z_wTXiTFw=>=%9X2Ft zlmb%VRDsJ}_Fn(*=s)!TrzEYUfE4&w3fOA1-K_bfs;!I1d97{q9o=(|bT`g}!Xe5r kG0HI)UXHILDf61oxjz)ni9u&P=tTVtxGpj&@Yf1_0E)RJ(EtDd diff --git a/img/blue.png b/img/blue.png deleted file mode 100644 index 820bdce8f886436d9d1f8cc06595e1b55c08ae19..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5218 zcmbVwhf~vA(DpC%aw&pDZv>?ykl+QS7wNr|gb<212to)|5Tr@O1f@xjf*^v@LV!>L zNKuH=6)_M(ks^X9h$vkUdAaX=^ZfzunK^T2_w3H>K4;F(vzzQ_Zy~@3;R66bz{=9p z82~`g|27ZTu_ikH{*B|~?+7zggiFY^h$zf;U%<#G#M@WWDhT7}>+Fm1i4Gg^)dPT& z99E`A@S9WLij4flSdcyi>ByXZPE9n?tD7&6WIt_&&Wvev^k^MfF>d?G#aEYV9Pxew zOp+ZVP7rw`KHf22C~qApAo9N_YMNEL!OKx6Df2M@Pv$)GkJ<)wkDmK6aLSOJSifQI z&4cbGd4qkC<>B4UqoQBKwkJWyG5#MGzHTd&XC8s_@Sq%i%JAMKLpLuMU#wfq7o}EI zbUP838b~HUklNs4jun=5xh&#f_LKjuk6#%HoAd8GqG8b0qlBSeugw+r{TFpnMYle0 z`e+2r$u(-r&BwY3|TCb zC3U*rw(=S^_i`x|;Nkxe_*2bl?cM8VW0!J%=Ql_B8V30!{EjK;n&Qy#6`eQUn#hRMjM4OQrz}pKqASrVdlf<$JJBO5g3LJ!4<3Fe&;lD_DZ8@i;Vp<0r*f^T zvI=E>SR~=vPXU~yVQ<# z=kBakj~H#d*ERgMqu7>LcE>snch9ycO@U*gBGK3)C3i&VTU?a4LrD8v+q&cq?F$x>>ipT-qUru z0^TQfSb2muoB0IuV{X_YD`?bOn$q_z-Xc>?fw3tPcrm@{eweB7cz|hHHJ&xbcI(z} zCH~bBu_noc&#%8z%*5xFr0M8n$`-r;H^p8F&XjWeA`j6(r26m53jTnfBWx=*kRP>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3&Nb{ROzosqF=viaK2FUqTigg}! zDjOL%ZITTpNLD|yP1t>`c5B{}KU0iuj0XDoFgKjg9{L=`K8S+q+dQjsjAQbgZ=ITa zGnChk+Va*d4~^tmb;Ejg#IJ{?2kFgcQ@%w$GGF|e6Ra};u}>ZEzY{Ise~zSYq;=l$ zybkw;_#>-k%}~Hiin5$+6DwpP2m4;ZX;u>MuslynkAGUSF7Qn5n{6seGo<3Bp0?-n z&|fOt9M?^vhL{59pN=0=PUVX}WX(}HUX87;qm+0Ha-?)L>EG^Vj80p0zSD6)B zU8|mAyh_yT;DJ$asdfn+Rao~fE(=b~5)9^PCa!^9J&)xlWs!T|v^<4UWT1YGk{}bG*)Pd{Iqt(*E>KIPAV;*#HUfaE=ObE8#HfZzxK{)Rf Date: Thu, 11 Feb 2021 12:18:29 -0500 Subject: [PATCH 6/8] Delete .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 2138139aefc9210190b621d1abeead0b5a7fd809..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyKdVs6g`Zc)OjFq(WM;<=m#1gojWLjGIZ#YEZrKv>L!sa!;S-FDYW+wI`kL% z5B;3}M0@TfZIF_hF$fA?gFF;@4|VSmC7J-t>1uoo^a1o(1iO2zT1>{JG;GWDydWB# zV}vD^@AGmr%p2aZBPtLTcxnpByZa0S%=tTl_x_ecj>u=>gyrau8e725#`}8xu5WyQ z)_i-MvBVuFSdcZv#C{vr{^ncFzmJUmBdk!6Gs7)ex42^8jL{VshkT9ghZkFiz6GW= zuS;O-Rnse<9$$>gV$K-W=J-XKWy4&f?0tWie?0&FOH|m5jvpAEe`(Bmh-+rEWG14p zbvij;}wL{MZRU0syy066V`|jeNehXcdF845FjofFfSJ+cR?%86!eT%V< z3Pc5>0viS7`;f2*rVcBM`srY$M*w1%-D+&hp9bM14pWDfMUK#nr4lXGxFd$KboM9C zFLhX1v~(DE_%QCy#+^`%-ktL&>JF1yjCE8XDiA8rv6p?>|Ihw?{trp Date: Thu, 11 Feb 2021 13:34:06 -0500 Subject: [PATCH 7/8] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20message/stimul?= =?UTF-8?q?us=20to=20countdonw,=20rm=20patient=20refs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- tests/countdown.spec.js | 6 +++--- trials/countdown.js | 14 +++++++++----- trials/userId.js | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 3f5a8b0..a7fc6b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules coverage testapp.js -.yarn.lock \ No newline at end of file +.yarn.lock +**/.DS_Store \ No newline at end of file diff --git a/tests/countdown.spec.js b/tests/countdown.spec.js index dae2a2f..ca8cfcb 100644 --- a/tests/countdown.spec.js +++ b/tests/countdown.spec.js @@ -1,10 +1,10 @@ const countdown = require("../trials/countdown.js"); describe("Countdown trial", () => { - it("counts to 10 with a text countdown", () => { + it("counts to 10 with a message countdown", () => { const returnobject = { type: "html_keyboard_response", - stimulus: "

CountdownCountdown

", trial_duration: 1000, timeline: [ { prompt: "

10

" }, @@ -23,7 +23,7 @@ describe("Countdown trial", () => { expect( countdown({ duration: 1000, - text: "Countdown", + message: "Countdown", time: 10, }) ).toEqual(returnobject); diff --git a/trials/countdown.js b/trials/countdown.js index 20623fe..2ede044 100644 --- a/trials/countdown.js +++ b/trials/countdown.js @@ -2,22 +2,26 @@ const _ = require("lodash"); /** * @description - * Builds a countdown transition with the given text and number of seconds. + * Builds a countdown transition with the given message and number of seconds. * * @module * @param {Object} options * @param {number} options.duration - trial duration in milliseconds. (default: 1000) - * @param {string} options.text - (optional) text for the countdown. (default: "") + * @param {string} options.stimulus - Onscreen stimulus in HTML to be shown in the trial. If the stimulus is not provided, message should be provided as a string. (default: "") + * @param {string} options.message - (optional) message for the countdown. (default: "") * @param {number} options.time - start number for the countdown. (default: 3) */ module.exports = function (options) { const defaults = { duration: 1000, - text: "", + stimulus: "", + message: "", time: 3, }; - const { duration, text, time } = { ...defaults, ...options }; + const { duration, message, stimulus, time } = { ...defaults, ...options }; + + const stimulusOrMessage = message !== "" ? `

${message}

` : stimulus; const times = _.range(time, 0, -1); const timeline = times.map((val) => { return { prompt: `

${val}

` }; @@ -25,7 +29,7 @@ module.exports = function (options) { return { type: "html_keyboard_response", - stimulus: `

${text} Date: Thu, 11 Feb 2021 13:39:12 -0500 Subject: [PATCH 8/8] =?UTF-8?q?fix:=20=F0=9F=90=9B=20replace=20jitter=20by?= =?UTF-8?q?=20jitterx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 79b6d5d..e46004d 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,12 +1,8 @@ // add a random number between 0 and offset to the base number -const jitter = (base, offset) => ( +const jitterx = (base, offset) => ( base + Math.floor(Math.random() * Math.floor(offset)) ) -// add a random number between 0 and x to the base number -const jitterx = (base, x) => jitter(base, x) - module.exports ={ - jitter, jitterx }