feat: import externally-authored jsPsych and lab.js experiments - #246
Open
jdpigeon wants to merge 3 commits into
Open
feat: import externally-authored jsPsych and lab.js experiments#246jdpigeon wants to merge 3 commits into
jdpigeon wants to merge 3 commits into
Conversation
…al normalization, timeline scan)
Add a full Import Experiment path that runs third-party jsPsych v8 timelines and lab.js studies through the existing Collect → Clean → Analyze pipeline. Key pieces: - New EXPERIMENTS.IMPORTED type with ImportedExperiment contract persisted in ExperimentParameters (kind, file path, conditionKey, correctKey, conditionLabels[] ordered for stable numeric codes) - Runtime seam: rename ExperimentWindow → LabjsExperimentWindow, add ImportedExperimentWindow, both behind an ExperimentRuntime dispatcher so RunComponent and PreviewExperimentComponent stay runtime-agnostic - jsPsych host owns initJsPsych() via window injection: merges display_element, override_safe_mode, on_trial_start marker emission (requestAnimationFrame from resolved trial data), on_finish → BrainWaves behavioral CSV via normalize.ts - All 52 official @jspsych/plugin-* packages ship in the bundle; missing plugins are a hard classroom failure - Static scan.ts rejects v6, surfaces data keys/values and missing globals - Asset URL rewriting to bwfile:// for offline stimulus serving - Markers tab in ImportedDesignComponent: teacher declares condition key and confirms label order before first subject; empty labels = behavior-only with EEG forced off - main-process file import copies the .js/.json into the workspace; asset folders are authorized in-place through existing StimulusFileAccess - markerRegistry.ts gains buildMarkerRegistryFromLabels + resolveMarkerRegistry; used by both collection (CSV + events sidecar) and pyodideEpics (MNE event_id) - Custom bank card relabelled to 'Experiment Builder' (enum value stays 'Custom') Tests: 168 passing across 29 files. TypeScript, lint, and build clean. Closes TODOS.md/ROADMAP.md items; updates .llms/learnings.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds an Import Experiment path that runs externally-authored jsPsych v8 timelines and lab.js
.study.jsonfiles through the existing Collect → Clean → Analyze pipeline.What changed
EXPERIMENTS.IMPORTEDwith anImportedExperimentcontract persisted inExperimentParameters(kind, copied file path, conditionKey, correctKey, ordered conditionLabels[])ExperimentWindow→LabjsExperimentWindow, addedImportedExperimentWindow, both behind anExperimentRuntimedispatcher soRunComponentandPreviewExperimentComponentstay runtime-agnosticinitJsPsych()call via window injection — mergesdisplay_element,override_safe_mode(required underfile://),on_trial_startmarker emission from resolved trial data, andon_finish→ BrainWaves behavioral CSV@jspsych/plugin-*packages ship in the bundle — a missing plugin is a hard classroom failure, so the full set is includeddatakeys/values, and names missing plugin globalsbwfile://for offline stimulus servingdatakey carries condition labels, confirm the label order (codes = index + 1), and add labels the scan missed. Empty labels = behavior-only with EEG forced off..js/.jsoninto the workspace; asset folders stay in-place through the existingStimulusFileAccessallowlistbuildMarkerRegistryFromLabels+resolveMarkerRegistryinmarkerRegistry.tsfeeds both collection (CSV + events sidecar) and MNE analysis (event_id)'Custom'for backwards compat)Testing
npm run typecheckcleannpx eslint src/cleannpm run buildclean (main/preload/renderer + viewer)Out of scope for this PR
@jspsych-contribplugins<webview>path collides with EEG viewer preload wiring; kept as a one-file change for v2)Closes the jsPsych import items in
TODOS.mdandROADMAP.md.