This repository contains the code for the paper: Déjà Vu? Decoding Repeated Reading from Eye Movements (ACL 2025)
- Mamba or Conda
-
Clone the Repository
Start by cloning the repository to your local machine:
git clone https://github.com/lacclab/Cognitive-State-Decoding.git cd Cognitive-State-Decoding -
Create a Virtual Environment
Create a new virtual environment using Mamba (or Conda) and install the dependencies:
mamba env create -f environment.yaml # or exact_environment.yaml -
Get the Data
You have two options to get the data:
-
Directly copy the data files: Use the
scpcommand to copy the data files to your localdata/interim/directory:scp /data/home/shubi/Cognitive-State-Decoding/data/interim/ia_data_enriched_360_260124.csv /data/home/shubi/Cognitive-State-Decoding/data/interim/fixation_data_enriched_360_260124.csv data/interim/
-
Run the data parsing script: If you have access to the raw data, you can run the
parse_data.pyscript to process the data. This script is based on OneStopGaze-Preprocessing.To run the script, use the following command:
python scripts/parse_data.py
-
-
Log in to WandB
Log in to your WandB account to track and visualize your experiments:
wandb login
You'll be prompted to enter the API key from your WandB account.
-
Default Training:
Run the training + eval script with default parameters. This will perform training and predictions on the test set in a cross-validation setting:
python scripts/run_wrapper.py
-
Custom Training:
Run the training script with custom data, model, and trainer options. You can choose to not perform cross-validation by adding the
--single_runflag. Add--skip_trainto skip training and only perform predictions on the test set. Add--skip_evalto skip evaluation and only perform training. If you want the terminal pane to close after the run, add the--do_not_keep_pane_aliveflag:python scripts/run_wrapper.py --data_options "hunting" "gathering" --model_options "roberteye_duplicate_fixation" --trainer "shubi"
-
Advanced Training:
Run the training script with custom parameters and specify the GPU device for training. You can also override any other parameters defined in
model_args.py:python src/train.py +trainer=shubi +model=roberteye_duplicate_fixation +data=hunting trainer.devices=[1] # and any other overrides
Remember to replace the placeholders with your actual parameters.
-
Model Configurations Used in "Déjà Vu? Decoding Repeated Reading from Eye Movements" First, run
scripts/reread_decoding/create_folds_RereadStratified.pyUse the advanced training command and plug in element configurations according to the following table:Task Variant Model E-Z Reader augmented Training Script Model Configuration ( +model=)Data Configuration ( +data=)Trainer ( +trainer=)Single Trial Majority Class src/train_ml.pyXGBoostBinaryRereadReadingSpeedMLArgsGatheringWRereadPairedFrOnlyRereadMLVanilaSingle Trial Reading Speed src/train_ml.pyXGBoostBinaryRereadReadingSpeedMLArgsGatheringWRereadPairedFrOnlyRereadMLVanilaSingle Trial Reading Speed ✔️ src/train_ml.pyXGBoostSyntEZBinaryRereadReadingSpeedMLArgsGatheringWRereadWSynthesizedEZPairedFrOnlyRereadMLVanilaSingle Trial XG-Boost src/train_ml.pyXGBoostBinaryRereadFullFeaturesMLArgsGatheringWRereadPairedFrOnlyRereadMLVanilaSingle Trial XG-Boost ✔️ src/train_ml.pyXGBoostSyntBinaryRereadFullFeaturesMLArgsGatheringWRereadWSynthesizedEZPairedFrOnlyRereadMLVanilaSingle Trial RoBERTEye-Fixations src/train.pyRoberteyeConcatBinaryRereadFixationArgsGatheringWRereadPairedFrOnlyBinaryRereadRoBERTaEyeSingle Trial RoBERTEye-Fixations ✔️ src/train.pyRoberteyeConcatSyntBinaryRereadFixationArgsGatheringWRereadWSynthesizedEZPairedFrOnlyBinaryRereadRoBERTaEyeSingle Trial RoBERTEye-Words src/train.pyRoberteyeConcatBinaryRereadWordsArgsGatheringWRereadPairedFrOnlyBinaryRereadRoBERTaEyeSingle Trial RoBERTEye-Words ✔️ src/train.pyRoberteyeConcatSyntBinaryRereadWordsArgsGatheringWRereadWSynthesizedEZPairedFrOnlyBinaryRereadRoBERTaEyePaired Trials Majority Class src/train_ml.pyXGBoostPairedBinaryRereadReadingSpeedMLArgsGatheringWRereadPairedFrOnlyRereadMLVanilaPaired Trials Reading Speed src/train_ml.pyXGBoostPairedBinaryRereadReadingSpeedMLArgsGatheringWRereadPairedFrOnlyRereadMLVanilaPaired Trials XG-Boost src/train_ml.pyXGBoostPairedBinaryRereadFullFeaturesMLArgsGatheringWRereadPairedFrOnlyRereadMLVanilaPaired Trials RoBERTEye-Fixations src/train.pyRoberteyeConcatPairedBinaryRereadFixationArgsGatheringWRereadPairedFrOnlyBinaryRereadRoBERTaEyePaired Trials RoBERTEye-Words src/train.pyRoberteyeConcatPairedBinaryRereadWordsArgsGatheringWRereadPairedFrOnlyBinaryRereadRoBERTaEyeAs default, set
+data_path=onestop_v1RereadStratifiedanddata.fold_index=between 0 and 9
Follow these steps to add a new model:
-
Create Model Class: In the
src/modelsdirectory, create a new Python file. In this file, define a class that inherits fromBaseModeland implements the following methods:forward: This method should define the forward pass of your model.shared_step: This method should define the entire forward process. It should call theforwardmethod, calculate the loss and metrics, and returnordered_label, loss, ordered_logits. See existing models for examples.
-
Update ModelNames Enum: Add a new entry to the
ModelNamesenum insrc/configs/enums.py. This will be the identifier for your model. -
Update Model Configurations: In the
src/configs/model_args.pyfile, perform the following steps:- Create a new class that inherits from
BaseModelArgs. This class should (atleast) define any variables that are marked asMISSINGin theBaseModelArgsclass. - Add your new class to the
register_model_configsfunction.
- Create a new class that inherits from
-
Update ModelMapping Enum: Add a new entry for your model to the
ModelMappingenum insrc/configs/config.py. This will allow your model to be selected based on the configuration.
The code for the generation of eye movements based on the E-Z Reader model can be found in the scripts/reread_decoding/EZReader10.4_src directory.
This project was developed with the assistance of GitHub Copilot, an AI-powered coding assistant for code completion only. All generated code was carefully reviewed.
Run pre-commit install to install the pre-commit hooks.
Also use ruff and pylint.