From 30e1e3e753676765114c7017c390c5ab49730672 Mon Sep 17 00:00:00 2001 From: CharlieHFFF Date: Mon, 25 Nov 2024 02:14:46 -0500 Subject: [PATCH] Updating Stroop Task Timeline --- packages/stroop-task/README.md | 71 ++++++++++++++++++++++++ packages/stroop-task/docs/stroop-task.md | 51 +++++++++++++++++ packages/stroop-task/examples/index.html | 44 +++++++++++++++ packages/stroop-task/jest.config.js | 1 + packages/stroop-task/package.json | 37 ++++++++++++ packages/stroop-task/src/index.ts | 42 ++++++++++++++ packages/stroop-task/tsconfig.json | 10 ++++ 7 files changed, 256 insertions(+) create mode 100644 packages/stroop-task/README.md create mode 100644 packages/stroop-task/docs/stroop-task.md create mode 100644 packages/stroop-task/examples/index.html create mode 100644 packages/stroop-task/jest.config.js create mode 100644 packages/stroop-task/package.json create mode 100644 packages/stroop-task/src/index.ts create mode 100644 packages/stroop-task/tsconfig.json diff --git a/packages/stroop-task/README.md b/packages/stroop-task/README.md new file mode 100644 index 0000000..6a26119 --- /dev/null +++ b/packages/stroop-task/README.md @@ -0,0 +1,71 @@ +# n-back + +## Overview + +A timeline for the nback task + +## Loading + +### In browser + +```html + + + + + + + + + + \ No newline at end of file diff --git a/packages/stroop-task/jest.config.js b/packages/stroop-task/jest.config.js new file mode 100644 index 0000000..bd1aace --- /dev/null +++ b/packages/stroop-task/jest.config.js @@ -0,0 +1 @@ +module.exports = require("@jspsych/config/jest").makePackageConfig(__dirname); \ No newline at end of file diff --git a/packages/stroop-task/package.json b/packages/stroop-task/package.json new file mode 100644 index 0000000..de56665 --- /dev/null +++ b/packages/stroop-task/package.json @@ -0,0 +1,37 @@ +{ + "name": "@jspsych-timelines/stroop-task", + "version": "0.0.1", + "description": "Implementing stroop task in JsPsych Timelines", + "type": "module", + "main": "dist/index.mjs", + "types": "dist/index.d.ts", + "unpkg": "dist/index.browser.min.js", + "scripts": { + "build": "tsup src/index.ts --format esm,iife --sourcemap --dts --treeshake --clean --global-name jsPsychTimelineStroopTask" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/jspsych/jspsych-timelines.git" + }, + "keywords": [ + "jsPsych" + ], + "author": { + "name": "Feng Wan", + "url": "https://github.com/CharlieHFFF" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/jspsych/jspsych-timelines/issues" + }, + "homepage": "https://github.com/jspsych/jspsych-timelines/packages/stroop-task#readme", + "peerDependencies": { + "jspsych": "^8.0.1" + }, + "dependencies": { + }, + "devDependencies": { + "tsup": "^6.7.0", + "typescript": "^5.0.2" + } + } \ No newline at end of file diff --git a/packages/stroop-task/src/index.ts b/packages/stroop-task/src/index.ts new file mode 100644 index 0000000..fd41b6d --- /dev/null +++ b/packages/stroop-task/src/index.ts @@ -0,0 +1,42 @@ +import jsPsychHtmlKeyboardResponse from '@jspsych/plugin-html-keyboard-response' + +export function createTimeline(jsPsych: any, + stimuli: any, + font: number = 48, + trial_duration: number = 10000, + post_trial_gap: number = 500, + fixation_duration: number = 500, + randomize_trials: boolean = true, +) { + + const timeline = [] + + const fixation = { + type: jsPsychHtmlKeyboardResponse, + stimulus: `

+

`, + choices: "NO_KEYS", + trial_duration: fixation_duration, + } + + const trial = { + type: jsPsychHtmlKeyboardResponse, + stimulus: function() { + console.log("Stimuli:", stimuli); + console.log("color", jsPsych.evaluateTimelineVariable('color')) + return `

${jsPsych.evaluateTimelineVariable('word')}

`; + }, + choices: "NO_KEYS", + trial_duration: trial_duration, + post_trial_gap: post_trial_gap, + } + + const full_trial = { + timeline: [fixation, trial], + timeline_variables: stimuli, + randomize_order: randomize_trials, + } + + timeline.push(full_trial) + + return timeline +} \ No newline at end of file diff --git a/packages/stroop-task/tsconfig.json b/packages/stroop-task/tsconfig.json new file mode 100644 index 0000000..33655f7 --- /dev/null +++ b/packages/stroop-task/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "@jspsych/config/tsconfig.contrib.json", + "compilerOptions": { + "baseUrl": "." + }, + "include": [ + "src", + "../cli/src/build.js" + ] +} \ No newline at end of file