Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 6, 2025

Overview

This PR implements a complete digit memory experiment integrated into the closed-loop AutoSciDis workflow, replacing the previous dots comparison experiment with a cognitive memory task.

What's New

Digit Memory Experiment

The experiment measures participants' ability to remember sequences of digits:

  1. Display Phase (5s): Random digit sequence is shown
  2. Recall Phase: Participant types the remembered digits
  3. Feedback Phase (1s): Immediate correct/incorrect feedback

Variables:

  • Independent Variable: n_digits (3-9) - number of digits in sequence
  • Dependent Variable: accuracy (0 or 1) - whether recall was correct

Key Features

  • 🔄 Closed-Loop Integration: Fully integrated with AutoRA workflow
  • 🤖 Multi-Model Support: Works with Nuts, BMS, and Logistic Regression theorists
  • 🎯 Adaptive Sampling: Uses model disagreement to select optimal conditions
  • 🌐 Firebase Ready: Configured for online data collection via Firebase
  • Robust Data Collection: Handles early termination and edge cases
  • 📊 Visual Analytics: Generates 1D plots comparing model predictions

Implementation Details

Core Components

experiment_digit_memory.py (204 lines)

  • trial_sequence(): Generates counterbalanced trials using SweetPea or balanced randomization
  • stimulus_sequence(): Compiles jsPsych JavaScript code for browser-based experiment

preprocessing.py (updated)

  • digit_memory_to_experiment_data(): Converts raw trial data to analysis format

autora_workflow.py (adapted)

  • Changed from 2D experiment (dots_left, dots_right) to 1D (n_digits)
  • Updated visualization from 3D surfaces to 1D line plots
  • Maintained all closed-loop functionality (experimentalist → runner → theorist)

Testing Zone (updated)

  • Added jsPsych dependencies (v7.3.0, html-keyboard-response, survey-html-form)
  • Exposed jsPsychSurveyHtmlForm plugin globally for experiment code

Example Usage

from experiment_digit_memory import trial_sequence, stimulus_sequence

# Generate 8 trials with 3, 5, and 7 digits
trials = trial_sequence(number_of_trials=8, n_levels=[3, 5, 7])

# Compile to JavaScript for web deployment
js_code = stimulus_sequence(trials)

# Deploy via Firebase and collect data automatically

Data Flow

Experimentalist → Generate Conditions (n_digits values)
       ↓
Runner → Create JavaScript → Upload to Firebase
       ↓
Participant → Complete Experiment → Submit Results
       ↓
Preprocessing → Parse to (n_digits, accuracy) DataFrame
       ↓
Theorist → Fit Models (Nuts, BMS, Logistic)
       ↓
Experimentalist → Select New Conditions (Model Disagreement)
       ↓
Repeat Cycle...

Testing

All components tested and verified:

  • ✅ Trial sequence generation with counterbalancing
  • ✅ JavaScript code compilation for jsPsych
  • ✅ Data preprocessing pipeline
  • ✅ Full pipeline integration
  • ✅ Syntax validation

Documentation

  • QUICKSTART.md: User-friendly deployment guide with step-by-step instructions
  • DIGIT_MEMORY_README.md: Technical documentation with architecture details
  • Comprehensive inline comments in all new code

Migration Notes

The original dots comparison experiment files remain intact (trial_sequence.py, stimulus_sequence.py). Users can switch between experiments by modifying imports in autora_workflow.py.

Before:

from trial_sequence import trial_sequence
from stimulus_sequence import stimulus_sequence

After:

from experiment_digit_memory import trial_sequence as dm_trial_sequence
from experiment_digit_memory import stimulus_sequence as dm_stimulus_sequence

Deployment

Users need to:

  1. Add Firebase credentials (firebase-service-account.json)
  2. Install dependencies (npm install, pip install -r requirements.txt)
  3. Deploy web app (firebase deploy)
  4. Run workflow (python autora_workflow.py)

Statistics

  • Added: 422 lines (experiment, preprocessing, docs)
  • Removed: 58 lines (old workflow code)
  • Files created: 3 (experiment.py, 2 docs)
  • Files modified: 5 (workflow, preprocessing, package.json, main.js, .gitignore)

Related Links

Original prompt

On closed_loop_autoscidis, We need a new experiment. A digit_memory_experiment in wich numbers are represented (with a certain amount of digits, this amout should be the independent variable of the experiment. This variable defines the number of digits that are represented) The participant has time (5 sec for example) to rememner this numbers, and that type them in. The result should be correkt if the shown number matches the typed numer from the participant. The collected data should than be able to be loaded from firebase to the projekt again so the date can be used by the theorist and the experimentalist to make new conditions for the experiment. So that the digit_memory_experiment is integrated in the closed loop flow.
(this could be usefull links https://autoresearch.github.io/autora/examples/closed-loop-basic/experiment/

https://autoresearch.github.io/autora/examples/closed-loop-basic/preprocessing/

https://autoresearch.github.io/autora/examples/closed-loop-basic/workflow/

https://autoresearch.github.io/autora/cheat-sheet/ )


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 4 commits October 6, 2025 11:47
Co-authored-by: Edogor <63065545+Edogor@users.noreply.github.com>
Co-authored-by: Edogor <63065545+Edogor@users.noreply.github.com>
Co-authored-by: Edogor <63065545+Edogor@users.noreply.github.com>
Co-authored-by: Edogor <63065545+Edogor@users.noreply.github.com>
Copilot AI changed the title We need a new experiment. A digit_memory_experiment in wich numbers are represented (with a certain amount of digits, this amout should be the independent variable of the experiment. This variable defines the number of digits that are represented) The... Implement digit memory experiment with full closed-loop AutoRA integration Oct 6, 2025
Copilot AI requested a review from Edogor October 6, 2025 12:00
@Edogor Edogor marked this pull request as ready for review October 7, 2025 14:16
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.

2 participants