s42chen commited on
Commit
4aeddd8
·
verified ·
1 Parent(s): 2ad13e8

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S002/data.py +33 -0
  2. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S002/infer.py +24 -0
  3. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S002/training.json +844 -0
  4. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/covariances.py +25 -0
  5. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/data.py +33 -0
  6. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/features.py +63 -0
  7. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/infer.py +24 -0
  8. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/infer.sh +3 -0
  9. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/model.py +103 -0
  10. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/training.json +2097 -0
  11. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/config.json +205 -0
  12. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/covariances.py +25 -0
  13. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/data.py +33 -0
  14. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/features.py +63 -0
  15. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/infer.py +24 -0
  16. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/infer.sh +3 -0
  17. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/model.py +111 -0
  18. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/training.json +0 -0
  19. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/alpha_features.py +45 -0
  20. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/config.json +611 -0
  21. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/covariances.py +25 -0
  22. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/data.py +33 -0
  23. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/envelope_features.py +44 -0
  24. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/features.py +63 -0
  25. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/frequency_features.py +11 -0
  26. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/infer.py +24 -0
  27. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/infer.sh +3 -0
  28. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/model.py +161 -0
  29. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/alpha_features.py +45 -0
  30. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/config.json +637 -0
  31. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/covariances.py +25 -0
  32. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/envelope_features.py +44 -0
  33. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/frequency_features.py +11 -0
  34. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/infer.py +24 -0
  35. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/infer.sh +3 -0
  36. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/model.py +179 -0
  37. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S032/infer.py +24 -0
  38. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/alpha_features.py +45 -0
  39. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/covariances.py +25 -0
  40. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/data.py +33 -0
  41. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/features.py +63 -0
  42. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/infer.py +24 -0
  43. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/infer.sh +3 -0
  44. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/tangent_features.py +25 -0
  45. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/alpha_features.py +45 -0
  46. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/config.json +682 -0
  47. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/covariances.py +25 -0
  48. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/data.py +33 -0
  49. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/envelope_features.py +44 -0
  50. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/features.py +63 -0
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S002/data.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from functools import lru_cache
3
+ from pathlib import Path
4
+ import numpy as np
5
+ import torch
6
+ @lru_cache(maxsize=8)
7
+ def array(path):return np.load(path,mmap_mode='r',allow_pickle=False)
8
+ class Dataset(torch.utils.data.Dataset):
9
+ def __init__(self,root,limit=None,cache=False):
10
+ self.root=Path(root)
11
+ self.rows=json.loads((self.root/'manifest.json').read_text())['samples']
12
+ if limit:self.rows=self.rows[:limit]
13
+ self.cached=None
14
+ if cache and self.rows:
15
+ from collections import defaultdict
16
+ groups=defaultdict(list)
17
+ for i,r in enumerate(self.rows):groups[r['path']].append((i,r['index']))
18
+ for name,indices in groups.items():
19
+ path=(self.root/name).resolve()
20
+ if not path.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
21
+ source=np.load(path,mmap_mode='r',allow_pickle=False)
22
+ if self.cached is None:self.cached=torch.empty((len(self.rows),*source.shape[1:]),dtype=torch.float32)
23
+ dst,src=zip(*indices)
24
+ self.cached[list(dst)]=torch.as_tensor(source[list(src)]/100,dtype=torch.float32)
25
+ def __len__(self):return len(self.rows)
26
+ def __getitem__(self,i):
27
+ r=self.rows[i]
28
+ if self.cached is not None:return self.cached[i],r.get('label',-1),r['id']
29
+ p=(self.root/r['path']).resolve()
30
+ if not p.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
31
+ # Division precedes float32 conversion, matching official FACED/TUEV collate.
32
+ x=np.asarray(array(str(p))[r['index']])/100
33
+ return torch.as_tensor(x,dtype=torch.float32),r.get('label',-1),r['id']
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S002/infer.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse,json
2
+ from pathlib import Path
3
+ import numpy as np
4
+ import torch
5
+ from model import SharedSpectral,SPECS
6
+ from data import Dataset
7
+
8
+ def main():
9
+ ap=argparse.ArgumentParser();ap.add_argument('input',type=Path);ap.add_argument('output',type=Path);a=ap.parse_args()
10
+ root=Path(__file__).resolve().parent
11
+ cfg=json.loads((root/'config.json').read_text())
12
+ track=json.loads((a.input/'manifest.json').read_text())['track']
13
+ if track not in SPECS: raise ValueError('Unknown track')
14
+ torch.set_num_threads(4)
15
+ device='cuda' if torch.cuda.is_available() else 'cpu'
16
+ model=SharedSpectral(**cfg['architecture']).to(device)
17
+ model.load_state_dict(torch.load(root/'weights.pt',map_location=device,weights_only=True),strict=True)
18
+ model.eval();a.output.mkdir(parents=True,exist_ok=True)
19
+ loader=torch.utils.data.DataLoader(Dataset(a.input),batch_size=128,num_workers=0,shuffle=False)
20
+ with torch.inference_mode(),(a.output/'predictions.jsonl').open('w') as f:
21
+ for x,_,ids in loader:
22
+ p=model(track,x.to(device)).softmax(-1).cpu().numpy()
23
+ for sid,pp in zip(ids,p):f.write(json.dumps({'id':sid,'probabilities':pp.tolist()})+'\n')
24
+ if __name__=='__main__':main()
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S002/training.json ADDED
@@ -0,0 +1,844 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "settings": {
3
+ "output": "/workspace/research/runs/spectral1",
4
+ "seed": 42,
5
+ "epochs": 30,
6
+ "steps": 500,
7
+ "batch_size": 128,
8
+ "lr": 0.0005,
9
+ "width": 256,
10
+ "depth": 3,
11
+ "dropout": 0.35,
12
+ "weight_decay": 0.05,
13
+ "mixup": 0.0,
14
+ "init": null
15
+ },
16
+ "shared_backbone": "backbone",
17
+ "all_tracks_update_shared_backbone": true,
18
+ "normalization_fit_split": "train",
19
+ "parameters": 14112534,
20
+ "history": [
21
+ {
22
+ "epoch": 1,
23
+ "updates_by_track": 100,
24
+ "losses": {
25
+ "faced": 1.837755205631256,
26
+ "tuev": 0.4842070505023003,
27
+ "ad65": 0.21590098470449448,
28
+ "openbmi": 0.5858061927556991,
29
+ "longitudinal": 0.42181126683950426
30
+ },
31
+ "validation": {
32
+ "faced": {
33
+ "class_counts": [
34
+ 180,
35
+ 180,
36
+ 180,
37
+ 180,
38
+ 240,
39
+ 180,
40
+ 180,
41
+ 180,
42
+ 180
43
+ ],
44
+ "predicted_class_counts": [
45
+ 257,
46
+ 245,
47
+ 165,
48
+ 195,
49
+ 119,
50
+ 133,
51
+ 193,
52
+ 53,
53
+ 320
54
+ ],
55
+ "confusion_matrix": [
56
+ [
57
+ 48,
58
+ 17,
59
+ 14,
60
+ 22,
61
+ 14,
62
+ 11,
63
+ 25,
64
+ 5,
65
+ 24
66
+ ],
67
+ [
68
+ 18,
69
+ 62,
70
+ 10,
71
+ 24,
72
+ 12,
73
+ 9,
74
+ 18,
75
+ 4,
76
+ 23
77
+ ],
78
+ [
79
+ 28,
80
+ 19,
81
+ 32,
82
+ 12,
83
+ 11,
84
+ 19,
85
+ 27,
86
+ 4,
87
+ 28
88
+ ],
89
+ [
90
+ 22,
91
+ 24,
92
+ 23,
93
+ 36,
94
+ 15,
95
+ 4,
96
+ 16,
97
+ 8,
98
+ 32
99
+ ],
100
+ [
101
+ 38,
102
+ 38,
103
+ 25,
104
+ 45,
105
+ 20,
106
+ 15,
107
+ 17,
108
+ 2,
109
+ 40
110
+ ],
111
+ [
112
+ 18,
113
+ 15,
114
+ 17,
115
+ 15,
116
+ 12,
117
+ 34,
118
+ 20,
119
+ 13,
120
+ 36
121
+ ],
122
+ [
123
+ 26,
124
+ 25,
125
+ 18,
126
+ 16,
127
+ 14,
128
+ 14,
129
+ 34,
130
+ 3,
131
+ 30
132
+ ],
133
+ [
134
+ 22,
135
+ 27,
136
+ 11,
137
+ 23,
138
+ 11,
139
+ 19,
140
+ 22,
141
+ 11,
142
+ 34
143
+ ],
144
+ [
145
+ 37,
146
+ 18,
147
+ 15,
148
+ 2,
149
+ 10,
150
+ 8,
151
+ 14,
152
+ 3,
153
+ 73
154
+ ]
155
+ ],
156
+ "per_class_recall": [
157
+ 0.26666666666666666,
158
+ 0.34444444444444444,
159
+ 0.17777777777777778,
160
+ 0.2,
161
+ 0.08333333333333333,
162
+ 0.18888888888888888,
163
+ 0.18888888888888888,
164
+ 0.06111111111111111,
165
+ 0.40555555555555556
166
+ ],
167
+ "balanced_accuracy": 0.21296296296296294,
168
+ "accuracy": 0.20833333333333334,
169
+ "weighted_f1": 0.19537403895666947,
170
+ "macro_f1": 0.19848342511012498,
171
+ "kappa": 0.11081397292328254,
172
+ "samples": 1680,
173
+ "reward": 0.21296296296296294,
174
+ "subjects": 20
175
+ },
176
+ "tuev": {
177
+ "class_counts": [
178
+ 119,
179
+ 291,
180
+ 669,
181
+ 86,
182
+ 500,
183
+ 13822
184
+ ],
185
+ "predicted_class_counts": [
186
+ 224,
187
+ 539,
188
+ 102,
189
+ 356,
190
+ 2505,
191
+ 11761
192
+ ],
193
+ "confusion_matrix": [
194
+ [
195
+ 19,
196
+ 29,
197
+ 26,
198
+ 0,
199
+ 9,
200
+ 36
201
+ ],
202
+ [
203
+ 0,
204
+ 12,
205
+ 0,
206
+ 0,
207
+ 279,
208
+ 0
209
+ ],
210
+ [
211
+ 7,
212
+ 65,
213
+ 10,
214
+ 0,
215
+ 581,
216
+ 6
217
+ ],
218
+ [
219
+ 0,
220
+ 36,
221
+ 0,
222
+ 35,
223
+ 0,
224
+ 15
225
+ ],
226
+ [
227
+ 0,
228
+ 1,
229
+ 0,
230
+ 1,
231
+ 468,
232
+ 30
233
+ ],
234
+ [
235
+ 198,
236
+ 396,
237
+ 66,
238
+ 320,
239
+ 1168,
240
+ 11674
241
+ ]
242
+ ],
243
+ "per_class_recall": [
244
+ 0.15966386554621848,
245
+ 0.041237113402061855,
246
+ 0.014947683109118086,
247
+ 0.4069767441860465,
248
+ 0.936,
249
+ 0.8445955722760816
250
+ ],
251
+ "balanced_accuracy": 0.4005701630865877,
252
+ "accuracy": 0.7889197391360496,
253
+ "weighted_f1": 0.8279708978381558,
254
+ "macro_f1": 0.2580220626735159,
255
+ "kappa": 0.3316723247964325,
256
+ "samples": 15487,
257
+ "reward": 0.4005701630865877,
258
+ "subjects": 58
259
+ },
260
+ "ad65": {
261
+ "class_counts": [
262
+ 464,
263
+ 393,
264
+ 486
265
+ ],
266
+ "predicted_class_counts": [
267
+ 544,
268
+ 346,
269
+ 453
270
+ ],
271
+ "confusion_matrix": [
272
+ [
273
+ 274,
274
+ 145,
275
+ 45
276
+ ],
277
+ [
278
+ 145,
279
+ 172,
280
+ 76
281
+ ],
282
+ [
283
+ 125,
284
+ 29,
285
+ 332
286
+ ]
287
+ ],
288
+ "per_class_recall": [
289
+ 0.5905172413793104,
290
+ 0.43765903307888043,
291
+ 0.6831275720164609
292
+ ],
293
+ "balanced_accuracy": 0.5704346154915506,
294
+ "accuracy": 0.5793000744601638,
295
+ "weighted_f1": 0.5799410326020693,
296
+ "macro_f1": 0.5720933182023854,
297
+ "kappa": 0.3650766423143895,
298
+ "samples": 1343,
299
+ "subject_metrics": {
300
+ "class_counts": [
301
+ 7,
302
+ 5,
303
+ 6
304
+ ],
305
+ "predicted_class_counts": [
306
+ 8,
307
+ 5,
308
+ 5
309
+ ],
310
+ "confusion_matrix": [
311
+ [
312
+ 4,
313
+ 3,
314
+ 0
315
+ ],
316
+ [
317
+ 2,
318
+ 2,
319
+ 1
320
+ ],
321
+ [
322
+ 2,
323
+ 0,
324
+ 4
325
+ ]
326
+ ],
327
+ "per_class_recall": [
328
+ 0.5714285714285714,
329
+ 0.4,
330
+ 0.6666666666666666
331
+ ],
332
+ "balanced_accuracy": 0.546031746031746,
333
+ "accuracy": 0.5555555555555556,
334
+ "weighted_f1": 0.560942760942761,
335
+ "macro_f1": 0.5535353535353535,
336
+ "kappa": 0.3239436619718309
337
+ },
338
+ "reward": 0.546031746031746,
339
+ "subjects": 18
340
+ },
341
+ "openbmi": {
342
+ "class_counts": [
343
+ 2200,
344
+ 2200
345
+ ],
346
+ "predicted_class_counts": [
347
+ 1443,
348
+ 2957
349
+ ],
350
+ "confusion_matrix": [
351
+ [
352
+ 964,
353
+ 1236
354
+ ],
355
+ [
356
+ 479,
357
+ 1721
358
+ ]
359
+ ],
360
+ "per_class_recall": [
361
+ 0.4381818181818182,
362
+ 0.7822727272727272
363
+ ],
364
+ "balanced_accuracy": 0.6102272727272727,
365
+ "accuracy": 0.6102272727272727,
366
+ "weighted_f1": 0.5983382295509261,
367
+ "macro_f1": 0.5983382295509261,
368
+ "kappa": 0.22045454545454546,
369
+ "samples": 4400,
370
+ "subject_scores": {
371
+ "19": 0.6950000000000001,
372
+ "35": 0.545,
373
+ "34": 0.5349999999999999,
374
+ "51": 0.6675,
375
+ "20": 0.6525,
376
+ "44": 0.7375,
377
+ "24": 0.5549999999999999,
378
+ "15": 0.5325,
379
+ "31": 0.68,
380
+ "26": 0.5525,
381
+ "23": 0.56
382
+ },
383
+ "reward": 0.6102272727272727,
384
+ "subjects": 11
385
+ },
386
+ "longitudinal": {
387
+ "class_counts": [
388
+ 4260,
389
+ 4158
390
+ ],
391
+ "predicted_class_counts": [
392
+ 4602,
393
+ 3816
394
+ ],
395
+ "confusion_matrix": [
396
+ [
397
+ 3652,
398
+ 608
399
+ ],
400
+ [
401
+ 950,
402
+ 3208
403
+ ]
404
+ ],
405
+ "per_class_recall": [
406
+ 0.8572769953051643,
407
+ 0.7715247715247715
408
+ ],
409
+ "balanced_accuracy": 0.8144008834149679,
410
+ "accuracy": 0.814920408648135,
411
+ "weighted_f1": 0.8145227049484558,
412
+ "macro_f1": 0.814404091564341,
413
+ "kappa": 0.6294215557528924,
414
+ "samples": 8418,
415
+ "subject_scores": {
416
+ "sub-G2021": 0.8322374249306739,
417
+ "sub-G2007": 0.7939135582111965,
418
+ "sub-G2019": 0.8546280166979509,
419
+ "sub-G2031": 0.7822427227936398,
420
+ "sub-G2015": 0.8509791437797529,
421
+ "sub-CTR002": 0.8928359222476869,
422
+ "sub-G2011": 0.7801365675763949,
423
+ "sub-G2035": 0.9022323249571733,
424
+ "sub-CTR003": 0.46374458874458874
425
+ },
426
+ "reward": 0.7947722522154508,
427
+ "subjects": 9
428
+ }
429
+ },
430
+ "seconds": 8.115101099014282
431
+ },
432
+ {
433
+ "epoch": 2,
434
+ "updates_by_track": 200,
435
+ "losses": {
436
+ "faced": 1.3197942888736724,
437
+ "tuev": 0.35953703671693804,
438
+ "ad65": 0.17408071279525758,
439
+ "openbmi": 0.4457417243719101,
440
+ "longitudinal": 0.32790970653295515
441
+ },
442
+ "validation": {
443
+ "faced": {
444
+ "class_counts": [
445
+ 180,
446
+ 180,
447
+ 180,
448
+ 180,
449
+ 240,
450
+ 180,
451
+ 180,
452
+ 180,
453
+ 180
454
+ ],
455
+ "predicted_class_counts": [
456
+ 175,
457
+ 179,
458
+ 184,
459
+ 261,
460
+ 229,
461
+ 121,
462
+ 161,
463
+ 124,
464
+ 246
465
+ ],
466
+ "confusion_matrix": [
467
+ [
468
+ 30,
469
+ 12,
470
+ 14,
471
+ 28,
472
+ 25,
473
+ 8,
474
+ 27,
475
+ 8,
476
+ 28
477
+ ],
478
+ [
479
+ 9,
480
+ 57,
481
+ 9,
482
+ 28,
483
+ 28,
484
+ 5,
485
+ 18,
486
+ 13,
487
+ 13
488
+ ],
489
+ [
490
+ 24,
491
+ 15,
492
+ 34,
493
+ 26,
494
+ 13,
495
+ 16,
496
+ 15,
497
+ 12,
498
+ 25
499
+ ],
500
+ [
501
+ 12,
502
+ 15,
503
+ 29,
504
+ 44,
505
+ 29,
506
+ 2,
507
+ 14,
508
+ 12,
509
+ 23
510
+ ],
511
+ [
512
+ 15,
513
+ 25,
514
+ 28,
515
+ 49,
516
+ 50,
517
+ 15,
518
+ 16,
519
+ 12,
520
+ 30
521
+ ],
522
+ [
523
+ 15,
524
+ 7,
525
+ 20,
526
+ 17,
527
+ 22,
528
+ 43,
529
+ 12,
530
+ 20,
531
+ 24
532
+ ],
533
+ [
534
+ 26,
535
+ 15,
536
+ 15,
537
+ 28,
538
+ 20,
539
+ 11,
540
+ 32,
541
+ 15,
542
+ 18
543
+ ],
544
+ [
545
+ 19,
546
+ 22,
547
+ 18,
548
+ 25,
549
+ 25,
550
+ 15,
551
+ 15,
552
+ 19,
553
+ 22
554
+ ],
555
+ [
556
+ 25,
557
+ 11,
558
+ 17,
559
+ 16,
560
+ 17,
561
+ 6,
562
+ 12,
563
+ 13,
564
+ 63
565
+ ]
566
+ ],
567
+ "per_class_recall": [
568
+ 0.16666666666666666,
569
+ 0.31666666666666665,
570
+ 0.18888888888888888,
571
+ 0.24444444444444444,
572
+ 0.20833333333333334,
573
+ 0.2388888888888889,
574
+ 0.17777777777777778,
575
+ 0.10555555555555556,
576
+ 0.35
577
+ ],
578
+ "balanced_accuracy": 0.22191358024691357,
579
+ "accuracy": 0.22142857142857142,
580
+ "weighted_f1": 0.21979152243904798,
581
+ "macro_f1": 0.22003492637365382,
582
+ "kappa": 0.12321945847597604,
583
+ "samples": 1680,
584
+ "reward": 0.22191358024691357,
585
+ "subjects": 20
586
+ },
587
+ "tuev": {
588
+ "class_counts": [
589
+ 119,
590
+ 291,
591
+ 669,
592
+ 86,
593
+ 500,
594
+ 13822
595
+ ],
596
+ "predicted_class_counts": [
597
+ 113,
598
+ 573,
599
+ 83,
600
+ 202,
601
+ 2202,
602
+ 12314
603
+ ],
604
+ "confusion_matrix": [
605
+ [
606
+ 0,
607
+ 37,
608
+ 27,
609
+ 0,
610
+ 22,
611
+ 33
612
+ ],
613
+ [
614
+ 0,
615
+ 12,
616
+ 0,
617
+ 0,
618
+ 279,
619
+ 0
620
+ ],
621
+ [
622
+ 3,
623
+ 104,
624
+ 12,
625
+ 0,
626
+ 527,
627
+ 23
628
+ ],
629
+ [
630
+ 0,
631
+ 24,
632
+ 0,
633
+ 51,
634
+ 0,
635
+ 11
636
+ ],
637
+ [
638
+ 0,
639
+ 0,
640
+ 0,
641
+ 1,
642
+ 468,
643
+ 31
644
+ ],
645
+ [
646
+ 110,
647
+ 396,
648
+ 44,
649
+ 150,
650
+ 906,
651
+ 12216
652
+ ]
653
+ ],
654
+ "per_class_recall": [
655
+ 0.0,
656
+ 0.041237113402061855,
657
+ 0.017937219730941704,
658
+ 0.5930232558139535,
659
+ 0.936,
660
+ 0.8838084213572566
661
+ ],
662
+ "balanced_accuracy": 0.412001001717369,
663
+ "accuracy": 0.8238522631884807,
664
+ "weighted_f1": 0.849353580581419,
665
+ "macro_f1": 0.2825119959741656,
666
+ "kappa": 0.38132710505585,
667
+ "samples": 15487,
668
+ "reward": 0.412001001717369,
669
+ "subjects": 58
670
+ },
671
+ "ad65": {
672
+ "class_counts": [
673
+ 464,
674
+ 393,
675
+ 486
676
+ ],
677
+ "predicted_class_counts": [
678
+ 536,
679
+ 352,
680
+ 455
681
+ ],
682
+ "confusion_matrix": [
683
+ [
684
+ 279,
685
+ 150,
686
+ 35
687
+ ],
688
+ [
689
+ 152,
690
+ 170,
691
+ 71
692
+ ],
693
+ [
694
+ 105,
695
+ 32,
696
+ 349
697
+ ]
698
+ ],
699
+ "per_class_recall": [
700
+ 0.6012931034482759,
701
+ 0.43256997455470736,
702
+ 0.7181069958847737
703
+ ],
704
+ "balanced_accuracy": 0.5839900246292523,
705
+ "accuracy": 0.5941921072226359,
706
+ "weighted_f1": 0.5947617631793346,
707
+ "macro_f1": 0.5853799732304393,
708
+ "kappa": 0.38774750539323577,
709
+ "samples": 1343,
710
+ "subject_metrics": {
711
+ "class_counts": [
712
+ 7,
713
+ 5,
714
+ 6
715
+ ],
716
+ "predicted_class_counts": [
717
+ 6,
718
+ 6,
719
+ 6
720
+ ],
721
+ "confusion_matrix": [
722
+ [
723
+ 3,
724
+ 4,
725
+ 0
726
+ ],
727
+ [
728
+ 2,
729
+ 2,
730
+ 1
731
+ ],
732
+ [
733
+ 1,
734
+ 0,
735
+ 5
736
+ ]
737
+ ],
738
+ "per_class_recall": [
739
+ 0.42857142857142855,
740
+ 0.4,
741
+ 0.8333333333333334
742
+ ],
743
+ "balanced_accuracy": 0.5539682539682539,
744
+ "accuracy": 0.5555555555555556,
745
+ "weighted_f1": 0.5582750582750583,
746
+ "macro_f1": 0.5528360528360529,
747
+ "kappa": 0.33333333333333337
748
+ },
749
+ "reward": 0.5539682539682539,
750
+ "subjects": 18
751
+ },
752
+ "openbmi": {
753
+ "class_counts": [
754
+ 2200,
755
+ 2200
756
+ ],
757
+ "predicted_class_counts": [
758
+ 2332,
759
+ 2068
760
+ ],
761
+ "confusion_matrix": [
762
+ [
763
+ 1461,
764
+ 739
765
+ ],
766
+ [
767
+ 871,
768
+ 1329
769
+ ]
770
+ ],
771
+ "per_class_recall": [
772
+ 0.6640909090909091,
773
+ 0.6040909090909091
774
+ ],
775
+ "balanced_accuracy": 0.634090909090909,
776
+ "accuracy": 0.634090909090909,
777
+ "weighted_f1": 0.6337612942557392,
778
+ "macro_f1": 0.6337612942557392,
779
+ "kappa": 0.2681818181818182,
780
+ "samples": 4400,
781
+ "subject_scores": {
782
+ "19": 0.7124999999999999,
783
+ "35": 0.55,
784
+ "34": 0.5425,
785
+ "51": 0.6525,
786
+ "20": 0.6875,
787
+ "44": 0.865,
788
+ "24": 0.57,
789
+ "15": 0.52,
790
+ "31": 0.685,
791
+ "26": 0.54,
792
+ "23": 0.65
793
+ },
794
+ "reward": 0.6340909090909091,
795
+ "subjects": 11
796
+ },
797
+ "longitudinal": {
798
+ "class_counts": [
799
+ 4260,
800
+ 4158
801
+ ],
802
+ "predicted_class_counts": [
803
+ 4743,
804
+ 3675
805
+ ],
806
+ "confusion_matrix": [
807
+ [
808
+ 3660,
809
+ 600
810
+ ],
811
+ [
812
+ 1083,
813
+ 3075
814
+ ]
815
+ ],
816
+ "per_class_recall": [
817
+ 0.8591549295774648,
818
+ 0.7395382395382395
819
+ ],
820
+ "balanced_accuracy": 0.7993465845578521,
821
+ "accuracy": 0.800071275837491,
822
+ "weighted_f1": 0.7992702199536446,
823
+ "macro_f1": 0.7991010528725839,
824
+ "kappa": 0.5995269115485379,
825
+ "samples": 8418,
826
+ "subject_scores": {
827
+ "sub-G2021": 0.8247760032614722,
828
+ "sub-G2007": 0.6755647147391388,
829
+ "sub-G2019": 0.817720267605105,
830
+ "sub-G2031": 0.7768687400624462,
831
+ "sub-G2015": 0.887980417124405,
832
+ "sub-CTR002": 0.9382480264833206,
833
+ "sub-G2011": 0.7719037383413225,
834
+ "sub-G2035": 0.926835468058191,
835
+ "sub-CTR003": 0.5305735930735931
836
+ },
837
+ "reward": 0.7944967743054439,
838
+ "subjects": 9
839
+ }
840
+ },
841
+ "seconds": 9.67720913887024
842
+ }
843
+ ]
844
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/covariances.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared neural filter-bank covariance decoder with spatial input adapters."""
2
+ import torch
3
+ from torch import nn
4
+ SPECS={'faced':(32,10,9),'tuev':(16,5,6),'ad65':(19,10,3),'openbmi':(62,4,2),'longitudinal':(58,2,2)}
5
+ TRACKS=tuple(SPECS)
6
+ BANDS=[(1,4),(4,8),(8,12),(12,16),(16,20),(20,24),(24,28),(28,32),(32,40),(40,48)]
7
+
8
+ @torch.no_grad()
9
+ def extract_covariances(t,x):
10
+ x=torch.nan_to_num(x.float().flatten(2)).clamp(-1e5,1e5)
11
+ x=x-x.mean(-1,keepdim=True)
12
+ if t in ('faced','tuev'):
13
+ x=x/x.square().mean(-1,keepdim=True).clamp_min(1e-12).sqrt()
14
+ else:x=x-x.mean(1,keepdim=True)
15
+ # Per-window normalization, preserving spatial and frequency power ratios.
16
+ x=x/x.square().mean((1,2),keepdim=True).clamp_min(1e-12).sqrt()
17
+ frames=x.unfold(-1,400,200);frames=frames-frames.mean(-1,keepdim=True)
18
+ z=torch.fft.rfft(frames*torch.hann_window(400,device=x.device),dim=-1)/200
19
+ covs=[]
20
+ for lo,hi in BANDS:
21
+ v=z[...,2*lo:2*hi].flatten(2)
22
+ cov=(v.real@v.real.transpose(-1,-2)+v.imag@v.imag.transpose(-1,-2))/v.shape[-1]
23
+ covs.append(cov)
24
+ return torch.stack(covs,1)
25
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/data.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from functools import lru_cache
3
+ from pathlib import Path
4
+ import numpy as np
5
+ import torch
6
+ @lru_cache(maxsize=8)
7
+ def array(path):return np.load(path,mmap_mode='r',allow_pickle=False)
8
+ class Dataset(torch.utils.data.Dataset):
9
+ def __init__(self,root,limit=None,cache=False):
10
+ self.root=Path(root)
11
+ self.rows=json.loads((self.root/'manifest.json').read_text())['samples']
12
+ if limit:self.rows=self.rows[:limit]
13
+ self.cached=None
14
+ if cache and self.rows:
15
+ from collections import defaultdict
16
+ groups=defaultdict(list)
17
+ for i,r in enumerate(self.rows):groups[r['path']].append((i,r['index']))
18
+ for name,indices in groups.items():
19
+ path=(self.root/name).resolve()
20
+ if not path.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
21
+ source=np.load(path,mmap_mode='r',allow_pickle=False)
22
+ if self.cached is None:self.cached=torch.empty((len(self.rows),*source.shape[1:]),dtype=torch.float32)
23
+ dst,src=zip(*indices)
24
+ self.cached[list(dst)]=torch.as_tensor(source[list(src)]/100,dtype=torch.float32)
25
+ def __len__(self):return len(self.rows)
26
+ def __getitem__(self,i):
27
+ r=self.rows[i]
28
+ if self.cached is not None:return self.cached[i],r.get('label',-1),r['id']
29
+ p=(self.root/r['path']).resolve()
30
+ if not p.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
31
+ # Division precedes float32 conversion, matching official FACED/TUEV collate.
32
+ x=np.asarray(array(str(p))[r['index']])/100
33
+ return torch.as_tensor(x,dtype=torch.float32),r.get('label',-1),r['id']
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/features.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One shared residual backbone, five linear input adapters and output heads."""
2
+ import torch
3
+ from torch import nn
4
+
5
+ SPECS = {'faced': (32, 10, 9), 'tuev': (16, 5, 6), 'ad65': (19, 10, 3),
6
+ 'openbmi': (62, 4, 2), 'longitudinal': (58, 2, 2)}
7
+ TRACKS = tuple(SPECS)
8
+ EDGES = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,18,20,22,25,28,32,36,40,45,50,60,70,80,95]
9
+ COV_BANDS = [(1,4),(4,8),(8,12),(12,16),(16,20),(20,28),(28,40)]
10
+
11
+ def feature_dim(channels):
12
+ return channels * (4*(len(EDGES)-1)+4) + len(COV_BANDS)*channels*(channels-1)//2
13
+
14
+ @torch.no_grad()
15
+ def extract_features(track, x):
16
+ """Fixed features; no batch statistics or fitted inference transformations."""
17
+ x = x.float().flatten(2)
18
+ x = torch.nan_to_num(x, nan=0., posinf=1e5, neginf=-1e5).clamp(-1e5,1e5)
19
+ x = x - x.mean(-1,keepdim=True)
20
+ if track in ('ad65','openbmi','longitudinal'):
21
+ x = x - x.mean(1,keepdim=True)
22
+ rms = x.square().mean(-1).clamp_min(1e-12).sqrt()
23
+ norm = x / rms.unsqueeze(-1)
24
+ moments = torch.stack([rms.log(), norm.abs().amax(-1).clamp_min(1).log(),
25
+ norm.pow(4).mean(-1).clamp_min(1).log(),
26
+ (norm[...,1:]-norm[...,:-1]).square().mean(-1).clamp_min(1e-10).log()],-1)
27
+ frames = x.unfold(-1,400,200)
28
+ frames = frames - frames.mean(-1,keepdim=True)
29
+ window = torch.hann_window(400,device=x.device)
30
+ z = torch.fft.rfft(frames*window,dim=-1)/200
31
+ power = z.abs().square()
32
+ bands = torch.stack([power[...,2*lo:2*hi].mean(-1) for lo,hi in zip(EDGES[:-1],EDGES[1:])],-1)
33
+ lp = bands.mean(-2).clamp_min(1e-12).log()
34
+ variation = bands.clamp_min(1e-12).log().std(-2,correction=0)
35
+ relative_frequency = lp - lp.mean(-1,keepdim=True)
36
+ relative_channel = lp - lp.mean(1,keepdim=True)
37
+ parts = [torch.cat([lp, relative_frequency, relative_channel, variation, moments],-1).flatten(1)]
38
+ ii,jj = torch.triu_indices(x.shape[1],x.shape[1],offset=1,device=x.device)
39
+ for lo,hi in COV_BANDS:
40
+ v = z[...,2*lo:2*hi].flatten(2)
41
+ cov = v.real @ v.real.transpose(-1,-2) + v.imag @ v.imag.transpose(-1,-2)
42
+ d = cov.diagonal(dim1=-2,dim2=-1).clamp_min(1e-12).sqrt()
43
+ cor = cov / (d.unsqueeze(1)*d.unsqueeze(2)).clamp_min(1e-12)
44
+ parts.append(cor[:,ii,jj].clamp(-1,1))
45
+ result = torch.cat(parts,-1)
46
+ return torch.nan_to_num(result).clamp(-40,40)
47
+
48
+ class Standardize(nn.Module):
49
+ def __init__(self, dim):
50
+ super().__init__()
51
+ self.register_buffer('mean',torch.zeros(dim))
52
+ self.register_buffer('scale',torch.ones(dim))
53
+ def forward(self,x):
54
+ return ((x-self.mean)/self.scale).clamp(-8,8)
55
+
56
+ class Residual(nn.Module):
57
+ def __init__(self,width,dropout):
58
+ super().__init__()
59
+ self.net=nn.Sequential(nn.LayerNorm(width),nn.Linear(width,width*2),nn.GELU(),
60
+ nn.Dropout(dropout),nn.Linear(width*2,width),nn.Dropout(dropout))
61
+ def forward(self,x):
62
+ return x+self.net(x)
63
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/infer.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse,json
2
+ from pathlib import Path
3
+ import torch
4
+ from model import HybridModel,SPECS
5
+ from data import Dataset
6
+ from covariances import extract_covariances
7
+ p=argparse.ArgumentParser();p.add_argument('input',type=Path);p.add_argument('output',type=Path);a=p.parse_args()
8
+ root=Path(__file__).resolve().parent;c=json.loads((root/'config.json').read_text());t=json.loads((a.input/'manifest.json').read_text())['track']
9
+ if t not in SPECS:raise ValueError('unknown track')
10
+ torch.set_num_threads(4);device='cuda' if torch.cuda.is_available() else 'cpu'
11
+ m=HybridModel(**c['architecture']).to(device);m.load_state_dict(torch.load(root/'weights.pt',map_location=device,weights_only=True));m.eval()
12
+ a.output.mkdir(parents=True,exist_ok=True)
13
+ with torch.inference_mode(),(a.output/'predictions.jsonl').open('w') as f:
14
+ for x,_,ids in torch.utils.data.DataLoader(Dataset(a.input),batch_size=64,num_workers=0):
15
+ # FFT features stay float32; convolutions can use bfloat16 on CUDA.
16
+ x=x.to(device)
17
+ from features import extract_features
18
+ torch.backends.cuda.matmul.allow_tf32=False
19
+ features=extract_features(t,x)
20
+ covariances=extract_covariances(t,x)
21
+ torch.backends.cuda.matmul.allow_tf32=True
22
+ with torch.autocast(device,dtype=torch.bfloat16,enabled=device=='cuda'):pred=m(t,x,features,covariances=covariances)
23
+ pp=pred.float().softmax(-1).cpu().numpy()
24
+ for sid,pr in zip(ids,pp):f.write(json.dumps({'id':sid,'probabilities':pr.tolist()})+'\n')
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/infer.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ exec python "$(dirname -- "$0")/infer.py" "$1" "$2"
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/model.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One fused waveform/spectral backbone used identically by all five tasks."""
2
+ import torch
3
+ from torch import nn
4
+ from braindecode.models import BIOT
5
+ from features import SPECS,TRACKS,feature_dim,extract_features,Standardize,Residual
6
+ from covariances import BANDS,extract_covariances
7
+
8
+ class InputAdapter(nn.Module):
9
+ def __init__(self,c,width,channels,spectral_enabled=True):
10
+ super().__init__()
11
+ self.signal=nn.Conv1d(c,channels,1,bias=False)
12
+ self.neural=nn.Conv1d(c,18,1,bias=False)
13
+ self.normalizer=Standardize(feature_dim(c))
14
+ self.spectral=nn.Linear(feature_dim(c),width)
15
+ self.dropout=nn.Dropout(.1)
16
+ self.register_buffer("spectral_enabled",torch.tensor(float(spectral_enabled)))
17
+ self.spatial_weight=nn.Parameter(torch.randn(len(BANDS),24,c)/c**.5)
18
+ def spatial_features(self,covariances):
19
+ with torch.autocast(covariances.device.type,enabled=False):
20
+ w=self.spatial_weight.float()/self.spatial_weight.float().norm(dim=-1,keepdim=True).clamp_min(1e-6)
21
+ power=torch.einsum('bfc,nbcd,bfd->nbf',w,covariances.float(),w).clamp_min(1e-8).log()
22
+ return torch.cat([power,power-power.mean(1,keepdim=True)],1).flatten(1)
23
+ def forward(self,x,features,covariance_features):
24
+ return self.signal(x).unsqueeze(1),self.spectral_enabled*self.spectral(self.dropout(self.normalizer(features))),self.neural(x),covariance_features
25
+
26
+ class SharedBackbone(nn.Module):
27
+ def __init__(self,channels,width,depth,dropout,wave_filters):
28
+ super().__init__()
29
+ self.waveform=nn.Sequential(
30
+ nn.Conv2d(1,wave_filters,(1,64),padding=(0,32),bias=False),nn.GroupNorm(1,wave_filters),
31
+ nn.Conv2d(wave_filters,2*wave_filters,(channels,1),groups=wave_filters,bias=False),nn.GroupNorm(1,2*wave_filters),nn.ELU(),
32
+ nn.AvgPool2d((1,4)),nn.Dropout(.35),
33
+ nn.Conv2d(2*wave_filters,2*wave_filters,(1,16),padding=(0,8),groups=2*wave_filters,bias=False),nn.Conv2d(2*wave_filters,2*wave_filters,1,bias=False),
34
+ nn.GroupNorm(1,2*wave_filters),nn.ELU(),nn.AvgPool2d((1,8)),nn.Dropout(.35))
35
+ self.wave_summary=nn.Sequential(nn.AdaptiveAvgPool2d((1,8)),nn.Flatten(),nn.Linear(2*wave_filters*8,width))
36
+ self.fusion=nn.Sequential(nn.LayerNorm(width),nn.GELU(),nn.Dropout(dropout),
37
+ *[Residual(width,dropout) for _ in range(depth)],nn.LayerNorm(width))
38
+ # Both representations interact before the shared residual stack.
39
+ self.wave_gain=nn.Parameter(torch.tensor(.1))
40
+ self.biot=BIOT(n_chans=18,n_outputs=2,n_times=400,sfreq=200)
41
+ self.biot.final_layer=nn.Identity()
42
+ self.biot_projection=nn.Sequential(nn.LayerNorm(256),nn.Linear(256,width),nn.Dropout(.2))
43
+ nn.init.normal_(self.biot_projection[1].weight,std=.001);nn.init.zeros_(self.biot_projection[1].bias)
44
+ self.covariance_encoder=nn.Sequential(nn.LayerNorm(len(BANDS)*24*2),nn.Linear(len(BANDS)*24*2,width),nn.GELU(),nn.Dropout(.4),
45
+ *[Residual(width,.4) for _ in range(2)],nn.LayerNorm(width))
46
+ self.covariance_projection=nn.Linear(width,width)
47
+ nn.init.zeros_(self.covariance_projection.weight);nn.init.zeros_(self.covariance_projection.bias)
48
+ def forward(self,signal,spectral,neural_signal,covariance_features):
49
+ wave=self.waveform(signal)
50
+ neural=self.biot(neural_signal.float())
51
+ neural=self.biot_projection[0](neural)
52
+ projected=self.biot_projection[2](self.biot_projection[1](neural))
53
+ with torch.autocast(signal.device.type,enabled=False):
54
+ covariance_embedding=self.covariance_encoder(covariance_features.float())
55
+ original=spectral+self.wave_gain*self.wave_summary(wave)+.01*projected
56
+ coupled=.001*self.covariance_projection(covariance_embedding).to(original.dtype)
57
+ fused=self.fusion(original+coupled)
58
+ return torch.cat([wave.flatten(1),fused,neural,covariance_embedding],-1)
59
+
60
+ class HybridModel(nn.Module):
61
+ def __init__(self,channels=32,width=128,depth=2,dropout=.5,wave_filters=32):
62
+ super().__init__()
63
+ self.adapters=nn.ModuleDict({t:InputAdapter(c,width,channels,spectral_enabled=t not in ("faced","tuev","openbmi")) for t,(c,s,k) in SPECS.items()})
64
+ self.backbone=SharedBackbone(channels,width,depth,dropout,wave_filters)
65
+ self.heads=nn.ModuleDict({t:nn.Linear(2*wave_filters*(((s*200+1)//4+1)//8)+width+256+width,k) for t,(c,s,k) in SPECS.items()})
66
+ def forward(self,t,x,features=None,covariances=None,covariance_features=None):
67
+ if features is None:features=extract_features(t,x)
68
+ if covariance_features is None:
69
+ if covariances is None:covariances=extract_covariances(t,x)
70
+ covariance_features=self.adapters[t].spatial_features(covariances)
71
+ signal=x.flatten(2);signal=signal-signal.mean(-1,keepdim=True)
72
+ if t in ('faced','tuev'):signal=signal/signal.std(-1,keepdim=True,correction=0).clamp_min(1e-6)
73
+ else:signal=signal-signal.mean(1,keepdim=True)
74
+ signal=signal.clamp(-20,20)
75
+ adapted=self.adapters[t](signal,features,covariance_features)
76
+ representation=self.backbone(*adapted)
77
+ if t in ('faced','openbmi'):
78
+ representation=torch.cat([representation[:,:-384],torch.zeros_like(representation[:,-384:-128]),representation[:,-128:]],-1)
79
+ if t=='ad65':
80
+ with torch.autocast(x.device.type,enabled=False):return self.heads[t](representation.float())
81
+ # This is one linear head, evaluated in feature blocks so appending
82
+ # zero-weight columns preserves the prior bfloat16 GEMM dimensions.
83
+ head=self.heads[t]
84
+ prior=nn.functional.linear(representation[:,:-128].contiguous(),head.weight[:,:-128].contiguous(),head.bias)
85
+ added=nn.functional.linear(representation[:,-128:].contiguous(),head.weight[:,-128:].contiguous())
86
+ return prior+added
87
+
88
+ def widen_state_dict(state,multiplier=2):
89
+ """Duplicate temporal features and divide downstream sums to preserve outputs."""
90
+ result={}
91
+ for key,value in state.items():
92
+ if key.startswith('backbone.waveform.'):
93
+ layer=int(key.split('.')[2])
94
+ if layer in (0,2,7):value=value.repeat(multiplier,1,1,1)
95
+ elif layer in (1,3,9):value=value.repeat(multiplier)
96
+ elif layer==8:value=value.repeat(multiplier,multiplier,1,1)/multiplier
97
+ elif key=='backbone.wave_summary.2.weight':value=value.repeat(1,multiplier)/multiplier
98
+ elif key.startswith('heads.') and key.endswith('.weight'):
99
+ raw=value[:,:-128]/multiplier
100
+ value=torch.cat([raw]*multiplier+[value[:,-128:]],1)
101
+ result[key]=value
102
+ return result
103
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/training.json ADDED
@@ -0,0 +1,2097 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "settings": {
3
+ "source": "/workspace/research/runs/hybrid_biot_csp_bf16head/epoch-001",
4
+ "features": "/workspace/research/head_features_v1",
5
+ "incumbent": "/workspace/research/runs/head_refinement1/epoch-012",
6
+ "output": "/workspace/research/runs/head_dropout1",
7
+ "epochs": 30,
8
+ "steps": 200,
9
+ "batch_size": 256,
10
+ "lr": 1e-05,
11
+ "clinical_lr": 0.0001,
12
+ "retention": 2.0,
13
+ "dropout": 0.2,
14
+ "seed": 7
15
+ },
16
+ "history": [
17
+ {
18
+ "epoch": 14,
19
+ "validation": {
20
+ "faced": {
21
+ "class_counts": [
22
+ 180,
23
+ 180,
24
+ 180,
25
+ 180,
26
+ 240,
27
+ 180,
28
+ 180,
29
+ 180,
30
+ 180
31
+ ],
32
+ "predicted_class_counts": [
33
+ 157,
34
+ 194,
35
+ 179,
36
+ 214,
37
+ 244,
38
+ 162,
39
+ 180,
40
+ 173,
41
+ 177
42
+ ],
43
+ "confusion_matrix": [
44
+ [
45
+ 78,
46
+ 14,
47
+ 5,
48
+ 23,
49
+ 19,
50
+ 9,
51
+ 13,
52
+ 9,
53
+ 10
54
+ ],
55
+ [
56
+ 11,
57
+ 88,
58
+ 9,
59
+ 13,
60
+ 19,
61
+ 11,
62
+ 13,
63
+ 6,
64
+ 10
65
+ ],
66
+ [
67
+ 6,
68
+ 7,
69
+ 94,
70
+ 20,
71
+ 17,
72
+ 5,
73
+ 7,
74
+ 10,
75
+ 14
76
+ ],
77
+ [
78
+ 14,
79
+ 18,
80
+ 9,
81
+ 71,
82
+ 21,
83
+ 8,
84
+ 16,
85
+ 15,
86
+ 8
87
+ ],
88
+ [
89
+ 13,
90
+ 13,
91
+ 16,
92
+ 26,
93
+ 113,
94
+ 17,
95
+ 13,
96
+ 18,
97
+ 11
98
+ ],
99
+ [
100
+ 6,
101
+ 12,
102
+ 12,
103
+ 15,
104
+ 12,
105
+ 83,
106
+ 10,
107
+ 14,
108
+ 16
109
+ ],
110
+ [
111
+ 8,
112
+ 12,
113
+ 8,
114
+ 14,
115
+ 16,
116
+ 14,
117
+ 90,
118
+ 9,
119
+ 9
120
+ ],
121
+ [
122
+ 8,
123
+ 16,
124
+ 15,
125
+ 17,
126
+ 15,
127
+ 10,
128
+ 10,
129
+ 83,
130
+ 6
131
+ ],
132
+ [
133
+ 13,
134
+ 14,
135
+ 11,
136
+ 15,
137
+ 12,
138
+ 5,
139
+ 8,
140
+ 9,
141
+ 93
142
+ ]
143
+ ],
144
+ "per_class_recall": [
145
+ 0.43333333333333335,
146
+ 0.4888888888888889,
147
+ 0.5222222222222223,
148
+ 0.39444444444444443,
149
+ 0.4708333333333333,
150
+ 0.46111111111111114,
151
+ 0.5,
152
+ 0.46111111111111114,
153
+ 0.5166666666666667
154
+ ],
155
+ "balanced_accuracy": 0.472067901234568,
156
+ "accuracy": 0.4720238095238095,
157
+ "weighted_f1": 0.4732298815998091,
158
+ "macro_f1": 0.47346276059386383,
159
+ "kappa": 0.40521122712903535,
160
+ "samples": 1680,
161
+ "reward": 0.472067901234568,
162
+ "subjects": 20
163
+ },
164
+ "tuev": {
165
+ "class_counts": [
166
+ 119,
167
+ 291,
168
+ 669,
169
+ 86,
170
+ 500,
171
+ 13822
172
+ ],
173
+ "predicted_class_counts": [
174
+ 995,
175
+ 658,
176
+ 146,
177
+ 706,
178
+ 1616,
179
+ 11366
180
+ ],
181
+ "confusion_matrix": [
182
+ [
183
+ 42,
184
+ 38,
185
+ 18,
186
+ 4,
187
+ 0,
188
+ 17
189
+ ],
190
+ [
191
+ 0,
192
+ 185,
193
+ 0,
194
+ 78,
195
+ 28,
196
+ 0
197
+ ],
198
+ [
199
+ 110,
200
+ 127,
201
+ 128,
202
+ 61,
203
+ 243,
204
+ 0
205
+ ],
206
+ [
207
+ 6,
208
+ 0,
209
+ 0,
210
+ 79,
211
+ 0,
212
+ 1
213
+ ],
214
+ [
215
+ 2,
216
+ 0,
217
+ 0,
218
+ 25,
219
+ 420,
220
+ 53
221
+ ],
222
+ [
223
+ 835,
224
+ 308,
225
+ 0,
226
+ 459,
227
+ 925,
228
+ 11295
229
+ ]
230
+ ],
231
+ "per_class_recall": [
232
+ 0.35294117647058826,
233
+ 0.6357388316151202,
234
+ 0.19133034379671152,
235
+ 0.9186046511627907,
236
+ 0.84,
237
+ 0.8171755172912748
238
+ ],
239
+ "balanced_accuracy": 0.6259650867227476,
240
+ "accuracy": 0.7844643894879576,
241
+ "weighted_f1": 0.8358334233956254,
242
+ "macro_f1": 0.3787874146773398,
243
+ "kappa": 0.36546485724249755,
244
+ "samples": 15487,
245
+ "reward": 0.6259650867227476,
246
+ "subjects": 58
247
+ },
248
+ "ad65": {
249
+ "class_counts": [
250
+ 464,
251
+ 393,
252
+ 486
253
+ ],
254
+ "predicted_class_counts": [
255
+ 440,
256
+ 309,
257
+ 594
258
+ ],
259
+ "confusion_matrix": [
260
+ [
261
+ 287,
262
+ 86,
263
+ 91
264
+ ],
265
+ [
266
+ 96,
267
+ 185,
268
+ 112
269
+ ],
270
+ [
271
+ 57,
272
+ 38,
273
+ 391
274
+ ]
275
+ ],
276
+ "per_class_recall": [
277
+ 0.6185344827586207,
278
+ 0.4707379134860051,
279
+ 0.8045267489711934
280
+ ],
281
+ "balanced_accuracy": 0.6312663817386064,
282
+ "accuracy": 0.6425912137006702,
283
+ "weighted_f1": 0.6356338206725993,
284
+ "macro_f1": 0.6286984511173302,
285
+ "kappa": 0.4579978610488933,
286
+ "samples": 1343,
287
+ "subject_metrics": {
288
+ "class_counts": [
289
+ 7,
290
+ 5,
291
+ 6
292
+ ],
293
+ "predicted_class_counts": [
294
+ 5,
295
+ 6,
296
+ 7
297
+ ],
298
+ "confusion_matrix": [
299
+ [
300
+ 5,
301
+ 2,
302
+ 0
303
+ ],
304
+ [
305
+ 0,
306
+ 4,
307
+ 1
308
+ ],
309
+ [
310
+ 0,
311
+ 0,
312
+ 6
313
+ ]
314
+ ],
315
+ "per_class_recall": [
316
+ 0.7142857142857143,
317
+ 0.8,
318
+ 1.0
319
+ ],
320
+ "balanced_accuracy": 0.8380952380952381,
321
+ "accuracy": 0.8333333333333334,
322
+ "weighted_f1": 0.8337865837865839,
323
+ "macro_f1": 0.8278943278943279,
324
+ "kappa": 0.7511520737327189
325
+ },
326
+ "reward": 0.8380952380952381,
327
+ "subjects": 18
328
+ },
329
+ "openbmi": {
330
+ "class_counts": [
331
+ 2200,
332
+ 2200
333
+ ],
334
+ "predicted_class_counts": [
335
+ 2040,
336
+ 2360
337
+ ],
338
+ "confusion_matrix": [
339
+ [
340
+ 1690,
341
+ 510
342
+ ],
343
+ [
344
+ 350,
345
+ 1850
346
+ ]
347
+ ],
348
+ "per_class_recall": [
349
+ 0.7681818181818182,
350
+ 0.8409090909090909
351
+ ],
352
+ "balanced_accuracy": 0.8045454545454546,
353
+ "accuracy": 0.8045454545454546,
354
+ "weighted_f1": 0.8042866600463423,
355
+ "macro_f1": 0.8042866600463423,
356
+ "kappa": 0.6090909090909091,
357
+ "samples": 4400,
358
+ "subject_scores": {
359
+ "19": 0.8574999999999999,
360
+ "35": 0.9525,
361
+ "34": 0.6475,
362
+ "51": 0.75,
363
+ "20": 0.815,
364
+ "44": 0.935,
365
+ "24": 0.595,
366
+ "15": 0.8975,
367
+ "31": 0.8825000000000001,
368
+ "26": 0.7925,
369
+ "23": 0.725
370
+ },
371
+ "reward": 0.8045454545454546,
372
+ "subjects": 11
373
+ },
374
+ "longitudinal": {
375
+ "class_counts": [
376
+ 4260,
377
+ 4158
378
+ ],
379
+ "predicted_class_counts": [
380
+ 4576,
381
+ 3842
382
+ ],
383
+ "confusion_matrix": [
384
+ [
385
+ 3659,
386
+ 601
387
+ ],
388
+ [
389
+ 917,
390
+ 3241
391
+ ]
392
+ ],
393
+ "per_class_recall": [
394
+ 0.8589201877934273,
395
+ 0.7794612794612794
396
+ ],
397
+ "balanced_accuracy": 0.8191907336273534,
398
+ "accuracy": 0.819672131147541,
399
+ "weighted_f1": 0.8193351694632243,
400
+ "macro_f1": 0.8192264033499321,
401
+ "kappa": 0.6389628187072087,
402
+ "samples": 8418,
403
+ "subject_scores": {
404
+ "sub-G2021": 0.837643455629449,
405
+ "sub-G2007": 0.7651266214233094,
406
+ "sub-G2019": 0.8242345047591977,
407
+ "sub-G2031": 0.788678938415735,
408
+ "sub-G2015": 0.8446221994740171,
409
+ "sub-CTR002": 0.9869493251846193,
410
+ "sub-G2011": 0.765938925240826,
411
+ "sub-G2035": 0.9564871486872261,
412
+ "sub-CTR003": 0.5773809523809523
413
+ },
414
+ "reward": 0.8163402301328146,
415
+ "subjects": 9
416
+ }
417
+ },
418
+ "selected_head_epochs": {
419
+ "faced": 0,
420
+ "tuev": 0,
421
+ "ad65": 0,
422
+ "openbmi": 0,
423
+ "longitudinal": 14
424
+ }
425
+ },
426
+ {
427
+ "epoch": 16,
428
+ "validation": {
429
+ "faced": {
430
+ "class_counts": [
431
+ 180,
432
+ 180,
433
+ 180,
434
+ 180,
435
+ 240,
436
+ 180,
437
+ 180,
438
+ 180,
439
+ 180
440
+ ],
441
+ "predicted_class_counts": [
442
+ 157,
443
+ 194,
444
+ 179,
445
+ 214,
446
+ 244,
447
+ 162,
448
+ 180,
449
+ 173,
450
+ 177
451
+ ],
452
+ "confusion_matrix": [
453
+ [
454
+ 78,
455
+ 14,
456
+ 5,
457
+ 23,
458
+ 19,
459
+ 9,
460
+ 13,
461
+ 9,
462
+ 10
463
+ ],
464
+ [
465
+ 11,
466
+ 88,
467
+ 9,
468
+ 13,
469
+ 19,
470
+ 11,
471
+ 13,
472
+ 6,
473
+ 10
474
+ ],
475
+ [
476
+ 6,
477
+ 7,
478
+ 94,
479
+ 20,
480
+ 17,
481
+ 5,
482
+ 7,
483
+ 10,
484
+ 14
485
+ ],
486
+ [
487
+ 14,
488
+ 18,
489
+ 9,
490
+ 71,
491
+ 21,
492
+ 8,
493
+ 16,
494
+ 15,
495
+ 8
496
+ ],
497
+ [
498
+ 13,
499
+ 13,
500
+ 16,
501
+ 26,
502
+ 113,
503
+ 17,
504
+ 13,
505
+ 18,
506
+ 11
507
+ ],
508
+ [
509
+ 6,
510
+ 12,
511
+ 12,
512
+ 15,
513
+ 12,
514
+ 83,
515
+ 10,
516
+ 14,
517
+ 16
518
+ ],
519
+ [
520
+ 8,
521
+ 12,
522
+ 8,
523
+ 14,
524
+ 16,
525
+ 14,
526
+ 90,
527
+ 9,
528
+ 9
529
+ ],
530
+ [
531
+ 8,
532
+ 16,
533
+ 15,
534
+ 17,
535
+ 15,
536
+ 10,
537
+ 10,
538
+ 83,
539
+ 6
540
+ ],
541
+ [
542
+ 13,
543
+ 14,
544
+ 11,
545
+ 15,
546
+ 12,
547
+ 5,
548
+ 8,
549
+ 9,
550
+ 93
551
+ ]
552
+ ],
553
+ "per_class_recall": [
554
+ 0.43333333333333335,
555
+ 0.4888888888888889,
556
+ 0.5222222222222223,
557
+ 0.39444444444444443,
558
+ 0.4708333333333333,
559
+ 0.46111111111111114,
560
+ 0.5,
561
+ 0.46111111111111114,
562
+ 0.5166666666666667
563
+ ],
564
+ "balanced_accuracy": 0.472067901234568,
565
+ "accuracy": 0.4720238095238095,
566
+ "weighted_f1": 0.4732298815998091,
567
+ "macro_f1": 0.47346276059386383,
568
+ "kappa": 0.40521122712903535,
569
+ "samples": 1680,
570
+ "reward": 0.472067901234568,
571
+ "subjects": 20
572
+ },
573
+ "tuev": {
574
+ "class_counts": [
575
+ 119,
576
+ 291,
577
+ 669,
578
+ 86,
579
+ 500,
580
+ 13822
581
+ ],
582
+ "predicted_class_counts": [
583
+ 995,
584
+ 658,
585
+ 146,
586
+ 706,
587
+ 1616,
588
+ 11366
589
+ ],
590
+ "confusion_matrix": [
591
+ [
592
+ 42,
593
+ 38,
594
+ 18,
595
+ 4,
596
+ 0,
597
+ 17
598
+ ],
599
+ [
600
+ 0,
601
+ 185,
602
+ 0,
603
+ 78,
604
+ 28,
605
+ 0
606
+ ],
607
+ [
608
+ 110,
609
+ 127,
610
+ 128,
611
+ 61,
612
+ 243,
613
+ 0
614
+ ],
615
+ [
616
+ 6,
617
+ 0,
618
+ 0,
619
+ 79,
620
+ 0,
621
+ 1
622
+ ],
623
+ [
624
+ 2,
625
+ 0,
626
+ 0,
627
+ 25,
628
+ 420,
629
+ 53
630
+ ],
631
+ [
632
+ 835,
633
+ 308,
634
+ 0,
635
+ 459,
636
+ 925,
637
+ 11295
638
+ ]
639
+ ],
640
+ "per_class_recall": [
641
+ 0.35294117647058826,
642
+ 0.6357388316151202,
643
+ 0.19133034379671152,
644
+ 0.9186046511627907,
645
+ 0.84,
646
+ 0.8171755172912748
647
+ ],
648
+ "balanced_accuracy": 0.6259650867227476,
649
+ "accuracy": 0.7844643894879576,
650
+ "weighted_f1": 0.8358334233956254,
651
+ "macro_f1": 0.3787874146773398,
652
+ "kappa": 0.36546485724249755,
653
+ "samples": 15487,
654
+ "reward": 0.6259650867227476,
655
+ "subjects": 58
656
+ },
657
+ "ad65": {
658
+ "class_counts": [
659
+ 464,
660
+ 393,
661
+ 486
662
+ ],
663
+ "predicted_class_counts": [
664
+ 440,
665
+ 309,
666
+ 594
667
+ ],
668
+ "confusion_matrix": [
669
+ [
670
+ 287,
671
+ 86,
672
+ 91
673
+ ],
674
+ [
675
+ 96,
676
+ 185,
677
+ 112
678
+ ],
679
+ [
680
+ 57,
681
+ 38,
682
+ 391
683
+ ]
684
+ ],
685
+ "per_class_recall": [
686
+ 0.6185344827586207,
687
+ 0.4707379134860051,
688
+ 0.8045267489711934
689
+ ],
690
+ "balanced_accuracy": 0.6312663817386064,
691
+ "accuracy": 0.6425912137006702,
692
+ "weighted_f1": 0.6356338206725993,
693
+ "macro_f1": 0.6286984511173302,
694
+ "kappa": 0.4579978610488933,
695
+ "samples": 1343,
696
+ "subject_metrics": {
697
+ "class_counts": [
698
+ 7,
699
+ 5,
700
+ 6
701
+ ],
702
+ "predicted_class_counts": [
703
+ 5,
704
+ 6,
705
+ 7
706
+ ],
707
+ "confusion_matrix": [
708
+ [
709
+ 5,
710
+ 2,
711
+ 0
712
+ ],
713
+ [
714
+ 0,
715
+ 4,
716
+ 1
717
+ ],
718
+ [
719
+ 0,
720
+ 0,
721
+ 6
722
+ ]
723
+ ],
724
+ "per_class_recall": [
725
+ 0.7142857142857143,
726
+ 0.8,
727
+ 1.0
728
+ ],
729
+ "balanced_accuracy": 0.8380952380952381,
730
+ "accuracy": 0.8333333333333334,
731
+ "weighted_f1": 0.8337865837865839,
732
+ "macro_f1": 0.8278943278943279,
733
+ "kappa": 0.7511520737327189
734
+ },
735
+ "reward": 0.8380952380952381,
736
+ "subjects": 18
737
+ },
738
+ "openbmi": {
739
+ "class_counts": [
740
+ 2200,
741
+ 2200
742
+ ],
743
+ "predicted_class_counts": [
744
+ 2040,
745
+ 2360
746
+ ],
747
+ "confusion_matrix": [
748
+ [
749
+ 1690,
750
+ 510
751
+ ],
752
+ [
753
+ 350,
754
+ 1850
755
+ ]
756
+ ],
757
+ "per_class_recall": [
758
+ 0.7681818181818182,
759
+ 0.8409090909090909
760
+ ],
761
+ "balanced_accuracy": 0.8045454545454546,
762
+ "accuracy": 0.8045454545454546,
763
+ "weighted_f1": 0.8042866600463423,
764
+ "macro_f1": 0.8042866600463423,
765
+ "kappa": 0.6090909090909091,
766
+ "samples": 4400,
767
+ "subject_scores": {
768
+ "19": 0.8574999999999999,
769
+ "35": 0.9525,
770
+ "34": 0.6475,
771
+ "51": 0.75,
772
+ "20": 0.815,
773
+ "44": 0.935,
774
+ "24": 0.595,
775
+ "15": 0.8975,
776
+ "31": 0.8825000000000001,
777
+ "26": 0.7925,
778
+ "23": 0.725
779
+ },
780
+ "reward": 0.8045454545454546,
781
+ "subjects": 11
782
+ },
783
+ "longitudinal": {
784
+ "class_counts": [
785
+ 4260,
786
+ 4158
787
+ ],
788
+ "predicted_class_counts": [
789
+ 4574,
790
+ 3844
791
+ ],
792
+ "confusion_matrix": [
793
+ [
794
+ 3658,
795
+ 602
796
+ ],
797
+ [
798
+ 916,
799
+ 3242
800
+ ]
801
+ ],
802
+ "per_class_recall": [
803
+ 0.8586854460093897,
804
+ 0.7797017797017797
805
+ ],
806
+ "balanced_accuracy": 0.8191936128555847,
807
+ "accuracy": 0.819672131147541,
808
+ "weighted_f1": 0.8193389120476722,
809
+ "macro_f1": 0.819230668900581,
810
+ "kappa": 0.6389648996053923,
811
+ "samples": 8418,
812
+ "subject_scores": {
813
+ "sub-G2021": 0.8368421735781668,
814
+ "sub-G2007": 0.7651266214233094,
815
+ "sub-G2019": 0.8242345047591977,
816
+ "sub-G2031": 0.788678938415735,
817
+ "sub-G2015": 0.8446221994740171,
818
+ "sub-CTR002": 0.9869493251846193,
819
+ "sub-G2011": 0.765938925240826,
820
+ "sub-G2035": 0.9573204820205594,
821
+ "sub-CTR003": 0.5773809523809523
822
+ },
823
+ "reward": 0.8163437913863759,
824
+ "subjects": 9
825
+ }
826
+ },
827
+ "selected_head_epochs": {
828
+ "faced": 0,
829
+ "tuev": 0,
830
+ "ad65": 0,
831
+ "openbmi": 0,
832
+ "longitudinal": 16
833
+ }
834
+ }
835
+ ],
836
+ "shared_backbone_training": "inherited joint training on all five training splits; frozen during final linear-head refinement",
837
+ "parent_training_receipt": {
838
+ "all_tracks_update_shared_backbone": true,
839
+ "parameters": 10427373,
840
+ "source_training_settings": {
841
+ "output": "/workspace/research/runs/hybrid_biot_csp_stable1",
842
+ "epochs": 30,
843
+ "steps": 100,
844
+ "batch_size": 64,
845
+ "seed": 7,
846
+ "hidden": 32,
847
+ "dropout": 0.5,
848
+ "lr": 1e-06,
849
+ "head_lr": 1e-07,
850
+ "weight_decay": 0.05,
851
+ "init": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
852
+ "mixup": 0.0,
853
+ "clinical_lr": 0.0001,
854
+ "neural_lr": 1e-05,
855
+ "covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
856
+ "ad_pool": 8
857
+ },
858
+ "parent_training_history": [
859
+ {
860
+ "epoch": 1,
861
+ "validation": {
862
+ "faced": {
863
+ "class_counts": [
864
+ 180,
865
+ 180,
866
+ 180,
867
+ 180,
868
+ 240,
869
+ 180,
870
+ 180,
871
+ 180,
872
+ 180
873
+ ],
874
+ "predicted_class_counts": [
875
+ 157,
876
+ 190,
877
+ 178,
878
+ 212,
879
+ 242,
880
+ 166,
881
+ 182,
882
+ 175,
883
+ 178
884
+ ],
885
+ "confusion_matrix": [
886
+ [
887
+ 77,
888
+ 14,
889
+ 5,
890
+ 22,
891
+ 19,
892
+ 9,
893
+ 14,
894
+ 10,
895
+ 10
896
+ ],
897
+ [
898
+ 12,
899
+ 86,
900
+ 9,
901
+ 13,
902
+ 19,
903
+ 11,
904
+ 14,
905
+ 6,
906
+ 10
907
+ ],
908
+ [
909
+ 6,
910
+ 7,
911
+ 93,
912
+ 20,
913
+ 17,
914
+ 5,
915
+ 7,
916
+ 10,
917
+ 15
918
+ ],
919
+ [
920
+ 14,
921
+ 18,
922
+ 9,
923
+ 71,
924
+ 21,
925
+ 8,
926
+ 16,
927
+ 15,
928
+ 8
929
+ ],
930
+ [
931
+ 13,
932
+ 13,
933
+ 17,
934
+ 26,
935
+ 111,
936
+ 17,
937
+ 14,
938
+ 18,
939
+ 11
940
+ ],
941
+ [
942
+ 6,
943
+ 11,
944
+ 11,
945
+ 15,
946
+ 11,
947
+ 86,
948
+ 10,
949
+ 14,
950
+ 16
951
+ ],
952
+ [
953
+ 8,
954
+ 11,
955
+ 9,
956
+ 13,
957
+ 17,
958
+ 14,
959
+ 89,
960
+ 10,
961
+ 9
962
+ ],
963
+ [
964
+ 8,
965
+ 16,
966
+ 14,
967
+ 17,
968
+ 15,
969
+ 11,
970
+ 10,
971
+ 83,
972
+ 6
973
+ ],
974
+ [
975
+ 13,
976
+ 14,
977
+ 11,
978
+ 15,
979
+ 12,
980
+ 5,
981
+ 8,
982
+ 9,
983
+ 93
984
+ ]
985
+ ],
986
+ "per_class_recall": [
987
+ 0.42777777777777776,
988
+ 0.4777777777777778,
989
+ 0.5166666666666667,
990
+ 0.39444444444444443,
991
+ 0.4625,
992
+ 0.4777777777777778,
993
+ 0.49444444444444446,
994
+ 0.46111111111111114,
995
+ 0.5166666666666667
996
+ ],
997
+ "balanced_accuracy": 0.46990740740740744,
998
+ "accuracy": 0.46964285714285714,
999
+ "weighted_f1": 0.4707562771324448,
1000
+ "macro_f1": 0.471133142475755,
1001
+ "kappa": 0.4025575937544903,
1002
+ "samples": 1680,
1003
+ "reward": 0.46990740740740744,
1004
+ "subjects": 20
1005
+ },
1006
+ "tuev": {
1007
+ "class_counts": [
1008
+ 119,
1009
+ 291,
1010
+ 669,
1011
+ 86,
1012
+ 500,
1013
+ 13822
1014
+ ],
1015
+ "predicted_class_counts": [
1016
+ 1415,
1017
+ 660,
1018
+ 126,
1019
+ 754,
1020
+ 1618,
1021
+ 10914
1022
+ ],
1023
+ "confusion_matrix": [
1024
+ [
1025
+ 45,
1026
+ 38,
1027
+ 15,
1028
+ 0,
1029
+ 4,
1030
+ 17
1031
+ ],
1032
+ [
1033
+ 17,
1034
+ 164,
1035
+ 0,
1036
+ 61,
1037
+ 49,
1038
+ 0
1039
+ ],
1040
+ [
1041
+ 130,
1042
+ 126,
1043
+ 111,
1044
+ 89,
1045
+ 213,
1046
+ 0
1047
+ ],
1048
+ [
1049
+ 7,
1050
+ 2,
1051
+ 0,
1052
+ 76,
1053
+ 0,
1054
+ 1
1055
+ ],
1056
+ [
1057
+ 4,
1058
+ 0,
1059
+ 0,
1060
+ 24,
1061
+ 435,
1062
+ 37
1063
+ ],
1064
+ [
1065
+ 1212,
1066
+ 330,
1067
+ 0,
1068
+ 504,
1069
+ 917,
1070
+ 10859
1071
+ ]
1072
+ ],
1073
+ "per_class_recall": [
1074
+ 0.37815126050420167,
1075
+ 0.563573883161512,
1076
+ 0.16591928251121077,
1077
+ 0.8837209302325582,
1078
+ 0.87,
1079
+ 0.7856316017942411
1080
+ ],
1081
+ "balanced_accuracy": 0.6078328263672873,
1082
+ "accuracy": 0.7548266287854329,
1083
+ "weighted_f1": 0.8168597460216521,
1084
+ "macro_f1": 0.3587540627106629,
1085
+ "kappa": 0.32929623559334475,
1086
+ "samples": 15487,
1087
+ "reward": 0.6078328263672873,
1088
+ "subjects": 58
1089
+ },
1090
+ "ad65": {
1091
+ "class_counts": [
1092
+ 464,
1093
+ 393,
1094
+ 486
1095
+ ],
1096
+ "predicted_class_counts": [
1097
+ 440,
1098
+ 309,
1099
+ 594
1100
+ ],
1101
+ "confusion_matrix": [
1102
+ [
1103
+ 287,
1104
+ 86,
1105
+ 91
1106
+ ],
1107
+ [
1108
+ 96,
1109
+ 185,
1110
+ 112
1111
+ ],
1112
+ [
1113
+ 57,
1114
+ 38,
1115
+ 391
1116
+ ]
1117
+ ],
1118
+ "per_class_recall": [
1119
+ 0.6185344827586207,
1120
+ 0.4707379134860051,
1121
+ 0.8045267489711934
1122
+ ],
1123
+ "balanced_accuracy": 0.6312663817386064,
1124
+ "accuracy": 0.6425912137006702,
1125
+ "weighted_f1": 0.6356338206725993,
1126
+ "macro_f1": 0.6286984511173302,
1127
+ "kappa": 0.4579978610488933,
1128
+ "samples": 1343,
1129
+ "subject_metrics": {
1130
+ "class_counts": [
1131
+ 7,
1132
+ 5,
1133
+ 6
1134
+ ],
1135
+ "predicted_class_counts": [
1136
+ 5,
1137
+ 6,
1138
+ 7
1139
+ ],
1140
+ "confusion_matrix": [
1141
+ [
1142
+ 5,
1143
+ 2,
1144
+ 0
1145
+ ],
1146
+ [
1147
+ 0,
1148
+ 4,
1149
+ 1
1150
+ ],
1151
+ [
1152
+ 0,
1153
+ 0,
1154
+ 6
1155
+ ]
1156
+ ],
1157
+ "per_class_recall": [
1158
+ 0.7142857142857143,
1159
+ 0.8,
1160
+ 1.0
1161
+ ],
1162
+ "balanced_accuracy": 0.8380952380952381,
1163
+ "accuracy": 0.8333333333333334,
1164
+ "weighted_f1": 0.8337865837865839,
1165
+ "macro_f1": 0.8278943278943279,
1166
+ "kappa": 0.7511520737327189
1167
+ },
1168
+ "reward": 0.8380952380952381,
1169
+ "subjects": 18
1170
+ },
1171
+ "openbmi": {
1172
+ "class_counts": [
1173
+ 2200,
1174
+ 2200
1175
+ ],
1176
+ "predicted_class_counts": [
1177
+ 2059,
1178
+ 2341
1179
+ ],
1180
+ "confusion_matrix": [
1181
+ [
1182
+ 1696,
1183
+ 504
1184
+ ],
1185
+ [
1186
+ 363,
1187
+ 1837
1188
+ ]
1189
+ ],
1190
+ "per_class_recall": [
1191
+ 0.7709090909090909,
1192
+ 0.835
1193
+ ],
1194
+ "balanced_accuracy": 0.8029545454545455,
1195
+ "accuracy": 0.8029545454545455,
1196
+ "weighted_f1": 0.8027519892716276,
1197
+ "macro_f1": 0.8027519892716275,
1198
+ "kappa": 0.605909090909091,
1199
+ "samples": 4400,
1200
+ "subject_scores": {
1201
+ "19": 0.8425,
1202
+ "35": 0.9525,
1203
+ "34": 0.64,
1204
+ "51": 0.7475,
1205
+ "20": 0.82,
1206
+ "44": 0.94,
1207
+ "24": 0.5974999999999999,
1208
+ "15": 0.9,
1209
+ "31": 0.8825000000000001,
1210
+ "26": 0.79,
1211
+ "23": 0.72
1212
+ },
1213
+ "reward": 0.8029545454545456,
1214
+ "subjects": 11
1215
+ },
1216
+ "longitudinal": {
1217
+ "class_counts": [
1218
+ 4260,
1219
+ 4158
1220
+ ],
1221
+ "predicted_class_counts": [
1222
+ 4572,
1223
+ 3846
1224
+ ],
1225
+ "confusion_matrix": [
1226
+ [
1227
+ 3656,
1228
+ 604
1229
+ ],
1230
+ [
1231
+ 916,
1232
+ 3242
1233
+ ]
1234
+ ],
1235
+ "per_class_recall": [
1236
+ 0.8582159624413146,
1237
+ 0.7797017797017797
1238
+ ],
1239
+ "balanced_accuracy": 0.8189588710715472,
1240
+ "accuracy": 0.8194345450225707,
1241
+ "weighted_f1": 0.8191046137658184,
1242
+ "macro_f1": 0.8189967516241878,
1243
+ "kappa": 0.6384913111521573,
1244
+ "samples": 8418,
1245
+ "subject_scores": {
1246
+ "sub-G2021": 0.837643455629449,
1247
+ "sub-G2007": 0.7644167136410334,
1248
+ "sub-G2019": 0.8242345047591977,
1249
+ "sub-G2031": 0.788678938415735,
1250
+ "sub-G2015": 0.8429774626319118,
1251
+ "sub-CTR002": 0.9869493251846193,
1252
+ "sub-G2011": 0.765938925240826,
1253
+ "sub-G2035": 0.9564871486872261,
1254
+ "sub-CTR003": 0.5773809523809523
1255
+ },
1256
+ "reward": 0.8160786029523278,
1257
+ "subjects": 9
1258
+ }
1259
+ },
1260
+ "losses": {
1261
+ "faced": 1.1245228350162506,
1262
+ "tuev": 0.8237144947052002,
1263
+ "ad65": 0.5528117254376411,
1264
+ "openbmi": 0.41377417743206024,
1265
+ "longitudinal": 0.23846278339624405
1266
+ },
1267
+ "seconds": 33.64874625205994
1268
+ }
1269
+ ],
1270
+ "history": [
1271
+ {
1272
+ "epoch": 1,
1273
+ "validation": {
1274
+ "faced": {
1275
+ "class_counts": [
1276
+ 180,
1277
+ 180,
1278
+ 180,
1279
+ 180,
1280
+ 240,
1281
+ 180,
1282
+ 180,
1283
+ 180,
1284
+ 180
1285
+ ],
1286
+ "predicted_class_counts": [
1287
+ 158,
1288
+ 189,
1289
+ 178,
1290
+ 213,
1291
+ 242,
1292
+ 166,
1293
+ 182,
1294
+ 176,
1295
+ 176
1296
+ ],
1297
+ "confusion_matrix": [
1298
+ [
1299
+ 77,
1300
+ 14,
1301
+ 5,
1302
+ 22,
1303
+ 19,
1304
+ 9,
1305
+ 14,
1306
+ 10,
1307
+ 10
1308
+ ],
1309
+ [
1310
+ 12,
1311
+ 86,
1312
+ 9,
1313
+ 13,
1314
+ 19,
1315
+ 11,
1316
+ 14,
1317
+ 6,
1318
+ 10
1319
+ ],
1320
+ [
1321
+ 6,
1322
+ 7,
1323
+ 93,
1324
+ 21,
1325
+ 17,
1326
+ 5,
1327
+ 7,
1328
+ 10,
1329
+ 14
1330
+ ],
1331
+ [
1332
+ 14,
1333
+ 18,
1334
+ 9,
1335
+ 71,
1336
+ 21,
1337
+ 8,
1338
+ 16,
1339
+ 15,
1340
+ 8
1341
+ ],
1342
+ [
1343
+ 13,
1344
+ 13,
1345
+ 17,
1346
+ 26,
1347
+ 111,
1348
+ 17,
1349
+ 14,
1350
+ 18,
1351
+ 11
1352
+ ],
1353
+ [
1354
+ 6,
1355
+ 11,
1356
+ 11,
1357
+ 15,
1358
+ 11,
1359
+ 86,
1360
+ 10,
1361
+ 14,
1362
+ 16
1363
+ ],
1364
+ [
1365
+ 8,
1366
+ 11,
1367
+ 9,
1368
+ 13,
1369
+ 17,
1370
+ 14,
1371
+ 89,
1372
+ 10,
1373
+ 9
1374
+ ],
1375
+ [
1376
+ 8,
1377
+ 16,
1378
+ 14,
1379
+ 17,
1380
+ 15,
1381
+ 11,
1382
+ 10,
1383
+ 84,
1384
+ 5
1385
+ ],
1386
+ [
1387
+ 14,
1388
+ 13,
1389
+ 11,
1390
+ 15,
1391
+ 12,
1392
+ 5,
1393
+ 8,
1394
+ 9,
1395
+ 93
1396
+ ]
1397
+ ],
1398
+ "per_class_recall": [
1399
+ 0.42777777777777776,
1400
+ 0.4777777777777778,
1401
+ 0.5166666666666667,
1402
+ 0.39444444444444443,
1403
+ 0.4625,
1404
+ 0.4777777777777778,
1405
+ 0.49444444444444446,
1406
+ 0.4666666666666667,
1407
+ 0.5166666666666667
1408
+ ],
1409
+ "balanced_accuracy": 0.4705246913580247,
1410
+ "accuracy": 0.47023809523809523,
1411
+ "weighted_f1": 0.4714215675991068,
1412
+ "macro_f1": 0.47182307333007106,
1413
+ "kappa": 0.40322812395229657,
1414
+ "samples": 1680,
1415
+ "reward": 0.4705246913580247,
1416
+ "subjects": 20
1417
+ },
1418
+ "tuev": {
1419
+ "class_counts": [
1420
+ 119,
1421
+ 291,
1422
+ 669,
1423
+ 86,
1424
+ 500,
1425
+ 13822
1426
+ ],
1427
+ "predicted_class_counts": [
1428
+ 1415,
1429
+ 660,
1430
+ 126,
1431
+ 754,
1432
+ 1684,
1433
+ 10848
1434
+ ],
1435
+ "confusion_matrix": [
1436
+ [
1437
+ 45,
1438
+ 38,
1439
+ 15,
1440
+ 0,
1441
+ 4,
1442
+ 17
1443
+ ],
1444
+ [
1445
+ 17,
1446
+ 164,
1447
+ 0,
1448
+ 61,
1449
+ 49,
1450
+ 0
1451
+ ],
1452
+ [
1453
+ 130,
1454
+ 126,
1455
+ 111,
1456
+ 89,
1457
+ 213,
1458
+ 0
1459
+ ],
1460
+ [
1461
+ 7,
1462
+ 2,
1463
+ 0,
1464
+ 76,
1465
+ 0,
1466
+ 1
1467
+ ],
1468
+ [
1469
+ 4,
1470
+ 0,
1471
+ 0,
1472
+ 24,
1473
+ 435,
1474
+ 37
1475
+ ],
1476
+ [
1477
+ 1212,
1478
+ 330,
1479
+ 0,
1480
+ 504,
1481
+ 983,
1482
+ 10793
1483
+ ]
1484
+ ],
1485
+ "per_class_recall": [
1486
+ 0.37815126050420167,
1487
+ 0.563573883161512,
1488
+ 0.16591928251121077,
1489
+ 0.8837209302325582,
1490
+ 0.87,
1491
+ 0.7808566054116626
1492
+ ],
1493
+ "balanced_accuracy": 0.6070369936368575,
1494
+ "accuracy": 0.7505649899916058,
1495
+ "weighted_f1": 0.8137799723660881,
1496
+ "macro_f1": 0.3561849045209278,
1497
+ "kappa": 0.32441309326581047,
1498
+ "samples": 15487,
1499
+ "reward": 0.6070369936368575,
1500
+ "subjects": 58
1501
+ },
1502
+ "ad65": {
1503
+ "class_counts": [
1504
+ 464,
1505
+ 393,
1506
+ 486
1507
+ ],
1508
+ "predicted_class_counts": [
1509
+ 440,
1510
+ 309,
1511
+ 594
1512
+ ],
1513
+ "confusion_matrix": [
1514
+ [
1515
+ 287,
1516
+ 86,
1517
+ 91
1518
+ ],
1519
+ [
1520
+ 96,
1521
+ 185,
1522
+ 112
1523
+ ],
1524
+ [
1525
+ 57,
1526
+ 38,
1527
+ 391
1528
+ ]
1529
+ ],
1530
+ "per_class_recall": [
1531
+ 0.6185344827586207,
1532
+ 0.4707379134860051,
1533
+ 0.8045267489711934
1534
+ ],
1535
+ "balanced_accuracy": 0.6312663817386064,
1536
+ "accuracy": 0.6425912137006702,
1537
+ "weighted_f1": 0.6356338206725993,
1538
+ "macro_f1": 0.6286984511173302,
1539
+ "kappa": 0.4579978610488933,
1540
+ "samples": 1343,
1541
+ "subject_metrics": {
1542
+ "class_counts": [
1543
+ 7,
1544
+ 5,
1545
+ 6
1546
+ ],
1547
+ "predicted_class_counts": [
1548
+ 5,
1549
+ 6,
1550
+ 7
1551
+ ],
1552
+ "confusion_matrix": [
1553
+ [
1554
+ 5,
1555
+ 2,
1556
+ 0
1557
+ ],
1558
+ [
1559
+ 0,
1560
+ 4,
1561
+ 1
1562
+ ],
1563
+ [
1564
+ 0,
1565
+ 0,
1566
+ 6
1567
+ ]
1568
+ ],
1569
+ "per_class_recall": [
1570
+ 0.7142857142857143,
1571
+ 0.8,
1572
+ 1.0
1573
+ ],
1574
+ "balanced_accuracy": 0.8380952380952381,
1575
+ "accuracy": 0.8333333333333334,
1576
+ "weighted_f1": 0.8337865837865839,
1577
+ "macro_f1": 0.8278943278943279,
1578
+ "kappa": 0.7511520737327189
1579
+ },
1580
+ "reward": 0.8380952380952381,
1581
+ "subjects": 18
1582
+ },
1583
+ "openbmi": {
1584
+ "class_counts": [
1585
+ 2200,
1586
+ 2200
1587
+ ],
1588
+ "predicted_class_counts": [
1589
+ 2061,
1590
+ 2339
1591
+ ],
1592
+ "confusion_matrix": [
1593
+ [
1594
+ 1698,
1595
+ 502
1596
+ ],
1597
+ [
1598
+ 363,
1599
+ 1837
1600
+ ]
1601
+ ],
1602
+ "per_class_recall": [
1603
+ 0.7718181818181818,
1604
+ 0.835
1605
+ ],
1606
+ "balanced_accuracy": 0.803409090909091,
1607
+ "accuracy": 0.803409090909091,
1608
+ "weighted_f1": 0.8032127000298179,
1609
+ "macro_f1": 0.8032127000298179,
1610
+ "kappa": 0.6068181818181818,
1611
+ "samples": 4400,
1612
+ "subject_scores": {
1613
+ "19": 0.8425,
1614
+ "35": 0.9525,
1615
+ "34": 0.6425000000000001,
1616
+ "51": 0.7475,
1617
+ "20": 0.82,
1618
+ "44": 0.94,
1619
+ "24": 0.5974999999999999,
1620
+ "15": 0.9,
1621
+ "31": 0.8825000000000001,
1622
+ "26": 0.7925,
1623
+ "23": 0.72
1624
+ },
1625
+ "reward": 0.803409090909091,
1626
+ "subjects": 11
1627
+ },
1628
+ "longitudinal": {
1629
+ "class_counts": [
1630
+ 4260,
1631
+ 4158
1632
+ ],
1633
+ "predicted_class_counts": [
1634
+ 4573,
1635
+ 3845
1636
+ ],
1637
+ "confusion_matrix": [
1638
+ [
1639
+ 3657,
1640
+ 603
1641
+ ],
1642
+ [
1643
+ 916,
1644
+ 3242
1645
+ ]
1646
+ ],
1647
+ "per_class_recall": [
1648
+ 0.8584507042253521,
1649
+ 0.7797017797017797
1650
+ ],
1651
+ "balanced_accuracy": 0.8190762419635659,
1652
+ "accuracy": 0.8195533380850558,
1653
+ "weighted_f1": 0.8192217642599872,
1654
+ "macro_f1": 0.8191137114479841,
1655
+ "kappa": 0.6387281046963751,
1656
+ "samples": 8418,
1657
+ "subject_scores": {
1658
+ "sub-G2021": 0.837643455629449,
1659
+ "sub-G2007": 0.7644167136410334,
1660
+ "sub-G2019": 0.82505149822325,
1661
+ "sub-G2031": 0.788678938415735,
1662
+ "sub-G2015": 0.8429774626319118,
1663
+ "sub-CTR002": 0.9869493251846193,
1664
+ "sub-G2011": 0.765938925240826,
1665
+ "sub-G2035": 0.9564871486872261,
1666
+ "sub-CTR003": 0.5773809523809523
1667
+ },
1668
+ "reward": 0.8161693800038893,
1669
+ "subjects": 9
1670
+ }
1671
+ },
1672
+ "validation_method": "complete portable infer.sh on all five validation splits"
1673
+ }
1674
+ ],
1675
+ "averaged_validation": {
1676
+ "faced": {
1677
+ "class_counts": [
1678
+ 180,
1679
+ 180,
1680
+ 180,
1681
+ 180,
1682
+ 240,
1683
+ 180,
1684
+ 180,
1685
+ 180,
1686
+ 180
1687
+ ],
1688
+ "predicted_class_counts": [
1689
+ 158,
1690
+ 189,
1691
+ 178,
1692
+ 213,
1693
+ 242,
1694
+ 166,
1695
+ 182,
1696
+ 176,
1697
+ 176
1698
+ ],
1699
+ "confusion_matrix": [
1700
+ [
1701
+ 77,
1702
+ 14,
1703
+ 5,
1704
+ 22,
1705
+ 19,
1706
+ 9,
1707
+ 14,
1708
+ 10,
1709
+ 10
1710
+ ],
1711
+ [
1712
+ 12,
1713
+ 86,
1714
+ 9,
1715
+ 13,
1716
+ 19,
1717
+ 11,
1718
+ 14,
1719
+ 6,
1720
+ 10
1721
+ ],
1722
+ [
1723
+ 6,
1724
+ 7,
1725
+ 93,
1726
+ 21,
1727
+ 17,
1728
+ 5,
1729
+ 7,
1730
+ 10,
1731
+ 14
1732
+ ],
1733
+ [
1734
+ 14,
1735
+ 18,
1736
+ 9,
1737
+ 71,
1738
+ 21,
1739
+ 8,
1740
+ 16,
1741
+ 15,
1742
+ 8
1743
+ ],
1744
+ [
1745
+ 13,
1746
+ 13,
1747
+ 17,
1748
+ 26,
1749
+ 111,
1750
+ 17,
1751
+ 14,
1752
+ 18,
1753
+ 11
1754
+ ],
1755
+ [
1756
+ 6,
1757
+ 11,
1758
+ 11,
1759
+ 15,
1760
+ 11,
1761
+ 86,
1762
+ 10,
1763
+ 14,
1764
+ 16
1765
+ ],
1766
+ [
1767
+ 8,
1768
+ 11,
1769
+ 9,
1770
+ 13,
1771
+ 17,
1772
+ 14,
1773
+ 89,
1774
+ 10,
1775
+ 9
1776
+ ],
1777
+ [
1778
+ 8,
1779
+ 16,
1780
+ 14,
1781
+ 17,
1782
+ 15,
1783
+ 11,
1784
+ 10,
1785
+ 84,
1786
+ 5
1787
+ ],
1788
+ [
1789
+ 14,
1790
+ 13,
1791
+ 11,
1792
+ 15,
1793
+ 12,
1794
+ 5,
1795
+ 8,
1796
+ 9,
1797
+ 93
1798
+ ]
1799
+ ],
1800
+ "per_class_recall": [
1801
+ 0.42777777777777776,
1802
+ 0.4777777777777778,
1803
+ 0.5166666666666667,
1804
+ 0.39444444444444443,
1805
+ 0.4625,
1806
+ 0.4777777777777778,
1807
+ 0.49444444444444446,
1808
+ 0.4666666666666667,
1809
+ 0.5166666666666667
1810
+ ],
1811
+ "balanced_accuracy": 0.4705246913580247,
1812
+ "accuracy": 0.47023809523809523,
1813
+ "weighted_f1": 0.4714215675991068,
1814
+ "macro_f1": 0.47182307333007106,
1815
+ "kappa": 0.40322812395229657,
1816
+ "samples": 1680,
1817
+ "reward": 0.4705246913580247,
1818
+ "subjects": 20
1819
+ },
1820
+ "tuev": {
1821
+ "class_counts": [
1822
+ 119,
1823
+ 291,
1824
+ 669,
1825
+ 86,
1826
+ 500,
1827
+ 13822
1828
+ ],
1829
+ "predicted_class_counts": [
1830
+ 1415,
1831
+ 660,
1832
+ 126,
1833
+ 754,
1834
+ 1684,
1835
+ 10848
1836
+ ],
1837
+ "confusion_matrix": [
1838
+ [
1839
+ 45,
1840
+ 38,
1841
+ 15,
1842
+ 0,
1843
+ 4,
1844
+ 17
1845
+ ],
1846
+ [
1847
+ 17,
1848
+ 164,
1849
+ 0,
1850
+ 61,
1851
+ 49,
1852
+ 0
1853
+ ],
1854
+ [
1855
+ 130,
1856
+ 126,
1857
+ 111,
1858
+ 89,
1859
+ 213,
1860
+ 0
1861
+ ],
1862
+ [
1863
+ 7,
1864
+ 2,
1865
+ 0,
1866
+ 76,
1867
+ 0,
1868
+ 1
1869
+ ],
1870
+ [
1871
+ 4,
1872
+ 0,
1873
+ 0,
1874
+ 24,
1875
+ 435,
1876
+ 37
1877
+ ],
1878
+ [
1879
+ 1212,
1880
+ 330,
1881
+ 0,
1882
+ 504,
1883
+ 983,
1884
+ 10793
1885
+ ]
1886
+ ],
1887
+ "per_class_recall": [
1888
+ 0.37815126050420167,
1889
+ 0.563573883161512,
1890
+ 0.16591928251121077,
1891
+ 0.8837209302325582,
1892
+ 0.87,
1893
+ 0.7808566054116626
1894
+ ],
1895
+ "balanced_accuracy": 0.6070369936368575,
1896
+ "accuracy": 0.7505649899916058,
1897
+ "weighted_f1": 0.8137799723660881,
1898
+ "macro_f1": 0.3561849045209278,
1899
+ "kappa": 0.32441309326581047,
1900
+ "samples": 15487,
1901
+ "reward": 0.6070369936368575,
1902
+ "subjects": 58
1903
+ },
1904
+ "ad65": {
1905
+ "class_counts": [
1906
+ 464,
1907
+ 393,
1908
+ 486
1909
+ ],
1910
+ "predicted_class_counts": [
1911
+ 440,
1912
+ 309,
1913
+ 594
1914
+ ],
1915
+ "confusion_matrix": [
1916
+ [
1917
+ 287,
1918
+ 86,
1919
+ 91
1920
+ ],
1921
+ [
1922
+ 96,
1923
+ 185,
1924
+ 112
1925
+ ],
1926
+ [
1927
+ 57,
1928
+ 38,
1929
+ 391
1930
+ ]
1931
+ ],
1932
+ "per_class_recall": [
1933
+ 0.6185344827586207,
1934
+ 0.4707379134860051,
1935
+ 0.8045267489711934
1936
+ ],
1937
+ "balanced_accuracy": 0.6312663817386064,
1938
+ "accuracy": 0.6425912137006702,
1939
+ "weighted_f1": 0.6356338206725993,
1940
+ "macro_f1": 0.6286984511173302,
1941
+ "kappa": 0.4579978610488933,
1942
+ "samples": 1343,
1943
+ "subject_metrics": {
1944
+ "class_counts": [
1945
+ 7,
1946
+ 5,
1947
+ 6
1948
+ ],
1949
+ "predicted_class_counts": [
1950
+ 5,
1951
+ 6,
1952
+ 7
1953
+ ],
1954
+ "confusion_matrix": [
1955
+ [
1956
+ 5,
1957
+ 2,
1958
+ 0
1959
+ ],
1960
+ [
1961
+ 0,
1962
+ 4,
1963
+ 1
1964
+ ],
1965
+ [
1966
+ 0,
1967
+ 0,
1968
+ 6
1969
+ ]
1970
+ ],
1971
+ "per_class_recall": [
1972
+ 0.7142857142857143,
1973
+ 0.8,
1974
+ 1.0
1975
+ ],
1976
+ "balanced_accuracy": 0.8380952380952381,
1977
+ "accuracy": 0.8333333333333334,
1978
+ "weighted_f1": 0.8337865837865839,
1979
+ "macro_f1": 0.8278943278943279,
1980
+ "kappa": 0.7511520737327189
1981
+ },
1982
+ "reward": 0.8380952380952381,
1983
+ "subjects": 18
1984
+ },
1985
+ "openbmi": {
1986
+ "class_counts": [
1987
+ 2200,
1988
+ 2200
1989
+ ],
1990
+ "predicted_class_counts": [
1991
+ 2061,
1992
+ 2339
1993
+ ],
1994
+ "confusion_matrix": [
1995
+ [
1996
+ 1698,
1997
+ 502
1998
+ ],
1999
+ [
2000
+ 363,
2001
+ 1837
2002
+ ]
2003
+ ],
2004
+ "per_class_recall": [
2005
+ 0.7718181818181818,
2006
+ 0.835
2007
+ ],
2008
+ "balanced_accuracy": 0.803409090909091,
2009
+ "accuracy": 0.803409090909091,
2010
+ "weighted_f1": 0.8032127000298179,
2011
+ "macro_f1": 0.8032127000298179,
2012
+ "kappa": 0.6068181818181818,
2013
+ "samples": 4400,
2014
+ "subject_scores": {
2015
+ "19": 0.8425,
2016
+ "35": 0.9525,
2017
+ "34": 0.6425000000000001,
2018
+ "51": 0.7475,
2019
+ "20": 0.82,
2020
+ "44": 0.94,
2021
+ "24": 0.5974999999999999,
2022
+ "15": 0.9,
2023
+ "31": 0.8825000000000001,
2024
+ "26": 0.7925,
2025
+ "23": 0.72
2026
+ },
2027
+ "reward": 0.803409090909091,
2028
+ "subjects": 11
2029
+ },
2030
+ "longitudinal": {
2031
+ "class_counts": [
2032
+ 4260,
2033
+ 4158
2034
+ ],
2035
+ "predicted_class_counts": [
2036
+ 4573,
2037
+ 3845
2038
+ ],
2039
+ "confusion_matrix": [
2040
+ [
2041
+ 3657,
2042
+ 603
2043
+ ],
2044
+ [
2045
+ 916,
2046
+ 3242
2047
+ ]
2048
+ ],
2049
+ "per_class_recall": [
2050
+ 0.8584507042253521,
2051
+ 0.7797017797017797
2052
+ ],
2053
+ "balanced_accuracy": 0.8190762419635659,
2054
+ "accuracy": 0.8195533380850558,
2055
+ "weighted_f1": 0.8192217642599872,
2056
+ "macro_f1": 0.8191137114479841,
2057
+ "kappa": 0.6387281046963751,
2058
+ "samples": 8418,
2059
+ "subject_scores": {
2060
+ "sub-G2021": 0.837643455629449,
2061
+ "sub-G2007": 0.7644167136410334,
2062
+ "sub-G2019": 0.82505149822325,
2063
+ "sub-G2031": 0.788678938415735,
2064
+ "sub-G2015": 0.8429774626319118,
2065
+ "sub-CTR002": 0.9869493251846193,
2066
+ "sub-G2011": 0.765938925240826,
2067
+ "sub-G2035": 0.9564871486872261,
2068
+ "sub-CTR003": 0.5773809523809523
2069
+ },
2070
+ "reward": 0.8161693800038893,
2071
+ "subjects": 9
2072
+ }
2073
+ },
2074
+ "settings": {
2075
+ "source": "/workspace/research/runs/hybrid_biot_csp_stable1/epoch-001",
2076
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
2077
+ "weights_unchanged": true
2078
+ }
2079
+ },
2080
+ "selected_head_epochs": {
2081
+ "faced": 0,
2082
+ "tuev": 0,
2083
+ "ad65": 0,
2084
+ "openbmi": 0,
2085
+ "longitudinal": 16
2086
+ },
2087
+ "incumbent_heads": "/workspace/research/runs/head_refinement1/epoch-012",
2088
+ "clinical_training_teacher": {
2089
+ "source": "/workspace/research/runs/hybrid_biot_readout1/epoch-009",
2090
+ "weights_sha256": "3216b27a1cfb7c1e927da0d91a61c7d516f71236a8adf89d84bc9cfbb932313f",
2091
+ "manifest_sha256": "49b7880052e6d093633e6e03d52bfd7df9084271ebf8e4f60e4fbe12da398354",
2092
+ "split": "train",
2093
+ "count": 68445,
2094
+ "source_trained_jointly_on_all_five_tracks": true
2095
+ },
2096
+ "no_prediction_ensemble": true
2097
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/config.json ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "bci-shared-biot-covariance-bf16head-v1",
3
+ "architecture": {
4
+ "channels": 32,
5
+ "width": 128,
6
+ "depth": 2,
7
+ "dropout": 0.5,
8
+ "wave_filters": 32,
9
+ "head_width": 64,
10
+ "head_dropout": 0.3
11
+ },
12
+ "initialization": {
13
+ "initialization": "continue joint training from a complete shared-model checkpoint",
14
+ "parent": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
15
+ "parent_initialization": {
16
+ "initialization": "jointly trained parent plus audited pretrained BIOT in a single coupled backbone",
17
+ "parent": "/workspace/research/runs/hybrid_wide1/epoch-004/weights.pt",
18
+ "audited_biot": {
19
+ "initialization": "pretrained",
20
+ "repo": "braindecode/biot-pretrained-six-datasets-18chs",
21
+ "revision": "7e9aabf302870012f73773276803aab97993951c",
22
+ "sha256": "a218f4054ae29962c6fd9d23d94c446d354c4f53e805a6771c85749ccc20baaa",
23
+ "license": "BSD-3-Clause",
24
+ "source_braindecode": "1.3.0",
25
+ "loaded_core_tensors": 56,
26
+ "skipped_classifier_tensors": 3
27
+ },
28
+ "neural_channel_indices": {
29
+ "faced": [
30
+ 0,
31
+ 1,
32
+ 2,
33
+ 3,
34
+ 4,
35
+ 5,
36
+ 6,
37
+ 7,
38
+ 8,
39
+ 9,
40
+ 10,
41
+ 11,
42
+ 12,
43
+ 13,
44
+ 14,
45
+ 15,
46
+ 16,
47
+ 17
48
+ ],
49
+ "tuev": [
50
+ 0,
51
+ 1,
52
+ 2,
53
+ 3,
54
+ 4,
55
+ 5,
56
+ 6,
57
+ 7,
58
+ 8,
59
+ 9,
60
+ 10,
61
+ 11,
62
+ 12,
63
+ 13,
64
+ 14,
65
+ 15
66
+ ],
67
+ "ad65": [
68
+ 0,
69
+ 1,
70
+ 2,
71
+ 3,
72
+ 4,
73
+ 5,
74
+ 6,
75
+ 7,
76
+ 8,
77
+ 9,
78
+ 10,
79
+ 11,
80
+ 12,
81
+ 13,
82
+ 14,
83
+ 15,
84
+ 16,
85
+ 17
86
+ ],
87
+ "openbmi": [
88
+ 0,
89
+ 1,
90
+ 3,
91
+ 5,
92
+ 12,
93
+ 14,
94
+ 23,
95
+ 25,
96
+ 28,
97
+ 30,
98
+ 2,
99
+ 6,
100
+ 11,
101
+ 15,
102
+ 22,
103
+ 26,
104
+ 4,
105
+ 13
106
+ ],
107
+ "longitudinal": [
108
+ 0,
109
+ 2,
110
+ 7,
111
+ 11,
112
+ 23,
113
+ 27,
114
+ 41,
115
+ 45,
116
+ 55,
117
+ 57,
118
+ 5,
119
+ 13,
120
+ 21,
121
+ 29,
122
+ 39,
123
+ 47,
124
+ 9,
125
+ 25
126
+ ]
127
+ },
128
+ "rebase": "incumbent waveform, fusion and four heads; joint BIOT and TUEV head from readout epoch 9; zero initialized neural interaction",
129
+ "jointly_finetuned_neural_parent": "/workspace/research/runs/hybrid_biot_readout1/epoch-009/weights.pt",
130
+ "tuev_high_dimensional_spectral_projection_disabled": true,
131
+ "frozen_prior_representation": true,
132
+ "nonclinical_head_updates": "only the 256 added BIOT columns; original columns and biases fixed",
133
+ "faced_openbmi_neural_path": "common nonlinear fusion only; direct head columns masked",
134
+ "retention_teacher": "/workspace/research/runs/hybrid_wide1/epoch-004",
135
+ "retention_loss": {
136
+ "split": "train",
137
+ "temperature": 2.0,
138
+ "kl_weight": 1.0,
139
+ "tracks": [
140
+ "faced",
141
+ "ad65",
142
+ "openbmi",
143
+ "longitudinal"
144
+ ]
145
+ }
146
+ },
147
+ "joint_covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
148
+ "frozen_prior_representation": true,
149
+ "head_updates": "one linear head per track; added 128 shared covariance columns trainable; AD head initialized from the joint covariance parent",
150
+ "new_shared_representation": "one common covariance MLP inside the coupled backbone, trained by all five tasks; fixed spatial input adapters from the same jointly trained source",
151
+ "head_arithmetic": "one linear head evaluated in fixed feature blocks to preserve original bfloat16 accumulation dimensions",
152
+ "retention_teacher": {
153
+ "ad65": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
154
+ "other_tracks": "/workspace/research/runs/hybrid_wide1/epoch-004"
155
+ },
156
+ "retention_loss": {
157
+ "split": "train",
158
+ "temperature": 2.0,
159
+ "kl_weight": 1.0,
160
+ "tracks": [
161
+ "faced",
162
+ "ad65",
163
+ "openbmi",
164
+ "longitudinal"
165
+ ]
166
+ }
167
+ },
168
+ "loader_scale": 0.01,
169
+ "tracks": [
170
+ "faced",
171
+ "tuev",
172
+ "ad65",
173
+ "openbmi",
174
+ "longitudinal"
175
+ ],
176
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
177
+ "head_refinement": {
178
+ "source": "/workspace/research/runs/residual_heads1/epoch-018",
179
+ "source_weights_sha256": "e0b609137391b47f99438ccadaa22fc0bc10d2c10ead0ddf0a3c25be2c907c85",
180
+ "shared_backbone_unchanged": true,
181
+ "selected_head_epochs": {
182
+ "faced": 5,
183
+ "tuev": 24,
184
+ "ad65": 0,
185
+ "openbmi": 0,
186
+ "longitudinal": 0
187
+ }
188
+ },
189
+ "clinical_spectral_refinement": {
190
+ "source": "/workspace/research/runs/head_dropout1/epoch-016",
191
+ "zero_initialized_input_adapter": true,
192
+ "backbone_unchanged": true
193
+ },
194
+ "head_estimation": {
195
+ "method": "class/subject-balanced Gaussian linear discriminant with shrunk within-class covariance",
196
+ "selected_shrinkage": {
197
+ "faced": "inherited",
198
+ "tuev": "inherited",
199
+ "ad65": "inherited",
200
+ "openbmi": "inherited",
201
+ "longitudinal": 0.9
202
+ },
203
+ "feature_scaling": "fitted on training data and folded into linear coefficients"
204
+ }
205
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/covariances.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared neural filter-bank covariance decoder with spatial input adapters."""
2
+ import torch
3
+ from torch import nn
4
+ SPECS={'faced':(32,10,9),'tuev':(16,5,6),'ad65':(19,10,3),'openbmi':(62,4,2),'longitudinal':(58,2,2)}
5
+ TRACKS=tuple(SPECS)
6
+ BANDS=[(1,4),(4,8),(8,12),(12,16),(16,20),(20,24),(24,28),(28,32),(32,40),(40,48)]
7
+
8
+ @torch.no_grad()
9
+ def extract_covariances(t,x):
10
+ x=torch.nan_to_num(x.float().flatten(2)).clamp(-1e5,1e5)
11
+ x=x-x.mean(-1,keepdim=True)
12
+ if t in ('faced','tuev'):
13
+ x=x/x.square().mean(-1,keepdim=True).clamp_min(1e-12).sqrt()
14
+ else:x=x-x.mean(1,keepdim=True)
15
+ # Per-window normalization, preserving spatial and frequency power ratios.
16
+ x=x/x.square().mean((1,2),keepdim=True).clamp_min(1e-12).sqrt()
17
+ frames=x.unfold(-1,400,200);frames=frames-frames.mean(-1,keepdim=True)
18
+ z=torch.fft.rfft(frames*torch.hann_window(400,device=x.device),dim=-1)/200
19
+ covs=[]
20
+ for lo,hi in BANDS:
21
+ v=z[...,2*lo:2*hi].flatten(2)
22
+ cov=(v.real@v.real.transpose(-1,-2)+v.imag@v.imag.transpose(-1,-2))/v.shape[-1]
23
+ covs.append(cov)
24
+ return torch.stack(covs,1)
25
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/data.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from functools import lru_cache
3
+ from pathlib import Path
4
+ import numpy as np
5
+ import torch
6
+ @lru_cache(maxsize=8)
7
+ def array(path):return np.load(path,mmap_mode='r',allow_pickle=False)
8
+ class Dataset(torch.utils.data.Dataset):
9
+ def __init__(self,root,limit=None,cache=False):
10
+ self.root=Path(root)
11
+ self.rows=json.loads((self.root/'manifest.json').read_text())['samples']
12
+ if limit:self.rows=self.rows[:limit]
13
+ self.cached=None
14
+ if cache and self.rows:
15
+ from collections import defaultdict
16
+ groups=defaultdict(list)
17
+ for i,r in enumerate(self.rows):groups[r['path']].append((i,r['index']))
18
+ for name,indices in groups.items():
19
+ path=(self.root/name).resolve()
20
+ if not path.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
21
+ source=np.load(path,mmap_mode='r',allow_pickle=False)
22
+ if self.cached is None:self.cached=torch.empty((len(self.rows),*source.shape[1:]),dtype=torch.float32)
23
+ dst,src=zip(*indices)
24
+ self.cached[list(dst)]=torch.as_tensor(source[list(src)]/100,dtype=torch.float32)
25
+ def __len__(self):return len(self.rows)
26
+ def __getitem__(self,i):
27
+ r=self.rows[i]
28
+ if self.cached is not None:return self.cached[i],r.get('label',-1),r['id']
29
+ p=(self.root/r['path']).resolve()
30
+ if not p.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
31
+ # Division precedes float32 conversion, matching official FACED/TUEV collate.
32
+ x=np.asarray(array(str(p))[r['index']])/100
33
+ return torch.as_tensor(x,dtype=torch.float32),r.get('label',-1),r['id']
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/features.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One shared residual backbone, five linear input adapters and output heads."""
2
+ import torch
3
+ from torch import nn
4
+
5
+ SPECS = {'faced': (32, 10, 9), 'tuev': (16, 5, 6), 'ad65': (19, 10, 3),
6
+ 'openbmi': (62, 4, 2), 'longitudinal': (58, 2, 2)}
7
+ TRACKS = tuple(SPECS)
8
+ EDGES = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,18,20,22,25,28,32,36,40,45,50,60,70,80,95]
9
+ COV_BANDS = [(1,4),(4,8),(8,12),(12,16),(16,20),(20,28),(28,40)]
10
+
11
+ def feature_dim(channels):
12
+ return channels * (4*(len(EDGES)-1)+4) + len(COV_BANDS)*channels*(channels-1)//2
13
+
14
+ @torch.no_grad()
15
+ def extract_features(track, x):
16
+ """Fixed features; no batch statistics or fitted inference transformations."""
17
+ x = x.float().flatten(2)
18
+ x = torch.nan_to_num(x, nan=0., posinf=1e5, neginf=-1e5).clamp(-1e5,1e5)
19
+ x = x - x.mean(-1,keepdim=True)
20
+ if track in ('ad65','openbmi','longitudinal'):
21
+ x = x - x.mean(1,keepdim=True)
22
+ rms = x.square().mean(-1).clamp_min(1e-12).sqrt()
23
+ norm = x / rms.unsqueeze(-1)
24
+ moments = torch.stack([rms.log(), norm.abs().amax(-1).clamp_min(1).log(),
25
+ norm.pow(4).mean(-1).clamp_min(1).log(),
26
+ (norm[...,1:]-norm[...,:-1]).square().mean(-1).clamp_min(1e-10).log()],-1)
27
+ frames = x.unfold(-1,400,200)
28
+ frames = frames - frames.mean(-1,keepdim=True)
29
+ window = torch.hann_window(400,device=x.device)
30
+ z = torch.fft.rfft(frames*window,dim=-1)/200
31
+ power = z.abs().square()
32
+ bands = torch.stack([power[...,2*lo:2*hi].mean(-1) for lo,hi in zip(EDGES[:-1],EDGES[1:])],-1)
33
+ lp = bands.mean(-2).clamp_min(1e-12).log()
34
+ variation = bands.clamp_min(1e-12).log().std(-2,correction=0)
35
+ relative_frequency = lp - lp.mean(-1,keepdim=True)
36
+ relative_channel = lp - lp.mean(1,keepdim=True)
37
+ parts = [torch.cat([lp, relative_frequency, relative_channel, variation, moments],-1).flatten(1)]
38
+ ii,jj = torch.triu_indices(x.shape[1],x.shape[1],offset=1,device=x.device)
39
+ for lo,hi in COV_BANDS:
40
+ v = z[...,2*lo:2*hi].flatten(2)
41
+ cov = v.real @ v.real.transpose(-1,-2) + v.imag @ v.imag.transpose(-1,-2)
42
+ d = cov.diagonal(dim1=-2,dim2=-1).clamp_min(1e-12).sqrt()
43
+ cor = cov / (d.unsqueeze(1)*d.unsqueeze(2)).clamp_min(1e-12)
44
+ parts.append(cor[:,ii,jj].clamp(-1,1))
45
+ result = torch.cat(parts,-1)
46
+ return torch.nan_to_num(result).clamp(-40,40)
47
+
48
+ class Standardize(nn.Module):
49
+ def __init__(self, dim):
50
+ super().__init__()
51
+ self.register_buffer('mean',torch.zeros(dim))
52
+ self.register_buffer('scale',torch.ones(dim))
53
+ def forward(self,x):
54
+ return ((x-self.mean)/self.scale).clamp(-8,8)
55
+
56
+ class Residual(nn.Module):
57
+ def __init__(self,width,dropout):
58
+ super().__init__()
59
+ self.net=nn.Sequential(nn.LayerNorm(width),nn.Linear(width,width*2),nn.GELU(),
60
+ nn.Dropout(dropout),nn.Linear(width*2,width),nn.Dropout(dropout))
61
+ def forward(self,x):
62
+ return x+self.net(x)
63
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/infer.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse,json
2
+ from pathlib import Path
3
+ import torch
4
+ from model import HybridModel,SPECS
5
+ from data import Dataset
6
+ from covariances import extract_covariances
7
+ p=argparse.ArgumentParser();p.add_argument('input',type=Path);p.add_argument('output',type=Path);a=p.parse_args()
8
+ root=Path(__file__).resolve().parent;c=json.loads((root/'config.json').read_text());t=json.loads((a.input/'manifest.json').read_text())['track']
9
+ if t not in SPECS:raise ValueError('unknown track')
10
+ torch.set_num_threads(4);device='cuda' if torch.cuda.is_available() else 'cpu'
11
+ m=HybridModel(**c['architecture']).to(device);m.load_state_dict(torch.load(root/'weights.pt',map_location=device,weights_only=True));m.eval()
12
+ a.output.mkdir(parents=True,exist_ok=True)
13
+ with torch.inference_mode(),(a.output/'predictions.jsonl').open('w') as f:
14
+ for x,_,ids in torch.utils.data.DataLoader(Dataset(a.input),batch_size=64,num_workers=0):
15
+ # FFT features stay float32; convolutions can use bfloat16 on CUDA.
16
+ x=x.to(device)
17
+ from features import extract_features
18
+ torch.backends.cuda.matmul.allow_tf32=False
19
+ features=extract_features(t,x)
20
+ covariances=extract_covariances(t,x)
21
+ torch.backends.cuda.matmul.allow_tf32=True
22
+ with torch.autocast(device,dtype=torch.bfloat16,enabled=device=='cuda'):pred=m(t,x,features,covariances=covariances)
23
+ pp=pred.float().softmax(-1).cpu().numpy()
24
+ for sid,pr in zip(ids,pp):f.write(json.dumps({'id':sid,'probabilities':pr.tolist()})+'\n')
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/infer.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ exec python "$(dirname -- "$0")/infer.py" "$1" "$2"
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/model.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One fused waveform/spectral backbone used identically by all five tasks."""
2
+ import torch
3
+ from torch import nn
4
+ from braindecode.models import BIOT
5
+ from features import SPECS,TRACKS,feature_dim,extract_features,Standardize,Residual
6
+ from covariances import BANDS,extract_covariances
7
+
8
+ class InputAdapter(nn.Module):
9
+ def __init__(self,c,width,channels,spectral_enabled=True):
10
+ super().__init__()
11
+ self.signal=nn.Conv1d(c,channels,1,bias=False)
12
+ self.neural=nn.Conv1d(c,18,1,bias=False)
13
+ self.normalizer=Standardize(feature_dim(c))
14
+ self.spectral=nn.Linear(feature_dim(c),width)
15
+ self.dropout=nn.Dropout(.1)
16
+ self.register_buffer("spectral_enabled",torch.tensor(float(spectral_enabled)))
17
+ self.spatial_weight=nn.Parameter(torch.randn(len(BANDS),24,c)/c**.5)
18
+ def spatial_features(self,covariances):
19
+ with torch.autocast(covariances.device.type,enabled=False):
20
+ w=self.spatial_weight.float()/self.spatial_weight.float().norm(dim=-1,keepdim=True).clamp_min(1e-6)
21
+ power=torch.einsum('bfc,nbcd,bfd->nbf',w,covariances.float(),w).clamp_min(1e-8).log()
22
+ return torch.cat([power,power-power.mean(1,keepdim=True)],1).flatten(1)
23
+ def forward(self,x,features,covariance_features):
24
+ return self.signal(x).unsqueeze(1),self.spectral_enabled*self.spectral(self.dropout(self.normalizer(features))),self.neural(x),covariance_features
25
+
26
+ class SharedBackbone(nn.Module):
27
+ def __init__(self,channels,width,depth,dropout,wave_filters):
28
+ super().__init__()
29
+ self.waveform=nn.Sequential(
30
+ nn.Conv2d(1,wave_filters,(1,64),padding=(0,32),bias=False),nn.GroupNorm(1,wave_filters),
31
+ nn.Conv2d(wave_filters,2*wave_filters,(channels,1),groups=wave_filters,bias=False),nn.GroupNorm(1,2*wave_filters),nn.ELU(),
32
+ nn.AvgPool2d((1,4)),nn.Dropout(.35),
33
+ nn.Conv2d(2*wave_filters,2*wave_filters,(1,16),padding=(0,8),groups=2*wave_filters,bias=False),nn.Conv2d(2*wave_filters,2*wave_filters,1,bias=False),
34
+ nn.GroupNorm(1,2*wave_filters),nn.ELU(),nn.AvgPool2d((1,8)),nn.Dropout(.35))
35
+ self.wave_summary=nn.Sequential(nn.AdaptiveAvgPool2d((1,8)),nn.Flatten(),nn.Linear(2*wave_filters*8,width))
36
+ self.fusion=nn.Sequential(nn.LayerNorm(width),nn.GELU(),nn.Dropout(dropout),
37
+ *[Residual(width,dropout) for _ in range(depth)],nn.LayerNorm(width))
38
+ # Both representations interact before the shared residual stack.
39
+ self.wave_gain=nn.Parameter(torch.tensor(.1))
40
+ self.biot=BIOT(n_chans=18,n_outputs=2,n_times=400,sfreq=200)
41
+ self.biot.final_layer=nn.Identity()
42
+ self.biot_projection=nn.Sequential(nn.LayerNorm(256),nn.Linear(256,width),nn.Dropout(.2))
43
+ nn.init.normal_(self.biot_projection[1].weight,std=.001);nn.init.zeros_(self.biot_projection[1].bias)
44
+ self.covariance_encoder=nn.Sequential(nn.LayerNorm(len(BANDS)*24*2),nn.Linear(len(BANDS)*24*2,width),nn.GELU(),nn.Dropout(.4),
45
+ *[Residual(width,.4) for _ in range(2)],nn.LayerNorm(width))
46
+ self.covariance_projection=nn.Linear(width,width)
47
+ nn.init.zeros_(self.covariance_projection.weight);nn.init.zeros_(self.covariance_projection.bias)
48
+ def forward(self,signal,spectral,neural_signal,covariance_features):
49
+ wave=self.waveform(signal)
50
+ neural=self.biot(neural_signal.float())
51
+ neural=self.biot_projection[0](neural)
52
+ projected=self.biot_projection[2](self.biot_projection[1](neural))
53
+ with torch.autocast(signal.device.type,enabled=False):
54
+ covariance_embedding=self.covariance_encoder(covariance_features.float())
55
+ original=spectral+self.wave_gain*self.wave_summary(wave)+.01*projected
56
+ coupled=.001*self.covariance_projection(covariance_embedding).to(original.dtype)
57
+ fused=self.fusion(original+coupled)
58
+ return torch.cat([wave.flatten(1),fused,neural,covariance_embedding],-1)
59
+
60
+ class ResidualHead(nn.Module):
61
+ """A small nonlinear classifier correction around an inherited linear readout."""
62
+ def __init__(self,features,classes,width=64,dropout=.3,full_precision=False):
63
+ super().__init__();self.full_precision=full_precision
64
+ self.base=nn.Linear(features,classes)
65
+ self.delta=nn.Sequential(nn.LayerNorm(features),nn.Linear(features,width),nn.GELU(),nn.Dropout(dropout),nn.Linear(width,classes))
66
+ nn.init.zeros_(self.delta[-1].weight);nn.init.zeros_(self.delta[-1].bias)
67
+ def forward(self,x):
68
+ if self.full_precision:
69
+ with torch.autocast(x.device.type,enabled=False):return self.base(x.float())+self.delta(x.float())
70
+ prior=nn.functional.linear(x[:,:-128].contiguous(),self.base.weight[:,:-128].contiguous(),self.base.bias)
71
+ added=nn.functional.linear(x[:,-128:].contiguous(),self.base.weight[:,-128:].contiguous())
72
+ value=prior+added
73
+ return value+self.delta(x).to(value.dtype)
74
+
75
+ class HybridModel(nn.Module):
76
+ def __init__(self,channels=32,width=128,depth=2,dropout=.5,wave_filters=32,head_width=64,head_dropout=.3):
77
+ super().__init__()
78
+ self.adapters=nn.ModuleDict({t:InputAdapter(c,width,channels,spectral_enabled=t not in ("faced","tuev","openbmi")) for t,(c,s,k) in SPECS.items()})
79
+ self.backbone=SharedBackbone(channels,width,depth,dropout,wave_filters)
80
+ self.heads=nn.ModuleDict({t:ResidualHead(2*wave_filters*(((s*200+1)//4+1)//8)+width+256+width,k,head_width,head_dropout,full_precision=t=='ad65') for t,(c,s,k) in SPECS.items()})
81
+ def forward(self,t,x,features=None,covariances=None,covariance_features=None):
82
+ if features is None:features=extract_features(t,x)
83
+ if covariance_features is None:
84
+ if covariances is None:covariances=extract_covariances(t,x)
85
+ covariance_features=self.adapters[t].spatial_features(covariances)
86
+ signal=x.flatten(2);signal=signal-signal.mean(-1,keepdim=True)
87
+ if t in ('faced','tuev'):signal=signal/signal.std(-1,keepdim=True,correction=0).clamp_min(1e-6)
88
+ else:signal=signal-signal.mean(1,keepdim=True)
89
+ signal=signal.clamp(-20,20)
90
+ adapted=self.adapters[t](signal,features,covariance_features)
91
+ representation=self.backbone(*adapted)
92
+ if t in ('faced','openbmi'):
93
+ representation=torch.cat([representation[:,:-384],torch.zeros_like(representation[:,-384:-128]),representation[:,-128:]],-1)
94
+ return self.heads[t](representation)
95
+
96
+ def widen_state_dict(state,multiplier=2):
97
+ """Duplicate temporal features and divide downstream sums to preserve outputs."""
98
+ result={}
99
+ for key,value in state.items():
100
+ if key.startswith('backbone.waveform.'):
101
+ layer=int(key.split('.')[2])
102
+ if layer in (0,2,7):value=value.repeat(multiplier,1,1,1)
103
+ elif layer in (1,3,9):value=value.repeat(multiplier)
104
+ elif layer==8:value=value.repeat(multiplier,multiplier,1,1)/multiplier
105
+ elif key=='backbone.wave_summary.2.weight':value=value.repeat(1,multiplier)/multiplier
106
+ elif key.startswith('heads.') and key.endswith('.weight'):
107
+ raw=value[:,:-128]/multiplier
108
+ value=torch.cat([raw]*multiplier+[value[:,-128:]],1)
109
+ result[key]=value
110
+ return result
111
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S016/training.json ADDED
The diff for this file is too large to render. See raw diff
 
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/alpha_features.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixed alpha prominence features from each individual two-second window."""
2
+ import torch
3
+
4
+ REGION_NAMES=('occipital','parietal','central','frontal','left_posterior','right_posterior')
5
+ REGIONS=(('PO7','PO5','PO3','POZ','PO4','PO6','PO8','O1','OZ','O2'),
6
+ ('P7','P5','P3','P1','PZ','P2','P4','P6','P8'),
7
+ ('FC5','FC3','FC1','FCZ','FC2','FC4','FC6','C5','C3','C1','CZ','C2','C4','C6'),
8
+ ('FP1','FPZ','FP2','AF3','AF4','F7','F5','F3','F1','FZ','F2','F4','F6','F8'),
9
+ ('P7','P5','P3','P1','PO7','PO5','PO3','O1'),
10
+ ('P2','P4','P6','P8','PO4','PO6','PO8','O2'))
11
+ ALPHA_DIM=58*7+6*22
12
+
13
+ def region_matrix(channels):
14
+ result=torch.zeros(len(REGIONS),len(channels))
15
+ for i,names in enumerate(REGIONS):
16
+ for name in names:result[i,channels.index(name)]=1/len(names)
17
+ return result.tolist()
18
+
19
+ @torch.no_grad()
20
+ def extract_alpha_features(signal,regions):
21
+ with torch.autocast(signal.device.type,enabled=False):
22
+ x=signal.float();x=x-x.mean(-1,keepdim=True)
23
+ spectrum=torch.fft.rfft(x*torch.hann_window(400,device=x.device),dim=-1)/200
24
+ power=spectrum.abs().square().clamp_min(1e-12)
25
+ lp=power.log()
26
+ # Geometric regional means resist domination by one high-amplitude channel.
27
+ regional=torch.einsum('rc,ncf->nrf',regions.float(),lp)
28
+ lp=torch.cat([lp,regional],1)
29
+ low=lp[...,8:13].mean(-1,keepdim=True)
30
+ high=lp[...,36:49].mean(-1,keepdim=True)
31
+ freq=torch.arange(7.,14.5,.5,device=x.device)
32
+ alpha=lp[...,14:29]
33
+ baseline=low+(high-low)*((freq-5)/16)
34
+ prominence=alpha-baseline
35
+ normalized=alpha.softmax(-1)
36
+ center=(normalized*freq).sum(-1)
37
+ entropy=-(normalized*normalized.clamp_min(1e-12).log()).sum(-1)
38
+ alpha_mean=torch.logsumexp(alpha,-1)-torch.log(torch.tensor(15.,device=x.device))
39
+ def log_band(lo,hi):
40
+ return torch.logsumexp(lp[...,lo:hi],-1)-torch.log(torch.tensor(float(hi-lo),device=x.device))
41
+ summaries=torch.stack([alpha_mean-log_band(2,81),alpha_mean-log_band(8,14),
42
+ alpha_mean-log_band(30,61),prominence.max(-1).values,
43
+ prominence.mean(-1),center,entropy],-1)
44
+ return torch.cat([summaries[:,:58].flatten(1),summaries[:,58:].flatten(1),
45
+ prominence[:,58:].flatten(1)],1)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/config.json ADDED
@@ -0,0 +1,611 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "bci-shared-biot-covariance-bf16head-v1",
3
+ "architecture": {
4
+ "channels": 32,
5
+ "width": 128,
6
+ "depth": 2,
7
+ "dropout": 0.5,
8
+ "wave_filters": 32,
9
+ "head_width": 64,
10
+ "head_dropout": 0.3,
11
+ "clinical_asymmetry": true,
12
+ "alpha_regions": [
13
+ [
14
+ 0.0,
15
+ 0.0,
16
+ 0.0,
17
+ 0.0,
18
+ 0.0,
19
+ 0.0,
20
+ 0.0,
21
+ 0.0,
22
+ 0.0,
23
+ 0.0,
24
+ 0.0,
25
+ 0.0,
26
+ 0.0,
27
+ 0.0,
28
+ 0.0,
29
+ 0.0,
30
+ 0.0,
31
+ 0.0,
32
+ 0.0,
33
+ 0.0,
34
+ 0.0,
35
+ 0.0,
36
+ 0.0,
37
+ 0.0,
38
+ 0.0,
39
+ 0.0,
40
+ 0.0,
41
+ 0.0,
42
+ 0.0,
43
+ 0.0,
44
+ 0.0,
45
+ 0.0,
46
+ 0.0,
47
+ 0.0,
48
+ 0.0,
49
+ 0.0,
50
+ 0.0,
51
+ 0.0,
52
+ 0.0,
53
+ 0.0,
54
+ 0.0,
55
+ 0.0,
56
+ 0.0,
57
+ 0.0,
58
+ 0.0,
59
+ 0.0,
60
+ 0.0,
61
+ 0.0,
62
+ 0.10000000149011612,
63
+ 0.10000000149011612,
64
+ 0.10000000149011612,
65
+ 0.10000000149011612,
66
+ 0.10000000149011612,
67
+ 0.10000000149011612,
68
+ 0.10000000149011612,
69
+ 0.10000000149011612,
70
+ 0.10000000149011612,
71
+ 0.10000000149011612
72
+ ],
73
+ [
74
+ 0.0,
75
+ 0.0,
76
+ 0.0,
77
+ 0.0,
78
+ 0.0,
79
+ 0.0,
80
+ 0.0,
81
+ 0.0,
82
+ 0.0,
83
+ 0.0,
84
+ 0.0,
85
+ 0.0,
86
+ 0.0,
87
+ 0.0,
88
+ 0.0,
89
+ 0.0,
90
+ 0.0,
91
+ 0.0,
92
+ 0.0,
93
+ 0.0,
94
+ 0.0,
95
+ 0.0,
96
+ 0.0,
97
+ 0.0,
98
+ 0.0,
99
+ 0.0,
100
+ 0.0,
101
+ 0.0,
102
+ 0.0,
103
+ 0.0,
104
+ 0.0,
105
+ 0.0,
106
+ 0.0,
107
+ 0.0,
108
+ 0.0,
109
+ 0.0,
110
+ 0.0,
111
+ 0.0,
112
+ 0.0,
113
+ 0.1111111119389534,
114
+ 0.1111111119389534,
115
+ 0.1111111119389534,
116
+ 0.1111111119389534,
117
+ 0.1111111119389534,
118
+ 0.1111111119389534,
119
+ 0.1111111119389534,
120
+ 0.1111111119389534,
121
+ 0.1111111119389534,
122
+ 0.0,
123
+ 0.0,
124
+ 0.0,
125
+ 0.0,
126
+ 0.0,
127
+ 0.0,
128
+ 0.0,
129
+ 0.0,
130
+ 0.0,
131
+ 0.0
132
+ ],
133
+ [
134
+ 0.0,
135
+ 0.0,
136
+ 0.0,
137
+ 0.0,
138
+ 0.0,
139
+ 0.0,
140
+ 0.0,
141
+ 0.0,
142
+ 0.0,
143
+ 0.0,
144
+ 0.0,
145
+ 0.0,
146
+ 0.0,
147
+ 0.0,
148
+ 0.0714285746216774,
149
+ 0.0714285746216774,
150
+ 0.0714285746216774,
151
+ 0.0714285746216774,
152
+ 0.0714285746216774,
153
+ 0.0714285746216774,
154
+ 0.0714285746216774,
155
+ 0.0,
156
+ 0.0714285746216774,
157
+ 0.0714285746216774,
158
+ 0.0714285746216774,
159
+ 0.0714285746216774,
160
+ 0.0714285746216774,
161
+ 0.0714285746216774,
162
+ 0.0714285746216774,
163
+ 0.0,
164
+ 0.0,
165
+ 0.0,
166
+ 0.0,
167
+ 0.0,
168
+ 0.0,
169
+ 0.0,
170
+ 0.0,
171
+ 0.0,
172
+ 0.0,
173
+ 0.0,
174
+ 0.0,
175
+ 0.0,
176
+ 0.0,
177
+ 0.0,
178
+ 0.0,
179
+ 0.0,
180
+ 0.0,
181
+ 0.0,
182
+ 0.0,
183
+ 0.0,
184
+ 0.0,
185
+ 0.0,
186
+ 0.0,
187
+ 0.0,
188
+ 0.0,
189
+ 0.0,
190
+ 0.0,
191
+ 0.0
192
+ ],
193
+ [
194
+ 0.0714285746216774,
195
+ 0.0714285746216774,
196
+ 0.0714285746216774,
197
+ 0.0714285746216774,
198
+ 0.0714285746216774,
199
+ 0.0714285746216774,
200
+ 0.0714285746216774,
201
+ 0.0714285746216774,
202
+ 0.0714285746216774,
203
+ 0.0714285746216774,
204
+ 0.0714285746216774,
205
+ 0.0714285746216774,
206
+ 0.0714285746216774,
207
+ 0.0714285746216774,
208
+ 0.0,
209
+ 0.0,
210
+ 0.0,
211
+ 0.0,
212
+ 0.0,
213
+ 0.0,
214
+ 0.0,
215
+ 0.0,
216
+ 0.0,
217
+ 0.0,
218
+ 0.0,
219
+ 0.0,
220
+ 0.0,
221
+ 0.0,
222
+ 0.0,
223
+ 0.0,
224
+ 0.0,
225
+ 0.0,
226
+ 0.0,
227
+ 0.0,
228
+ 0.0,
229
+ 0.0,
230
+ 0.0,
231
+ 0.0,
232
+ 0.0,
233
+ 0.0,
234
+ 0.0,
235
+ 0.0,
236
+ 0.0,
237
+ 0.0,
238
+ 0.0,
239
+ 0.0,
240
+ 0.0,
241
+ 0.0,
242
+ 0.0,
243
+ 0.0,
244
+ 0.0,
245
+ 0.0,
246
+ 0.0,
247
+ 0.0,
248
+ 0.0,
249
+ 0.0,
250
+ 0.0,
251
+ 0.0
252
+ ],
253
+ [
254
+ 0.0,
255
+ 0.0,
256
+ 0.0,
257
+ 0.0,
258
+ 0.0,
259
+ 0.0,
260
+ 0.0,
261
+ 0.0,
262
+ 0.0,
263
+ 0.0,
264
+ 0.0,
265
+ 0.0,
266
+ 0.0,
267
+ 0.0,
268
+ 0.0,
269
+ 0.0,
270
+ 0.0,
271
+ 0.0,
272
+ 0.0,
273
+ 0.0,
274
+ 0.0,
275
+ 0.0,
276
+ 0.0,
277
+ 0.0,
278
+ 0.0,
279
+ 0.0,
280
+ 0.0,
281
+ 0.0,
282
+ 0.0,
283
+ 0.0,
284
+ 0.0,
285
+ 0.0,
286
+ 0.0,
287
+ 0.0,
288
+ 0.0,
289
+ 0.0,
290
+ 0.0,
291
+ 0.0,
292
+ 0.0,
293
+ 0.125,
294
+ 0.125,
295
+ 0.125,
296
+ 0.125,
297
+ 0.0,
298
+ 0.0,
299
+ 0.0,
300
+ 0.0,
301
+ 0.0,
302
+ 0.125,
303
+ 0.125,
304
+ 0.125,
305
+ 0.0,
306
+ 0.0,
307
+ 0.0,
308
+ 0.0,
309
+ 0.125,
310
+ 0.0,
311
+ 0.0
312
+ ],
313
+ [
314
+ 0.0,
315
+ 0.0,
316
+ 0.0,
317
+ 0.0,
318
+ 0.0,
319
+ 0.0,
320
+ 0.0,
321
+ 0.0,
322
+ 0.0,
323
+ 0.0,
324
+ 0.0,
325
+ 0.0,
326
+ 0.0,
327
+ 0.0,
328
+ 0.0,
329
+ 0.0,
330
+ 0.0,
331
+ 0.0,
332
+ 0.0,
333
+ 0.0,
334
+ 0.0,
335
+ 0.0,
336
+ 0.0,
337
+ 0.0,
338
+ 0.0,
339
+ 0.0,
340
+ 0.0,
341
+ 0.0,
342
+ 0.0,
343
+ 0.0,
344
+ 0.0,
345
+ 0.0,
346
+ 0.0,
347
+ 0.0,
348
+ 0.0,
349
+ 0.0,
350
+ 0.0,
351
+ 0.0,
352
+ 0.0,
353
+ 0.0,
354
+ 0.0,
355
+ 0.0,
356
+ 0.0,
357
+ 0.0,
358
+ 0.125,
359
+ 0.125,
360
+ 0.125,
361
+ 0.125,
362
+ 0.0,
363
+ 0.0,
364
+ 0.0,
365
+ 0.0,
366
+ 0.125,
367
+ 0.125,
368
+ 0.125,
369
+ 0.0,
370
+ 0.0,
371
+ 0.125
372
+ ]
373
+ ],
374
+ "clinical_envelope": true
375
+ },
376
+ "initialization": {
377
+ "initialization": "continue joint training from a complete shared-model checkpoint",
378
+ "parent": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
379
+ "parent_initialization": {
380
+ "initialization": "jointly trained parent plus audited pretrained BIOT in a single coupled backbone",
381
+ "parent": "/workspace/research/runs/hybrid_wide1/epoch-004/weights.pt",
382
+ "audited_biot": {
383
+ "initialization": "pretrained",
384
+ "repo": "braindecode/biot-pretrained-six-datasets-18chs",
385
+ "revision": "7e9aabf302870012f73773276803aab97993951c",
386
+ "sha256": "a218f4054ae29962c6fd9d23d94c446d354c4f53e805a6771c85749ccc20baaa",
387
+ "license": "BSD-3-Clause",
388
+ "source_braindecode": "1.3.0",
389
+ "loaded_core_tensors": 56,
390
+ "skipped_classifier_tensors": 3
391
+ },
392
+ "neural_channel_indices": {
393
+ "faced": [
394
+ 0,
395
+ 1,
396
+ 2,
397
+ 3,
398
+ 4,
399
+ 5,
400
+ 6,
401
+ 7,
402
+ 8,
403
+ 9,
404
+ 10,
405
+ 11,
406
+ 12,
407
+ 13,
408
+ 14,
409
+ 15,
410
+ 16,
411
+ 17
412
+ ],
413
+ "tuev": [
414
+ 0,
415
+ 1,
416
+ 2,
417
+ 3,
418
+ 4,
419
+ 5,
420
+ 6,
421
+ 7,
422
+ 8,
423
+ 9,
424
+ 10,
425
+ 11,
426
+ 12,
427
+ 13,
428
+ 14,
429
+ 15
430
+ ],
431
+ "ad65": [
432
+ 0,
433
+ 1,
434
+ 2,
435
+ 3,
436
+ 4,
437
+ 5,
438
+ 6,
439
+ 7,
440
+ 8,
441
+ 9,
442
+ 10,
443
+ 11,
444
+ 12,
445
+ 13,
446
+ 14,
447
+ 15,
448
+ 16,
449
+ 17
450
+ ],
451
+ "openbmi": [
452
+ 0,
453
+ 1,
454
+ 3,
455
+ 5,
456
+ 12,
457
+ 14,
458
+ 23,
459
+ 25,
460
+ 28,
461
+ 30,
462
+ 2,
463
+ 6,
464
+ 11,
465
+ 15,
466
+ 22,
467
+ 26,
468
+ 4,
469
+ 13
470
+ ],
471
+ "longitudinal": [
472
+ 0,
473
+ 2,
474
+ 7,
475
+ 11,
476
+ 23,
477
+ 27,
478
+ 41,
479
+ 45,
480
+ 55,
481
+ 57,
482
+ 5,
483
+ 13,
484
+ 21,
485
+ 29,
486
+ 39,
487
+ 47,
488
+ 9,
489
+ 25
490
+ ]
491
+ },
492
+ "rebase": "incumbent waveform, fusion and four heads; joint BIOT and TUEV head from readout epoch 9; zero initialized neural interaction",
493
+ "jointly_finetuned_neural_parent": "/workspace/research/runs/hybrid_biot_readout1/epoch-009/weights.pt",
494
+ "tuev_high_dimensional_spectral_projection_disabled": true,
495
+ "frozen_prior_representation": true,
496
+ "nonclinical_head_updates": "only the 256 added BIOT columns; original columns and biases fixed",
497
+ "faced_openbmi_neural_path": "common nonlinear fusion only; direct head columns masked",
498
+ "retention_teacher": "/workspace/research/runs/hybrid_wide1/epoch-004",
499
+ "retention_loss": {
500
+ "split": "train",
501
+ "temperature": 2.0,
502
+ "kl_weight": 1.0,
503
+ "tracks": [
504
+ "faced",
505
+ "ad65",
506
+ "openbmi",
507
+ "longitudinal"
508
+ ]
509
+ }
510
+ },
511
+ "joint_covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
512
+ "frozen_prior_representation": true,
513
+ "head_updates": "one linear head per track; added 128 shared covariance columns trainable; AD head initialized from the joint covariance parent",
514
+ "new_shared_representation": "one common covariance MLP inside the coupled backbone, trained by all five tasks; fixed spatial input adapters from the same jointly trained source",
515
+ "head_arithmetic": "one linear head evaluated in fixed feature blocks to preserve original bfloat16 accumulation dimensions",
516
+ "retention_teacher": {
517
+ "ad65": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
518
+ "other_tracks": "/workspace/research/runs/hybrid_wide1/epoch-004"
519
+ },
520
+ "retention_loss": {
521
+ "split": "train",
522
+ "temperature": 2.0,
523
+ "kl_weight": 1.0,
524
+ "tracks": [
525
+ "faced",
526
+ "ad65",
527
+ "openbmi",
528
+ "longitudinal"
529
+ ]
530
+ }
531
+ },
532
+ "loader_scale": 0.01,
533
+ "tracks": [
534
+ "faced",
535
+ "tuev",
536
+ "ad65",
537
+ "openbmi",
538
+ "longitudinal"
539
+ ],
540
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
541
+ "head_refinement": {
542
+ "source": "/workspace/research/runs/residual_heads1/epoch-018",
543
+ "source_weights_sha256": "e0b609137391b47f99438ccadaa22fc0bc10d2c10ead0ddf0a3c25be2c907c85",
544
+ "shared_backbone_unchanged": true,
545
+ "selected_head_epochs": {
546
+ "faced": 5,
547
+ "tuev": 24,
548
+ "ad65": 0,
549
+ "openbmi": 0,
550
+ "longitudinal": 0
551
+ }
552
+ },
553
+ "clinical_spectral_refinement": {
554
+ "source": "/workspace/research/runs/head_dropout1/epoch-016",
555
+ "zero_initialized_input_adapter": true,
556
+ "backbone_unchanged": true
557
+ },
558
+ "head_estimation": {
559
+ "method": "class/subject-balanced Gaussian linear discriminant; covariance augmented by class-conditional subject/session mean variation before shrinkage",
560
+ "selected_shrinkage": {
561
+ "faced": "inherited",
562
+ "tuev": "inherited",
563
+ "ad65": "inherited",
564
+ "openbmi": "inherited",
565
+ "longitudinal": {
566
+ "shrinkage": 0.9,
567
+ "domain_strength": 1.0
568
+ }
569
+ },
570
+ "feature_scaling": "fitted on training data and folded into linear coefficients"
571
+ },
572
+ "clinical_asymmetry_refinement": {
573
+ "source": "/workspace/research/runs/domain_lda_heads1/epoch-001",
574
+ "zero_initialized_input_adapter": true,
575
+ "backbone_unchanged": true
576
+ },
577
+ "alpha_rhythm_adapter": {
578
+ "training_normalization_only": true,
579
+ "regions": [
580
+ "occipital",
581
+ "parietal",
582
+ "central",
583
+ "frontal",
584
+ "left_posterior",
585
+ "right_posterior"
586
+ ],
587
+ "features": "per-window alpha prominence relative to adjacent frequencies",
588
+ "shared_backbone_unchanged": true
589
+ },
590
+ "clinical_envelope_refinement": {
591
+ "source": "/workspace/research/runs/clinical_asymmetry1/epoch-001",
592
+ "zero_initialized_input_adapter": true,
593
+ "backbone_unchanged": true
594
+ },
595
+ "independent_adapter_merge": {
596
+ "alpha_source": "/workspace/research/runs/alpha_calibrated1/epoch-003",
597
+ "clinical_source": "/workspace/research/runs/clinical_envelope1/epoch-002",
598
+ "all_shared_and_head_tensors_equal": true
599
+ },
600
+ "frequency_montage_refinement": {
601
+ "six_frequency_bands": true,
602
+ "shared_encoder_unchanged": true,
603
+ "selected_track_epochs": {
604
+ "faced": 0,
605
+ "tuev": 2,
606
+ "ad65": 0,
607
+ "openbmi": 0,
608
+ "longitudinal": 2
609
+ }
610
+ }
611
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/covariances.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared neural filter-bank covariance decoder with spatial input adapters."""
2
+ import torch
3
+ from torch import nn
4
+ SPECS={'faced':(32,10,9),'tuev':(16,5,6),'ad65':(19,10,3),'openbmi':(62,4,2),'longitudinal':(58,2,2)}
5
+ TRACKS=tuple(SPECS)
6
+ BANDS=[(1,4),(4,8),(8,12),(12,16),(16,20),(20,24),(24,28),(28,32),(32,40),(40,48)]
7
+
8
+ @torch.no_grad()
9
+ def extract_covariances(t,x):
10
+ x=torch.nan_to_num(x.float().flatten(2)).clamp(-1e5,1e5)
11
+ x=x-x.mean(-1,keepdim=True)
12
+ if t in ('faced','tuev'):
13
+ x=x/x.square().mean(-1,keepdim=True).clamp_min(1e-12).sqrt()
14
+ else:x=x-x.mean(1,keepdim=True)
15
+ # Per-window normalization, preserving spatial and frequency power ratios.
16
+ x=x/x.square().mean((1,2),keepdim=True).clamp_min(1e-12).sqrt()
17
+ frames=x.unfold(-1,400,200);frames=frames-frames.mean(-1,keepdim=True)
18
+ z=torch.fft.rfft(frames*torch.hann_window(400,device=x.device),dim=-1)/200
19
+ covs=[]
20
+ for lo,hi in BANDS:
21
+ v=z[...,2*lo:2*hi].flatten(2)
22
+ cov=(v.real@v.real.transpose(-1,-2)+v.imag@v.imag.transpose(-1,-2))/v.shape[-1]
23
+ covs.append(cov)
24
+ return torch.stack(covs,1)
25
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/data.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from functools import lru_cache
3
+ from pathlib import Path
4
+ import numpy as np
5
+ import torch
6
+ @lru_cache(maxsize=8)
7
+ def array(path):return np.load(path,mmap_mode='r',allow_pickle=False)
8
+ class Dataset(torch.utils.data.Dataset):
9
+ def __init__(self,root,limit=None,cache=False):
10
+ self.root=Path(root)
11
+ self.rows=json.loads((self.root/'manifest.json').read_text())['samples']
12
+ if limit:self.rows=self.rows[:limit]
13
+ self.cached=None
14
+ if cache and self.rows:
15
+ from collections import defaultdict
16
+ groups=defaultdict(list)
17
+ for i,r in enumerate(self.rows):groups[r['path']].append((i,r['index']))
18
+ for name,indices in groups.items():
19
+ path=(self.root/name).resolve()
20
+ if not path.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
21
+ source=np.load(path,mmap_mode='r',allow_pickle=False)
22
+ if self.cached is None:self.cached=torch.empty((len(self.rows),*source.shape[1:]),dtype=torch.float32)
23
+ dst,src=zip(*indices)
24
+ self.cached[list(dst)]=torch.as_tensor(source[list(src)]/100,dtype=torch.float32)
25
+ def __len__(self):return len(self.rows)
26
+ def __getitem__(self,i):
27
+ r=self.rows[i]
28
+ if self.cached is not None:return self.cached[i],r.get('label',-1),r['id']
29
+ p=(self.root/r['path']).resolve()
30
+ if not p.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
31
+ # Division precedes float32 conversion, matching official FACED/TUEV collate.
32
+ x=np.asarray(array(str(p))[r['index']])/100
33
+ return torch.as_tensor(x,dtype=torch.float32),r.get('label',-1),r['id']
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/envelope_features.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Per-window burst-envelope regularity and bilateral synchrony, without fitting."""
2
+ import torch
3
+ import torch.nn.functional as F
4
+
5
+ BANDS=((1,4),(4,8),(8,13),(13,30),(30,45))
6
+ ENVELOPE_DIM=16*5*12+8*5*2
7
+
8
+ @torch.no_grad()
9
+ def extract_envelope_features(signal):
10
+ with torch.autocast(signal.device.type,enabled=False):
11
+ x=signal.float();x=x-x.mean(-1,keepdim=True)
12
+ spectrum=torch.fft.fft(x,dim=-1)
13
+ frequency=torch.fft.fftfreq(x.shape[-1],1/200,device=x.device)
14
+ envelopes=[]
15
+ for lo,hi in BANDS:
16
+ mask=((frequency>=lo)&(frequency<hi)).to(x.dtype)*2
17
+ analytic=torch.fft.ifft(spectrum*mask,dim=-1)
18
+ energy=analytic.abs().square()
19
+ envelope=F.avg_pool1d(energy.flatten(0,1).unsqueeze(1),20,10).squeeze(1)
20
+ envelopes.append(envelope.reshape(len(x),16,-1))
21
+ e=torch.stack(envelopes,2)
22
+ mean=e.mean(-1,keepdim=True).clamp_min(1e-12)
23
+ relative=e/mean
24
+ centered=relative-relative.mean(-1,keepdim=True)
25
+ std=centered.square().mean(-1,keepdim=True).sqrt().clamp_min(1e-6)
26
+ normalized=centered/std
27
+ acf=torch.stack([(normalized[...,:-lag]*normalized[...,lag:]).mean(-1)
28
+ for lag in range(4,41)],-1).clamp(-1,1)
29
+ acf_peak,acf_index=acf.max(-1)
30
+ probability=(relative/relative.sum(-1,keepdim=True).clamp_min(1e-12)).clamp_min(1e-12)
31
+ entropy=-(probability*probability.log()).sum(-1)
32
+ summaries=[std.squeeze(-1).clamp_min(1e-6).log(),relative.amax(-1).clamp_min(1).log(),entropy,
33
+ (relative>2).float().mean(-1),(relative>4).float().mean(-1),
34
+ ((relative[...,1:]>2)&(relative[...,:-1]<=2)).float().mean(-1),
35
+ acf_peak,(acf_index.float()+4)/40,
36
+ acf[...,0],acf[...,6],acf[...,16],acf[...,36]]
37
+ left=torch.tensor([0,1,2,3,8,9,10,11],device=x.device);right=left+4
38
+ synchrony=(normalized[:,left]*normalized[:,right]).mean(-1).clamp(-1,1)
39
+ imbalance=(std[:,left].squeeze(-1).log()-std[:,right].squeeze(-1).log()).abs()
40
+ return torch.cat([torch.stack(summaries,-1).flatten(1),synchrony.flatten(1),imbalance.flatten(1)],1)
41
+
42
+ def mirrored_features(features):
43
+ channels=torch.tensor([4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11],device=features.device)
44
+ return torch.cat([features[:,:16*5*12].reshape(-1,16,5,12)[:,channels].flatten(1),features[:,16*5*12:]],1)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/features.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One shared residual backbone, five linear input adapters and output heads."""
2
+ import torch
3
+ from torch import nn
4
+
5
+ SPECS = {'faced': (32, 10, 9), 'tuev': (16, 5, 6), 'ad65': (19, 10, 3),
6
+ 'openbmi': (62, 4, 2), 'longitudinal': (58, 2, 2)}
7
+ TRACKS = tuple(SPECS)
8
+ EDGES = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,18,20,22,25,28,32,36,40,45,50,60,70,80,95]
9
+ COV_BANDS = [(1,4),(4,8),(8,12),(12,16),(16,20),(20,28),(28,40)]
10
+
11
+ def feature_dim(channels):
12
+ return channels * (4*(len(EDGES)-1)+4) + len(COV_BANDS)*channels*(channels-1)//2
13
+
14
+ @torch.no_grad()
15
+ def extract_features(track, x):
16
+ """Fixed features; no batch statistics or fitted inference transformations."""
17
+ x = x.float().flatten(2)
18
+ x = torch.nan_to_num(x, nan=0., posinf=1e5, neginf=-1e5).clamp(-1e5,1e5)
19
+ x = x - x.mean(-1,keepdim=True)
20
+ if track in ('ad65','openbmi','longitudinal'):
21
+ x = x - x.mean(1,keepdim=True)
22
+ rms = x.square().mean(-1).clamp_min(1e-12).sqrt()
23
+ norm = x / rms.unsqueeze(-1)
24
+ moments = torch.stack([rms.log(), norm.abs().amax(-1).clamp_min(1).log(),
25
+ norm.pow(4).mean(-1).clamp_min(1).log(),
26
+ (norm[...,1:]-norm[...,:-1]).square().mean(-1).clamp_min(1e-10).log()],-1)
27
+ frames = x.unfold(-1,400,200)
28
+ frames = frames - frames.mean(-1,keepdim=True)
29
+ window = torch.hann_window(400,device=x.device)
30
+ z = torch.fft.rfft(frames*window,dim=-1)/200
31
+ power = z.abs().square()
32
+ bands = torch.stack([power[...,2*lo:2*hi].mean(-1) for lo,hi in zip(EDGES[:-1],EDGES[1:])],-1)
33
+ lp = bands.mean(-2).clamp_min(1e-12).log()
34
+ variation = bands.clamp_min(1e-12).log().std(-2,correction=0)
35
+ relative_frequency = lp - lp.mean(-1,keepdim=True)
36
+ relative_channel = lp - lp.mean(1,keepdim=True)
37
+ parts = [torch.cat([lp, relative_frequency, relative_channel, variation, moments],-1).flatten(1)]
38
+ ii,jj = torch.triu_indices(x.shape[1],x.shape[1],offset=1,device=x.device)
39
+ for lo,hi in COV_BANDS:
40
+ v = z[...,2*lo:2*hi].flatten(2)
41
+ cov = v.real @ v.real.transpose(-1,-2) + v.imag @ v.imag.transpose(-1,-2)
42
+ d = cov.diagonal(dim1=-2,dim2=-1).clamp_min(1e-12).sqrt()
43
+ cor = cov / (d.unsqueeze(1)*d.unsqueeze(2)).clamp_min(1e-12)
44
+ parts.append(cor[:,ii,jj].clamp(-1,1))
45
+ result = torch.cat(parts,-1)
46
+ return torch.nan_to_num(result).clamp(-40,40)
47
+
48
+ class Standardize(nn.Module):
49
+ def __init__(self, dim):
50
+ super().__init__()
51
+ self.register_buffer('mean',torch.zeros(dim))
52
+ self.register_buffer('scale',torch.ones(dim))
53
+ def forward(self,x):
54
+ return ((x-self.mean)/self.scale).clamp(-8,8)
55
+
56
+ class Residual(nn.Module):
57
+ def __init__(self,width,dropout):
58
+ super().__init__()
59
+ self.net=nn.Sequential(nn.LayerNorm(width),nn.Linear(width,width*2),nn.GELU(),
60
+ nn.Dropout(dropout),nn.Linear(width*2,width),nn.Dropout(dropout))
61
+ def forward(self,x):
62
+ return x+self.net(x)
63
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/frequency_features.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixed per-window frequency decomposition for a linear montage adapter."""
2
+ import torch
3
+
4
+ FREQUENCY_BANDS=((1,4),(4,8),(8,13),(13,20),(20,30),(30,45))
5
+
6
+ def frequency_components(signal):
7
+ with torch.autocast(signal.device.type,enabled=False):
8
+ x=signal.float();spectrum=torch.fft.rfft(x,dim=-1)
9
+ frequency=torch.fft.rfftfreq(x.shape[-1],d=1/200,device=x.device)
10
+ masks=torch.stack([((frequency>=lo)&(frequency<hi)).float() for lo,hi in FREQUENCY_BANDS])
11
+ return torch.fft.irfft(spectrum[:,None]*masks[None,:,None],n=x.shape[-1],dim=-1)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/infer.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse,json
2
+ from pathlib import Path
3
+ import torch
4
+ from model import HybridModel,SPECS
5
+ from data import Dataset
6
+ from covariances import extract_covariances
7
+ p=argparse.ArgumentParser();p.add_argument('input',type=Path);p.add_argument('output',type=Path);a=p.parse_args()
8
+ root=Path(__file__).resolve().parent;c=json.loads((root/'config.json').read_text());t=json.loads((a.input/'manifest.json').read_text())['track']
9
+ if t not in SPECS:raise ValueError('unknown track')
10
+ torch.set_num_threads(4);device='cuda' if torch.cuda.is_available() else 'cpu'
11
+ m=HybridModel(**c['architecture']).to(device);m.load_state_dict(torch.load(root/'weights.pt',map_location=device,weights_only=True));m.eval()
12
+ a.output.mkdir(parents=True,exist_ok=True)
13
+ with torch.inference_mode(),(a.output/'predictions.jsonl').open('w') as f:
14
+ for x,_,ids in torch.utils.data.DataLoader(Dataset(a.input),batch_size=64,num_workers=0):
15
+ # FFT features stay float32; convolutions can use bfloat16 on CUDA.
16
+ x=x.to(device)
17
+ from features import extract_features
18
+ torch.backends.cuda.matmul.allow_tf32=False
19
+ features=extract_features(t,x)
20
+ covariances=extract_covariances(t,x)
21
+ torch.backends.cuda.matmul.allow_tf32=True
22
+ with torch.autocast(device,dtype=torch.bfloat16,enabled=device=='cuda'):pred=m(t,x,features,covariances=covariances)
23
+ pp=pred.float().softmax(-1).cpu().numpy()
24
+ for sid,pr in zip(ids,pp):f.write(json.dumps({'id':sid,'probabilities':pr.tolist()})+'\n')
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/infer.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ exec python "$(dirname -- "$0")/infer.py" "$1" "$2"
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S021/model.py ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One fused waveform/spectral backbone used identically by all five tasks."""
2
+ import torch
3
+ from torch import nn
4
+ from braindecode.models import BIOT
5
+ from features import SPECS,TRACKS,feature_dim,extract_features,Standardize,Residual,EDGES,COV_BANDS
6
+ from covariances import BANDS,extract_covariances
7
+ from alpha_features import extract_alpha_features,ALPHA_DIM
8
+ from envelope_features import extract_envelope_features,ENVELOPE_DIM
9
+ from frequency_features import frequency_components,FREQUENCY_BANDS
10
+
11
+ def clinical_asymmetry_features(features):
12
+ """Bipolar homologous-channel amplitude and coherence, invariant to mirroring."""
13
+ bands=len(EDGES)-1;per_channel=4*bands+4
14
+ block=features[:,:16*per_channel].reshape(-1,16,per_channel)
15
+ left=torch.tensor([0,1,2,3,8,9,10,11],device=features.device);right=left+4
16
+ pair_power=(block[:,left,:bands]-block[:,right,:bands]).abs().flatten(1)
17
+ pair_rms=(block[:,left,4*bands]-block[:,right,4*bands]).abs()
18
+ hemisphere=(block[:,left,:bands].mean(1)-block[:,right,:bands].mean(1)).abs()
19
+ index=left*(32-left-1)//2+(right-left-1)
20
+ correlations=features[:,16*per_channel:].reshape(-1,len(COV_BANDS),120)[:,:,index].flatten(1)
21
+ return torch.cat([pair_power,pair_rms,hemisphere,correlations],1)
22
+
23
+ class InputAdapter(nn.Module):
24
+ def __init__(self,c,width,channels,spectral_enabled=True,asymmetry=False,alpha_regions=None,envelope=False):
25
+ super().__init__()
26
+ self.signal=nn.Conv1d(c,channels,1,bias=False)
27
+ self.frequency_weight=nn.Parameter(torch.zeros(len(FREQUENCY_BANDS),channels,c))
28
+ self.neural=nn.Conv1d(c,18,1,bias=False)
29
+ self.normalizer=Standardize(feature_dim(c))
30
+ self.spectral=nn.Linear(feature_dim(c),width)
31
+ self.dropout=nn.Dropout(.1)
32
+ self.register_buffer("spectral_enabled",torch.tensor(float(spectral_enabled)))
33
+ self.spatial_weight=nn.Parameter(torch.randn(len(BANDS),24,c)/c**.5)
34
+ self.asymmetry_projection=nn.Linear(316,width,bias=False) if asymmetry else None
35
+ if asymmetry:
36
+ nn.init.zeros_(self.asymmetry_projection.weight)
37
+ self.asymmetry_normalizer=Standardize(316)
38
+ self.asymmetry_dropout=nn.Dropout(.1)
39
+ self.alpha_projection=None
40
+ if alpha_regions is not None:
41
+ self.register_buffer('alpha_regions',torch.tensor(alpha_regions,dtype=torch.float32))
42
+ self.alpha_normalizer=Standardize(ALPHA_DIM)
43
+ self.alpha_projection=nn.Linear(ALPHA_DIM,width,bias=False)
44
+ nn.init.zeros_(self.alpha_projection.weight)
45
+ self.alpha_dropout=nn.Dropout(.3)
46
+ self.envelope_projection=None
47
+ if envelope:
48
+ self.envelope_normalizer=Standardize(ENVELOPE_DIM)
49
+ self.envelope_projection=nn.Linear(ENVELOPE_DIM,width,bias=False)
50
+ nn.init.zeros_(self.envelope_projection.weight)
51
+ self.envelope_dropout=nn.Dropout(.3)
52
+ def spectral_features(self,features,signal=None,alpha_features=None,envelope_features=None):
53
+ value=self.spectral_enabled*self.spectral(self.dropout(self.normalizer(features)))
54
+ if self.asymmetry_projection is not None:
55
+ extra=self.asymmetry_dropout(self.asymmetry_normalizer(clinical_asymmetry_features(features)))
56
+ value=value+self.asymmetry_projection(extra)
57
+ if self.alpha_projection is not None:
58
+ if alpha_features is None:alpha_features=extract_alpha_features(signal,self.alpha_regions)
59
+ value=value+self.alpha_projection(self.alpha_dropout(self.alpha_normalizer(alpha_features)))
60
+ if self.envelope_projection is not None:
61
+ if envelope_features is None:envelope_features=extract_envelope_features(signal)
62
+ value=value+self.envelope_projection(self.envelope_dropout(self.envelope_normalizer(envelope_features)))
63
+ return value
64
+ def spatial_features(self,covariances):
65
+ with torch.autocast(covariances.device.type,enabled=False):
66
+ w=self.spatial_weight.float()/self.spatial_weight.float().norm(dim=-1,keepdim=True).clamp_min(1e-6)
67
+ power=torch.einsum('bfc,nbcd,bfd->nbf',w,covariances.float(),w).clamp_min(1e-8).log()
68
+ return torch.cat([power,power-power.mean(1,keepdim=True)],1).flatten(1)
69
+ def wave_signal(self,x,components=None):
70
+ if components is None:components=frequency_components(x)
71
+ correction=torch.einsum('blc,nbct->nlt',self.frequency_weight,components.to(self.frequency_weight.dtype))
72
+ return (self.signal(x)+correction.to(x.dtype)).unsqueeze(1)
73
+ def forward(self,x,features,covariance_features):
74
+ return self.wave_signal(x),self.spectral_features(features,signal=x),self.neural(x),covariance_features
75
+
76
+ class SharedBackbone(nn.Module):
77
+ def __init__(self,channels,width,depth,dropout,wave_filters):
78
+ super().__init__()
79
+ self.waveform=nn.Sequential(
80
+ nn.Conv2d(1,wave_filters,(1,64),padding=(0,32),bias=False),nn.GroupNorm(1,wave_filters),
81
+ nn.Conv2d(wave_filters,2*wave_filters,(channels,1),groups=wave_filters,bias=False),nn.GroupNorm(1,2*wave_filters),nn.ELU(),
82
+ nn.AvgPool2d((1,4)),nn.Dropout(.35),
83
+ nn.Conv2d(2*wave_filters,2*wave_filters,(1,16),padding=(0,8),groups=2*wave_filters,bias=False),nn.Conv2d(2*wave_filters,2*wave_filters,1,bias=False),
84
+ nn.GroupNorm(1,2*wave_filters),nn.ELU(),nn.AvgPool2d((1,8)),nn.Dropout(.35))
85
+ self.wave_summary=nn.Sequential(nn.AdaptiveAvgPool2d((1,8)),nn.Flatten(),nn.Linear(2*wave_filters*8,width))
86
+ self.fusion=nn.Sequential(nn.LayerNorm(width),nn.GELU(),nn.Dropout(dropout),
87
+ *[Residual(width,dropout) for _ in range(depth)],nn.LayerNorm(width))
88
+ # Both representations interact before the shared residual stack.
89
+ self.wave_gain=nn.Parameter(torch.tensor(.1))
90
+ self.biot=BIOT(n_chans=18,n_outputs=2,n_times=400,sfreq=200)
91
+ self.biot.final_layer=nn.Identity()
92
+ self.biot_projection=nn.Sequential(nn.LayerNorm(256),nn.Linear(256,width),nn.Dropout(.2))
93
+ nn.init.normal_(self.biot_projection[1].weight,std=.001);nn.init.zeros_(self.biot_projection[1].bias)
94
+ self.covariance_encoder=nn.Sequential(nn.LayerNorm(len(BANDS)*24*2),nn.Linear(len(BANDS)*24*2,width),nn.GELU(),nn.Dropout(.4),
95
+ *[Residual(width,.4) for _ in range(2)],nn.LayerNorm(width))
96
+ self.covariance_projection=nn.Linear(width,width)
97
+ nn.init.zeros_(self.covariance_projection.weight);nn.init.zeros_(self.covariance_projection.bias)
98
+ def forward(self,signal,spectral,neural_signal,covariance_features):
99
+ wave=self.waveform(signal)
100
+ neural=self.biot(neural_signal.float())
101
+ neural=self.biot_projection[0](neural)
102
+ projected=self.biot_projection[2](self.biot_projection[1](neural))
103
+ with torch.autocast(signal.device.type,enabled=False):
104
+ covariance_embedding=self.covariance_encoder(covariance_features.float())
105
+ original=spectral+self.wave_gain*self.wave_summary(wave)+.01*projected
106
+ coupled=.001*self.covariance_projection(covariance_embedding).to(original.dtype)
107
+ fused=self.fusion(original+coupled)
108
+ return torch.cat([wave.flatten(1),fused,neural,covariance_embedding],-1)
109
+
110
+ class ResidualHead(nn.Module):
111
+ """A small nonlinear classifier correction around an inherited linear readout."""
112
+ def __init__(self,features,classes,width=64,dropout=.3,full_precision=False):
113
+ super().__init__();self.full_precision=full_precision
114
+ self.base=nn.Linear(features,classes)
115
+ self.delta=nn.Sequential(nn.LayerNorm(features),nn.Linear(features,width),nn.GELU(),nn.Dropout(dropout),nn.Linear(width,classes))
116
+ nn.init.zeros_(self.delta[-1].weight);nn.init.zeros_(self.delta[-1].bias)
117
+ def forward(self,x):
118
+ if self.full_precision:
119
+ with torch.autocast(x.device.type,enabled=False):return self.base(x.float())+self.delta(x.float())
120
+ prior=nn.functional.linear(x[:,:-128].contiguous(),self.base.weight[:,:-128].contiguous(),self.base.bias)
121
+ added=nn.functional.linear(x[:,-128:].contiguous(),self.base.weight[:,-128:].contiguous())
122
+ value=prior+added
123
+ return value+self.delta(x).to(value.dtype)
124
+
125
+ class HybridModel(nn.Module):
126
+ def __init__(self,channels=32,width=128,depth=2,dropout=.5,wave_filters=32,head_width=64,head_dropout=.3,clinical_asymmetry=True,alpha_regions=None,clinical_envelope=False):
127
+ super().__init__()
128
+ self.adapters=nn.ModuleDict({t:InputAdapter(c,width,channels,spectral_enabled=t not in ("faced","tuev","openbmi"),asymmetry=clinical_asymmetry and t=="tuev",alpha_regions=alpha_regions if t=="longitudinal" else None,envelope=clinical_envelope and t=="tuev") for t,(c,s,k) in SPECS.items()})
129
+ self.backbone=SharedBackbone(channels,width,depth,dropout,wave_filters)
130
+ self.heads=nn.ModuleDict({t:ResidualHead(2*wave_filters*(((s*200+1)//4+1)//8)+width+256+width,k,head_width,head_dropout,full_precision=t=='ad65') for t,(c,s,k) in SPECS.items()})
131
+ def forward(self,t,x,features=None,covariances=None,covariance_features=None):
132
+ if features is None:features=extract_features(t,x)
133
+ if covariance_features is None:
134
+ if covariances is None:covariances=extract_covariances(t,x)
135
+ covariance_features=self.adapters[t].spatial_features(covariances)
136
+ signal=x.flatten(2);signal=signal-signal.mean(-1,keepdim=True)
137
+ if t in ('faced','tuev'):signal=signal/signal.std(-1,keepdim=True,correction=0).clamp_min(1e-6)
138
+ else:signal=signal-signal.mean(1,keepdim=True)
139
+ signal=signal.clamp(-20,20)
140
+ adapted=self.adapters[t](signal,features,covariance_features)
141
+ representation=self.backbone(*adapted)
142
+ if t in ('faced','openbmi'):
143
+ representation=torch.cat([representation[:,:-384],torch.zeros_like(representation[:,-384:-128]),representation[:,-128:]],-1)
144
+ return self.heads[t](representation)
145
+
146
+ def widen_state_dict(state,multiplier=2):
147
+ """Duplicate temporal features and divide downstream sums to preserve outputs."""
148
+ result={}
149
+ for key,value in state.items():
150
+ if key.startswith('backbone.waveform.'):
151
+ layer=int(key.split('.')[2])
152
+ if layer in (0,2,7):value=value.repeat(multiplier,1,1,1)
153
+ elif layer in (1,3,9):value=value.repeat(multiplier)
154
+ elif layer==8:value=value.repeat(multiplier,multiplier,1,1)/multiplier
155
+ elif key=='backbone.wave_summary.2.weight':value=value.repeat(1,multiplier)/multiplier
156
+ elif key.startswith('heads.') and key.endswith('.weight'):
157
+ raw=value[:,:-128]/multiplier
158
+ value=torch.cat([raw]*multiplier+[value[:,-128:]],1)
159
+ result[key]=value
160
+ return result
161
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/alpha_features.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixed alpha prominence features from each individual two-second window."""
2
+ import torch
3
+
4
+ REGION_NAMES=('occipital','parietal','central','frontal','left_posterior','right_posterior')
5
+ REGIONS=(('PO7','PO5','PO3','POZ','PO4','PO6','PO8','O1','OZ','O2'),
6
+ ('P7','P5','P3','P1','PZ','P2','P4','P6','P8'),
7
+ ('FC5','FC3','FC1','FCZ','FC2','FC4','FC6','C5','C3','C1','CZ','C2','C4','C6'),
8
+ ('FP1','FPZ','FP2','AF3','AF4','F7','F5','F3','F1','FZ','F2','F4','F6','F8'),
9
+ ('P7','P5','P3','P1','PO7','PO5','PO3','O1'),
10
+ ('P2','P4','P6','P8','PO4','PO6','PO8','O2'))
11
+ ALPHA_DIM=58*7+6*22
12
+
13
+ def region_matrix(channels):
14
+ result=torch.zeros(len(REGIONS),len(channels))
15
+ for i,names in enumerate(REGIONS):
16
+ for name in names:result[i,channels.index(name)]=1/len(names)
17
+ return result.tolist()
18
+
19
+ @torch.no_grad()
20
+ def extract_alpha_features(signal,regions):
21
+ with torch.autocast(signal.device.type,enabled=False):
22
+ x=signal.float();x=x-x.mean(-1,keepdim=True)
23
+ spectrum=torch.fft.rfft(x*torch.hann_window(400,device=x.device),dim=-1)/200
24
+ power=spectrum.abs().square().clamp_min(1e-12)
25
+ lp=power.log()
26
+ # Geometric regional means resist domination by one high-amplitude channel.
27
+ regional=torch.einsum('rc,ncf->nrf',regions.float(),lp)
28
+ lp=torch.cat([lp,regional],1)
29
+ low=lp[...,8:13].mean(-1,keepdim=True)
30
+ high=lp[...,36:49].mean(-1,keepdim=True)
31
+ freq=torch.arange(7.,14.5,.5,device=x.device)
32
+ alpha=lp[...,14:29]
33
+ baseline=low+(high-low)*((freq-5)/16)
34
+ prominence=alpha-baseline
35
+ normalized=alpha.softmax(-1)
36
+ center=(normalized*freq).sum(-1)
37
+ entropy=-(normalized*normalized.clamp_min(1e-12).log()).sum(-1)
38
+ alpha_mean=torch.logsumexp(alpha,-1)-torch.log(torch.tensor(15.,device=x.device))
39
+ def log_band(lo,hi):
40
+ return torch.logsumexp(lp[...,lo:hi],-1)-torch.log(torch.tensor(float(hi-lo),device=x.device))
41
+ summaries=torch.stack([alpha_mean-log_band(2,81),alpha_mean-log_band(8,14),
42
+ alpha_mean-log_band(30,61),prominence.max(-1).values,
43
+ prominence.mean(-1),center,entropy],-1)
44
+ return torch.cat([summaries[:,:58].flatten(1),summaries[:,58:].flatten(1),
45
+ prominence[:,58:].flatten(1)],1)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/config.json ADDED
@@ -0,0 +1,637 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "bci-shared-biot-covariance-bf16head-v1",
3
+ "architecture": {
4
+ "channels": 32,
5
+ "width": 128,
6
+ "depth": 2,
7
+ "dropout": 0.5,
8
+ "wave_filters": 32,
9
+ "head_width": 64,
10
+ "head_dropout": 0.3,
11
+ "clinical_asymmetry": true,
12
+ "alpha_regions": [
13
+ [
14
+ 0.0,
15
+ 0.0,
16
+ 0.0,
17
+ 0.0,
18
+ 0.0,
19
+ 0.0,
20
+ 0.0,
21
+ 0.0,
22
+ 0.0,
23
+ 0.0,
24
+ 0.0,
25
+ 0.0,
26
+ 0.0,
27
+ 0.0,
28
+ 0.0,
29
+ 0.0,
30
+ 0.0,
31
+ 0.0,
32
+ 0.0,
33
+ 0.0,
34
+ 0.0,
35
+ 0.0,
36
+ 0.0,
37
+ 0.0,
38
+ 0.0,
39
+ 0.0,
40
+ 0.0,
41
+ 0.0,
42
+ 0.0,
43
+ 0.0,
44
+ 0.0,
45
+ 0.0,
46
+ 0.0,
47
+ 0.0,
48
+ 0.0,
49
+ 0.0,
50
+ 0.0,
51
+ 0.0,
52
+ 0.0,
53
+ 0.0,
54
+ 0.0,
55
+ 0.0,
56
+ 0.0,
57
+ 0.0,
58
+ 0.0,
59
+ 0.0,
60
+ 0.0,
61
+ 0.0,
62
+ 0.10000000149011612,
63
+ 0.10000000149011612,
64
+ 0.10000000149011612,
65
+ 0.10000000149011612,
66
+ 0.10000000149011612,
67
+ 0.10000000149011612,
68
+ 0.10000000149011612,
69
+ 0.10000000149011612,
70
+ 0.10000000149011612,
71
+ 0.10000000149011612
72
+ ],
73
+ [
74
+ 0.0,
75
+ 0.0,
76
+ 0.0,
77
+ 0.0,
78
+ 0.0,
79
+ 0.0,
80
+ 0.0,
81
+ 0.0,
82
+ 0.0,
83
+ 0.0,
84
+ 0.0,
85
+ 0.0,
86
+ 0.0,
87
+ 0.0,
88
+ 0.0,
89
+ 0.0,
90
+ 0.0,
91
+ 0.0,
92
+ 0.0,
93
+ 0.0,
94
+ 0.0,
95
+ 0.0,
96
+ 0.0,
97
+ 0.0,
98
+ 0.0,
99
+ 0.0,
100
+ 0.0,
101
+ 0.0,
102
+ 0.0,
103
+ 0.0,
104
+ 0.0,
105
+ 0.0,
106
+ 0.0,
107
+ 0.0,
108
+ 0.0,
109
+ 0.0,
110
+ 0.0,
111
+ 0.0,
112
+ 0.0,
113
+ 0.1111111119389534,
114
+ 0.1111111119389534,
115
+ 0.1111111119389534,
116
+ 0.1111111119389534,
117
+ 0.1111111119389534,
118
+ 0.1111111119389534,
119
+ 0.1111111119389534,
120
+ 0.1111111119389534,
121
+ 0.1111111119389534,
122
+ 0.0,
123
+ 0.0,
124
+ 0.0,
125
+ 0.0,
126
+ 0.0,
127
+ 0.0,
128
+ 0.0,
129
+ 0.0,
130
+ 0.0,
131
+ 0.0
132
+ ],
133
+ [
134
+ 0.0,
135
+ 0.0,
136
+ 0.0,
137
+ 0.0,
138
+ 0.0,
139
+ 0.0,
140
+ 0.0,
141
+ 0.0,
142
+ 0.0,
143
+ 0.0,
144
+ 0.0,
145
+ 0.0,
146
+ 0.0,
147
+ 0.0,
148
+ 0.0714285746216774,
149
+ 0.0714285746216774,
150
+ 0.0714285746216774,
151
+ 0.0714285746216774,
152
+ 0.0714285746216774,
153
+ 0.0714285746216774,
154
+ 0.0714285746216774,
155
+ 0.0,
156
+ 0.0714285746216774,
157
+ 0.0714285746216774,
158
+ 0.0714285746216774,
159
+ 0.0714285746216774,
160
+ 0.0714285746216774,
161
+ 0.0714285746216774,
162
+ 0.0714285746216774,
163
+ 0.0,
164
+ 0.0,
165
+ 0.0,
166
+ 0.0,
167
+ 0.0,
168
+ 0.0,
169
+ 0.0,
170
+ 0.0,
171
+ 0.0,
172
+ 0.0,
173
+ 0.0,
174
+ 0.0,
175
+ 0.0,
176
+ 0.0,
177
+ 0.0,
178
+ 0.0,
179
+ 0.0,
180
+ 0.0,
181
+ 0.0,
182
+ 0.0,
183
+ 0.0,
184
+ 0.0,
185
+ 0.0,
186
+ 0.0,
187
+ 0.0,
188
+ 0.0,
189
+ 0.0,
190
+ 0.0,
191
+ 0.0
192
+ ],
193
+ [
194
+ 0.0714285746216774,
195
+ 0.0714285746216774,
196
+ 0.0714285746216774,
197
+ 0.0714285746216774,
198
+ 0.0714285746216774,
199
+ 0.0714285746216774,
200
+ 0.0714285746216774,
201
+ 0.0714285746216774,
202
+ 0.0714285746216774,
203
+ 0.0714285746216774,
204
+ 0.0714285746216774,
205
+ 0.0714285746216774,
206
+ 0.0714285746216774,
207
+ 0.0714285746216774,
208
+ 0.0,
209
+ 0.0,
210
+ 0.0,
211
+ 0.0,
212
+ 0.0,
213
+ 0.0,
214
+ 0.0,
215
+ 0.0,
216
+ 0.0,
217
+ 0.0,
218
+ 0.0,
219
+ 0.0,
220
+ 0.0,
221
+ 0.0,
222
+ 0.0,
223
+ 0.0,
224
+ 0.0,
225
+ 0.0,
226
+ 0.0,
227
+ 0.0,
228
+ 0.0,
229
+ 0.0,
230
+ 0.0,
231
+ 0.0,
232
+ 0.0,
233
+ 0.0,
234
+ 0.0,
235
+ 0.0,
236
+ 0.0,
237
+ 0.0,
238
+ 0.0,
239
+ 0.0,
240
+ 0.0,
241
+ 0.0,
242
+ 0.0,
243
+ 0.0,
244
+ 0.0,
245
+ 0.0,
246
+ 0.0,
247
+ 0.0,
248
+ 0.0,
249
+ 0.0,
250
+ 0.0,
251
+ 0.0
252
+ ],
253
+ [
254
+ 0.0,
255
+ 0.0,
256
+ 0.0,
257
+ 0.0,
258
+ 0.0,
259
+ 0.0,
260
+ 0.0,
261
+ 0.0,
262
+ 0.0,
263
+ 0.0,
264
+ 0.0,
265
+ 0.0,
266
+ 0.0,
267
+ 0.0,
268
+ 0.0,
269
+ 0.0,
270
+ 0.0,
271
+ 0.0,
272
+ 0.0,
273
+ 0.0,
274
+ 0.0,
275
+ 0.0,
276
+ 0.0,
277
+ 0.0,
278
+ 0.0,
279
+ 0.0,
280
+ 0.0,
281
+ 0.0,
282
+ 0.0,
283
+ 0.0,
284
+ 0.0,
285
+ 0.0,
286
+ 0.0,
287
+ 0.0,
288
+ 0.0,
289
+ 0.0,
290
+ 0.0,
291
+ 0.0,
292
+ 0.0,
293
+ 0.125,
294
+ 0.125,
295
+ 0.125,
296
+ 0.125,
297
+ 0.0,
298
+ 0.0,
299
+ 0.0,
300
+ 0.0,
301
+ 0.0,
302
+ 0.125,
303
+ 0.125,
304
+ 0.125,
305
+ 0.0,
306
+ 0.0,
307
+ 0.0,
308
+ 0.0,
309
+ 0.125,
310
+ 0.0,
311
+ 0.0
312
+ ],
313
+ [
314
+ 0.0,
315
+ 0.0,
316
+ 0.0,
317
+ 0.0,
318
+ 0.0,
319
+ 0.0,
320
+ 0.0,
321
+ 0.0,
322
+ 0.0,
323
+ 0.0,
324
+ 0.0,
325
+ 0.0,
326
+ 0.0,
327
+ 0.0,
328
+ 0.0,
329
+ 0.0,
330
+ 0.0,
331
+ 0.0,
332
+ 0.0,
333
+ 0.0,
334
+ 0.0,
335
+ 0.0,
336
+ 0.0,
337
+ 0.0,
338
+ 0.0,
339
+ 0.0,
340
+ 0.0,
341
+ 0.0,
342
+ 0.0,
343
+ 0.0,
344
+ 0.0,
345
+ 0.0,
346
+ 0.0,
347
+ 0.0,
348
+ 0.0,
349
+ 0.0,
350
+ 0.0,
351
+ 0.0,
352
+ 0.0,
353
+ 0.0,
354
+ 0.0,
355
+ 0.0,
356
+ 0.0,
357
+ 0.0,
358
+ 0.125,
359
+ 0.125,
360
+ 0.125,
361
+ 0.125,
362
+ 0.0,
363
+ 0.0,
364
+ 0.0,
365
+ 0.0,
366
+ 0.125,
367
+ 0.125,
368
+ 0.125,
369
+ 0.0,
370
+ 0.0,
371
+ 0.125
372
+ ]
373
+ ],
374
+ "clinical_envelope": true,
375
+ "temporal_pool": true
376
+ },
377
+ "initialization": {
378
+ "initialization": "continue joint training from a complete shared-model checkpoint",
379
+ "parent": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
380
+ "parent_initialization": {
381
+ "initialization": "jointly trained parent plus audited pretrained BIOT in a single coupled backbone",
382
+ "parent": "/workspace/research/runs/hybrid_wide1/epoch-004/weights.pt",
383
+ "audited_biot": {
384
+ "initialization": "pretrained",
385
+ "repo": "braindecode/biot-pretrained-six-datasets-18chs",
386
+ "revision": "7e9aabf302870012f73773276803aab97993951c",
387
+ "sha256": "a218f4054ae29962c6fd9d23d94c446d354c4f53e805a6771c85749ccc20baaa",
388
+ "license": "BSD-3-Clause",
389
+ "source_braindecode": "1.3.0",
390
+ "loaded_core_tensors": 56,
391
+ "skipped_classifier_tensors": 3
392
+ },
393
+ "neural_channel_indices": {
394
+ "faced": [
395
+ 0,
396
+ 1,
397
+ 2,
398
+ 3,
399
+ 4,
400
+ 5,
401
+ 6,
402
+ 7,
403
+ 8,
404
+ 9,
405
+ 10,
406
+ 11,
407
+ 12,
408
+ 13,
409
+ 14,
410
+ 15,
411
+ 16,
412
+ 17
413
+ ],
414
+ "tuev": [
415
+ 0,
416
+ 1,
417
+ 2,
418
+ 3,
419
+ 4,
420
+ 5,
421
+ 6,
422
+ 7,
423
+ 8,
424
+ 9,
425
+ 10,
426
+ 11,
427
+ 12,
428
+ 13,
429
+ 14,
430
+ 15
431
+ ],
432
+ "ad65": [
433
+ 0,
434
+ 1,
435
+ 2,
436
+ 3,
437
+ 4,
438
+ 5,
439
+ 6,
440
+ 7,
441
+ 8,
442
+ 9,
443
+ 10,
444
+ 11,
445
+ 12,
446
+ 13,
447
+ 14,
448
+ 15,
449
+ 16,
450
+ 17
451
+ ],
452
+ "openbmi": [
453
+ 0,
454
+ 1,
455
+ 3,
456
+ 5,
457
+ 12,
458
+ 14,
459
+ 23,
460
+ 25,
461
+ 28,
462
+ 30,
463
+ 2,
464
+ 6,
465
+ 11,
466
+ 15,
467
+ 22,
468
+ 26,
469
+ 4,
470
+ 13
471
+ ],
472
+ "longitudinal": [
473
+ 0,
474
+ 2,
475
+ 7,
476
+ 11,
477
+ 23,
478
+ 27,
479
+ 41,
480
+ 45,
481
+ 55,
482
+ 57,
483
+ 5,
484
+ 13,
485
+ 21,
486
+ 29,
487
+ 39,
488
+ 47,
489
+ 9,
490
+ 25
491
+ ]
492
+ },
493
+ "rebase": "incumbent waveform, fusion and four heads; joint BIOT and TUEV head from readout epoch 9; zero initialized neural interaction",
494
+ "jointly_finetuned_neural_parent": "/workspace/research/runs/hybrid_biot_readout1/epoch-009/weights.pt",
495
+ "tuev_high_dimensional_spectral_projection_disabled": true,
496
+ "frozen_prior_representation": true,
497
+ "nonclinical_head_updates": "only the 256 added BIOT columns; original columns and biases fixed",
498
+ "faced_openbmi_neural_path": "common nonlinear fusion only; direct head columns masked",
499
+ "retention_teacher": "/workspace/research/runs/hybrid_wide1/epoch-004",
500
+ "retention_loss": {
501
+ "split": "train",
502
+ "temperature": 2.0,
503
+ "kl_weight": 1.0,
504
+ "tracks": [
505
+ "faced",
506
+ "ad65",
507
+ "openbmi",
508
+ "longitudinal"
509
+ ]
510
+ }
511
+ },
512
+ "joint_covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
513
+ "frozen_prior_representation": true,
514
+ "head_updates": "one linear head per track; added 128 shared covariance columns trainable; AD head initialized from the joint covariance parent",
515
+ "new_shared_representation": "one common covariance MLP inside the coupled backbone, trained by all five tasks; fixed spatial input adapters from the same jointly trained source",
516
+ "head_arithmetic": "one linear head evaluated in fixed feature blocks to preserve original bfloat16 accumulation dimensions",
517
+ "retention_teacher": {
518
+ "ad65": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
519
+ "other_tracks": "/workspace/research/runs/hybrid_wide1/epoch-004"
520
+ },
521
+ "retention_loss": {
522
+ "split": "train",
523
+ "temperature": 2.0,
524
+ "kl_weight": 1.0,
525
+ "tracks": [
526
+ "faced",
527
+ "ad65",
528
+ "openbmi",
529
+ "longitudinal"
530
+ ]
531
+ }
532
+ },
533
+ "loader_scale": 0.01,
534
+ "tracks": [
535
+ "faced",
536
+ "tuev",
537
+ "ad65",
538
+ "openbmi",
539
+ "longitudinal"
540
+ ],
541
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
542
+ "head_refinement": {
543
+ "source": "/workspace/research/runs/residual_heads1/epoch-018",
544
+ "source_weights_sha256": "e0b609137391b47f99438ccadaa22fc0bc10d2c10ead0ddf0a3c25be2c907c85",
545
+ "shared_backbone_unchanged": true,
546
+ "selected_head_epochs": {
547
+ "faced": 5,
548
+ "tuev": 24,
549
+ "ad65": 0,
550
+ "openbmi": 0,
551
+ "longitudinal": 0
552
+ }
553
+ },
554
+ "clinical_spectral_refinement": {
555
+ "source": "/workspace/research/runs/head_dropout1/epoch-016",
556
+ "zero_initialized_input_adapter": true,
557
+ "backbone_unchanged": true
558
+ },
559
+ "head_estimation": {
560
+ "method": "class/subject-balanced Gaussian linear discriminant; covariance augmented by class-conditional subject/session mean variation before shrinkage",
561
+ "selected_shrinkage": {
562
+ "faced": "inherited",
563
+ "tuev": "inherited",
564
+ "ad65": "inherited",
565
+ "openbmi": "inherited",
566
+ "longitudinal": {
567
+ "shrinkage": 0.9,
568
+ "domain_strength": 1.0
569
+ }
570
+ },
571
+ "feature_scaling": "fitted on training data and folded into linear coefficients"
572
+ },
573
+ "clinical_asymmetry_refinement": {
574
+ "source": "/workspace/research/runs/domain_lda_heads1/epoch-001",
575
+ "zero_initialized_input_adapter": true,
576
+ "backbone_unchanged": true
577
+ },
578
+ "alpha_rhythm_adapter": {
579
+ "training_normalization_only": true,
580
+ "regions": [
581
+ "occipital",
582
+ "parietal",
583
+ "central",
584
+ "frontal",
585
+ "left_posterior",
586
+ "right_posterior"
587
+ ],
588
+ "features": "per-window alpha prominence relative to adjacent frequencies",
589
+ "shared_backbone_unchanged": true
590
+ },
591
+ "clinical_envelope_refinement": {
592
+ "source": "/workspace/research/runs/clinical_asymmetry1/epoch-001",
593
+ "zero_initialized_input_adapter": true,
594
+ "backbone_unchanged": true
595
+ },
596
+ "independent_adapter_merge": {
597
+ "alpha_source": "/workspace/research/runs/alpha_calibrated1/epoch-003",
598
+ "clinical_source": "/workspace/research/runs/clinical_envelope1/epoch-002",
599
+ "all_shared_and_head_tensors_equal": true
600
+ },
601
+ "frequency_montage_refinement": {
602
+ "six_frequency_bands": true,
603
+ "shared_encoder_unchanged": true,
604
+ "selected_track_epochs": {
605
+ "faced": 0,
606
+ "tuev": 1,
607
+ "ad65": 0,
608
+ "openbmi": 10,
609
+ "longitudinal": 2
610
+ }
611
+ },
612
+ "private_track_selection": {
613
+ "track": "tuev",
614
+ "donor": "/workspace/research/replicates/frequency_head_control1/epoch-001"
615
+ },
616
+ "clinical_sampling_refinement": {
617
+ "subject_exponent": 0.0,
618
+ "class_balanced": true,
619
+ "only_clinical_head_updated": true
620
+ },
621
+ "temporal_statistics_readout": {
622
+ "statistics": [
623
+ "mean",
624
+ "standard deviation",
625
+ "maximum",
626
+ "minimum"
627
+ ],
628
+ "shared_encoder_and_prior_heads_unchanged": true,
629
+ "selected_pool_epochs": {
630
+ "faced": 2,
631
+ "tuev": 0,
632
+ "ad65": 0,
633
+ "openbmi": 33,
634
+ "longitudinal": 3
635
+ }
636
+ }
637
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/covariances.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared neural filter-bank covariance decoder with spatial input adapters."""
2
+ import torch
3
+ from torch import nn
4
+ SPECS={'faced':(32,10,9),'tuev':(16,5,6),'ad65':(19,10,3),'openbmi':(62,4,2),'longitudinal':(58,2,2)}
5
+ TRACKS=tuple(SPECS)
6
+ BANDS=[(1,4),(4,8),(8,12),(12,16),(16,20),(20,24),(24,28),(28,32),(32,40),(40,48)]
7
+
8
+ @torch.no_grad()
9
+ def extract_covariances(t,x):
10
+ x=torch.nan_to_num(x.float().flatten(2)).clamp(-1e5,1e5)
11
+ x=x-x.mean(-1,keepdim=True)
12
+ if t in ('faced','tuev'):
13
+ x=x/x.square().mean(-1,keepdim=True).clamp_min(1e-12).sqrt()
14
+ else:x=x-x.mean(1,keepdim=True)
15
+ # Per-window normalization, preserving spatial and frequency power ratios.
16
+ x=x/x.square().mean((1,2),keepdim=True).clamp_min(1e-12).sqrt()
17
+ frames=x.unfold(-1,400,200);frames=frames-frames.mean(-1,keepdim=True)
18
+ z=torch.fft.rfft(frames*torch.hann_window(400,device=x.device),dim=-1)/200
19
+ covs=[]
20
+ for lo,hi in BANDS:
21
+ v=z[...,2*lo:2*hi].flatten(2)
22
+ cov=(v.real@v.real.transpose(-1,-2)+v.imag@v.imag.transpose(-1,-2))/v.shape[-1]
23
+ covs.append(cov)
24
+ return torch.stack(covs,1)
25
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/envelope_features.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Per-window burst-envelope regularity and bilateral synchrony, without fitting."""
2
+ import torch
3
+ import torch.nn.functional as F
4
+
5
+ BANDS=((1,4),(4,8),(8,13),(13,30),(30,45))
6
+ ENVELOPE_DIM=16*5*12+8*5*2
7
+
8
+ @torch.no_grad()
9
+ def extract_envelope_features(signal):
10
+ with torch.autocast(signal.device.type,enabled=False):
11
+ x=signal.float();x=x-x.mean(-1,keepdim=True)
12
+ spectrum=torch.fft.fft(x,dim=-1)
13
+ frequency=torch.fft.fftfreq(x.shape[-1],1/200,device=x.device)
14
+ envelopes=[]
15
+ for lo,hi in BANDS:
16
+ mask=((frequency>=lo)&(frequency<hi)).to(x.dtype)*2
17
+ analytic=torch.fft.ifft(spectrum*mask,dim=-1)
18
+ energy=analytic.abs().square()
19
+ envelope=F.avg_pool1d(energy.flatten(0,1).unsqueeze(1),20,10).squeeze(1)
20
+ envelopes.append(envelope.reshape(len(x),16,-1))
21
+ e=torch.stack(envelopes,2)
22
+ mean=e.mean(-1,keepdim=True).clamp_min(1e-12)
23
+ relative=e/mean
24
+ centered=relative-relative.mean(-1,keepdim=True)
25
+ std=centered.square().mean(-1,keepdim=True).sqrt().clamp_min(1e-6)
26
+ normalized=centered/std
27
+ acf=torch.stack([(normalized[...,:-lag]*normalized[...,lag:]).mean(-1)
28
+ for lag in range(4,41)],-1).clamp(-1,1)
29
+ acf_peak,acf_index=acf.max(-1)
30
+ probability=(relative/relative.sum(-1,keepdim=True).clamp_min(1e-12)).clamp_min(1e-12)
31
+ entropy=-(probability*probability.log()).sum(-1)
32
+ summaries=[std.squeeze(-1).clamp_min(1e-6).log(),relative.amax(-1).clamp_min(1).log(),entropy,
33
+ (relative>2).float().mean(-1),(relative>4).float().mean(-1),
34
+ ((relative[...,1:]>2)&(relative[...,:-1]<=2)).float().mean(-1),
35
+ acf_peak,(acf_index.float()+4)/40,
36
+ acf[...,0],acf[...,6],acf[...,16],acf[...,36]]
37
+ left=torch.tensor([0,1,2,3,8,9,10,11],device=x.device);right=left+4
38
+ synchrony=(normalized[:,left]*normalized[:,right]).mean(-1).clamp(-1,1)
39
+ imbalance=(std[:,left].squeeze(-1).log()-std[:,right].squeeze(-1).log()).abs()
40
+ return torch.cat([torch.stack(summaries,-1).flatten(1),synchrony.flatten(1),imbalance.flatten(1)],1)
41
+
42
+ def mirrored_features(features):
43
+ channels=torch.tensor([4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11],device=features.device)
44
+ return torch.cat([features[:,:16*5*12].reshape(-1,16,5,12)[:,channels].flatten(1),features[:,16*5*12:]],1)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/frequency_features.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixed per-window frequency decomposition for a linear montage adapter."""
2
+ import torch
3
+
4
+ FREQUENCY_BANDS=((1,4),(4,8),(8,13),(13,20),(20,30),(30,45))
5
+
6
+ def frequency_components(signal):
7
+ with torch.autocast(signal.device.type,enabled=False):
8
+ x=signal.float();spectrum=torch.fft.rfft(x,dim=-1)
9
+ frequency=torch.fft.rfftfreq(x.shape[-1],d=1/200,device=x.device)
10
+ masks=torch.stack([((frequency>=lo)&(frequency<hi)).float() for lo,hi in FREQUENCY_BANDS])
11
+ return torch.fft.irfft(spectrum[:,None]*masks[None,:,None],n=x.shape[-1],dim=-1)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/infer.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse,json
2
+ from pathlib import Path
3
+ import torch
4
+ from model import HybridModel,SPECS
5
+ from data import Dataset
6
+ from covariances import extract_covariances
7
+ p=argparse.ArgumentParser();p.add_argument('input',type=Path);p.add_argument('output',type=Path);a=p.parse_args()
8
+ root=Path(__file__).resolve().parent;c=json.loads((root/'config.json').read_text());t=json.loads((a.input/'manifest.json').read_text())['track']
9
+ if t not in SPECS:raise ValueError('unknown track')
10
+ torch.set_num_threads(4);device='cuda' if torch.cuda.is_available() else 'cpu'
11
+ m=HybridModel(**c['architecture']).to(device);m.load_state_dict(torch.load(root/'weights.pt',map_location=device,weights_only=True));m.eval()
12
+ a.output.mkdir(parents=True,exist_ok=True)
13
+ with torch.inference_mode(),(a.output/'predictions.jsonl').open('w') as f:
14
+ for x,_,ids in torch.utils.data.DataLoader(Dataset(a.input),batch_size=64,num_workers=0):
15
+ # FFT features stay float32; convolutions can use bfloat16 on CUDA.
16
+ x=x.to(device)
17
+ from features import extract_features
18
+ torch.backends.cuda.matmul.allow_tf32=False
19
+ features=extract_features(t,x)
20
+ covariances=extract_covariances(t,x)
21
+ torch.backends.cuda.matmul.allow_tf32=True
22
+ with torch.autocast(device,dtype=torch.bfloat16,enabled=device=='cuda'):pred=m(t,x,features,covariances=covariances)
23
+ pp=pred.float().softmax(-1).cpu().numpy()
24
+ for sid,pr in zip(ids,pp):f.write(json.dumps({'id':sid,'probabilities':pr.tolist()})+'\n')
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/infer.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ exec python "$(dirname -- "$0")/infer.py" "$1" "$2"
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/model.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One fused waveform/spectral backbone used identically by all five tasks."""
2
+ import torch
3
+ from torch import nn
4
+ from braindecode.models import BIOT
5
+ from features import SPECS,TRACKS,feature_dim,extract_features,Standardize,Residual,EDGES,COV_BANDS
6
+ from covariances import BANDS,extract_covariances
7
+ from alpha_features import extract_alpha_features,ALPHA_DIM
8
+ from envelope_features import extract_envelope_features,ENVELOPE_DIM
9
+ from frequency_features import frequency_components,FREQUENCY_BANDS
10
+
11
+ def clinical_asymmetry_features(features):
12
+ """Bipolar homologous-channel amplitude and coherence, invariant to mirroring."""
13
+ bands=len(EDGES)-1;per_channel=4*bands+4
14
+ block=features[:,:16*per_channel].reshape(-1,16,per_channel)
15
+ left=torch.tensor([0,1,2,3,8,9,10,11],device=features.device);right=left+4
16
+ pair_power=(block[:,left,:bands]-block[:,right,:bands]).abs().flatten(1)
17
+ pair_rms=(block[:,left,4*bands]-block[:,right,4*bands]).abs()
18
+ hemisphere=(block[:,left,:bands].mean(1)-block[:,right,:bands].mean(1)).abs()
19
+ index=left*(32-left-1)//2+(right-left-1)
20
+ correlations=features[:,16*per_channel:].reshape(-1,len(COV_BANDS),120)[:,:,index].flatten(1)
21
+ return torch.cat([pair_power,pair_rms,hemisphere,correlations],1)
22
+
23
+ class InputAdapter(nn.Module):
24
+ def __init__(self,c,width,channels,spectral_enabled=True,asymmetry=False,alpha_regions=None,envelope=False):
25
+ super().__init__()
26
+ self.signal=nn.Conv1d(c,channels,1,bias=False)
27
+ self.frequency_weight=nn.Parameter(torch.zeros(len(FREQUENCY_BANDS),channels,c))
28
+ self.neural=nn.Conv1d(c,18,1,bias=False)
29
+ self.normalizer=Standardize(feature_dim(c))
30
+ self.spectral=nn.Linear(feature_dim(c),width)
31
+ self.dropout=nn.Dropout(.1)
32
+ self.register_buffer("spectral_enabled",torch.tensor(float(spectral_enabled)))
33
+ self.spatial_weight=nn.Parameter(torch.randn(len(BANDS),24,c)/c**.5)
34
+ self.asymmetry_projection=nn.Linear(316,width,bias=False) if asymmetry else None
35
+ if asymmetry:
36
+ nn.init.zeros_(self.asymmetry_projection.weight)
37
+ self.asymmetry_normalizer=Standardize(316)
38
+ self.asymmetry_dropout=nn.Dropout(.1)
39
+ self.alpha_projection=None
40
+ if alpha_regions is not None:
41
+ self.register_buffer('alpha_regions',torch.tensor(alpha_regions,dtype=torch.float32))
42
+ self.alpha_normalizer=Standardize(ALPHA_DIM)
43
+ self.alpha_projection=nn.Linear(ALPHA_DIM,width,bias=False)
44
+ nn.init.zeros_(self.alpha_projection.weight)
45
+ self.alpha_dropout=nn.Dropout(.3)
46
+ self.envelope_projection=None
47
+ if envelope:
48
+ self.envelope_normalizer=Standardize(ENVELOPE_DIM)
49
+ self.envelope_projection=nn.Linear(ENVELOPE_DIM,width,bias=False)
50
+ nn.init.zeros_(self.envelope_projection.weight)
51
+ self.envelope_dropout=nn.Dropout(.3)
52
+ def spectral_features(self,features,signal=None,alpha_features=None,envelope_features=None):
53
+ value=self.spectral_enabled*self.spectral(self.dropout(self.normalizer(features)))
54
+ if self.asymmetry_projection is not None:
55
+ extra=self.asymmetry_dropout(self.asymmetry_normalizer(clinical_asymmetry_features(features)))
56
+ value=value+self.asymmetry_projection(extra)
57
+ if self.alpha_projection is not None:
58
+ if alpha_features is None:alpha_features=extract_alpha_features(signal,self.alpha_regions)
59
+ value=value+self.alpha_projection(self.alpha_dropout(self.alpha_normalizer(alpha_features)))
60
+ if self.envelope_projection is not None:
61
+ if envelope_features is None:envelope_features=extract_envelope_features(signal)
62
+ value=value+self.envelope_projection(self.envelope_dropout(self.envelope_normalizer(envelope_features)))
63
+ return value
64
+ def spatial_features(self,covariances):
65
+ with torch.autocast(covariances.device.type,enabled=False):
66
+ w=self.spatial_weight.float()/self.spatial_weight.float().norm(dim=-1,keepdim=True).clamp_min(1e-6)
67
+ power=torch.einsum('bfc,nbcd,bfd->nbf',w,covariances.float(),w).clamp_min(1e-8).log()
68
+ return torch.cat([power,power-power.mean(1,keepdim=True)],1).flatten(1)
69
+ def wave_signal(self,x,components=None):
70
+ if components is None:components=frequency_components(x)
71
+ correction=torch.einsum('blc,nbct->nlt',self.frequency_weight,components.to(self.frequency_weight.dtype))
72
+ return (self.signal(x)+correction.to(x.dtype)).unsqueeze(1)
73
+ def forward(self,x,features,covariance_features):
74
+ return self.wave_signal(x),self.spectral_features(features,signal=x),self.neural(x),covariance_features
75
+
76
+ class SharedBackbone(nn.Module):
77
+ def __init__(self,channels,width,depth,dropout,wave_filters):
78
+ super().__init__()
79
+ self.waveform=nn.Sequential(
80
+ nn.Conv2d(1,wave_filters,(1,64),padding=(0,32),bias=False),nn.GroupNorm(1,wave_filters),
81
+ nn.Conv2d(wave_filters,2*wave_filters,(channels,1),groups=wave_filters,bias=False),nn.GroupNorm(1,2*wave_filters),nn.ELU(),
82
+ nn.AvgPool2d((1,4)),nn.Dropout(.35),
83
+ nn.Conv2d(2*wave_filters,2*wave_filters,(1,16),padding=(0,8),groups=2*wave_filters,bias=False),nn.Conv2d(2*wave_filters,2*wave_filters,1,bias=False),
84
+ nn.GroupNorm(1,2*wave_filters),nn.ELU(),nn.AvgPool2d((1,8)),nn.Dropout(.35))
85
+ self.wave_summary=nn.Sequential(nn.AdaptiveAvgPool2d((1,8)),nn.Flatten(),nn.Linear(2*wave_filters*8,width))
86
+ self.fusion=nn.Sequential(nn.LayerNorm(width),nn.GELU(),nn.Dropout(dropout),
87
+ *[Residual(width,dropout) for _ in range(depth)],nn.LayerNorm(width))
88
+ # Both representations interact before the shared residual stack.
89
+ self.wave_gain=nn.Parameter(torch.tensor(.1))
90
+ self.biot=BIOT(n_chans=18,n_outputs=2,n_times=400,sfreq=200)
91
+ self.biot.final_layer=nn.Identity()
92
+ self.biot_projection=nn.Sequential(nn.LayerNorm(256),nn.Linear(256,width),nn.Dropout(.2))
93
+ nn.init.normal_(self.biot_projection[1].weight,std=.001);nn.init.zeros_(self.biot_projection[1].bias)
94
+ self.covariance_encoder=nn.Sequential(nn.LayerNorm(len(BANDS)*24*2),nn.Linear(len(BANDS)*24*2,width),nn.GELU(),nn.Dropout(.4),
95
+ *[Residual(width,.4) for _ in range(2)],nn.LayerNorm(width))
96
+ self.covariance_projection=nn.Linear(width,width)
97
+ nn.init.zeros_(self.covariance_projection.weight);nn.init.zeros_(self.covariance_projection.bias)
98
+ def forward(self,signal,spectral,neural_signal,covariance_features):
99
+ wave=self.waveform(signal)
100
+ neural=self.biot(neural_signal.float())
101
+ neural=self.biot_projection[0](neural)
102
+ projected=self.biot_projection[2](self.biot_projection[1](neural))
103
+ with torch.autocast(signal.device.type,enabled=False):
104
+ covariance_embedding=self.covariance_encoder(covariance_features.float())
105
+ original=spectral+self.wave_gain*self.wave_summary(wave)+.01*projected
106
+ coupled=.001*self.covariance_projection(covariance_embedding).to(original.dtype)
107
+ fused=self.fusion(original+coupled)
108
+ return torch.cat([wave.flatten(1),fused,neural,covariance_embedding],-1)
109
+
110
+ class ResidualHead(nn.Module):
111
+ """A small nonlinear classifier correction around an inherited linear readout."""
112
+ def __init__(self,features,classes,width=64,dropout=.3,full_precision=False):
113
+ super().__init__();self.full_precision=full_precision
114
+ self.base=nn.Linear(features,classes)
115
+ self.delta=nn.Sequential(nn.LayerNorm(features),nn.Linear(features,width),nn.GELU(),nn.Dropout(dropout),nn.Linear(width,classes))
116
+ nn.init.zeros_(self.delta[-1].weight);nn.init.zeros_(self.delta[-1].bias)
117
+ def forward(self,x):
118
+ if self.full_precision:
119
+ with torch.autocast(x.device.type,enabled=False):return self.base(x.float())+self.delta(x.float())
120
+ prior=nn.functional.linear(x[:,:-128].contiguous(),self.base.weight[:,:-128].contiguous(),self.base.bias)
121
+ added=nn.functional.linear(x[:,-128:].contiguous(),self.base.weight[:,-128:].contiguous())
122
+ value=prior+added
123
+ return value+self.delta(x).to(value.dtype)
124
+
125
+ class TemporalPoolHead(nn.Module):
126
+ def __init__(self,prior,channels=64):
127
+ super().__init__();self.prior=prior;self.channels=channels
128
+ self.register_buffer('pool_output_scale',torch.ones(()));self.register_buffer('pool_mean',torch.zeros(channels*4));self.register_buffer('pool_scale',torch.ones(channels*4))
129
+ self.pool_projection=nn.Linear(channels*4,prior.base.out_features)
130
+ nn.init.zeros_(self.pool_projection.weight);nn.init.zeros_(self.pool_projection.bias)
131
+ def statistics(self,x):
132
+ with torch.autocast(x.device.type,enabled=False):
133
+ wave=x[:,:-512].float().reshape(len(x),self.channels,-1)
134
+ return torch.cat([wave.mean(-1),wave.std(-1,correction=0),wave.amax(-1),wave.amin(-1)],-1)
135
+ def forward(self,x):
136
+ prior=self.prior(x)
137
+ with torch.autocast(x.device.type,enabled=False):
138
+ values=((self.statistics(x)-self.pool_mean)/self.pool_scale).clamp(-8,8)
139
+ added=self.pool_output_scale*self.pool_projection(values)
140
+ return prior+added.to(prior.dtype)
141
+
142
+ class HybridModel(nn.Module):
143
+ def __init__(self,channels=32,width=128,depth=2,dropout=.5,wave_filters=32,head_width=64,head_dropout=.3,clinical_asymmetry=True,alpha_regions=None,clinical_envelope=False,temporal_pool=True):
144
+ super().__init__()
145
+ self.adapters=nn.ModuleDict({t:InputAdapter(c,width,channels,spectral_enabled=t not in ("faced","tuev","openbmi"),asymmetry=clinical_asymmetry and t=="tuev",alpha_regions=alpha_regions if t=="longitudinal" else None,envelope=clinical_envelope and t=="tuev") for t,(c,s,k) in SPECS.items()})
146
+ self.backbone=SharedBackbone(channels,width,depth,dropout,wave_filters)
147
+ self.heads=nn.ModuleDict({t:ResidualHead(2*wave_filters*(((s*200+1)//4+1)//8)+width+256+width,k,head_width,head_dropout,full_precision=t=='ad65') for t,(c,s,k) in SPECS.items()})
148
+ if temporal_pool:self.heads=nn.ModuleDict({t:TemporalPoolHead(head,wave_filters*2) for t,head in self.heads.items()})
149
+ def forward(self,t,x,features=None,covariances=None,covariance_features=None):
150
+ if features is None:features=extract_features(t,x)
151
+ if covariance_features is None:
152
+ if covariances is None:covariances=extract_covariances(t,x)
153
+ covariance_features=self.adapters[t].spatial_features(covariances)
154
+ signal=x.flatten(2);signal=signal-signal.mean(-1,keepdim=True)
155
+ if t in ('faced','tuev'):signal=signal/signal.std(-1,keepdim=True,correction=0).clamp_min(1e-6)
156
+ else:signal=signal-signal.mean(1,keepdim=True)
157
+ signal=signal.clamp(-20,20)
158
+ adapted=self.adapters[t](signal,features,covariance_features)
159
+ representation=self.backbone(*adapted)
160
+ if t in ('faced','openbmi'):
161
+ representation=torch.cat([representation[:,:-384],torch.zeros_like(representation[:,-384:-128]),representation[:,-128:]],-1)
162
+ return self.heads[t](representation)
163
+
164
+ def widen_state_dict(state,multiplier=2):
165
+ """Duplicate temporal features and divide downstream sums to preserve outputs."""
166
+ result={}
167
+ for key,value in state.items():
168
+ if key.startswith('backbone.waveform.'):
169
+ layer=int(key.split('.')[2])
170
+ if layer in (0,2,7):value=value.repeat(multiplier,1,1,1)
171
+ elif layer in (1,3,9):value=value.repeat(multiplier)
172
+ elif layer==8:value=value.repeat(multiplier,multiplier,1,1)/multiplier
173
+ elif key=='backbone.wave_summary.2.weight':value=value.repeat(1,multiplier)/multiplier
174
+ elif key.startswith('heads.') and key.endswith('.weight'):
175
+ raw=value[:,:-128]/multiplier
176
+ value=torch.cat([raw]*multiplier+[value[:,-128:]],1)
177
+ result[key]=value
178
+ return result
179
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S032/infer.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse,json
2
+ from pathlib import Path
3
+ import torch
4
+ from model import HybridModel,SPECS
5
+ from data import Dataset
6
+ from covariances import extract_covariances
7
+ p=argparse.ArgumentParser();p.add_argument('input',type=Path);p.add_argument('output',type=Path);a=p.parse_args()
8
+ root=Path(__file__).resolve().parent;c=json.loads((root/'config.json').read_text());t=json.loads((a.input/'manifest.json').read_text())['track']
9
+ if t not in SPECS:raise ValueError('unknown track')
10
+ torch.set_num_threads(4);device='cuda' if torch.cuda.is_available() else 'cpu'
11
+ m=HybridModel(**c['architecture']).to(device);m.load_state_dict(torch.load(root/'weights.pt',map_location=device,weights_only=True));m.eval()
12
+ a.output.mkdir(parents=True,exist_ok=True)
13
+ with torch.inference_mode(),(a.output/'predictions.jsonl').open('w') as f:
14
+ for x,_,ids in torch.utils.data.DataLoader(Dataset(a.input),batch_size=64,num_workers=0):
15
+ # FFT features stay float32; convolutions can use bfloat16 on CUDA.
16
+ x=x.to(device)
17
+ from features import extract_features
18
+ torch.backends.cuda.matmul.allow_tf32=False
19
+ features=extract_features(t,x)
20
+ covariances=extract_covariances(t,x)
21
+ torch.backends.cuda.matmul.allow_tf32=True
22
+ with torch.autocast(device,dtype=torch.bfloat16,enabled=device=='cuda'):pred=m(t,x,features,covariances=covariances)
23
+ pp=pred.float().softmax(-1).cpu().numpy()
24
+ for sid,pr in zip(ids,pp):f.write(json.dumps({'id':sid,'probabilities':pr.tolist()})+'\n')
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/alpha_features.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixed alpha prominence features from each individual two-second window."""
2
+ import torch
3
+
4
+ REGION_NAMES=('occipital','parietal','central','frontal','left_posterior','right_posterior')
5
+ REGIONS=(('PO7','PO5','PO3','POZ','PO4','PO6','PO8','O1','OZ','O2'),
6
+ ('P7','P5','P3','P1','PZ','P2','P4','P6','P8'),
7
+ ('FC5','FC3','FC1','FCZ','FC2','FC4','FC6','C5','C3','C1','CZ','C2','C4','C6'),
8
+ ('FP1','FPZ','FP2','AF3','AF4','F7','F5','F3','F1','FZ','F2','F4','F6','F8'),
9
+ ('P7','P5','P3','P1','PO7','PO5','PO3','O1'),
10
+ ('P2','P4','P6','P8','PO4','PO6','PO8','O2'))
11
+ ALPHA_DIM=58*7+6*22
12
+
13
+ def region_matrix(channels):
14
+ result=torch.zeros(len(REGIONS),len(channels))
15
+ for i,names in enumerate(REGIONS):
16
+ for name in names:result[i,channels.index(name)]=1/len(names)
17
+ return result.tolist()
18
+
19
+ @torch.no_grad()
20
+ def extract_alpha_features(signal,regions):
21
+ with torch.autocast(signal.device.type,enabled=False):
22
+ x=signal.float();x=x-x.mean(-1,keepdim=True)
23
+ spectrum=torch.fft.rfft(x*torch.hann_window(400,device=x.device),dim=-1)/200
24
+ power=spectrum.abs().square().clamp_min(1e-12)
25
+ lp=power.log()
26
+ # Geometric regional means resist domination by one high-amplitude channel.
27
+ regional=torch.einsum('rc,ncf->nrf',regions.float(),lp)
28
+ lp=torch.cat([lp,regional],1)
29
+ low=lp[...,8:13].mean(-1,keepdim=True)
30
+ high=lp[...,36:49].mean(-1,keepdim=True)
31
+ freq=torch.arange(7.,14.5,.5,device=x.device)
32
+ alpha=lp[...,14:29]
33
+ baseline=low+(high-low)*((freq-5)/16)
34
+ prominence=alpha-baseline
35
+ normalized=alpha.softmax(-1)
36
+ center=(normalized*freq).sum(-1)
37
+ entropy=-(normalized*normalized.clamp_min(1e-12).log()).sum(-1)
38
+ alpha_mean=torch.logsumexp(alpha,-1)-torch.log(torch.tensor(15.,device=x.device))
39
+ def log_band(lo,hi):
40
+ return torch.logsumexp(lp[...,lo:hi],-1)-torch.log(torch.tensor(float(hi-lo),device=x.device))
41
+ summaries=torch.stack([alpha_mean-log_band(2,81),alpha_mean-log_band(8,14),
42
+ alpha_mean-log_band(30,61),prominence.max(-1).values,
43
+ prominence.mean(-1),center,entropy],-1)
44
+ return torch.cat([summaries[:,:58].flatten(1),summaries[:,58:].flatten(1),
45
+ prominence[:,58:].flatten(1)],1)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/covariances.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared neural filter-bank covariance decoder with spatial input adapters."""
2
+ import torch
3
+ from torch import nn
4
+ SPECS={'faced':(32,10,9),'tuev':(16,5,6),'ad65':(19,10,3),'openbmi':(62,4,2),'longitudinal':(58,2,2)}
5
+ TRACKS=tuple(SPECS)
6
+ BANDS=[(1,4),(4,8),(8,12),(12,16),(16,20),(20,24),(24,28),(28,32),(32,40),(40,48)]
7
+
8
+ @torch.no_grad()
9
+ def extract_covariances(t,x):
10
+ x=torch.nan_to_num(x.float().flatten(2)).clamp(-1e5,1e5)
11
+ x=x-x.mean(-1,keepdim=True)
12
+ if t in ('faced','tuev'):
13
+ x=x/x.square().mean(-1,keepdim=True).clamp_min(1e-12).sqrt()
14
+ else:x=x-x.mean(1,keepdim=True)
15
+ # Per-window normalization, preserving spatial and frequency power ratios.
16
+ x=x/x.square().mean((1,2),keepdim=True).clamp_min(1e-12).sqrt()
17
+ frames=x.unfold(-1,400,200);frames=frames-frames.mean(-1,keepdim=True)
18
+ z=torch.fft.rfft(frames*torch.hann_window(400,device=x.device),dim=-1)/200
19
+ covs=[]
20
+ for lo,hi in BANDS:
21
+ v=z[...,2*lo:2*hi].flatten(2)
22
+ cov=(v.real@v.real.transpose(-1,-2)+v.imag@v.imag.transpose(-1,-2))/v.shape[-1]
23
+ covs.append(cov)
24
+ return torch.stack(covs,1)
25
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/data.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from functools import lru_cache
3
+ from pathlib import Path
4
+ import numpy as np
5
+ import torch
6
+ @lru_cache(maxsize=8)
7
+ def array(path):return np.load(path,mmap_mode='r',allow_pickle=False)
8
+ class Dataset(torch.utils.data.Dataset):
9
+ def __init__(self,root,limit=None,cache=False):
10
+ self.root=Path(root)
11
+ self.rows=json.loads((self.root/'manifest.json').read_text())['samples']
12
+ if limit:self.rows=self.rows[:limit]
13
+ self.cached=None
14
+ if cache and self.rows:
15
+ from collections import defaultdict
16
+ groups=defaultdict(list)
17
+ for i,r in enumerate(self.rows):groups[r['path']].append((i,r['index']))
18
+ for name,indices in groups.items():
19
+ path=(self.root/name).resolve()
20
+ if not path.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
21
+ source=np.load(path,mmap_mode='r',allow_pickle=False)
22
+ if self.cached is None:self.cached=torch.empty((len(self.rows),*source.shape[1:]),dtype=torch.float32)
23
+ dst,src=zip(*indices)
24
+ self.cached[list(dst)]=torch.as_tensor(source[list(src)]/100,dtype=torch.float32)
25
+ def __len__(self):return len(self.rows)
26
+ def __getitem__(self,i):
27
+ r=self.rows[i]
28
+ if self.cached is not None:return self.cached[i],r.get('label',-1),r['id']
29
+ p=(self.root/r['path']).resolve()
30
+ if not p.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
31
+ # Division precedes float32 conversion, matching official FACED/TUEV collate.
32
+ x=np.asarray(array(str(p))[r['index']])/100
33
+ return torch.as_tensor(x,dtype=torch.float32),r.get('label',-1),r['id']
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/features.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One shared residual backbone, five linear input adapters and output heads."""
2
+ import torch
3
+ from torch import nn
4
+
5
+ SPECS = {'faced': (32, 10, 9), 'tuev': (16, 5, 6), 'ad65': (19, 10, 3),
6
+ 'openbmi': (62, 4, 2), 'longitudinal': (58, 2, 2)}
7
+ TRACKS = tuple(SPECS)
8
+ EDGES = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,18,20,22,25,28,32,36,40,45,50,60,70,80,95]
9
+ COV_BANDS = [(1,4),(4,8),(8,12),(12,16),(16,20),(20,28),(28,40)]
10
+
11
+ def feature_dim(channels):
12
+ return channels * (4*(len(EDGES)-1)+4) + len(COV_BANDS)*channels*(channels-1)//2
13
+
14
+ @torch.no_grad()
15
+ def extract_features(track, x):
16
+ """Fixed features; no batch statistics or fitted inference transformations."""
17
+ x = x.float().flatten(2)
18
+ x = torch.nan_to_num(x, nan=0., posinf=1e5, neginf=-1e5).clamp(-1e5,1e5)
19
+ x = x - x.mean(-1,keepdim=True)
20
+ if track in ('ad65','openbmi','longitudinal'):
21
+ x = x - x.mean(1,keepdim=True)
22
+ rms = x.square().mean(-1).clamp_min(1e-12).sqrt()
23
+ norm = x / rms.unsqueeze(-1)
24
+ moments = torch.stack([rms.log(), norm.abs().amax(-1).clamp_min(1).log(),
25
+ norm.pow(4).mean(-1).clamp_min(1).log(),
26
+ (norm[...,1:]-norm[...,:-1]).square().mean(-1).clamp_min(1e-10).log()],-1)
27
+ frames = x.unfold(-1,400,200)
28
+ frames = frames - frames.mean(-1,keepdim=True)
29
+ window = torch.hann_window(400,device=x.device)
30
+ z = torch.fft.rfft(frames*window,dim=-1)/200
31
+ power = z.abs().square()
32
+ bands = torch.stack([power[...,2*lo:2*hi].mean(-1) for lo,hi in zip(EDGES[:-1],EDGES[1:])],-1)
33
+ lp = bands.mean(-2).clamp_min(1e-12).log()
34
+ variation = bands.clamp_min(1e-12).log().std(-2,correction=0)
35
+ relative_frequency = lp - lp.mean(-1,keepdim=True)
36
+ relative_channel = lp - lp.mean(1,keepdim=True)
37
+ parts = [torch.cat([lp, relative_frequency, relative_channel, variation, moments],-1).flatten(1)]
38
+ ii,jj = torch.triu_indices(x.shape[1],x.shape[1],offset=1,device=x.device)
39
+ for lo,hi in COV_BANDS:
40
+ v = z[...,2*lo:2*hi].flatten(2)
41
+ cov = v.real @ v.real.transpose(-1,-2) + v.imag @ v.imag.transpose(-1,-2)
42
+ d = cov.diagonal(dim1=-2,dim2=-1).clamp_min(1e-12).sqrt()
43
+ cor = cov / (d.unsqueeze(1)*d.unsqueeze(2)).clamp_min(1e-12)
44
+ parts.append(cor[:,ii,jj].clamp(-1,1))
45
+ result = torch.cat(parts,-1)
46
+ return torch.nan_to_num(result).clamp(-40,40)
47
+
48
+ class Standardize(nn.Module):
49
+ def __init__(self, dim):
50
+ super().__init__()
51
+ self.register_buffer('mean',torch.zeros(dim))
52
+ self.register_buffer('scale',torch.ones(dim))
53
+ def forward(self,x):
54
+ return ((x-self.mean)/self.scale).clamp(-8,8)
55
+
56
+ class Residual(nn.Module):
57
+ def __init__(self,width,dropout):
58
+ super().__init__()
59
+ self.net=nn.Sequential(nn.LayerNorm(width),nn.Linear(width,width*2),nn.GELU(),
60
+ nn.Dropout(dropout),nn.Linear(width*2,width),nn.Dropout(dropout))
61
+ def forward(self,x):
62
+ return x+self.net(x)
63
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/infer.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse,json
2
+ from pathlib import Path
3
+ import torch
4
+ from model import HybridModel,SPECS
5
+ from data import Dataset
6
+ from covariances import extract_covariances
7
+ p=argparse.ArgumentParser();p.add_argument('input',type=Path);p.add_argument('output',type=Path);a=p.parse_args()
8
+ root=Path(__file__).resolve().parent;c=json.loads((root/'config.json').read_text());t=json.loads((a.input/'manifest.json').read_text())['track']
9
+ if t not in SPECS:raise ValueError('unknown track')
10
+ torch.set_num_threads(4);device='cuda' if torch.cuda.is_available() else 'cpu'
11
+ m=HybridModel(**c['architecture']).to(device);m.load_state_dict(torch.load(root/'weights.pt',map_location=device,weights_only=True));m.eval()
12
+ a.output.mkdir(parents=True,exist_ok=True)
13
+ with torch.inference_mode(),(a.output/'predictions.jsonl').open('w') as f:
14
+ for x,_,ids in torch.utils.data.DataLoader(Dataset(a.input),batch_size=64,num_workers=0):
15
+ # FFT features stay float32; convolutions can use bfloat16 on CUDA.
16
+ x=x.to(device)
17
+ from features import extract_features
18
+ torch.backends.cuda.matmul.allow_tf32=False
19
+ features=extract_features(t,x)
20
+ covariances=extract_covariances(t,x)
21
+ torch.backends.cuda.matmul.allow_tf32=True
22
+ with torch.autocast(device,dtype=torch.bfloat16,enabled=device=='cuda'):pred=m(t,x,features,covariances=covariances)
23
+ pp=pred.float().softmax(-1).cpu().numpy()
24
+ for sid,pr in zip(ids,pp):f.write(json.dumps({'id':sid,'probabilities':pr.tolist()})+'\n')
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/infer.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ exec python "$(dirname -- "$0")/infer.py" "$1" "$2"
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S033/tangent_features.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Window-local log-correlation geometry in the existing spatial-filter basis."""
2
+ import torch
3
+
4
+ TANGENT_DIM=10*24*25//2
5
+
6
+ @torch.no_grad()
7
+ def extract_tangent_features(covariances,spatial_weight):
8
+ old_tf32=torch.backends.cuda.matmul.allow_tf32
9
+ torch.backends.cuda.matmul.allow_tf32=False
10
+ try:
11
+ with torch.autocast(covariances.device.type,enabled=False):
12
+ w=spatial_weight.float()
13
+ w=w/w.norm(dim=-1,keepdim=True).clamp_min(1e-6)
14
+ projected=torch.einsum('bfc,nbcd,bgd->nbfg',w,covariances.float(),w)
15
+ d=projected.diagonal(dim1=-2,dim2=-1).clamp_min(1e-10).sqrt()
16
+ correlation=(projected/(d.unsqueeze(-1)*d.unsqueeze(-2))).clamp(-1,1)
17
+ correlation=(correlation+correlation.transpose(-1,-2))/2
18
+ correlation=.95*correlation+.05*torch.eye(24,device=correlation.device)
19
+ values,vectors=torch.linalg.eigh(correlation)
20
+ logarithm=(vectors*values.clamp_min(1e-6).log().unsqueeze(-2))@vectors.transpose(-1,-2)
21
+ i,j=torch.triu_indices(24,24,device=correlation.device)
22
+ scale=torch.where(i==j,1.,2.**.5)
23
+ return (logarithm[...,i,j]*scale).flatten(1)
24
+ finally:
25
+ torch.backends.cuda.matmul.allow_tf32=old_tf32
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/alpha_features.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixed alpha prominence features from each individual two-second window."""
2
+ import torch
3
+
4
+ REGION_NAMES=('occipital','parietal','central','frontal','left_posterior','right_posterior')
5
+ REGIONS=(('PO7','PO5','PO3','POZ','PO4','PO6','PO8','O1','OZ','O2'),
6
+ ('P7','P5','P3','P1','PZ','P2','P4','P6','P8'),
7
+ ('FC5','FC3','FC1','FCZ','FC2','FC4','FC6','C5','C3','C1','CZ','C2','C4','C6'),
8
+ ('FP1','FPZ','FP2','AF3','AF4','F7','F5','F3','F1','FZ','F2','F4','F6','F8'),
9
+ ('P7','P5','P3','P1','PO7','PO5','PO3','O1'),
10
+ ('P2','P4','P6','P8','PO4','PO6','PO8','O2'))
11
+ ALPHA_DIM=58*7+6*22
12
+
13
+ def region_matrix(channels):
14
+ result=torch.zeros(len(REGIONS),len(channels))
15
+ for i,names in enumerate(REGIONS):
16
+ for name in names:result[i,channels.index(name)]=1/len(names)
17
+ return result.tolist()
18
+
19
+ @torch.no_grad()
20
+ def extract_alpha_features(signal,regions):
21
+ with torch.autocast(signal.device.type,enabled=False):
22
+ x=signal.float();x=x-x.mean(-1,keepdim=True)
23
+ spectrum=torch.fft.rfft(x*torch.hann_window(400,device=x.device),dim=-1)/200
24
+ power=spectrum.abs().square().clamp_min(1e-12)
25
+ lp=power.log()
26
+ # Geometric regional means resist domination by one high-amplitude channel.
27
+ regional=torch.einsum('rc,ncf->nrf',regions.float(),lp)
28
+ lp=torch.cat([lp,regional],1)
29
+ low=lp[...,8:13].mean(-1,keepdim=True)
30
+ high=lp[...,36:49].mean(-1,keepdim=True)
31
+ freq=torch.arange(7.,14.5,.5,device=x.device)
32
+ alpha=lp[...,14:29]
33
+ baseline=low+(high-low)*((freq-5)/16)
34
+ prominence=alpha-baseline
35
+ normalized=alpha.softmax(-1)
36
+ center=(normalized*freq).sum(-1)
37
+ entropy=-(normalized*normalized.clamp_min(1e-12).log()).sum(-1)
38
+ alpha_mean=torch.logsumexp(alpha,-1)-torch.log(torch.tensor(15.,device=x.device))
39
+ def log_band(lo,hi):
40
+ return torch.logsumexp(lp[...,lo:hi],-1)-torch.log(torch.tensor(float(hi-lo),device=x.device))
41
+ summaries=torch.stack([alpha_mean-log_band(2,81),alpha_mean-log_band(8,14),
42
+ alpha_mean-log_band(30,61),prominence.max(-1).values,
43
+ prominence.mean(-1),center,entropy],-1)
44
+ return torch.cat([summaries[:,:58].flatten(1),summaries[:,58:].flatten(1),
45
+ prominence[:,58:].flatten(1)],1)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/config.json ADDED
@@ -0,0 +1,682 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "bci-shared-biot-covariance-bf16head-v1",
3
+ "architecture": {
4
+ "channels": 32,
5
+ "width": 128,
6
+ "depth": 2,
7
+ "dropout": 0.5,
8
+ "wave_filters": 32,
9
+ "head_width": 64,
10
+ "head_dropout": 0.3,
11
+ "clinical_asymmetry": true,
12
+ "alpha_regions": [
13
+ [
14
+ 0.0,
15
+ 0.0,
16
+ 0.0,
17
+ 0.0,
18
+ 0.0,
19
+ 0.0,
20
+ 0.0,
21
+ 0.0,
22
+ 0.0,
23
+ 0.0,
24
+ 0.0,
25
+ 0.0,
26
+ 0.0,
27
+ 0.0,
28
+ 0.0,
29
+ 0.0,
30
+ 0.0,
31
+ 0.0,
32
+ 0.0,
33
+ 0.0,
34
+ 0.0,
35
+ 0.0,
36
+ 0.0,
37
+ 0.0,
38
+ 0.0,
39
+ 0.0,
40
+ 0.0,
41
+ 0.0,
42
+ 0.0,
43
+ 0.0,
44
+ 0.0,
45
+ 0.0,
46
+ 0.0,
47
+ 0.0,
48
+ 0.0,
49
+ 0.0,
50
+ 0.0,
51
+ 0.0,
52
+ 0.0,
53
+ 0.0,
54
+ 0.0,
55
+ 0.0,
56
+ 0.0,
57
+ 0.0,
58
+ 0.0,
59
+ 0.0,
60
+ 0.0,
61
+ 0.0,
62
+ 0.10000000149011612,
63
+ 0.10000000149011612,
64
+ 0.10000000149011612,
65
+ 0.10000000149011612,
66
+ 0.10000000149011612,
67
+ 0.10000000149011612,
68
+ 0.10000000149011612,
69
+ 0.10000000149011612,
70
+ 0.10000000149011612,
71
+ 0.10000000149011612
72
+ ],
73
+ [
74
+ 0.0,
75
+ 0.0,
76
+ 0.0,
77
+ 0.0,
78
+ 0.0,
79
+ 0.0,
80
+ 0.0,
81
+ 0.0,
82
+ 0.0,
83
+ 0.0,
84
+ 0.0,
85
+ 0.0,
86
+ 0.0,
87
+ 0.0,
88
+ 0.0,
89
+ 0.0,
90
+ 0.0,
91
+ 0.0,
92
+ 0.0,
93
+ 0.0,
94
+ 0.0,
95
+ 0.0,
96
+ 0.0,
97
+ 0.0,
98
+ 0.0,
99
+ 0.0,
100
+ 0.0,
101
+ 0.0,
102
+ 0.0,
103
+ 0.0,
104
+ 0.0,
105
+ 0.0,
106
+ 0.0,
107
+ 0.0,
108
+ 0.0,
109
+ 0.0,
110
+ 0.0,
111
+ 0.0,
112
+ 0.0,
113
+ 0.1111111119389534,
114
+ 0.1111111119389534,
115
+ 0.1111111119389534,
116
+ 0.1111111119389534,
117
+ 0.1111111119389534,
118
+ 0.1111111119389534,
119
+ 0.1111111119389534,
120
+ 0.1111111119389534,
121
+ 0.1111111119389534,
122
+ 0.0,
123
+ 0.0,
124
+ 0.0,
125
+ 0.0,
126
+ 0.0,
127
+ 0.0,
128
+ 0.0,
129
+ 0.0,
130
+ 0.0,
131
+ 0.0
132
+ ],
133
+ [
134
+ 0.0,
135
+ 0.0,
136
+ 0.0,
137
+ 0.0,
138
+ 0.0,
139
+ 0.0,
140
+ 0.0,
141
+ 0.0,
142
+ 0.0,
143
+ 0.0,
144
+ 0.0,
145
+ 0.0,
146
+ 0.0,
147
+ 0.0,
148
+ 0.0714285746216774,
149
+ 0.0714285746216774,
150
+ 0.0714285746216774,
151
+ 0.0714285746216774,
152
+ 0.0714285746216774,
153
+ 0.0714285746216774,
154
+ 0.0714285746216774,
155
+ 0.0,
156
+ 0.0714285746216774,
157
+ 0.0714285746216774,
158
+ 0.0714285746216774,
159
+ 0.0714285746216774,
160
+ 0.0714285746216774,
161
+ 0.0714285746216774,
162
+ 0.0714285746216774,
163
+ 0.0,
164
+ 0.0,
165
+ 0.0,
166
+ 0.0,
167
+ 0.0,
168
+ 0.0,
169
+ 0.0,
170
+ 0.0,
171
+ 0.0,
172
+ 0.0,
173
+ 0.0,
174
+ 0.0,
175
+ 0.0,
176
+ 0.0,
177
+ 0.0,
178
+ 0.0,
179
+ 0.0,
180
+ 0.0,
181
+ 0.0,
182
+ 0.0,
183
+ 0.0,
184
+ 0.0,
185
+ 0.0,
186
+ 0.0,
187
+ 0.0,
188
+ 0.0,
189
+ 0.0,
190
+ 0.0,
191
+ 0.0
192
+ ],
193
+ [
194
+ 0.0714285746216774,
195
+ 0.0714285746216774,
196
+ 0.0714285746216774,
197
+ 0.0714285746216774,
198
+ 0.0714285746216774,
199
+ 0.0714285746216774,
200
+ 0.0714285746216774,
201
+ 0.0714285746216774,
202
+ 0.0714285746216774,
203
+ 0.0714285746216774,
204
+ 0.0714285746216774,
205
+ 0.0714285746216774,
206
+ 0.0714285746216774,
207
+ 0.0714285746216774,
208
+ 0.0,
209
+ 0.0,
210
+ 0.0,
211
+ 0.0,
212
+ 0.0,
213
+ 0.0,
214
+ 0.0,
215
+ 0.0,
216
+ 0.0,
217
+ 0.0,
218
+ 0.0,
219
+ 0.0,
220
+ 0.0,
221
+ 0.0,
222
+ 0.0,
223
+ 0.0,
224
+ 0.0,
225
+ 0.0,
226
+ 0.0,
227
+ 0.0,
228
+ 0.0,
229
+ 0.0,
230
+ 0.0,
231
+ 0.0,
232
+ 0.0,
233
+ 0.0,
234
+ 0.0,
235
+ 0.0,
236
+ 0.0,
237
+ 0.0,
238
+ 0.0,
239
+ 0.0,
240
+ 0.0,
241
+ 0.0,
242
+ 0.0,
243
+ 0.0,
244
+ 0.0,
245
+ 0.0,
246
+ 0.0,
247
+ 0.0,
248
+ 0.0,
249
+ 0.0,
250
+ 0.0,
251
+ 0.0
252
+ ],
253
+ [
254
+ 0.0,
255
+ 0.0,
256
+ 0.0,
257
+ 0.0,
258
+ 0.0,
259
+ 0.0,
260
+ 0.0,
261
+ 0.0,
262
+ 0.0,
263
+ 0.0,
264
+ 0.0,
265
+ 0.0,
266
+ 0.0,
267
+ 0.0,
268
+ 0.0,
269
+ 0.0,
270
+ 0.0,
271
+ 0.0,
272
+ 0.0,
273
+ 0.0,
274
+ 0.0,
275
+ 0.0,
276
+ 0.0,
277
+ 0.0,
278
+ 0.0,
279
+ 0.0,
280
+ 0.0,
281
+ 0.0,
282
+ 0.0,
283
+ 0.0,
284
+ 0.0,
285
+ 0.0,
286
+ 0.0,
287
+ 0.0,
288
+ 0.0,
289
+ 0.0,
290
+ 0.0,
291
+ 0.0,
292
+ 0.0,
293
+ 0.125,
294
+ 0.125,
295
+ 0.125,
296
+ 0.125,
297
+ 0.0,
298
+ 0.0,
299
+ 0.0,
300
+ 0.0,
301
+ 0.0,
302
+ 0.125,
303
+ 0.125,
304
+ 0.125,
305
+ 0.0,
306
+ 0.0,
307
+ 0.0,
308
+ 0.0,
309
+ 0.125,
310
+ 0.0,
311
+ 0.0
312
+ ],
313
+ [
314
+ 0.0,
315
+ 0.0,
316
+ 0.0,
317
+ 0.0,
318
+ 0.0,
319
+ 0.0,
320
+ 0.0,
321
+ 0.0,
322
+ 0.0,
323
+ 0.0,
324
+ 0.0,
325
+ 0.0,
326
+ 0.0,
327
+ 0.0,
328
+ 0.0,
329
+ 0.0,
330
+ 0.0,
331
+ 0.0,
332
+ 0.0,
333
+ 0.0,
334
+ 0.0,
335
+ 0.0,
336
+ 0.0,
337
+ 0.0,
338
+ 0.0,
339
+ 0.0,
340
+ 0.0,
341
+ 0.0,
342
+ 0.0,
343
+ 0.0,
344
+ 0.0,
345
+ 0.0,
346
+ 0.0,
347
+ 0.0,
348
+ 0.0,
349
+ 0.0,
350
+ 0.0,
351
+ 0.0,
352
+ 0.0,
353
+ 0.0,
354
+ 0.0,
355
+ 0.0,
356
+ 0.0,
357
+ 0.0,
358
+ 0.125,
359
+ 0.125,
360
+ 0.125,
361
+ 0.125,
362
+ 0.0,
363
+ 0.0,
364
+ 0.0,
365
+ 0.0,
366
+ 0.125,
367
+ 0.125,
368
+ 0.125,
369
+ 0.0,
370
+ 0.0,
371
+ 0.125
372
+ ]
373
+ ],
374
+ "clinical_envelope": true,
375
+ "temporal_pool": true,
376
+ "temporal_evidence": true,
377
+ "evidence_temperature": 0.25,
378
+ "random_fourier": true,
379
+ "fourier_features": 256,
380
+ "tangent_readout": true
381
+ },
382
+ "initialization": {
383
+ "initialization": "continue joint training from a complete shared-model checkpoint",
384
+ "parent": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
385
+ "parent_initialization": {
386
+ "initialization": "jointly trained parent plus audited pretrained BIOT in a single coupled backbone",
387
+ "parent": "/workspace/research/runs/hybrid_wide1/epoch-004/weights.pt",
388
+ "audited_biot": {
389
+ "initialization": "pretrained",
390
+ "repo": "braindecode/biot-pretrained-six-datasets-18chs",
391
+ "revision": "7e9aabf302870012f73773276803aab97993951c",
392
+ "sha256": "a218f4054ae29962c6fd9d23d94c446d354c4f53e805a6771c85749ccc20baaa",
393
+ "license": "BSD-3-Clause",
394
+ "source_braindecode": "1.3.0",
395
+ "loaded_core_tensors": 56,
396
+ "skipped_classifier_tensors": 3
397
+ },
398
+ "neural_channel_indices": {
399
+ "faced": [
400
+ 0,
401
+ 1,
402
+ 2,
403
+ 3,
404
+ 4,
405
+ 5,
406
+ 6,
407
+ 7,
408
+ 8,
409
+ 9,
410
+ 10,
411
+ 11,
412
+ 12,
413
+ 13,
414
+ 14,
415
+ 15,
416
+ 16,
417
+ 17
418
+ ],
419
+ "tuev": [
420
+ 0,
421
+ 1,
422
+ 2,
423
+ 3,
424
+ 4,
425
+ 5,
426
+ 6,
427
+ 7,
428
+ 8,
429
+ 9,
430
+ 10,
431
+ 11,
432
+ 12,
433
+ 13,
434
+ 14,
435
+ 15
436
+ ],
437
+ "ad65": [
438
+ 0,
439
+ 1,
440
+ 2,
441
+ 3,
442
+ 4,
443
+ 5,
444
+ 6,
445
+ 7,
446
+ 8,
447
+ 9,
448
+ 10,
449
+ 11,
450
+ 12,
451
+ 13,
452
+ 14,
453
+ 15,
454
+ 16,
455
+ 17
456
+ ],
457
+ "openbmi": [
458
+ 0,
459
+ 1,
460
+ 3,
461
+ 5,
462
+ 12,
463
+ 14,
464
+ 23,
465
+ 25,
466
+ 28,
467
+ 30,
468
+ 2,
469
+ 6,
470
+ 11,
471
+ 15,
472
+ 22,
473
+ 26,
474
+ 4,
475
+ 13
476
+ ],
477
+ "longitudinal": [
478
+ 0,
479
+ 2,
480
+ 7,
481
+ 11,
482
+ 23,
483
+ 27,
484
+ 41,
485
+ 45,
486
+ 55,
487
+ 57,
488
+ 5,
489
+ 13,
490
+ 21,
491
+ 29,
492
+ 39,
493
+ 47,
494
+ 9,
495
+ 25
496
+ ]
497
+ },
498
+ "rebase": "incumbent waveform, fusion and four heads; joint BIOT and TUEV head from readout epoch 9; zero initialized neural interaction",
499
+ "jointly_finetuned_neural_parent": "/workspace/research/runs/hybrid_biot_readout1/epoch-009/weights.pt",
500
+ "tuev_high_dimensional_spectral_projection_disabled": true,
501
+ "frozen_prior_representation": true,
502
+ "nonclinical_head_updates": "only the 256 added BIOT columns; original columns and biases fixed",
503
+ "faced_openbmi_neural_path": "common nonlinear fusion only; direct head columns masked",
504
+ "retention_teacher": "/workspace/research/runs/hybrid_wide1/epoch-004",
505
+ "retention_loss": {
506
+ "split": "train",
507
+ "temperature": 2.0,
508
+ "kl_weight": 1.0,
509
+ "tracks": [
510
+ "faced",
511
+ "ad65",
512
+ "openbmi",
513
+ "longitudinal"
514
+ ]
515
+ }
516
+ },
517
+ "joint_covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
518
+ "frozen_prior_representation": true,
519
+ "head_updates": "one linear head per track; added 128 shared covariance columns trainable; AD head initialized from the joint covariance parent",
520
+ "new_shared_representation": "one common covariance MLP inside the coupled backbone, trained by all five tasks; fixed spatial input adapters from the same jointly trained source",
521
+ "head_arithmetic": "one linear head evaluated in fixed feature blocks to preserve original bfloat16 accumulation dimensions",
522
+ "retention_teacher": {
523
+ "ad65": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
524
+ "other_tracks": "/workspace/research/runs/hybrid_wide1/epoch-004"
525
+ },
526
+ "retention_loss": {
527
+ "split": "train",
528
+ "temperature": 2.0,
529
+ "kl_weight": 1.0,
530
+ "tracks": [
531
+ "faced",
532
+ "ad65",
533
+ "openbmi",
534
+ "longitudinal"
535
+ ]
536
+ }
537
+ },
538
+ "loader_scale": 0.01,
539
+ "tracks": [
540
+ "faced",
541
+ "tuev",
542
+ "ad65",
543
+ "openbmi",
544
+ "longitudinal"
545
+ ],
546
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
547
+ "head_refinement": {
548
+ "source": "/workspace/research/runs/residual_heads1/epoch-018",
549
+ "source_weights_sha256": "e0b609137391b47f99438ccadaa22fc0bc10d2c10ead0ddf0a3c25be2c907c85",
550
+ "shared_backbone_unchanged": true,
551
+ "selected_head_epochs": {
552
+ "faced": 5,
553
+ "tuev": 24,
554
+ "ad65": 0,
555
+ "openbmi": 0,
556
+ "longitudinal": 0
557
+ }
558
+ },
559
+ "clinical_spectral_refinement": {
560
+ "source": "/workspace/research/runs/head_dropout1/epoch-016",
561
+ "zero_initialized_input_adapter": true,
562
+ "backbone_unchanged": true
563
+ },
564
+ "head_estimation": {
565
+ "method": "class/subject-balanced Gaussian linear discriminant; covariance augmented by class-conditional subject/session mean variation before shrinkage",
566
+ "selected_shrinkage": {
567
+ "faced": "inherited",
568
+ "tuev": "inherited",
569
+ "ad65": "inherited",
570
+ "openbmi": "inherited",
571
+ "longitudinal": {
572
+ "shrinkage": 0.9,
573
+ "domain_strength": 1.0
574
+ }
575
+ },
576
+ "feature_scaling": "fitted on training data and folded into linear coefficients"
577
+ },
578
+ "clinical_asymmetry_refinement": {
579
+ "source": "/workspace/research/runs/domain_lda_heads1/epoch-001",
580
+ "zero_initialized_input_adapter": true,
581
+ "backbone_unchanged": true
582
+ },
583
+ "alpha_rhythm_adapter": {
584
+ "training_normalization_only": true,
585
+ "regions": [
586
+ "occipital",
587
+ "parietal",
588
+ "central",
589
+ "frontal",
590
+ "left_posterior",
591
+ "right_posterior"
592
+ ],
593
+ "features": "per-window alpha prominence relative to adjacent frequencies",
594
+ "shared_backbone_unchanged": true
595
+ },
596
+ "clinical_envelope_refinement": {
597
+ "source": "/workspace/research/runs/clinical_asymmetry1/epoch-001",
598
+ "zero_initialized_input_adapter": true,
599
+ "backbone_unchanged": true
600
+ },
601
+ "independent_adapter_merge": {
602
+ "alpha_source": "/workspace/research/runs/alpha_calibrated1/epoch-003",
603
+ "clinical_source": "/workspace/research/runs/clinical_envelope1/epoch-002",
604
+ "all_shared_and_head_tensors_equal": true
605
+ },
606
+ "frequency_montage_refinement": {
607
+ "six_frequency_bands": true,
608
+ "shared_encoder_unchanged": true,
609
+ "selected_track_epochs": {
610
+ "faced": 0,
611
+ "tuev": 1,
612
+ "ad65": 0,
613
+ "openbmi": 10,
614
+ "longitudinal": 2
615
+ }
616
+ },
617
+ "private_track_selection": {
618
+ "track": "tuev",
619
+ "donor": "/workspace/research/replicates/frequency_head_control1/epoch-001"
620
+ },
621
+ "clinical_sampling_refinement": {
622
+ "subject_exponent": 0.0,
623
+ "class_balanced": true,
624
+ "only_clinical_head_updated": true
625
+ },
626
+ "temporal_statistics_readout": {
627
+ "statistics": [
628
+ "mean",
629
+ "standard deviation",
630
+ "maximum",
631
+ "minimum"
632
+ ],
633
+ "shared_encoder_and_prior_heads_unchanged": true,
634
+ "selected_pool_epochs": {
635
+ "faced": 2,
636
+ "tuev": 0,
637
+ "ad65": 0,
638
+ "openbmi": 33,
639
+ "longitudinal": 3
640
+ }
641
+ },
642
+ "temporal_evidence_readout": {
643
+ "pooling": "log mean exp of per-patch class evidence",
644
+ "temperature": 0.25,
645
+ "shared_encoder_and_prior_heads_unchanged": true,
646
+ "selected_evidence_epochs": {
647
+ "faced": 0,
648
+ "tuev": 0,
649
+ "ad65": 0,
650
+ "openbmi": 6,
651
+ "longitudinal": 8
652
+ }
653
+ },
654
+ "fourier_basis_readout": {
655
+ "basis_functions": 256,
656
+ "bandwidths": [
657
+ 0.5,
658
+ 1.0,
659
+ 2.0
660
+ ],
661
+ "shared_encoder_and_prior_heads_unchanged": true,
662
+ "selected_fourier_epochs": {
663
+ "faced": 21,
664
+ "tuev": 0,
665
+ "ad65": 0,
666
+ "openbmi": 0,
667
+ "longitudinal": 2
668
+ }
669
+ },
670
+ "shared_tangent_readout": {
671
+ "one_shared_tangent_module": true,
672
+ "original_and_corrected_shared_features_retained": true,
673
+ "private_head_scalar_gains": {
674
+ "faced": 0.0,
675
+ "tuev": 0.1,
676
+ "ad65": 0.0,
677
+ "openbmi": 1.0,
678
+ "longitudinal": 0.1
679
+ },
680
+ "all_common_weights_fixed_during_gain_refinement": true
681
+ }
682
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/covariances.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared neural filter-bank covariance decoder with spatial input adapters."""
2
+ import torch
3
+ from torch import nn
4
+ SPECS={'faced':(32,10,9),'tuev':(16,5,6),'ad65':(19,10,3),'openbmi':(62,4,2),'longitudinal':(58,2,2)}
5
+ TRACKS=tuple(SPECS)
6
+ BANDS=[(1,4),(4,8),(8,12),(12,16),(16,20),(20,24),(24,28),(28,32),(32,40),(40,48)]
7
+
8
+ @torch.no_grad()
9
+ def extract_covariances(t,x):
10
+ x=torch.nan_to_num(x.float().flatten(2)).clamp(-1e5,1e5)
11
+ x=x-x.mean(-1,keepdim=True)
12
+ if t in ('faced','tuev'):
13
+ x=x/x.square().mean(-1,keepdim=True).clamp_min(1e-12).sqrt()
14
+ else:x=x-x.mean(1,keepdim=True)
15
+ # Per-window normalization, preserving spatial and frequency power ratios.
16
+ x=x/x.square().mean((1,2),keepdim=True).clamp_min(1e-12).sqrt()
17
+ frames=x.unfold(-1,400,200);frames=frames-frames.mean(-1,keepdim=True)
18
+ z=torch.fft.rfft(frames*torch.hann_window(400,device=x.device),dim=-1)/200
19
+ covs=[]
20
+ for lo,hi in BANDS:
21
+ v=z[...,2*lo:2*hi].flatten(2)
22
+ cov=(v.real@v.real.transpose(-1,-2)+v.imag@v.imag.transpose(-1,-2))/v.shape[-1]
23
+ covs.append(cov)
24
+ return torch.stack(covs,1)
25
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/data.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from functools import lru_cache
3
+ from pathlib import Path
4
+ import numpy as np
5
+ import torch
6
+ @lru_cache(maxsize=8)
7
+ def array(path):return np.load(path,mmap_mode='r',allow_pickle=False)
8
+ class Dataset(torch.utils.data.Dataset):
9
+ def __init__(self,root,limit=None,cache=False):
10
+ self.root=Path(root)
11
+ self.rows=json.loads((self.root/'manifest.json').read_text())['samples']
12
+ if limit:self.rows=self.rows[:limit]
13
+ self.cached=None
14
+ if cache and self.rows:
15
+ from collections import defaultdict
16
+ groups=defaultdict(list)
17
+ for i,r in enumerate(self.rows):groups[r['path']].append((i,r['index']))
18
+ for name,indices in groups.items():
19
+ path=(self.root/name).resolve()
20
+ if not path.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
21
+ source=np.load(path,mmap_mode='r',allow_pickle=False)
22
+ if self.cached is None:self.cached=torch.empty((len(self.rows),*source.shape[1:]),dtype=torch.float32)
23
+ dst,src=zip(*indices)
24
+ self.cached[list(dst)]=torch.as_tensor(source[list(src)]/100,dtype=torch.float32)
25
+ def __len__(self):return len(self.rows)
26
+ def __getitem__(self,i):
27
+ r=self.rows[i]
28
+ if self.cached is not None:return self.cached[i],r.get('label',-1),r['id']
29
+ p=(self.root/r['path']).resolve()
30
+ if not p.is_relative_to(self.root.resolve()):raise ValueError('input outside root')
31
+ # Division precedes float32 conversion, matching official FACED/TUEV collate.
32
+ x=np.asarray(array(str(p))[r['index']])/100
33
+ return torch.as_tensor(x,dtype=torch.float32),r.get('label',-1),r['id']
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/envelope_features.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Per-window burst-envelope regularity and bilateral synchrony, without fitting."""
2
+ import torch
3
+ import torch.nn.functional as F
4
+
5
+ BANDS=((1,4),(4,8),(8,13),(13,30),(30,45))
6
+ ENVELOPE_DIM=16*5*12+8*5*2
7
+
8
+ @torch.no_grad()
9
+ def extract_envelope_features(signal):
10
+ with torch.autocast(signal.device.type,enabled=False):
11
+ x=signal.float();x=x-x.mean(-1,keepdim=True)
12
+ spectrum=torch.fft.fft(x,dim=-1)
13
+ frequency=torch.fft.fftfreq(x.shape[-1],1/200,device=x.device)
14
+ envelopes=[]
15
+ for lo,hi in BANDS:
16
+ mask=((frequency>=lo)&(frequency<hi)).to(x.dtype)*2
17
+ analytic=torch.fft.ifft(spectrum*mask,dim=-1)
18
+ energy=analytic.abs().square()
19
+ envelope=F.avg_pool1d(energy.flatten(0,1).unsqueeze(1),20,10).squeeze(1)
20
+ envelopes.append(envelope.reshape(len(x),16,-1))
21
+ e=torch.stack(envelopes,2)
22
+ mean=e.mean(-1,keepdim=True).clamp_min(1e-12)
23
+ relative=e/mean
24
+ centered=relative-relative.mean(-1,keepdim=True)
25
+ std=centered.square().mean(-1,keepdim=True).sqrt().clamp_min(1e-6)
26
+ normalized=centered/std
27
+ acf=torch.stack([(normalized[...,:-lag]*normalized[...,lag:]).mean(-1)
28
+ for lag in range(4,41)],-1).clamp(-1,1)
29
+ acf_peak,acf_index=acf.max(-1)
30
+ probability=(relative/relative.sum(-1,keepdim=True).clamp_min(1e-12)).clamp_min(1e-12)
31
+ entropy=-(probability*probability.log()).sum(-1)
32
+ summaries=[std.squeeze(-1).clamp_min(1e-6).log(),relative.amax(-1).clamp_min(1).log(),entropy,
33
+ (relative>2).float().mean(-1),(relative>4).float().mean(-1),
34
+ ((relative[...,1:]>2)&(relative[...,:-1]<=2)).float().mean(-1),
35
+ acf_peak,(acf_index.float()+4)/40,
36
+ acf[...,0],acf[...,6],acf[...,16],acf[...,36]]
37
+ left=torch.tensor([0,1,2,3,8,9,10,11],device=x.device);right=left+4
38
+ synchrony=(normalized[:,left]*normalized[:,right]).mean(-1).clamp(-1,1)
39
+ imbalance=(std[:,left].squeeze(-1).log()-std[:,right].squeeze(-1).log()).abs()
40
+ return torch.cat([torch.stack(summaries,-1).flatten(1),synchrony.flatten(1),imbalance.flatten(1)],1)
41
+
42
+ def mirrored_features(features):
43
+ channels=torch.tensor([4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11],device=features.device)
44
+ return torch.cat([features[:,:16*5*12].reshape(-1,16,5,12)[:,channels].flatten(1),features[:,16*5*12:]],1)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S035/features.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One shared residual backbone, five linear input adapters and output heads."""
2
+ import torch
3
+ from torch import nn
4
+
5
+ SPECS = {'faced': (32, 10, 9), 'tuev': (16, 5, 6), 'ad65': (19, 10, 3),
6
+ 'openbmi': (62, 4, 2), 'longitudinal': (58, 2, 2)}
7
+ TRACKS = tuple(SPECS)
8
+ EDGES = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,18,20,22,25,28,32,36,40,45,50,60,70,80,95]
9
+ COV_BANDS = [(1,4),(4,8),(8,12),(12,16),(16,20),(20,28),(28,40)]
10
+
11
+ def feature_dim(channels):
12
+ return channels * (4*(len(EDGES)-1)+4) + len(COV_BANDS)*channels*(channels-1)//2
13
+
14
+ @torch.no_grad()
15
+ def extract_features(track, x):
16
+ """Fixed features; no batch statistics or fitted inference transformations."""
17
+ x = x.float().flatten(2)
18
+ x = torch.nan_to_num(x, nan=0., posinf=1e5, neginf=-1e5).clamp(-1e5,1e5)
19
+ x = x - x.mean(-1,keepdim=True)
20
+ if track in ('ad65','openbmi','longitudinal'):
21
+ x = x - x.mean(1,keepdim=True)
22
+ rms = x.square().mean(-1).clamp_min(1e-12).sqrt()
23
+ norm = x / rms.unsqueeze(-1)
24
+ moments = torch.stack([rms.log(), norm.abs().amax(-1).clamp_min(1).log(),
25
+ norm.pow(4).mean(-1).clamp_min(1).log(),
26
+ (norm[...,1:]-norm[...,:-1]).square().mean(-1).clamp_min(1e-10).log()],-1)
27
+ frames = x.unfold(-1,400,200)
28
+ frames = frames - frames.mean(-1,keepdim=True)
29
+ window = torch.hann_window(400,device=x.device)
30
+ z = torch.fft.rfft(frames*window,dim=-1)/200
31
+ power = z.abs().square()
32
+ bands = torch.stack([power[...,2*lo:2*hi].mean(-1) for lo,hi in zip(EDGES[:-1],EDGES[1:])],-1)
33
+ lp = bands.mean(-2).clamp_min(1e-12).log()
34
+ variation = bands.clamp_min(1e-12).log().std(-2,correction=0)
35
+ relative_frequency = lp - lp.mean(-1,keepdim=True)
36
+ relative_channel = lp - lp.mean(1,keepdim=True)
37
+ parts = [torch.cat([lp, relative_frequency, relative_channel, variation, moments],-1).flatten(1)]
38
+ ii,jj = torch.triu_indices(x.shape[1],x.shape[1],offset=1,device=x.device)
39
+ for lo,hi in COV_BANDS:
40
+ v = z[...,2*lo:2*hi].flatten(2)
41
+ cov = v.real @ v.real.transpose(-1,-2) + v.imag @ v.imag.transpose(-1,-2)
42
+ d = cov.diagonal(dim1=-2,dim2=-1).clamp_min(1e-12).sqrt()
43
+ cor = cov / (d.unsqueeze(1)*d.unsqueeze(2)).clamp_min(1e-12)
44
+ parts.append(cor[:,ii,jj].clamp(-1,1))
45
+ result = torch.cat(parts,-1)
46
+ return torch.nan_to_num(result).clamp(-40,40)
47
+
48
+ class Standardize(nn.Module):
49
+ def __init__(self, dim):
50
+ super().__init__()
51
+ self.register_buffer('mean',torch.zeros(dim))
52
+ self.register_buffer('scale',torch.ones(dim))
53
+ def forward(self,x):
54
+ return ((x-self.mean)/self.scale).clamp(-8,8)
55
+
56
+ class Residual(nn.Module):
57
+ def __init__(self,width,dropout):
58
+ super().__init__()
59
+ self.net=nn.Sequential(nn.LayerNorm(width),nn.Linear(width,width*2),nn.GELU(),
60
+ nn.Dropout(dropout),nn.Linear(width*2,width),nn.Dropout(dropout))
61
+ def forward(self,x):
62
+ return x+self.net(x)
63
+