How bine022/eegpt works
Main Components
• Data Preparation and Datasets:
– Represent the datasets folder split into two parts:
• Pretrain datasets: “datasets/pretrain”, showing the script (prepare_pretrain_dataset.py) and its README.
• Downstream datasets: “datasets/downstream”, with corresponding preparation scripts and README.
– Include preprocessing for additional EEG datasets (TUAB, TUEV) from “downstream_tueg” components.
• Pretraining Pipeline:
– Show the “pretrain” directory that contains configuration (configs.py), model definition (modeling_pretraining.py), engine (engine_pretraining.py), and the run script (run_pretraining.py).
– Indicate that this module implements the mask-based dual self-supervised learning with spatio-temporal representation alignment.
• Downstream Task Pipelines:
– Group the various downstream scripts (e.g., finetuning and linear probing scripts like finetune_BENDR_PhysioP300.py, linear_probe_EEGPT_BCIC2A.py) from the “downstream” directory.
– Highlight the downstream data processing submodule (“downstream/Data_process”) that handles EEG data reading, transformation, and utility functions.
• Modular Models and Extensions:
– Indicate the “downstream/Modules” folder structured into various submodules:
• Specific model implementations (EEGPT_mcae*, dn3 extensions, LaBraM, BIOT, etc.).
• The “dn3” submodules: This contains configuration, training utilities, data pipelines, metrics, and transformation utilities forming an encapsulated framework.
• The “Transformers” directory for supplementary transformer-based components (e.g. positional embeddings).
• External Dependencies / Pretrained Models:
– Clearly show how these checkpoints feed into downstream modules (for example, the checkpoint used with EEGPTClassifier).
• Downstream TUAB/TUEV:
– Note that it includes its own dataset maker scripts, network modules, and dedicated finetuning scripts.
Relationships and Interactions
– From “Datasets” (various EEG data sources) → Data preprocessing modules (in “datasets” and “downstream/Data_process”).
– Processed EEG data → Pretraining Pipeline: Feed into transformer-based self-supervised training.
– Output pretrained transformer model (saved as a checkpoint) → Downstream fine-tuning modules (various finetuning scripts and modules in “downstream/Modules/models”).
– Alternate flow from data → Downstream tasks directly, if “linear_probe” scripts are executed.
• Interactions between modular components:
– Downstream modules interact with the pre-trained weights (model loading in EEGPTClassifier) and with additional models (BENDR, BIOT, LaBraM).
• External integration points for pretrained model files (illustrate external storage sources feeding into the system’s “checkpoint” and model directories).
Architectural Patterns and Design Principles
• Modularity: The project is separated into distinct folders for data preparation, pretraining, and downstream tasks. Within each, components are modularized (e.g., separating data process, training configurations, model definitions, etc.).
• Pipeline-based design: There is a clear preparation → pretraining → finetuning pipeline.
• Plugin for multiple models: The use of directories such as “BIOT”, “LaBraM”, and “EEGPT” indicates a design meant to handle several variations of transformer-based models.
• Clear separation of concerns: The pretraining is isolated from downstream tasks, and both have their dedicated configuration and execution scripts.