Class 4 — Custom Code Components
Part I
Write your own logic for the first time using a PsychoPy Code Component — dictionary-based accuracy scoring and dynamic feedback — plus the course-wide minimum-observations design constraint every final project must satisfy.
Class 3 was about reading and lightly editing Builder’s generated Python. Today you write your own logic using a Code Component, the Builder-safe way to add custom Python that survives Builder regenerating the script. You’ll build a dictionary-based accuracy check with feedback text, then program a minimal version of it into your own HW1 task. Along the way, you’ll name this course’s minimum-observations design constraint explicitly — already satisfied by the original Stroop task’s conditions file and reps setting, not by anything you build today.
Reading due: Think Python ch. 9–10 · Due today: —
What you’ll be able to do
- Build and index a Python dictionary, count occurrences of a value in a list, and compute the mean of a list of numbers, reinforced through a Colab warm-up.
- Explain what a PsychoPy Code Component is, where its six code tabs (Before Experiment / Begin Experiment / Begin Routine / Each Frame / End Routine / End Experiment) run relative to a routine’s lifecycle, and why it’s the Builder-safe alternative to Class 3’s direct script edits.
- Add a code component to the original Stroop task that scores accuracy and/or produces dynamic feedback, using a dictionary lookup rather than hard-coded per-trial logic, and that saves each condition’s proportion correct to the data file.
- Explain the course-wide minimum-observations design constraint — every final project needs at least 18 observations per level for its manipulated factor — and recognize that for the original Stroop task it’s already guaranteed by the conditions file and reps setting from Class 2, not by any runtime check built today.
- Connect today’s dictionary-based scoring back to Class 3’s discovery of the correct-answer conditional in the generated code, and recognize that a code component is where you now write the kind of logic Builder was writing for you automatically.