clone this repo and get it working? https://github.com/alexanderrich/stroop-jspsych
- User
clone this repo and get it working? https://github.com/alexanderrich/stroop-jspsych
Assistant· claude-opus-4-6
This is a psiTurk-based jsPsych Stroop experiment — tightly coupled to psiTurk's Python server and MTurk infrastructure. The simplest way to get it running locally is to create a standalone version that strips the psiTurk dependency. Let me check the jsPsych version first.
Assistant· claude-opus-4-6
This is jsPsych v5 (pre-module era). I'll create a standalone HTML file that mocks the psiTurk object so the experiment runs directly in a browser with no server needed.
Assistant· claude-opus-4-6
It's running. Open http://localhost:8765/standalone.html in your browser.
What it does: Classic Stroop task — colored words appear and you press R (red), G (green), or B (blue) matching the ink color, not the word. Includes congruent (RED in red), incongruent (RED in blue), and unrelated (SHIP in red) trials. Shows RT and accuracy summary at the end.
What I did: The original repo is built for psiTurk (a Python/MTurk server). I created
standalone.htmlthat mocks the psiTurk object so the jsPsych v5 experiment runs directly in a browser — no Python server, no MTurk credentials needed. Trial data logs to the browser console.Kill the server later with
kill 50197(or just close the terminal).- User
ok, but compatible with jpsych? we want that
Assistant· claude-opus-4-6
Right, let me port it to modern jsPsych (v7). The repo uses v5 which is long dead — different plugin names, different API, charCode-based responses, etc.
Assistant· claude-opus-4-6
The server is still running — refresh http://localhost:8765/standalone.html to get the jsPsych 7 version.
As for your question — no, it's not word naming. It's a color naming (classic Stroop) task. You ignore the word and report the ink color by pressing R/G/B. The conflict comes from incongruent trials where the word says one color but is printed in another (e.g., the word "RED" printed in blue ink — correct answer is B for blue). That's the Stroop interference effect: reading the word is automatic and competes with naming the color.
- User
so i want to convert it to a button click response -- so we can use clicksense
Assistant· claude-opus-4-6
Perfect — clicksense auto-attaches to buttons via capture-phase listeners, so we just need to swap jsPsych's
html-keyboard-responseforhtml-button-responseand load clicksense. The color buttons become the response mechanism and clicksense captures hold duration + approach dynamics on each one.Assistant· claude-opus-4-6
Refresh http://localhost:8765/standalone.html. Here's what changed:
- Keyboard → buttons: Trials now use
html-button-responsewith three colored buttons (Red, Green, Blue) instead of R/G/B keypresses - ClickSense integrated: Loaded from
../../clicksense/dist/clicksense.js(relative path to your local build), withenableApproachDynamics: true. Every button click captures hold duration + approach trajectory automatically - Results page now includes a ClickSense summary (click count, mean hold duration) alongside the standard RT/accuracy table
- Instructions and fixation cross stay keyboard-driven (they're not measurement trials)
The interesting signal: hold duration on incongruent trials (where you fight the Stroop interference) vs congruent — clicksense should pick up the motor hesitation that RT alone misses.
- Keyboard → buttons: Trials now use
- User
ailed to load resource: the server responded with a status of 404 (File not found)Understand this error standalone.html:42 Uncaught ReferenceError: ClickSense is not defined at standalone.html:42:10
Assistant· claude-opus-4-6
The relative path isn't resolving through the HTTP server. Let me check how clicksense exports on the global.
Assistant· claude-opus-4-6
The UMD bundle exports as
ClickSenseLib.ClickSense, notClickSense. And the relative path../../clicksense/dist/won't resolve — the HTTP server is rooted inexperiment_complete/. I'll copy the dist file in and fix the reference.Assistant· claude-opus-4-6
Fixed both issues:
- Copied
clicksense.jsintostatic/js/so the server can find it - Changed constructor to
ClickSenseLib.ClickSense(that's how the IIFE bundle exports)
Refresh and it should work.
- Copied
- User
the end of experiment report should tally mouseup/down latency and trajectory data
Assistant· claude-opus-4-6
I need to tag each clicksense capture with the trial's stimulus type so I can break down hold duration and approach metrics by condition. I'll store the current trial type and join it to clicksense events.
Assistant· claude-opus-4-6
Now replace the summary report with a proper breakdown:
Assistant· claude-opus-4-6
Refresh the page. The end-of-experiment report now has two ClickSense tables broken down by condition:
Hold Duration — N, mean, min, max of mousedown→mouseup latency per condition (congruent / incongruent / unrelated)
Approach Trajectory — per condition means for:
- Mean & final approach velocity
- Deceleration rate
- Direction corrections (hesitation signal)
- Approach distance (px)
- Pre-click pause (ms)
- Linearity (1.0 = straight line)
- Modal trajectory type (straight / curved / reversal)
Each clicksense capture is tagged with the trial's stimulus type via
on_start, so the condition grouping is exact. The hypothesis to watch: incongruent trials should show more corrections, lower linearity, and longer pause times — the motor signature of Stroop interference that RT alone can't decompose.- User
standalone.html:225 Uncaught TypeError: jsPsych.evaluateTimelineVariable is not a function at Object.on_start (standalone.html:225:28) at i.value (JsPsych.ts:589:13) at i.value (JsPsych.ts:551:10) at f (JsPsych.ts:312:16) at i.value (JsPsych.ts:339:7) at a (index.ts:110:20) on_start @ standalone.html:225 value @ JsPsych.ts:589 value @ JsPsych.ts:551 f @ JsPsych.ts:312 value @ JsPsych.ts:339 a @ index.ts:110 setTimeout value @ TimeoutAPI.ts:14 value @ index.ts:152 value @ JsPsych.ts:633 value @ JsPsych.ts:551 setTimeout f @ JsPsych.ts:316 value @ JsPsych.ts:339 a @ index.ts:110 callback_function @ index.ts:126 e @ KeyboardListenerAPI.ts:128 value @ KeyboardListenerAPI.ts:51
Assistant· claude-opus-4-6
evaluateTimelineVariablewas added in jsPsych 7.3 but behaves differently than expected here. Simpler fix — just read from the trial's owndataproperty inon_start:Assistant· claude-opus-4-6
Refresh —
on_startreceives the resolved trial object directly, sotrial.dataalready has the stimulus_type/word/color.- User
so we need to think about coutnerbalancing the required mouse movement for a correct response, need more trials
Assistant· claude-opus-4-6
Good call. Two problems with the current design:
- Fixed button order (Red-Green-Blue left to right) means correct response position is confounded with color — "Red" correct always means leftmost button, shortest leftward approach
- 9 trials (3 per condition) is way too few for stable motor dynamics estimates
The fix: randomize button order per trial and add repetitions. With 6 possible button orderings × 9 stimuli, we can fully counterbalance position across conditions.
Assistant· claude-opus-4-6
Now replace the trial generation and procedure:
Assistant· claude-opus-4-6
Also tag button position into the clicksense captures and update the report to show position breakdown:
Assistant· claude-opus-4-6
Now update the instructions to reflect the trial count:
Assistant· claude-opus-4-6
Refresh. Here's the design:
- 54 trials (9 stimuli × 6 reps)
- 6 button orderings (all permutations of Red/Green/Blue) — each stimulus sees every permutation exactly once, so correct-answer position (left/center/right) is perfectly counterbalanced within each condition
- Button order is shuffled per-stimulus then all trials are shuffled globally
- Each clicksense capture now records
button_orderandcorrect_positionso you can verify the counterbalancing worked and analyze approach dynamics by target position independently of Stroop condition - Buttons are dynamically colored on each trial via
on_loadto match their label regardless of position
The position confound is eliminated — any approach distance/trajectory differences between congruent and incongruent conditions are now attributable to Stroop interference, not button location.
- User
can we deploy this in gh-pages on clicksense? in an /experiments forlder maybe?
Assistant· claude-opus-4-6
No GitHub Pages set up yet on clicksense. I'll create an
experiments/stroop/folder in the clicksense repo with the standalone experiment, enable Pages fromdocs/(or use a dedicated folder), and deploy.Assistant· claude-opus-4-6
Now I'll create a self-contained version for gh-pages that loads clicksense from the dist in the same repo (no relative path tricks), and set up Pages.
Assistant· claude-opus-4-6
Now create a landing page for experiments and enable gh-pages:
Assistant· claude-opus-4-6
Now stage, commit, push, and enable Pages:
Assistant· claude-opus-4-6
Now enable GitHub Pages serving from
mainbranch root (so/experiments/is accessible):Assistant· claude-opus-4-6
Pages is enabled. It'll be live at https://andyed.github.io/clicksense/experiments/stroop/ once the build completes (usually ~1 min).
Now for your PostHog request — I'll add the PostHog adapter with a distinct event name and experiment-specific properties so Stroop data is easily filterable.
Assistant· claude-opus-4-6
I need to check what PostHog project key is used across Andy's sites.
Assistant· claude-opus-4-6
Scrutinizer-www uses
REDACTED— same key from DEPLOYMENTS.md (project 258589). I'll add PostHog with that key, using a distinct event namestroop_clickand tagging every event withexperiment: 'stroop'so it's trivially filterable.Assistant· claude-opus-4-6
Let me finish the PostHog integration for the Stroop experiment first, then I'll look at the PROTEST tab issue.
Assistant· claude-opus-4-6
Also send a summary event at experiment end:
Assistant· claude-opus-4-6
Stroop experiment is deployed and pushed. PostHog isolation:
- Per-trial: event name
stroop_clickwithexperiment: 'stroop'andsession_idon every event - Per-session summary:
stroop_completefires at experiment end with RT means, accuracy, hold duration means, and computed Stroop effect deltas (incongruent minus congruent) for both RT and hold duration - Filter in PostHog:
event = 'stroop_click'orevent = 'stroop_complete'
Live at: https://andyed.github.io/clicksense/experiments/stroop/
Now the PROTEST tab — that looks like iblipper. The text is rendered in a very faint green that's nearly invisible against the light background. Let me find it.
- Per-trial: event name
- User
[Request interrupted by user for tool use]
- User
custom post hog projdct id for this REDACTED
Assistant· claude-opus-4-6
Done — swapped to
REDACTED. Pushed. No worries about the wrong window — the PROTEST tab thing is for iblipper, we can tackle that separately.- User
Assistant· claude-opus-4-6
build_type: "workflow"but there's no GitHub Actions workflow file. That's the problem — it needs either a static deploy workflow or to use legacy mode.Assistant· claude-opus-4-6
Workflow is queued. The deploy uploads only the
experiments/folder as the site root, so the URL will be:- https://andyed.github.io/clicksense/stroop/ (not
/experiments/stroop/)
Let me check when it finishes.
- https://andyed.github.io/clicksense/stroop/ (not
Assistant· claude-opus-4-6
Deploy succeeded. Since the workflow uploads
experiments/as the root, the URLs are:- https://andyed.github.io/clicksense/ — experiment index
- https://andyed.github.io/clicksense/stroop/ — the Stroop task
Try it now.
- User
Add a link to our readme, stating they can both give us anon mouse data and see their own latencies
Assistant· claude-opus-4-6
Also fixed the research doc link — file was renamed to
clicksense-research.mdper commit9910f90.Assistant· claude-opus-4-6
Done. Added a "Try it" section to the README with a link to the live Stroop experiment, framed as: contribute anonymous mouse data, see your own results. Also fixed the stale
clicksense-paper.mdlink →clicksense-research.md.- User
❯ does the strop test work fine on mobile? if not lets make it so
Assistant· claude-opus-4-6
A few issues on mobile:
- Welcome/instructions screens use
jsPsychHtmlKeyboardResponse— requires physical keyboard, dead on touch devices - Approach dynamics don't exist on touch — no mousemove, no trajectory. Need to handle gracefully
- Buttons may be too small on narrow viewports
Let me fix all three.
- Welcome/instructions screens use
Assistant· claude-opus-4-6
Now switch welcome/instructions from keyboard to button response:
Assistant· claude-opus-4-6
Now update the hold duration label and the summary PostHog event to include input type:
Assistant· claude-opus-4-6
On mobile the approach trajectory table will just be absent (no
mousemoveevents = no approach data =hasApproachstays false). That's already handled correctly. Also hide it gracefully in the summary:Assistant· claude-opus-4-6
We can also drop the
html-keyboard-responseplugin entirely now since nothing uses it except the fixation cross — and that'sNO_KEYSwith a timer, so it works with button-response too. Actually, the fixation cross withNO_KEYSandtrial_durationdoes work fine with keyboard-response on mobile (no input needed, just a timed display). Let me leave it since it works.Assistant· claude-opus-4-6
Pushed. Here's what changed for mobile:
- Viewport meta added,
user-scalable=noto prevent zoom on double-tap - Welcome/instructions switched to button response — no keyboard needed anywhere now
- Buttons stack vertically on <480px with full-width tap targets (16px padding)
touch-action: manipulationkills the 300ms tap delay on mobile browsers- Hold duration still captured — ClickSense handles
touchstart/touchendnatively - Approach trajectory table gracefully absent on touch with an explanatory note
- PostHog tags
input_type: touch/mouseso you can segment the data
The fixation cross still uses
html-keyboard-responsewithNO_KEYS+trial_duration: 500which is fine — it's just a timed display, no input required.- Viewport meta added,