File size: 5,627 Bytes
a483f90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd1bc1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a483f90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd1bc1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
license: other
library_name: braindecode
tags:
- braindecode
- pytorch
- safetensors
- fnirs
- geonirs
- foundation-model
---

# GeoNIRS-Base (pretrained encoder)

Weights of GeoNIRS-Base, the geometry-aware fNIRS foundation model of Li et al. (2026), for
[`braindecode.models.GeoNIRS`](https://braindecode.org/stable/generated/braindecode.models.GeoNIRS.html).
They are the encoder of `checkpoint/geonirs_base.pt` of
[GeoNIRS/GeoNIRS](https://github.com/GeoNIRS/GeoNIRS/tree/81f8995e5c3aa6b70e55812b194fc04e4e7ea5b7/checkpoint)
at commit `81f8995`, pretrained on 8 datasets (383.30 h), converted by `convert.py`.

```python
from braindecode.models import GeoNIRS

model = GeoNIRS.from_pretrained(
    "braindecode/geonirs-base-pretrained",
    chs_info=raw.info["chs"],
    n_outputs=2,
    n_times=60,
)
features = model(x, return_features=True)["features"]
```

The classification head (`final_layer`) is not part of the release: it reads
`2 * n_latent_channels * n_patches * feature_dim` features, so `from_pretrained` builds it for
your `n_times` and `n_outputs`. Fine-tune or linear-probe before use.

## Intended input

The inputs of the GeoNIRS paper (Appendix B.1): HbO and HbR in µmol/L resampled to 5 Hz, each
chromophore z-scored per recording over all its valid channels and time points, in windows of at
most 150 samples (30 s, the 15 rows of the temporal position embedding). `chs_info` gives each
HbO/HbR pair the positions of its source and detector (`loc[3:9]`, where MNE stores them); a NaN
marks a missing sample.

## Changes from the original release

`convert.py` unwraps the `{"model", "config"}` payload, builds the model from its `config`, drops
the two pretraining decoders (`hbo_to_hbr_decoder`, `hbr_to_hbo_decoder`: 122 of the 333
tensors), renames 6 tensors of the channel compressor and writes the encoder with `save_pretrained`.
The renames are plain prefix replacements: braindecode builds the compressor's feed-forward block from
a LayerNorm (`ffn_norm`) and its shared `FeedForwardBlock` (Linear, activation, dropout, Linear).

| original key | this repository | keys |
|---|---|---|
| `channel_compressor.ffn.0.{weight,bias}` (LayerNorm) | `channel_compressor.ffn_norm.{weight,bias}` | 2 |
| `channel_compressor.ffn.1.{weight,bias}` (Linear) | `channel_compressor.ffn.0.{weight,bias}` | 2 |
| `channel_compressor.ffn.4.{weight,bias}` (Linear) | `channel_compressor.ffn.3.{weight,bias}` | 2 |

The other 205 keys keep their names. `config.json` lists `projection_dims=[128, 96]`, the inner
widths of the chromophore projections: they run over `(embed_dim, *projection_dims, feature_dim)`, which is
the `projection_dimensions` `[192, 128, 96, 64]` of the original config. It also lists, at their defaults, the
numbers the original code fixes: `geometry_mlp_ratio` and `compressor_mlp_ratio` (2.0), `geometry_scale`
(0.02546058255683924, that is 25.46 mm), `time_embedding_init_std` and `latent_init_std` (0.02) and
`residual_init_scale` (0.1).

No value is changed: each of the 211 tensors is bitwise equal to its tensor in the original file (the six
renamed ones under their new names). This layout replaces revision `a483f904`, which holds the same
tensors under the authors' names.

## Verification

`GeoNIRS.from_pretrained` on these files (braindecode `32850d0b`) against braindecode's `GeoNIRS` on
revision `a483f904` (master before the renames, `252a0172`), on CPU and the same seeded inputs: the pinned
input, a batch with NaN samples and a `ch_mask`, `pool="mean_std"` at 60 samples, MNE-ordered `chs_info`
and an explicit `geometry`. In float32 and in float64 the features, the outputs (same head), the tokens
and their validity, and the features and outputs in train mode under one seed (the dropout draws) are
bitwise equal: 60 of 60 comparisons, max abs difference 0.0. A change of 1e-3 in one value of each renamed
tensor shows as a difference of 1e-5 or more in the features.

## Evaluation

Linear probe of the frozen encoder on DS42 (action mode, ds005935) and DS19 (pain intensity,
ds005777), with the folds and seeds of the paper. "Authors' pipeline" is GeoNIRS@81f8995 run end
to end; "braindecode" is `GeoNIRS` with a re-implementation of the authors' probe. Both build the
same windows (1628 and 1190), on which `GeoNIRS` gives the authors' encoder features exactly.

| Task | Metric | Paper | Authors' pipeline | braindecode |
|---|---|---|---|---|
| DS42 | macro-F1 | 0.7018 | 0.7000 | 0.7039 |
| DS42 | AUROC | 0.7840 | 0.7840 | 0.7840 |
| DS19 | macro-F1 | 0.5598 | 0.5599 | 0.5304 |
| DS19 | AUROC | 0.5683 | 0.5687 | 0.5549 |

## License and citation

The source repository has no licence file; the weights are by the GeoNIRS authors. Please cite:

```bibtex
@article{li2026geonirs,
  author  = {Li, Zongsheng and Zhu, Shengyuan and Zhang, Zimo and Li, Hanyao and Wang, Shengming and Liu, Quanying},
  title   = {{GeoNIRS}: Geometry-Aware Pretraining for Heterogeneous {fNIRS} Representation Learning},
  journal = {arXiv preprint arXiv:2610.17845},
  year    = {2026},
}
```

## Conversion

`convert.py` (in this repository) was run with braindecode at `32850d0b`:

```
python convert.py geonirs_base.pt <out_dir>
```

| file | sha256 |
|---|---|
| `model.safetensors` | `b60b1a7851ee762881ca4d0467a52c4383c9fa38642e28e0138d541df50dbb63` |
| `config.json` | `d3254e64e487566cd1f33fc3fe833973ddd08201066ca11e6329d1ea4ba7e0e5` |
| `convert.py` | `6e0e62f7f26b00143fed34aef3e6f95961598971df0fa66013654cf55747f8a5` |
| original `checkpoint/geonirs_base.pt` (GeoNIRS/GeoNIRS@81f8995, Git LFS) | `61e4d72221dd99225ac405124515c070a2ef0467df83a01f05e918e0941cd06a` |