dbroustail commited on
Commit
5b1eb7f
·
verified ·
1 Parent(s): 2469129

Preliminary sections of README.md

Browse files
Files changed (1) hide show
  1. README.md +172 -1
README.md CHANGED
@@ -23,4 +23,175 @@ Topology-Invariant and Efficient EEG Modeling</h1>
23
  <a href="https://arxiv.org/abs/2603.19100">
24
  <img src="https://img.shields.io/badge/arXiv-2510.22257-b31b1b.svg" alt="Paper">
25
  </a>
26
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  <a href="https://arxiv.org/abs/2603.19100">
24
  <img src="https://img.shields.io/badge/arXiv-2510.22257-b31b1b.svg" alt="Paper">
25
  </a>
26
+ </p>
27
+
28
+
29
+ **LuMamba** (Latent Unified Mamba) is an **EEG foundation model** built on efficient **Mamba state-space learning**, capable of handling **heterogeneous channel topologies**.
30
+ LuMamba addresses varying channel layouts with **LUNA channel unification**, projecting a given EEG channel layout to a **fixed latent topology**, and overcomes the quadratic complexity of transformers with **FEMBA**'s efficient **bidirectional Mamba encoder**.
31
+
32
+ ---
33
+
34
+ ## 🔒 License & Usage Policy (Weights)
35
+
36
+ **Weights license:** The released model weights are licensed under **Creative Commons Attribution–NoDerivatives 4.0 (CC BY-ND 4.0)**. This section summarizes the practical implications for users. *This is not legal advice; please read the full license text.*
37
+
38
+ ### ✅ You may
39
+ - **Use** and **redistribute** the **unmodified** LuMamba weights (including in commercial settings) **with proper attribution** to the LuMamba authors.
40
+ - **Fine-tune / adapt** the weights **for your internal use** (research or production) **without redistributing** the modified weights.
41
+ - **Publish your code, configs, logs, and papers** describing experiments with LuMamba (please cite the paper).
42
+
43
+ ### 🚫 You may not
44
+ - **Share, host, or redistribute any modified weights** (including LoRA/adapter/delta checkpoints or pruned/quantized variants). Any parameter set that encodes an adaptation is considered a derivative and cannot be shared under CC BY-ND 4.0.
45
+ - **Imply endorsement** by the LuMamba authors for any derivative or evaluation without our written permission.
46
+ - **Use the LuMamba name** in a way that suggests your modified model is an official LuMamba release.
47
+
48
+ ### 🤝 How to contribute improvements (PR-gated releases)
49
+ We welcome community improvements via a **pull-request (PR)** workflow. If you believe your improvements should become an **official LuMamba release**:
50
+ 1. **Open a PR** in the [BioFoundation repository](https://github.com/pulp-bio/BioFoundation) describing the change (architecture/head/training recipe, datasets, preprocessing, compute).
51
+ 2. Include **reproducibility artifacts**: configs, seeds, scripts, environment details, training/validation logs, and the **evaluation protocol** (e.g., TUAB/TUAR/TUSL) with exact splits.
52
+ 3. Provide **comprehensive results** (AUROC/AUPR/BA, FLOPs, memory) vs. the baselines reported in the LuMamba paper.
53
+ 4. After **maintainer review**, approved changes will be **retrained/validated** and, if accepted, **released by the maintainers** as a new **official LuMamba** checkpoint under **CC BY-ND 4.0**.
54
+
55
+ > Rationale: CC BY-ND protects users from fragmented, lower-quality “LuMamba variants,” while still enabling internal fine-tuning and a path for the community to upstream improvements through review.
56
+
57
+ ---
58
+
59
+ ## 🔎 Model Summary
60
+
61
+ - **Goal:** Efficient and topology-agnostic EEG modeling with linear complexity in sequence length.
62
+ - **Core idea:** **Channel-Unification Module** uses **learned queries** (Q) with **cross-attention** to map any set of channels to a fixed latent space. **bidirectional Mamba blocks** then operate on that latent sequence.
63
+ - **Pre-training data:** TUEG, **>21,000 hours** of raw EEG; downstream subjects removed to avoid leakage.
64
+ - **Downstream tasks:** **TUAB** (abnormal), **TUAR** (artifacts), **TUSL** (slowing), **SEED-V** (emotion; unseen 62-ch montage), **APAVA** (Alzheimer's disease; unseen 16-ch layout, **TDBrain** (Parkinson's disease; unseen 26-ch layout)
65
+
66
+ ---
67
+
68
+ ## 🚀 Model Variants
69
+
70
+ The model currently exists in a Tiny Variant, with the following parameters:
71
+
72
+ | Variant | Parameters | FEMBA parameters |LUNA parameters |
73
+ |-----------------|------------|-----------------------------|------------------------------------|
74
+ | LuMamba_tiny | 4.1M |(`num_blocks` = 2, `exp` = 2)|(`num_queries` = 6, `embed_dim` = 64)
75
+
76
+ Larger model sizes can be attained by increasing the number of bi-Mamba blocks `num_blocks` (e.g. 8 bi-Mamba blocks yields 15M parameters).
77
+
78
+ ---
79
+
80
+ ## 📊 Results (Highlights)
81
+
82
+ - **TUAB (abnormal vs normal):** 80.99 % Bal. Acc., 0.883 AUROC, 0.892 AUPR.
83
+ (LuMamba-Tiny, pre-trained with LeJEPA-reconstruction).
84
+ - **APAVA (Alzheimer's detection)**: 0.955 AUROC, 0.970 AUPR (LuMamba-Tiny, pre-trained with LeJEPA-reconstruction).
85
+ - **TDBrain (Parkinson's detection)**: 0.961 AUROC, 0.960 AUPR (LuMamba-Tiny, pre-trained with LeJEPA-reconstruction).
86
+
87
+ **Efficiency:** Up to **377× fewer FLOPs** relative to transformer-based baselines and supporting up to **500x longer** EEG windows, thanks to the efficient FEMBA bi-Mamba encoder.
88
+
89
+ ---
90
+
91
+ ## 🧠 Intended Use & Limitations
92
+
93
+ **Intended use.** Research on EEG representation learning & classification (abnormality, artifacts, slowing, emotion), especially when **montages vary** or **channel counts are high**.
94
+
95
+ **Limitations.**
96
+ - **Not a medical device.** Do **not** use for clinical decisions without proper validation & regulatory clearance.
97
+ - **Unseen topologies:** Zero-shot transfer to **very different/dense** layouts (e.g., SEED-V) can underperform SOTA despite positive scaling; consider augmenting pre-training montage diversity and spatial encodings.
98
+ - **Distribution shifts:** Performance varies across cohorts, devices, and label protocols; validate locally and consider domain adaptation.
99
+
100
+ ---
101
+
102
+ ## 🏗️ Architecture & Training
103
+
104
+ **LUNA Tokenizer & features.** EEG is patch-segmented; temporal features via 1D conv w/ GroupNorm+GELU; **frequency features** (FFT mag/phase → MLP) are added; 3D electrode coordinates encoded via **NeRF-style sinusoids → MLP** (positional enc).
105
+
106
+ **LUNA Channel-Unification Module.** **Q learned queries** cross-attend to **channel-wise patch features** to produce a **fixed Q×E latent** per patch; FFN + Transformer layers refine the query tokens. Complexity is **O(Q·C)** (linear in channels).
107
+
108
+ **FEMBA Bi-Mamba Temporal encoder.** **Mamba blocks** process the embeddings in separate forward and backward streams.
109
+
110
+ **Pre-training objectives.** **Masked-patch reconstruction** is used to reconstruct masked tokens. In parallel, the **LeJEPA loss** encourages an isotropic Gaussian embedding distribution to minimize downstream prediction risk.
111
+
112
+ ---
113
+
114
+ ## 🔧 How to Use
115
+
116
+ LuMamba weights are organized by pre-training configuration:
117
+
118
+ - **`Reconstruction-only`** → variants pre-trained with masked reconstruction exclusively
119
+ - **`LeJEPA-reconstruction`** → variants pre-trained with a balanced mixture of masked reconstruction and LeJEPA losses. Variants exist for two different LeJEPA hyperparameters: 128 and 300 projection slices.
120
+ - **`LeJEPA-only`** → variant pre-trained with LeJEPA exclusively.
121
+
122
+ All variants are pre-trained on TUEG.
123
+
124
+ LuMamba experiments are categorized by two Hydra configurations, in `BioFoundation/config/experiments`:
125
+ - **`LuMamba_finetune.yaml`** → configuration for fine-tuning experiments.
126
+ - **`LuMamba_pretrain.yaml`** → configuration for pre-training experiments.
127
+
128
+ ---
129
+
130
+ ## 🔧 Fine-tuning — General Checklist
131
+
132
+ 0. **Install & read data prep**: clone the [BioFoundation repo](https://github.com/pulp-bio/BioFoundation), set up the environment as described there, then open `make_datasets/README.md` for dataset-specific notes (naming, expected folder layout, and common pitfalls).
133
+ 1. **Point to weights**: set `pretrained_safetensors_path: /path/to/LuMamba_*.safetensors` in the experiment YAML.
134
+ 2. **Preprocess data**: acquire fine-tuning dataset and follow preprocessing protocol (in `/make_datasets/README.md` or in the paper)to generate `train/test/val.h5` files.
135
+ 3. **Update data module**:
136
+ - **TUH datasets (TUAB/TUSL/TUAR)** → change `_target_` in `/data_module:` to `datasets.tuh_dataset.TUH_Dataset`.
137
+ - **Other** → change `/data_module:_target_` to corresponding dataset.py file in `BioFoundation/datasets` (e.g., for TDBrain dataset use `_target_:datasets.tdbrain_dataset.TDBrain_Dataset`)
138
+ - **HDF5 file location** → change `/data_module:hdf5_file` for `train`, `test`, and `val` with the path to the corresponding HDF5 data split file.
139
+ 4. **Task settings**:
140
+ - **Task type**: override with `/task:finetune_task_LUNA` for classification and `/task:finetune_regression_task_LuMamba` for regression tasks
141
+ - **Classification type**: set `classification_type` (`bc`, `mcc`) and `model.num_classes` to match your downstream task. In a regression scenario,`mcc` is used and `model.num_classes` describes the number of features in the output.
142
+ - **Classifier choice**: set `/model:classifier_option` (`mamba` for FEMBA classifier, `linear` for single-layer linear classifier,`null` for default LUNA classifier)
143
+ 5. **Env vars**: export `DATA_PATH` (dataset root) and `CHECKPOINT_DIR` (artifacts).
144
+ 6. **Trainer/optimizer**: adjust `gpus/devices`, `batch_size`, `max_epochs`, LR/scheduler if needed.
145
+ 7. **I/O**: set `io.base_output_path` and confirm `io.checkpoint_dirpath` exists.
146
+
147
+
148
+ To launch fine-tuning (Hydra):
149
+
150
+ ```bash
151
+ python -u run_train.py +experiment=LuMamba_finetune
152
+ ```
153
+
154
+ ---
155
+
156
+ ## ⚖️ Responsible AI, Risks & Biases
157
+
158
+ - **Clinical safety:** research-only; human oversight required.
159
+ - **Bias & drift:** montage/device/population differences can induce shifts; validate and monitor.
160
+ - **Artifacts & rare events:** robustness varies; use QC and task-appropriate preprocessing.
161
+
162
+ ---
163
+
164
+ ## 🔗 Sources
165
+
166
+ - **Code:** https://github.com/pulp-bio/BioFoundation
167
+ - **Paper:** LuMamba: Latent Unified Mamba for Electrode Topology-Invariant and Efficient EEG Modeling (arxiv:2603.19100)
168
+
169
+ ---
170
+
171
+ ## 📜 Citation
172
+
173
+ If you use LuMamba, please cite:
174
+
175
+ ```bibtex
176
+ @misc{broustail2026lumambalatentunifiedmamba,
177
+ title={LuMamba: Latent Unified Mamba for Electrode Topology-Invariant and Efficient EEG Modeling},
178
+ author={Danaé Broustail and Anna Tegon and Thorir Mar Ingolfsson and Yawei Li and Luca Benini},
179
+ year={2026},
180
+ eprint={2603.19100},
181
+ archivePrefix={arXiv},
182
+ primaryClass={cs.AI},
183
+ url={https://arxiv.org/abs/2603.19100},
184
+ }
185
+ ```
186
+
187
+ ---
188
+
189
+ ## 🛠️ Maintenance & Contact
190
+
191
+ - **Issues & support:** please open a GitHub issue in the BioFoundation repository.
192
+
193
+ ---
194
+
195
+ ## 🗒️ Changelog
196
+
197
+ - **v1.0:** Initial release of LuMamba model card with task-specific checkpoints and instructions.