Skip to content

Legacy format support#3

Merged
ericwang401 merged 15 commits into
mainfrom
legacy-format-support
Jun 8, 2026
Merged

Legacy format support#3
ericwang401 merged 15 commits into
mainfrom
legacy-format-support

Conversation

@ericwang401

Copy link
Copy Markdown
Contributor

Summary

Related issue

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / internal
  • Task design / timing change (affects collected data)

How was this tested?

uv run pytest -v --ignore=tests/test_overlay.py

Checklist

  • Tests pass (uv run pytest), including the Octave/MATLAB parity test where an engine is available.
  • Changes are headless/CI safe — logic & timing tests run without PsychoPy or a display (no hard top-level import psychopy in tested modules).
  • Documentation and CHANGELOG.md are updated.
  • Changes work under both the UV (uv.lock) and conda (environment.yml) workflows; dependency changes are reflected in both pyproject.toml and environment.yml.
  • I linked the related issue and kept this PR focused on a single concern.

@ericwang401 ericwang401 self-assigned this Jun 8, 2026
…d modules

Rework run_response into a small stimulus state machine plus two helpers:
- _FlipTimer owns the per-flip timing diagnostics and the trial_clean math
- _ResponseState captures the early/hit/rt keypress outcome
Drop the dead 'frames_shown = 0' branch, rename the two confusing latches
(target_shown/clock_reset_scheduled -> target_onset_scheduled, target_onset_
flip_done -> target_on_screen), and document the pre-flip +1 frame prediction.

Split the ~600-line trial.py by responsibility, keeping the flat-module
convention and headless-importability:
- _psychopy.py  shared PsychoPy import shim (core/visual/keyboard/logging)
- phases.py     fixed-duration display loops (cue/fixation/outcome/iti) + _check_quit
- response.py   the timing-critical response window
- trial.py      orchestration only (_compute_reward + run_trial)

Behavior is unchanged: add test_response_diagnostics pinning the full
diagnostics dict, and update test_trial_boundary to target the response module.
Public API (trial.run_trial, trial._compute_reward) is preserved.

All 97 tests pass.
Group the flat ~15-module package into purpose-named subpackages, modeled
on the existing ratings/ subpackage:

- task/ : trial, phases, response, calibration, display, console, debug,
  plus newly extracted flip_timer (was response._FlipTimer, now public
  FlipTimer) and instructions (was session.display_instructions).
- io/   : bootstrap (renamed from session.py, minus instructions),
  setup_wizard, scanner, sequences, and recording/ (the recorder.py split
  into records / csv_writers / legacy / manifest with a re-export __init__).

Update all importers (__main__, ratings/*, tests) and docs. Entry points
in pyproject.toml are unchanged. Pure move/rename refactor; 97 tests pass.
@ericwang401 ericwang401 marked this pull request as ready for review June 8, 2026 21:08
@ericwang401 ericwang401 merged commit 2f935aa into main Jun 8, 2026
2 checks passed
@ericwang401 ericwang401 deleted the legacy-format-support branch June 8, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant