Skip to content

Commit

Permalink
Merge pull request #527 from brown-ccv/feat-v3.4.2
Browse files Browse the repository at this point in the history
Feat v3.4.2
  • Loading branch information
YUUU23 authored Aug 8, 2024
2 parents ba5da00 + 4ada736 commit 922ab53
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 27 deletions.
13 changes: 11 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^6.4.2",
"@jspsych/plugin-audio-keyboard-response": "^1.1.3",
"@jspsych/plugin-call-function": "^1.1.0",
"@jspsych/plugin-fullscreen": "^1.2.0",
"@jspsych/plugin-html-button-response": "^1.1.1",
"@jspsych/plugin-html-keyboard-response": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/experiment/honeycomb.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export function buildHoneycombTimeline(jsPsych) {

const timeline = [
startProcedure,
countdownTrial,
preloadTrial,
countdownTrial,
instructionsTrial,
honeycombProcedure,
debriefTrial,
Expand Down
6 changes: 6 additions & 0 deletions src/experiment/procedures/startProcedure.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { holdUpMarkerTrial } from "../trials/holdUpMarker";
import { nameTrial } from "../trials/name";
import { initPhotodiodeTrial } from "../trials/initPhotodiode";
import { introductionTrial } from "../trials/introduction";
import { buildCallFunctionTrial } from "../trials/callFunction";

/**
* Builds the block of trials needed to start and setup the experiment
Expand All @@ -24,6 +25,11 @@ export function buildStartProcedure(jsPsych) {
// Conditionally add the photodiode setup trials
if (config.USE_PHOTODIODE) {
procedure.push(holdUpMarkerTrial);
procedure.push(
buildCallFunctionTrial(() => {
window.electronAPI.checkSerialPort();
})
);
procedure.push(initPhotodiodeTrial);
}

Expand Down
14 changes: 14 additions & 0 deletions src/experiment/trials/callFunction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import callFunction from "@jspsych/plugin-call-function";

/**
* Trial to execute the callback function passed in
*
* @param {function} func callback function to execute
* @returns JS object as a trial
*/
export function buildCallFunctionTrial(func) {
return {
type: callFunction,
func: func,
};
}
30 changes: 6 additions & 24 deletions src/experiment/trials/holdUpMarker.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
import htmlButtonResponse from "@jspsych/plugin-html-button-response";

import { config, LANGUAGE } from "../../config/main";
import { eventCodes } from "../../config/trigger";
import { pdSpotEncode, photodiodeGhostBox } from "../../lib/markup/photodiode";
import { div, h1, p } from "../../lib/markup/tags";
import { LANGUAGE } from "../../config/main";
import { h1 } from "../../lib/markup/tags";
import { photodiodeGhostBox } from "../../lib/markup/photodiode";

// TODO @brown-ccv #330: Custom extension for EEG - this is initializeTriggerBox
// TODO @brown-ccv #330: Need to ping the serial part - this isn't doing anything yet
// TODO @brown-ccv: Prevent user from pressing continue until pdSpotEncode finishes (need to use jsPsych.pluginAPI.setTimeout)
export const holdUpMarkerTrial = {
type: htmlButtonResponse,
stimulus: function () {
const eventMarkerMarkup = h1(LANGUAGE.trials.eventMarker.connected, {
style: "color: green;",
});
return div(eventMarkerMarkup);
},
prompt: function () {
let holdUpMarkerPrompt = p(LANGUAGE.trials.holdUpMarker);

// Conditionally add the photodiodeGhostBox
if (config.USE_PHOTODIODE) holdUpMarkerPrompt += photodiodeGhostBox;

return holdUpMarkerPrompt;
},
stimulus:
h1(LANGUAGE.trials.holdUpMarker) +
photodiodeGhostBox,
choices: [LANGUAGE.prompts.continue.button],
on_load: function () {
// Conditionally flash the photodiode when the trial first loads
if (config.USE_PHOTODIODE) pdSpotEncode(eventCodes.test_connect);
},
};

0 comments on commit 922ab53

Please sign in to comment.