Backend API for running a naturalistic image-similarity study where each participant must receive a valid, non-conflicting design assignment.
This project belongs to a three-stage study pipeline:
- Stage 1: synthesis and model-based perceptual scaling of the stimulus set
- Stage 2: psychophysical validation via similarity judgements
- Stage 3: behavioral validation in a memory task
This repository is for Stage 2 infrastructure. It serves design allocation and participant submission handling used during psychophysical similarity-judgement data collection.
Pettini, L., Bogler, C., Doeller, C., & Haynes, J.-D. (2025). Synthesis and perceptual scaling of high-resolution naturalistic images using Stable Diffusion. Behavior Research Methods, 58(1), 24. https://doi.org/10.3758/s13428-025-02889-8
The API manages the assignment lifecycle for experiment designs stored in Supabase.
- Assignment step (
GET /)
- Finds designs marked as available in
experiment_design_batches. - Prioritizes the earliest batch (
lowest batch_number) and randomly picks one design from that batch. - Immediately reserves that design (
available = false) so concurrent participants are less likely to receive the same assignment.
- Submission step (
POST /)
- Accepts participant identifiers (
participant_id,study_id,session_id) plus the assigneddesign_file_name. - Updates the matching database row with participant metadata and a timestamped availability/status change.
- Access control
- Uses CORS allowlisting via
FRONTEND_ALLOWED_ORIGINSso only approved frontend origins can call the API from browsers.
This repository is organized with a clear app-first structure to separate runtime API code, tests, and operational scripts.
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn apps.api.src.main:app --reloadCreate .env from .env.example and set:
SUPABASE_URL=
SUPABASE_KEY=
FRONTEND_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001