From 026b2ee169794f69643626b70afcf79287344b5e Mon Sep 17 00:00:00 2001 From: Mohammad Javad Darvishi <653mjd@gmail.com> Date: Wed, 11 Dec 2024 23:15:43 -0500 Subject: [PATCH] 'prettier' --- .github/workflows/pre-commit.yaml | 7 +++---- .pre-commit-config.yaml | 16 +++++++--------- README.md | 20 ++++++++++++++++++++ bfm/configs/bfm-t5-base-nmt.yaml | 4 ++-- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 06288ac..8c1beff 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -7,10 +7,9 @@ concurrency: on: [pull_request] jobs: - pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - - uses: pre-commit/action@v3.0.1 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1340a80..0c2fa15 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ ci: autoupdate_branch: "master" autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate" autoupdate_schedule: quarterly - skip: [ ] + skip: [] submodules: false repos: @@ -29,22 +29,20 @@ repos: - id: check-case-conflict - id: forbid-new-submodules - id: pretty-format-json - args: [ "--autofix", "--no-sort-keys", "--indent=4" ] + args: ["--autofix", "--no-sort-keys", "--indent=4"] - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.4.8 hooks: - id: ruff - args: [ "--ignore=E402,E501,F401", "--fix" ] #, --exit-non-zero-on-fix, ] + args: ["--ignore=E402,E501,F401", "--fix"] #, --exit-non-zero-on-fix, ] - id: ruff name: ruff lint data notebooks - args: [ "--fix", "--preview", "--select=NPY201" ] + args: ["--fix", "--preview", "--select=NPY201"] - id: ruff - args: [ "check", "--select", "I", "--fix"] + args: ["check", "--select", "I", "--fix"] - id: ruff-format - types_or: [ python, pyi, jupyter ] - - + types_or: [python, pyi, jupyter] - repo: https://github.com/codespell-project/codespell rev: v2.3.0 @@ -54,7 +52,7 @@ repos: - --ignore-words-list=metadat,splitted,meaned,wil,whats,additionals,alle,alot,bund,currenty,datas,farenheit,falsy,fo,haa,hass,iif,incomfort,ines,ist,nam,nd,pres,pullrequests,resset,rime,ser,serie,te,technik,ue,unsecure,withing,zar,MAPE,mape - --skip="./.*,*.csv,*.json,*.ambr" - --quiet-level=2 - exclude_types: [ csv, json ] + exclude_types: [csv, json] exclude: ^tests/|generated/^.github - repo: https://github.com/asottile/blacken-docs diff --git a/README.md b/README.md index 7022692..457e10c 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,29 @@ # About + Code for ["General-Purpose Brain Foundation Models for Time-Series Neuroimaging Data"](https://openreview.net/forum?id=HwDQH0r37I) # Getting Started + ## 0. Install the requirements + To install the requirements, run the following command: + ```bash pip install -r requirements.txt ``` + ## 1. Download and preprocess the data + Download the NMT data from [here](https://ilabel.ai/datasets/Nust-Millitary-Hospital-TUKl-NMT-EEG-Dataset/NMT-Scalp-EEG.zip) and extract it to the `data` folder. or you can use the following command: + ```bash wget https://ilabel.ai/datasets/Nust-Millitary-Hospital-TUKl-NMT-EEG-Dataset/NMT-Scalp-EEG.zip unzip NMT-Scalp-EEG.zip -d data ``` + or you can use the following command: + ```bash gdown 'https://drive.google.com/uc?id=1jD_AcmfoaIfkOiO5lSU4J6IxHZtalnTk' @@ -22,7 +31,9 @@ unzip NMT.zip -d data/NMT/ ``` ## 2. Preprocess the data + To preprocess the data, run the following command: + ```bash python ./data/preprocess.py \ --dataset nmt \ @@ -31,10 +42,13 @@ python ./data/preprocess.py \ --exp_path ./data/NMT/NMT_dl/ \ --nmt_raw_path ./data/NMT/nmt_scalp_eeg_dataset/ ``` + It will preprocess the data and save it as .arrow files in the `data/NMT/nmt_dl/` folder. ## 3. Train the model + To train the model, run the following command: + ```bash accelerate launch bfm/train/train.py \ --config bfm/configs/bfm-t5-base-nmt.yaml \ @@ -49,10 +63,13 @@ accelerate launch bfm/train/train.py \ --n-gpus 4 \ --max-steps 2000 ``` + This will train the model on the NMT dataset using the T5-base model. You can modify the config file to use a different model or dataset. ## 4. Evaluate the model + To evaluate the model, run the following command: + ```bash CUDA_VISIBLE_DEVICES=0 python bfm/evaluate/evaluate.py \ --config_path "bfm/configs/bfm-inference.yaml" \ @@ -60,10 +77,13 @@ CUDA_VISIBLE_DEVICES=0 python bfm/evaluate/evaluate.py \ --seed 2024 \ --device "cuda" ``` + [Note:] You can also use 'data/download_moabb_datasets.py' to download the MOABB datasets. Then you can use 'data/preprocess_moabb.py' to preprocess the MOABB datasets and evaluate the model on them. # Citation + If you find this code useful, please consider citing our paper: + ``` @inproceedings{ bayazi2024generalpurpose, diff --git a/bfm/configs/bfm-t5-base-nmt.yaml b/bfm/configs/bfm-t5-base-nmt.yaml index ad44562..53df0cd 100644 --- a/bfm/configs/bfm-t5-base-nmt.yaml +++ b/bfm/configs/bfm-t5-base-nmt.yaml @@ -1,7 +1,7 @@ training_data_paths: -- ./data/NMT/NMT_dl/nmt_dl/train/ + - ./data/NMT/NMT_dl/nmt_dl/train/ validation_data_paths: -- ./data/NMT/NMT_dl/nmt_dl/val/ + - ./data/NMT/NMT_dl/nmt_dl/val/ dataset: "nmt" project_dir: "./bfm/" experiment_name: "test_experiment_v0"