Skip to content
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

Merged
merged 104 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
2ff0b89
ref: Renames photodiodeSpot and pdSpotEncode
RobertGemmaJr Dec 6, 2023
73c6178
ref: Export photodiodeGhostBox as a constant, not a function
RobertGemmaJr Dec 6, 2023
9b60a97
chore: TODO
RobertGemmaJr Dec 6, 2023
3e361ac
chore: TODO number
RobertGemmaJr Dec 6, 2023
68c7f4b
Merge branch 'chore-issues' into ref-photodiode_spot
RobertGemmaJr Dec 6, 2023
e84cb53
chore: TODO numbers
RobertGemmaJr Dec 6, 2023
850a0c8
Merge branch 'main' into ref-photodiode_spot
RobertGemmaJr Dec 8, 2023
f279d65
wip: Add fixation code directly to Honeycomb
RobertGemmaJr Dec 8, 2023
eb251a3
wip: Fixation trial uses global config object
RobertGemmaJr Dec 8, 2023
1886738
wip: Fixation uses helper function for creating the stimulus
RobertGemmaJr Dec 8, 2023
c9a9046
chore: TODO
RobertGemmaJr Dec 8, 2023
91b2f36
chore: TODOs for trigger code
RobertGemmaJr Dec 8, 2023
57a5f6d
ref: Clean up trigger codes
RobertGemmaJr Dec 8, 2023
06d0659
wip: Cleanup debrief trial
RobertGemmaJr Dec 8, 2023
229f255
ref: Rename task names
RobertGemmaJr Dec 8, 2023
3f391cf
ref: Rename functions from create_ to build_
RobertGemmaJr Dec 8, 2023
524a511
Merge branch 'ref-jsPsychExperiment' into ref-fixation
RobertGemmaJr Dec 11, 2023
65b76ae
chore: Docstrings for triggerbox settings
RobertGemmaJr Dec 11, 2023
6b48841
ref: Defaults productID to undefined
RobertGemmaJr Dec 11, 2023
167fffc
ref: Hard code audio code
RobertGemmaJr Dec 11, 2023
dd7a0f2
chore: Comments
RobertGemmaJr Dec 11, 2023
29935ff
chore: Remove TODO
RobertGemmaJr Dec 11, 2023
0ed2e8e
chore: TODOs
RobertGemmaJr Dec 11, 2023
31ad539
chore: comments
RobertGemmaJr Dec 11, 2023
61ac47e
chore: comments
RobertGemmaJr Dec 11, 2023
f78f795
chore: docstring
RobertGemmaJr Dec 11, 2023
222742b
wip: Add fixation code directly to Honeycomb
RobertGemmaJr Dec 8, 2023
8203af6
wip: Fixation trial uses global config object
RobertGemmaJr Dec 8, 2023
16ebef1
wip: Fixation uses helper function for creating the stimulus
RobertGemmaJr Dec 8, 2023
41c4c05
chore: TODO
RobertGemmaJr Dec 8, 2023
3279697
chore: TODOs for trigger code
RobertGemmaJr Dec 8, 2023
e677a33
ref: Clean up trigger codes
RobertGemmaJr Dec 8, 2023
24c2d92
wip: Cleanup debrief trial
RobertGemmaJr Dec 8, 2023
58f5834
ref: Rename task names
RobertGemmaJr Dec 8, 2023
edf891f
ref: Rename functions from create_ to build_
RobertGemmaJr Dec 8, 2023
a4c7735
chore: Docstrings for triggerbox settings
RobertGemmaJr Dec 11, 2023
35dcaba
ref: Defaults productID to undefined
RobertGemmaJr Dec 11, 2023
24bce9d
ref: Hard code audio code
RobertGemmaJr Dec 11, 2023
ac65df5
chore: Comments
RobertGemmaJr Dec 11, 2023
076f149
chore: Remove TODO
RobertGemmaJr Dec 11, 2023
8c1bbe2
chore: TODOs
RobertGemmaJr Dec 11, 2023
4ad4deb
chore: comments
RobertGemmaJr Dec 11, 2023
6826e89
chore: comments
RobertGemmaJr Dec 11, 2023
09350d0
chore: docstring
RobertGemmaJr Dec 11, 2023
e8672ea
Merge branch 'ref-old-actions' into ref-photodiode_spot
RobertGemmaJr Dec 11, 2023
00f391d
Merge branch 'ref-fixation' of https://github.com/brown-ccv/honeycomb…
RobertGemmaJr Dec 11, 2023
83400fb
chore: TODO
RobertGemmaJr Dec 11, 2023
ab5a532
ref(honeycombTimeline): Rename honeycombTrials as honeycombBlock
RobertGemmaJr Dec 11, 2023
f3626a3
feat: Pass photodiodeGhostBox and encode photodiode for both fixation…
RobertGemmaJr Dec 11, 2023
e4a9c94
Merge branch 'ref-photodiode_spot' into ref-fixation
RobertGemmaJr Dec 11, 2023
64a3bc7
chore: Fix merge issue
RobertGemmaJr Dec 11, 2023
05661dc
Merge branch 'ref-fixation' into feat-photodiodeGhostBox
RobertGemmaJr Dec 11, 2023
696db9a
chore: merge fix
RobertGemmaJr Dec 11, 2023
1fa9a1a
chore: style cleanup
RobertGemmaJr Dec 11, 2023
a705777
chore: Refactor comments
RobertGemmaJr Dec 12, 2023
cd35af2
chore: Comments
RobertGemmaJr Dec 12, 2023
588abd2
chore: Comments
RobertGemmaJr Dec 12, 2023
5a3f2ce
ref: pass trial_duration as a callback function
RobertGemmaJr Dec 12, 2023
2ae8b3c
ref: Pass photodiodeGhostBox as a const instead of function
RobertGemmaJr Dec 12, 2023
bf8d2ab
chore: TODO
RobertGemmaJr Dec 12, 2023
3406c4a
enh: Remove visible and invisible classes from photodiodeGhostBox as …
RobertGemmaJr Dec 12, 2023
97233c9
wip: holdUpMarker conditionally adds the photodiodeGhostBox
RobertGemmaJr Dec 12, 2023
bab5efb
Merge branch 'main' into ref-photodiode_spot
RobertGemmaJr Dec 12, 2023
02dbd79
Merge branch 'ref-photodiode_spot' into ref-fixation
RobertGemmaJr Dec 12, 2023
d72eb13
Merge branch 'ref-fixation' into feat-photodiodeGhostBox
RobertGemmaJr Dec 12, 2023
5cada3b
wip: holdUpMarker conditionally adds the photodiodeGhostBox
RobertGemmaJr Dec 12, 2023
2ff0fae
Merge branch 'main' into ref-photodiode_spot
RobertGemmaJr Dec 12, 2023
54e1052
Merge branch 'main' into ref-fixation
RobertGemmaJr Dec 12, 2023
c268638
Merge branch 'ref-fixation' into feat-photodiodeGhostBox
RobertGemmaJr Dec 12, 2023
f9b7ed5
Merge branch 'ref-check-at-trial' of https://github.com/brown-ccv/hon…
RobertGemmaJr Dec 12, 2023
d4481dd
Merge branch 'feat-photodiodeGhostBox' into ref-check-at-trial
RobertGemmaJr Dec 12, 2023
fd61b89
ref: Refactor adjustVolume trial to be a constant
RobertGemmaJr Dec 12, 2023
0c0b2bd
ref: Refactor holdUpMarker trial to be a constant
RobertGemmaJr Dec 12, 2023
8bb66fc
ref: Rename cameraStart as buildCameraStartTrial
RobertGemmaJr Dec 12, 2023
da1ba5f
ref: Rename cameraEnd as buildCameraEndTrial
RobertGemmaJr Dec 12, 2023
430a290
ref: Rename enterFullScreen as enterFullScreenTrial
RobertGemmaJr Dec 12, 2023
70b4fc5
ref: Rename exitFullScreen as exitFullScreenTrial
RobertGemmaJr Dec 12, 2023
fd766b7
ref: Make startCode, showName, and showWelcome constants instead of f…
RobertGemmaJr Dec 12, 2023
f535372
ref: Rename adjustVolume as adjustVolumeTrial
RobertGemmaJr Dec 12, 2023
9c0e598
ref: Rename startCode as startCodeTrial
RobertGemmaJr Dec 12, 2023
2af319d
chore: Remove uneeded todo
RobertGemmaJr Dec 12, 2023
bbde13b
ref: Remove preamble from base timeline
RobertGemmaJr Dec 12, 2023
8391c07
ref: Rename preamble as buldPreambleBlock
RobertGemmaJr Dec 12, 2023
30df87c
wip: Remove preamble from honeycomb timeline
RobertGemmaJr Dec 12, 2023
53c8099
chore: variable naming
RobertGemmaJr Dec 12, 2023
21eba5a
chore: Fix error message
RobertGemmaJr Dec 12, 2023
267ad71
chore: Fix error message
RobertGemmaJr Dec 12, 2023
e2d05a9
wip: Add config check for startCodeTrial
RobertGemmaJr Dec 12, 2023
518d976
ref: Conditionally flash the photodiode on the holdUpMarker trial
RobertGemmaJr Dec 12, 2023
d4a56fe
Merge branch 'ref-photodiode_spot' into ref-fixation
RobertGemmaJr Dec 12, 2023
c497130
Merge branch 'ref-fixation' into feat-photodiodeGhostBox
RobertGemmaJr Dec 12, 2023
e39f322
Merge branch 'feat-photodiodeGhostBox' into ref-check-at-trial
RobertGemmaJr Dec 12, 2023
6263182
style: Pass no-unused-vars as a warning
RobertGemmaJr Dec 12, 2023
d9c6494
Merge branch 'ref-photodiode_spot' into ref-fixation
RobertGemmaJr Dec 12, 2023
ec4bf12
Merge branch 'ref-fixation' into feat-photodiodeGhostBox
RobertGemmaJr Dec 12, 2023
5478530
Merge branch 'feat-photodiodeGhostBox' into ref-check-at-trial
RobertGemmaJr Dec 12, 2023
9660a15
Merge branch 'feat-v3.3' into ref-photodiode_spot
RobertGemmaJr Dec 13, 2023
3e446e6
chore: lock
RobertGemmaJr Dec 13, 2023
38a5f0a
Merge branch 'ref-photodiode_spot' into ref-fixation
RobertGemmaJr Dec 13, 2023
2286d09
Merge branch 'ref-fixation' into feat-photodiodeGhostBox
RobertGemmaJr Dec 13, 2023
c6605a5
Merge branch 'feat-photodiodeGhostBox' into ref-check-at-trial
RobertGemmaJr Dec 13, 2023
82ea02a
Merge branch 'hold-cleaning' into ref-check-at-trial
RobertGemmaJr Dec 13, 2023
f8fc7ec
Merge branch 'hold-cleaning' into ref-check-at-trial
RobertGemmaJr Dec 13, 2023
8ad2d60
chore: Fix language
RobertGemmaJr Dec 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/markup/photodiode.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const photodiodeGhostBox = div(span("", { id: "photodiode-spot", class: "photodi
* Note that this function must be executed inside the "on_load" callback of a trial
* @param {number} taskCode The unique code for the given trial on which this function executes
*/
// TODO #355: Conditional check should be at the task level (pass settings here)
function pdSpotEncode(taskCode) {
if (!config.USE_ELECTRON) {
throw new Error("photodiodeSpot trial is only available when running inside Electron");
Expand Down
14 changes: 11 additions & 3 deletions src/timelines/honeycombBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

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?

Copy link
Member Author

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, and ENV? At the very least I think env isa much better name than config


const fixationTrial = buildFixationTrial(jsPsych);

Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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) => {
Expand All @@ -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;
}
Expand Down
17 changes: 11 additions & 6 deletions src/timelines/honeycombTimeline.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { enterFullscreen, exitFullscreen } from "../trials/fullscreen";
import { enterFullscreenTrial, exitFullscreenTrial } from "../trials/fullscreen";
import {
buildDebriefTrial,
finishTrial,
Expand All @@ -8,7 +8,7 @@ import {
} from "../trials/honeycombTrials";

import { buildHoneycombBlock } from "./honeycombBlock";
import { preamble } from "./preamble";
import { buildPreambleBlock } from "./preamble";

/**
* This timeline builds the example reaction time task from the jsPsych tutorial.
Expand All @@ -17,20 +17,25 @@ import { preamble } from "./preamble";
* See the jsPsych documentation for more: https://www.jspsych.org/7.3/tutorials/rt-task/
*/
function buildHoneycombTimeline(jsPsych) {
const honeycombBlock = buildHoneycombBlock(jsPsych); // The first block repeats 5 times
const preambleBlock = buildPreambleBlock();

// The first block repeats 5 times
// TODO: Pull from config here and pass into function
const honeycombBlock = buildHoneycombBlock(jsPsych);

const debriefTrial = buildDebriefTrial(jsPsych);

const timeline = [
// TODO #231: Use the new welcome trial inside the preamble
preamble,
preambleBlock,
welcomeTrial,
enterFullscreen,
enterFullscreenTrial,
preloadTrial,
instructionsTrial,
honeycombBlock,
debriefTrial,
finishTrial,
exitFullscreen,
exitFullscreenTrial,
];
return timeline;
}
Expand Down
8 changes: 5 additions & 3 deletions src/timelines/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { config } from "../config/main";
import { cameraEnd, cameraStart } from "../trials/camera";
import { buildCameraEndTrial, buildCameraStartTrial } from "../trials/camera";

import { buildHoneycombTimeline } from "./honeycombTimeline";

/**
Expand All @@ -24,8 +25,9 @@ function buildTimeline(jsPsych, studyID, participantID) {

// Dynamically adds the camera trials to the experiment if config.USE_CAMERA
if (config.USE_CAMERA) {
timeline.unshift(cameraStart(jsPsych)); // Add cameraStart as the first trial
timeline.push(cameraEnd(jsPsych, 5000)); // Add cameraEnd as the last trial
// TODO: These should be a part of the start and end blocks
timeline.unshift(buildCameraStartTrial(jsPsych)); // Add buildCameraStartTrial as the first trial
timeline.push(buildCameraEndTrial(jsPsych, 5000)); // Add buildCameraEndTrial as the last trial
}

return timeline;
Expand Down
27 changes: 15 additions & 12 deletions src/timelines/preamble.js
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Member Author

Choose a reason for hiding this comment

The 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 };
23 changes: 11 additions & 12 deletions src/trials/adjustVolume.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import { language } from "../config/main";
import { baseStimulus } from "../lib/markup/stimuli";
import { h1 } from "../lib/markup/tags";

// TODO: Refactor to constant
function adjustVolume() {
const adjustVolumeMarkup = h1(language.trials.adjustVolume);
/** Trial that prompts the user to adjust the volume on their computer */
const adjustVolumeTrial = {
type: htmlKeyboardResponse,
stimulus: () => {
const adjustVolumeMarkup = h1(language.trials.adjustVolume);
return baseStimulus(adjustVolumeMarkup, true);
},
prompt: language.prompts.continue.prompt,
response_ends_trial: true,
};

return {
type: htmlKeyboardResponse,
stimulus: baseStimulus(adjustVolumeMarkup, true),
prompt: language.prompts.continue.prompt,
response_ends_trial: true,
};
}

export default adjustVolume;
export { adjustVolumeTrial };
34 changes: 21 additions & 13 deletions src/trials/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,11 @@ import { div, h1, p, tag } from "../lib/markup/tags";
/**
* A trial that begins recording the participant using their computer's default camera
* @param {Object} jsPsych The jsPsych instance being used to run the task
* @returns
* @returns {Object} A jsPsych trial object
*/
// TODO: Refactor to buildCameraStartTrial
// TODO #342: refactor to record using web USB
function cameraStart(jsPsych) {
const videoMarkup = tag("video", "", { id: "webcam", width: 640, height: 480, autoplay: true });
const cameraStartMarkup = p(language.trials.camera.start);
const markup = div(cameraStartMarkup + videoMarkup, {
// TODO #344: Need to get rid of bootstrap (this is just centering it)
class: "d-flex flex-column align-items-center",
});

function buildCameraStartTrial(jsPsych) {
return {
timeline: [
{
Expand All @@ -34,7 +27,21 @@ function cameraStart(jsPsych) {
{
// Helps participant center themselves inside the camera
type: htmlButtonResponse,
stimulus: baseStimulus(markup, true) + photodiodeGhostBox,
stimulus: () => {
const videoMarkup = tag("video", "", {
id: "camera",
width: 640,
height: 480,
autoplay: true,
});
const cameraStartMarkup = p(language.trials.camera.start);
const trialMarkup = div(cameraStartMarkup + videoMarkup, {
// TODO #344: Need to get rid of bootstrap (this is just centering it)
class: "d-flex flex-column align-items-center",
});
// TODO: Show photodiodeGhostBox as prompt
return baseStimulus(trialMarkup, true) + photodiodeGhostBox;
},
choices: [language.prompts.continue.button],
response_ends_trial: true,
on_start: () => {
Expand Down Expand Up @@ -85,13 +92,14 @@ function cameraStart(jsPsych) {
* A trial that finishes recording the participant using their computer's default camera
*
* @param {Number} duration How long to show the trial for
* @returns
* @returns {Object} A jsPsych trial object
*/
function cameraEnd(jsPsych, duration) {
function buildCameraEndTrial(jsPsych, duration) {
const recordingEndMarkup = h1(language.trials.camera.end);

return {
type: htmlKeyboardResponse,
// TODO: Show photodiodeGhostBox as prompt
stimulus: baseStimulus(recordingEndMarkup, true) + photodiodeGhostBox,
trial_duration: duration,
on_start: () => {
Expand All @@ -112,4 +120,4 @@ function cameraEnd(jsPsych, duration) {
};
}

export { cameraStart, cameraEnd };
export { buildCameraStartTrial, buildCameraEndTrial };
2 changes: 1 addition & 1 deletion src/trials/fixation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function buildFixationTrial(jsPsych) {
},
// Conditionally flash the photodiode when the trial first loads
on_load: () => {
if (config.USE_PHOTODIODE) pdSpotEncode(fixationCode, 1, config);
if (config.USE_PHOTODIODE) pdSpotEncode(fixationCode);
},
};
}
4 changes: 2 additions & 2 deletions src/trials/fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import jsPsychFullscreen from "@jspsych/plugin-fullscreen";
* Trial to enter fullscreen mode.
* Any trials after this one will be run while the app/browser is in fullscreen.
*/
export const enterFullscreen = {
export const enterFullscreenTrial = {
type: jsPsychFullscreen,
fullscreen_mode: true,
};
Expand All @@ -13,7 +13,7 @@ export const enterFullscreen = {
* Trial to exit fullscreen mode.
* Any trials after this one will NOT be run while the app/browser is in fullscreen.
*/
export const exitFullscreen = {
export const exitFullscreenTrial = {
type: jsPsychFullscreen,
fullscreen_mode: false,
};
41 changes: 24 additions & 17 deletions src/trials/holdUpMarker.js
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 };
33 changes: 17 additions & 16 deletions src/trials/startCode.js
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 };
Loading