-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref: Check config
at trial level
#357
Changes from all commits
2ff0b89
73c6178
9b60a97
3e361ac
68c7f4b
e84cb53
850a0c8
f279d65
eb251a3
1886738
c9a9046
91b2f36
57a5f6d
06d0659
229f255
3f391cf
524a511
65b76ae
6b48841
167fffc
dd7a0f2
29935ff
0ed2e8e
31ad539
61ac47e
f78f795
222742b
8203af6
16ebef1
41c4c05
3279697
e677a33
24c2d92
58f5834
edf891f
a4c7735
35dcaba
24bce9d
ac65df5
076f149
8c1bbe2
4ad4deb
6826e89
09350d0
e8672ea
00f391d
83400fb
ab5a532
f3626a3
e4a9c94
64a3bc7
05661dc
696db9a
1fa9a1a
a705777
cd35af2
588abd2
5a3f2ce
2ae8b3c
bf8d2ab
3406c4a
97233c9
bab5efb
02dbd79
d72eb13
5cada3b
2ff0fae
54e1052
c268638
f9b7ed5
d4481dd
fd61b89
0c0b2bd
8bb66fc
da1ba5f
430a290
70b4fc5
fd766b7
f535372
9c0e598
2af319d
bbde13b
8391c07
30df87c
53c8099
21eba5a
267ad71
e2d05a9
518d976
d4a56fe
c497130
e39f322
6263182
d9c6494
ec4bf12
5478530
9660a15
3e446e6
38a5f0a
2286d09
c6605a5
82ea02a
f8fc7ec
8ad2d60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,16 @@ import { config, eventCodes, taskSettings } from "../config/main"; | |
import { photodiodeGhostBox, pdSpotEncode } from "../lib/markup/photodiode"; | ||
import { buildFixationTrial } from "../trials/fixation"; | ||
|
||
/** | ||
* Builds the blocks of trials that form the core of the Honeycomb experiment | ||
* | ||
* 1) A fixation dot is shown at the center of the screen | ||
* 2) The stimulus image is shown and the user is prompted to press the correct key | ||
* | ||
* Note that the block is conditionally rendered and repeated based on the task settings | ||
*/ | ||
function buildHoneycombBlock(jsPsych) { | ||
const { honeycomb: honeycombSettings } = taskSettings; | ||
const honeycombSettings = taskSettings.honeycomb; | ||
|
||
const fixationTrial = buildFixationTrial(jsPsych); | ||
|
||
|
@@ -35,7 +43,7 @@ function buildHoneycombBlock(jsPsych) { | |
}, | ||
// Conditionally flashes the photodiode when the trial first loads | ||
on_load: () => { | ||
if (config.USE_PHOTODIODE) pdSpotEncode(eventCodes.honeycomb, 1, config); | ||
if (config.USE_PHOTODIODE) pdSpotEncode(eventCodes.honeycomb); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I guess that would make this look weird, so maybe never mind. |
||
}, | ||
// Add a boolean value ("correct") to the data - if the user responded with the correct key or not | ||
on_finish: (data) => { | ||
|
@@ -53,10 +61,10 @@ function buildHoneycombBlock(jsPsych) { | |
* | ||
*/ | ||
const honeycombBlock = { | ||
timeline: [fixationTrial, taskTrial], | ||
randomize_order: honeycombSettings.randomize_order, | ||
repetitions: honeycombSettings.repetitions, | ||
timeline_variables: honeycombSettings.timeline_variables, | ||
timeline: [fixationTrial, taskTrial], | ||
}; | ||
return honeycombBlock; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
import { config } from "../config/main"; | ||
|
||
import holdUpMarker from "../trials/holdUpMarker"; | ||
import startCode from "../trials/startCode"; | ||
import { showName, showWelcome } from "../trials/welcome"; | ||
import { enterFullscreenTrial } from "../trials/fullscreen"; | ||
import { holdUpMarkerTrial } from "../trials/holdUpMarker"; | ||
import { startCodeTrial } from "../trials/startCode"; | ||
import { welcomeTrial, nameTrial } from "../trials/welcome"; | ||
|
||
/** | ||
* Timeline of initial trials used for setup and instructions | ||
*/ | ||
const timeline = [showName(), showWelcome()]; | ||
/** Builds the blocks of trials needed to start and setup the experiment */ | ||
function buildPreambleBlock() { | ||
const timeline = [nameTrial, enterFullscreenTrial, welcomeTrial]; | ||
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this pattern a lot! You're basically moving things from the top level into functions, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. And there's a HUGE difference between code that's inside a function and code that's inside a trial's callback function. Hoping to be a little more clear about that. |
||
|
||
// Add photodiode trials | ||
if (config.USE_PHOTODIODE) { | ||
timeline.push(holdUpMarker()); | ||
timeline.push(startCode()); | ||
// Conditionally add the photodiode setup trials | ||
if (config.USE_PHOTODIODE) { | ||
timeline.push(holdUpMarkerTrial); | ||
timeline.push(startCodeTrial); | ||
} | ||
|
||
return { timeline }; | ||
} | ||
|
||
export const preamble = { timeline }; | ||
export { buildPreambleBlock }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
import htmlButtonResponse from "@jspsych/plugin-html-button-response"; | ||
|
||
import { config, language } from "../config/main"; | ||
import { photodiodeGhostBox } from "../lib/markup/photodiode"; | ||
import { config, eventCodes, language } from "../config/main"; | ||
import { pdSpotEncode, photodiodeGhostBox } from "../lib/markup/photodiode"; | ||
import { baseStimulus } from "../lib/markup/stimuli"; | ||
import { h1, p } from "../lib/markup/tags"; | ||
|
||
// TODO #330: Rename as checkEEG? (this is a similar trial to cameraStart) | ||
// TODO #330: Actually check to see if USB is connected? This isn't testing anything? | ||
// TODO: Refactor to constant | ||
function holdUpMarker() { | ||
const eventMarkerMarkup = h1(language.trials.eventMarker.connected, { style: "color: green;" }); | ||
const holdUpMarkerTrial = { | ||
type: htmlButtonResponse, | ||
stimulus: () => { | ||
const eventMarkerMarkup = h1(language.trials.eventMarker.connected, { | ||
style: "color: green;", | ||
}); | ||
return baseStimulus(eventMarkerMarkup, true); | ||
}, | ||
prompt: () => { | ||
let holdUpMarkerPrompt = p(language.trials.holdUpMarker); | ||
|
||
return { | ||
type: htmlButtonResponse, | ||
stimulus: baseStimulus(eventMarkerMarkup, true) + photodiodeGhostBox, | ||
prompt: [p(language.trials.holdUpMarker)], | ||
choices: [language.prompts.continue.button], | ||
on_start: async () => { | ||
// Ensure event marker is connected if using it | ||
if (config.USE_EEG) await window.electronAPI.checkSerialPort(); | ||
}, | ||
}; | ||
} | ||
// Conditionally add the photodiodeGhostBox | ||
if (config.USE_PHOTODIODE) holdUpMarkerPrompt += photodiodeGhostBox; | ||
|
||
export default holdUpMarker; | ||
return holdUpMarkerPrompt; | ||
}, | ||
choices: [language.prompts.continue.button], | ||
// Conditionally flash the photodiode when the trial first loads | ||
on_load: () => { | ||
if (config.USE_PHOTODIODE) pdSpotEncode(eventCodes.open_task); | ||
}, | ||
}; | ||
|
||
export { holdUpMarkerTrial }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response"; | ||
|
||
import { audioCodes, eventCodes, language } from "../config/main"; | ||
import { audioCodes, config, eventCodes, language } from "../config/main"; | ||
import { pdSpotEncode, photodiodeGhostBox } from "../lib/markup/photodiode"; | ||
import { baseStimulus } from "../lib/markup/stimuli"; | ||
import { h1 } from "../lib/markup/tags"; | ||
import { beep } from "../lib/utils"; | ||
|
||
// TODO: Refactor to constants | ||
function startCode() { | ||
const startCodeMarkup = h1(language.prompts.settingUp); | ||
return { | ||
type: htmlKeyboardResponse, | ||
stimulus: baseStimulus(startCodeMarkup, true) + photodiodeGhostBox, | ||
trial_duration: 2000, | ||
on_load: () => { | ||
// Displays the photodiode spot and plays an audible beep when the trial first loads | ||
pdSpotEncode(eventCodes.open_task); | ||
beep(audioCodes); | ||
}, | ||
}; | ||
} | ||
const startCodeTrial = { | ||
type: htmlKeyboardResponse, | ||
// TODO: Display photodiodeGhostBox as prompt | ||
stimulus: () => { | ||
const startCodeMarkup = h1(language.prompts.settingUp); | ||
return baseStimulus(startCodeMarkup, true) + photodiodeGhostBox; | ||
}, | ||
trial_duration: 2000, | ||
// Conditionally flash the photodiode and plays an audible beep when the trial first loads | ||
on_load: () => { | ||
// TODO: Pass config values as parameters to the function | ||
if (config.USE_PHOTODIODE) pdSpotEncode(eventCodes.open_task); | ||
if (config.USE_VOLUME) beep(audioCodes); | ||
}, | ||
}; | ||
|
||
export default startCode; | ||
export { startCodeTrial }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicky but it might be easier to read if config variables are in caps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely on my nice to haves but I'm not sure where to draw the line. Maybe just
SETTINGS
,LANGUAGE
, andENV
? At the very least I thinkenv
isa much better name thanconfig