Update README.md
Browse files
README.md
CHANGED
|
@@ -151,3 +151,177 @@ within a single shared encoder via **sensor-type embeddings** -- no modality spe
|
|
| 151 |
**Weights license:** The released model weights are licensed under **Creative Commons Attribution–NoDerivatives 4.0 (CC BY-ND 4.0)**.
|
| 152 |
This section summarizes the practical implications for users. *This is not legal advice; please read the full license text.*
|
| 153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
**Weights license:** The released model weights are licensed under **Creative Commons Attribution–NoDerivatives 4.0 (CC BY-ND 4.0)**.
|
| 152 |
This section summarizes the practical implications for users. *This is not legal advice; please read the full license text.*
|
| 153 |
|
| 154 |
+
### ✅ You may
|
| 155 |
+
- **Use** and **redistribute** the **unmodified** LUNA weights (including in commercial settings) **with proper attribution** to the LUNA authors.
|
| 156 |
+
- **Fine-tune / adapt** the weights **for your internal use** (research or production) **without redistributing** the modified weights.
|
| 157 |
+
- **Publish your code, configs, logs, and papers** describing experiments with LUNA (please cite the paper).
|
| 158 |
+
|
| 159 |
+
### 🚫 You may not
|
| 160 |
+
- **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.
|
| 161 |
+
- **Imply endorsement** by the LUNA authors for any derivative or evaluation without our written permission.
|
| 162 |
+
- **Use the LUNA name** in a way that suggests your modified model is an official LUNA release.
|
| 163 |
+
|
| 164 |
+
### 🤝 How to contribute improvements (PR-gated releases)
|
| 165 |
+
We welcome community improvements via a **pull-request (PR)** workflow. If you believe your improvements should become an **official LUNA release**:
|
| 166 |
+
1. **Open a PR** in the [BioFoundation repository](https://github.com/pulp-bio/BioFoundation) describing the change (architecture/head/training recipe, datasets, preprocessing, compute).
|
| 167 |
+
2. Include **reproducibility artifacts**: configs, seeds, scripts, environment details, training/validation logs, and the **evaluation protocol** (e.g., TUAB/TUAR/TUSL) with exact splits.
|
| 168 |
+
3. Provide **comprehensive results** (AUROC/AUPR/BA, FLOPs, memory) vs. the baselines reported in the PanLUNA paper.
|
| 169 |
+
4. After **maintainer review**, approved changes will be **retrained/validated** and, if accepted, **released by the maintainers** as a new **official PanLUNA** checkpoint under **CC BY-ND 4.0**.
|
| 170 |
+
|
| 171 |
+
> Rationale: CC BY-ND protects users from fragmented, lower-quality “PanLUNA variants,” while still enabling internal fine-tuning and a path for the community to upstream improvements through review.
|
| 172 |
+
|
| 173 |
+
---
|
| 174 |
+
|
| 175 |
+
## 🔎 Model Summary
|
| 176 |
+
|
| 177 |
+
- **Goal:** Compact pan-modal biosignal foundation model for EEG, ECG, and PPG within one shared encoder, with robustnes
|
| 178 |
+
to missing modalities and feasibility for ultra-low-power edge deployment.
|
| 179 |
+
- **Core idea:** PanLUNA extends LUNA’s Channel-Unification Module from EEG channel/topology unification
|
| 180 |
+
to cross-modal fusion: EEG, ECG, and PPG channels are treated as entries in a unified query set, augmented with sensor-type embeddings, and fused through cross-attention with learned latent queries inside a single encoder.
|
| 181 |
+
- **Pre-training data:** Approximately 40,000 hours of heterogeneous biosignal data from five public datasets: TUEG and Siena for EEG, MIMIC-IV and CODE-15% for ECG, and PulseDB for synchronized ECG+PPG.
|
| 182 |
+
- **Downstream tasks:** TUAB EEG abnormality detection; PTB-XL ECG Superclass (5-class), Subclass (23-class), Form (19-class), and Rhythm (12-class) classification; CSN ECG (38-class) classification; and HMC five-class sleep staging using EEG+ECG to evaluate cross-modal fusion and missing-modality robustness.
|
| 183 |
+
|
| 184 |
+
---
|
| 185 |
+
|
| 186 |
+
## 🚀 Model Variants
|
| 187 |
+
|
| 188 |
+
Aimed for feasible ultra-low-power edge deployment, PanLUNA exists in a Tiny Variant, with the following parameters:
|
| 189 |
+
|
| 190 |
+
| Variant | Parameters |PanLUNA parameters |
|
| 191 |
+
|-----------------|----------------|--------------------------------------|
|
| 192 |
+
| PanLUNA | 5.4M |(`num_queries` = 4, `embed_dim` = 64) |
|
| 193 |
+
|
| 194 |
+
To obtain the model of different size, consider scaling these parameters accordingly (e.g. num_queries=6 leads to 12M parameters).
|
| 195 |
+
|
| 196 |
+
---
|
| 197 |
+
|
| 198 |
+
## 📊 Results
|
| 199 |
+
|
| 200 |
+
- **TUAB (Abnormal EEG Detection, bipolar montage, 22-channels):** 81.21% Balanced Accuracy, 0.899 AUROC, 0.893 AUPR.
|
| 201 |
+
- **HMC (EEG Sleep Staging Detection, 4-channels):** 74.16% Balanced Accuracy, 0.695 Cohen's Kappa, 0.765 Weighted F1.
|
| 202 |
+
- **ECG PTB-XL Super Class:** 0.908 AUROC
|
| 203 |
+
- **ECG PTB-XL Sub Class:** 0.888 AUROC
|
| 204 |
+
- **ECG PTB-XL Form:** 0.833 AUROC
|
| 205 |
+
- **ECG PTB-XL Rhythm:** 0.964 AUROC
|
| 206 |
+
- **ECG CSN:** 0.964 AUROC
|
| 207 |
+
|
| 208 |
+
---
|
| 209 |
+
|
| 210 |
+
## 🧠 Intended Use & Limitations
|
| 211 |
+
|
| 212 |
+
**Intended use.** Research on biosignal (EEG, ECG, PPG) representation learning & classification (abnormality, sleep stages, waveform and rhythm irregularities in ECG), especially when aspiring for robustness in available channels and modalities.
|
| 213 |
+
|
| 214 |
+
**Limitations.**
|
| 215 |
+
- **Not a medical device.** Do **not** use for clinical decisions without proper validation & regulatory clearance.
|
| 216 |
+
- **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.
|
| 217 |
+
- **Distribution shifts:** Performance varies across cohorts, devices, and label protocols; validate locally and consider domain adaptation.
|
| 218 |
+
|
| 219 |
+
---
|
| 220 |
+
|
| 221 |
+
## 🏗️ Architecture & Training
|
| 222 |
+
|
| 223 |
+
**PanLUNA Tokenizer & features:** Biosignals (EEG, ECG, PPG) are patch-segmented using shared convolution-based feature extractor; 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).
|
| 224 |
+
|
| 225 |
+
**PanLUNA Channel-Modality-Unification Module:** **Q learned queries** cross-attend to **channel-wise patch features** from different modalities to produce a **fixed Q×E latent** per patch; FFN + Transformer layers refine the query tokens. Complexity is **O(Q·C)** (linear in channels).
|
| 226 |
+
|
| 227 |
+
**Temporal encoder:** **Patch-wise Transformer** with **RoPE** operates on the latent sequence (length = #patches), **not** on channels×patches, reducing sequence length and cost substantially.
|
| 228 |
+
|
| 229 |
+
**No Modality Specific Encoders:** All modalities are processed within a single shared encoder, embedded only with modality-type embedding.
|
| 230 |
+
|
| 231 |
+
**Pre-training objective:** **Masked-patch reconstruction** with Smooth-L1; decoder uses **channel-indexed queries** to reconstruct masked tokens. **Query specialization loss** encourages diverse query–channel affinities.
|
| 232 |
+
|
| 233 |
+
---
|
| 234 |
+
|
| 235 |
+
## 🔧 How to Use
|
| 236 |
+
|
| 237 |
+
We provide `PanLUNA.safetensors`, weights for the PanLUNA model pretrained on the 40,000 hours of heterogenous biosignal data.
|
| 238 |
+
|
| 239 |
+
PanLUNA experiments can be viewed through two Hydra configurations in `BioFoundation/config/experiments`:
|
| 240 |
+
- **`PanLUNA_finetune.yaml`** → configuration for fine-tuning experiments.
|
| 241 |
+
- **`PanLUNA_pretrain.yaml`** → configuration for pre-training experiments.
|
| 242 |
+
|
| 243 |
+
---
|
| 244 |
+
|
| 245 |
+
## 🔧 Fine-tuning — General Checklist
|
| 246 |
+
|
| 247 |
+
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).
|
| 248 |
+
1. **Point to weights**: set `pretrained_safetensors_path: /path/to/PanLUNA.safetensors` in the experiment YAML.
|
| 249 |
+
2. **Preprocess data**: acquire fine-tuning dataset and follow preprocessing protocol (see guide in `/make_datasets/README.md`) to generate `train/test/val.h5` files.
|
| 250 |
+
3. **Update data module of `PanLUNA_finetune.yaml` config**:
|
| 251 |
+
- **Unimodal Experiments:**
|
| 252 |
+
- Change `override /data_module` to `finetune_data_module_unimodal_PanLUNA`.
|
| 253 |
+
- Check out `config/data_module/dataset_types.yaml` to learn about parameters for each dataset.
|
| 254 |
+
- Keep `/data_module: _target_` to `datasets.finetuning_unimodal_datasets_PanLUNA.FinetuningUnimodal_Dataset`.
|
| 255 |
+
- **HDF5 file location** → change `/data_module:hdf5_file` for `train`, `test`, and `val` with the path to the corresponding HDF5 data split file.
|
| 256 |
+
- Change `channels`, `location_fn` and `sensor_type` for the intended dataset.
|
| 257 |
+
- **Multimodal Experiments:**
|
| 258 |
+
- Change `override /data_module` to `finetune_data_module_multimodal_PanLUNA`.
|
| 259 |
+
- Keep `/data_module: _target_` to `datasets.finetuning_multimodal_datasets_PanLUNA.FinetuningMultimodal_Dataset`.
|
| 260 |
+
- **HDF5 file location** → change `/data_module:hdf5_file` for `train`, `test`, and `val` with the path to the corresponding HDF5 data split file.
|
| 261 |
+
- Follow the example and instructions in the `config/data_module/finetune_data_module_multimodal_PanLUNA.yaml` to adjust channels and slicing for each multimodal dataset.
|
| 262 |
+
4. **Task settings**:
|
| 263 |
+
- **Fine-tuning strategy:** override `finetuning: mode` with `full`, `freeze_encoder` or `lora`. Use `full` if you want to fully update PanLUNA's weights after pre-training. For training only classification head use `frozen_encoder`. For Low-Rank Adapation on selected layers use `lora`.
|
| 264 |
+
- **Classification type**: set `classification_type` (`bc`, `mcc` or `mlp`) and `model.num_classes` to match your downstream task. Change `model.num_classes` to describe the number of features in the output.
|
| 265 |
+
- Configuration file includes further `#CHANGEME` tags and instructions for a working example.
|
| 266 |
+
5. **Env vars**: export `DATA_PATH` (dataset root) and `CHECKPOINT_DIR` (artifacts).
|
| 267 |
+
6. **Trainer/optimizer**: adjust `gpus/devices`, `batch_size`, `max_epochs`, LR/scheduler if needed.
|
| 268 |
+
7. **I/O**: set `io.base_output_path` and confirm `io.checkpoint_dirpath` exists.
|
| 269 |
+
|
| 270 |
+
To launch fine-tuning (Hydra):
|
| 271 |
+
|
| 272 |
+
```bash
|
| 273 |
+
python -u run_train.py +experiment=PanLUNA_finetune
|
| 274 |
+
```
|
| 275 |
+
|
| 276 |
+
---
|
| 277 |
+
|
| 278 |
+
## ⚖️ Responsible AI, Risks & Biases
|
| 279 |
+
|
| 280 |
+
- **Clinical safety:** research-only; human oversight required.
|
| 281 |
+
- **Bias & drift:** montage/device/population differences can induce shifts; validate and monitor.
|
| 282 |
+
- **Artifacts & rare events:** robustness varies; use QC and task-appropriate preprocessing.
|
| 283 |
+
|
| 284 |
+
---
|
| 285 |
+
|
| 286 |
+
## 🔗 Sources
|
| 287 |
+
|
| 288 |
+
- **Code:** https://github.com/pulp-bio/BioFoundation
|
| 289 |
+
- **Paper:** PanLUNA: An Efficient and Robust Query-Unified Multimodal Model for Edge Biosignal Intelligence (arxiv:2604.04297)
|
| 290 |
+
|
| 291 |
+
---
|
| 292 |
+
|
| 293 |
+
## 📜 Citation
|
| 294 |
+
|
| 295 |
+
If you use PanLUNA, please cite:
|
| 296 |
+
|
| 297 |
+
```bibtex
|
| 298 |
+
@misc{zelic2026panluna,
|
| 299 |
+
title={PanLUNA: An Efficient and Robust Query-Unified Multimodal Model for Edge Biosignal Intelligence},
|
| 300 |
+
author={Marija Zelic and Anna Tegon and Yawei Li and Thorir Mar Ingolfsson},
|
| 301 |
+
year={2026},
|
| 302 |
+
eprint={2604.04297},
|
| 303 |
+
archivePrefix={arXiv},
|
| 304 |
+
primaryClass={cs.AI},
|
| 305 |
+
url={https://arxiv.org/abs/2604.04297},
|
| 306 |
+
}
|
| 307 |
+
```
|
| 308 |
+
|
| 309 |
+
---
|
| 310 |
+
|
| 311 |
+
## 🛠️ Maintenance & Contact
|
| 312 |
+
|
| 313 |
+
- **Issues & support:** please open a GitHub issue in the BioFoundation repository.
|
| 314 |
+
|
| 315 |
+
---
|
| 316 |
+
---
|
| 317 |
+
|
| 318 |
+
## 🔗 Related Models
|
| 319 |
+
|
| 320 |
+
- **[LUNA](https://huggingface.co/PulpBio/LUNA)** — Transformer-based topology-agnostic EEG foundation model (NeurIPS 2025). Source of the channel-unification cross-attention module that LuMamba reuses.
|
| 321 |
+
- **[FEMBA](https://huggingface.co/PulpBio/FEMBA)** — Bidirectional Mamba foundation model for EEG. Source of the linear-complexity temporal backbone that LuMamba reuses.
|
| 322 |
+
- **[TinyMyo](https://huggingface.co/PulpBio/TinyMyo)** — Tiny foundation model for flexible EMG signal processing at the edge.
|
| 323 |
+
- **[LuMamba](https://huggingface.co/PulpBio/LuMamba)** - Extends LUNA's channel-unification to a linear-complexity Mamba backbone, with systematic analysis of LeJEPA for biosignal SSL.
|
| 324 |
+
|
| 325 |
+
## 🗒️ Changelog
|
| 326 |
+
|
| 327 |
+
- **v1.0:** Initial release of PanLUNA model card with pretrained checkpoint and instructions.
|