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