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

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/S003/data.py +33 -0
  2. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S004/config.json +22 -0
  3. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S004/data.py +33 -0
  4. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S004/features.py +63 -0
  5. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S004/infer.py +20 -0
  6. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S004/infer.sh +3 -0
  7. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S004/model.py +74 -0
  8. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S004/training.json +843 -0
  9. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/config.json +187 -0
  10. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S011/config.json +192 -0
  11. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S011/covariances.py +25 -0
  12. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S011/data.py +33 -0
  13. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S011/features.py +63 -0
  14. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S011/infer.py +24 -0
  15. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S011/model.py +103 -0
  16. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S011/training.json +2530 -0
  17. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/config.json +214 -0
  18. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/covariances.py +25 -0
  19. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/data.py +33 -0
  20. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/features.py +63 -0
  21. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/infer.py +24 -0
  22. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/infer.sh +3 -0
  23. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/model.py +134 -0
  24. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/training.json +0 -0
  25. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/alpha_features.py +45 -0
  26. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/config.json +615 -0
  27. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/covariances.py +25 -0
  28. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/data.py +33 -0
  29. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/envelope_features.py +44 -0
  30. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/features.py +63 -0
  31. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/frequency_features.py +11 -0
  32. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/infer.py +24 -0
  33. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/infer.sh +3 -0
  34. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/model.py +161 -0
  35. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S024/infer.sh +3 -0
  36. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/data.py +33 -0
  37. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S027/features.py +63 -0
  38. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/alpha_features.py +45 -0
  39. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/config.json +669 -0
  40. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/covariances.py +25 -0
  41. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/data.py +33 -0
  42. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/envelope_features.py +44 -0
  43. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/features.py +63 -0
  44. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/frequency_features.py +11 -0
  45. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/infer.py +24 -0
  46. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/infer.sh +3 -0
  47. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/model.py +222 -0
  48. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S031/alpha_features.py +45 -0
  49. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S031/config.json +669 -0
  50. tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S031/covariances.py +25 -0
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S003/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/S004/config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "bci-fused-shared-backbone-v1",
3
+ "architecture": {
4
+ "channels": 32,
5
+ "width": 128,
6
+ "depth": 2,
7
+ "dropout": 0.5
8
+ },
9
+ "initialization": {
10
+ "initialization": "jointly trained waveform and spectral stems, initialized task heads, coupled shared feature fusion",
11
+ "waveform_parent": "/workspace/research/runs/eegnet1/epoch-016/weights.pt",
12
+ "spectral_parent": "/workspace/research/runs/spectral2/epoch-010/weights.pt"
13
+ },
14
+ "loader_scale": 0.01,
15
+ "tracks": [
16
+ "faced",
17
+ "tuev",
18
+ "ad65",
19
+ "openbmi",
20
+ "longitudinal"
21
+ ]
22
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S004/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/S004/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/S004/infer.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse,json
2
+ from pathlib import Path
3
+ import torch
4
+ from model import HybridModel,SPECS
5
+ from data import Dataset
6
+ p=argparse.ArgumentParser();p.add_argument('input',type=Path);p.add_argument('output',type=Path);a=p.parse_args()
7
+ root=Path(__file__).resolve().parent;c=json.loads((root/'config.json').read_text());t=json.loads((a.input/'manifest.json').read_text())['track']
8
+ if t not in SPECS:raise ValueError('unknown track')
9
+ torch.set_num_threads(4);device='cuda' if torch.cuda.is_available() else 'cpu'
10
+ m=HybridModel(**c['architecture']).to(device);m.load_state_dict(torch.load(root/'weights.pt',map_location=device,weights_only=True));m.eval()
11
+ a.output.mkdir(parents=True,exist_ok=True)
12
+ with torch.inference_mode(),(a.output/'predictions.jsonl').open('w') as f:
13
+ for x,_,ids in torch.utils.data.DataLoader(Dataset(a.input),batch_size=64,num_workers=0):
14
+ # FFT features stay float32; convolutions can use bfloat16 on CUDA.
15
+ x=x.to(device)
16
+ from features import extract_features
17
+ features=extract_features(t,x)
18
+ with torch.autocast(device,dtype=torch.bfloat16,enabled=device=='cuda'):pred=m(t,x,features)
19
+ pp=pred.float().softmax(-1).cpu().numpy()
20
+ 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/S004/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/S004/model.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One fused waveform/spectral backbone used identically by all five tasks."""
2
+ import torch
3
+ from torch import nn
4
+ from features import SPECS,TRACKS,feature_dim,extract_features,Standardize,Residual
5
+
6
+ class InputAdapter(nn.Module):
7
+ def __init__(self,c,width,channels,spectral_enabled=True):
8
+ super().__init__()
9
+ self.signal=nn.Conv1d(c,channels,1,bias=False)
10
+ self.normalizer=Standardize(feature_dim(c))
11
+ self.spectral=nn.Linear(feature_dim(c),width)
12
+ self.dropout=nn.Dropout(.1)
13
+ self.register_buffer("spectral_enabled",torch.tensor(float(spectral_enabled)))
14
+ def forward(self,x,features):
15
+ return self.signal(x).unsqueeze(1),self.spectral_enabled*self.spectral(self.dropout(self.normalizer(features)))
16
+
17
+ class SharedBackbone(nn.Module):
18
+ def __init__(self,channels,width,depth,dropout):
19
+ super().__init__()
20
+ self.waveform=nn.Sequential(
21
+ nn.Conv2d(1,16,(1,64),padding=(0,32),bias=False),nn.GroupNorm(1,16),
22
+ nn.Conv2d(16,32,(channels,1),groups=16,bias=False),nn.GroupNorm(1,32),nn.ELU(),
23
+ nn.AvgPool2d((1,4)),nn.Dropout(.35),
24
+ nn.Conv2d(32,32,(1,16),padding=(0,8),groups=32,bias=False),nn.Conv2d(32,32,1,bias=False),
25
+ nn.GroupNorm(1,32),nn.ELU(),nn.AvgPool2d((1,8)),nn.Dropout(.35))
26
+ self.wave_summary=nn.Sequential(nn.AdaptiveAvgPool2d((1,8)),nn.Flatten(),nn.Linear(256,width))
27
+ self.fusion=nn.Sequential(nn.LayerNorm(width),nn.GELU(),nn.Dropout(dropout),
28
+ *[Residual(width,dropout) for _ in range(depth)],nn.LayerNorm(width))
29
+ # Both representations interact before the shared residual stack.
30
+ self.wave_gain=nn.Parameter(torch.tensor(.1))
31
+ def forward(self,signal,spectral):
32
+ wave=self.waveform(signal)
33
+ fused=self.fusion(spectral+self.wave_gain*self.wave_summary(wave))
34
+ return torch.cat([wave.flatten(1),fused],-1)
35
+
36
+ class HybridModel(nn.Module):
37
+ def __init__(self,channels=32,width=128,depth=2,dropout=.5):
38
+ super().__init__()
39
+ self.adapters=nn.ModuleDict({t:InputAdapter(c,width,channels,spectral_enabled=t not in ("faced","openbmi")) for t,(c,s,k) in SPECS.items()})
40
+ self.backbone=SharedBackbone(channels,width,depth,dropout)
41
+ self.heads=nn.ModuleDict({t:nn.Linear(32*(((s*200+1)//4+1)//8)+width,k) for t,(c,s,k) in SPECS.items()})
42
+ def forward(self,t,x,features=None):
43
+ if features is None:features=extract_features(t,x)
44
+ signal=x.flatten(2);signal=signal-signal.mean(-1,keepdim=True)
45
+ if t in ('faced','tuev'):signal=signal/signal.std(-1,keepdim=True,correction=0).clamp_min(1e-6)
46
+ else:signal=signal-signal.mean(1,keepdim=True)
47
+ signal=signal.clamp(-20,20)
48
+ adapted=self.adapters[t](signal,features)
49
+ return self.heads[t](self.backbone(*adapted))
50
+
51
+ def initialize_stems(self,waveform_state,spectral_state):
52
+ self.backbone.waveform.load_state_dict({k.removeprefix('backbone.'):v for k,v in waveform_state.items() if k.startswith('backbone.')})
53
+ self.backbone.fusion.load_state_dict({k.removeprefix('backbone.'):v for k,v in spectral_state.items() if k.startswith('backbone.')})
54
+ for t in TRACKS:
55
+ self.adapters[t].signal.load_state_dict({'weight':waveform_state[f'adapters.{t}.weight']})
56
+ self.adapters[t].normalizer.load_state_dict({k:spectral_state[f'normalizers.{t}.{k}'] for k in ('mean','scale')})
57
+ self.adapters[t].spectral.load_state_dict({k:spectral_state[f'adapters.{t}.{k}'] for k in ('weight','bias')})
58
+ with torch.no_grad():
59
+ for t in TRACKS:
60
+ self.heads[t].weight.zero_()
61
+ # Each head starts from the representation supported by validation.
62
+ # Shared waveform-to-spectral coupling remains active for every task.
63
+ if t in ('faced','openbmi'):
64
+ self.heads[t].weight[:,:-128].copy_(waveform_state[f'heads.{t}.weight'])
65
+ self.heads[t].weight[:,-128:].normal_(0,.001)
66
+ self.heads[t].bias.copy_(waveform_state[f'heads.{t}.bias'])
67
+ elif t in ('ad65','longitudinal'):
68
+ self.heads[t].weight[:,-128:].copy_(spectral_state[f'heads.{t}.weight'])
69
+ self.heads[t].weight[:,:-128].normal_(0,.001)
70
+ self.heads[t].bias.copy_(spectral_state[f'heads.{t}.bias'])
71
+ else:
72
+ self.heads[t].weight[:,:-128].copy_(waveform_state[f'heads.{t}.weight']*.5)
73
+ self.heads[t].weight[:,-128:].copy_(spectral_state[f'heads.{t}.weight']*.5)
74
+ self.heads[t].bias.copy_((spectral_state[f'heads.{t}.bias']+waveform_state[f'heads.{t}.bias'])*.5)
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S004/training.json ADDED
@@ -0,0 +1,843 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "settings": {
3
+ "output": "/workspace/research/runs/hybrid_distill1",
4
+ "epochs": 15,
5
+ "steps": 500,
6
+ "batch_size": 64,
7
+ "seed": 7,
8
+ "hidden": 32,
9
+ "dropout": 0.5,
10
+ "lr": 2e-05,
11
+ "head_lr": 5e-05,
12
+ "weight_decay": 0.05,
13
+ "waveform_parent": "/workspace/research/runs/eegnet1/epoch-016/weights.pt",
14
+ "spectral_parent": "/workspace/research/runs/spectral2/epoch-010/weights.pt",
15
+ "init": "/workspace/research/runs/hybrid_mil1/epoch-006/weights.pt",
16
+ "mixup": 0.0,
17
+ "ad_pool": 8
18
+ },
19
+ "all_tracks_update_shared_backbone": true,
20
+ "history": [
21
+ {
22
+ "epoch": 1,
23
+ "validation": {
24
+ "faced": {
25
+ "class_counts": [
26
+ 180,
27
+ 180,
28
+ 180,
29
+ 180,
30
+ 240,
31
+ 180,
32
+ 180,
33
+ 180,
34
+ 180
35
+ ],
36
+ "predicted_class_counts": [
37
+ 168,
38
+ 187,
39
+ 165,
40
+ 227,
41
+ 237,
42
+ 153,
43
+ 182,
44
+ 183,
45
+ 178
46
+ ],
47
+ "confusion_matrix": [
48
+ [
49
+ 80,
50
+ 14,
51
+ 6,
52
+ 23,
53
+ 19,
54
+ 6,
55
+ 10,
56
+ 11,
57
+ 11
58
+ ],
59
+ [
60
+ 13,
61
+ 75,
62
+ 9,
63
+ 20,
64
+ 21,
65
+ 11,
66
+ 16,
67
+ 7,
68
+ 8
69
+ ],
70
+ [
71
+ 7,
72
+ 9,
73
+ 86,
74
+ 21,
75
+ 16,
76
+ 6,
77
+ 7,
78
+ 12,
79
+ 16
80
+ ],
81
+ [
82
+ 18,
83
+ 21,
84
+ 7,
85
+ 68,
86
+ 19,
87
+ 6,
88
+ 15,
89
+ 18,
90
+ 8
91
+ ],
92
+ [
93
+ 14,
94
+ 18,
95
+ 15,
96
+ 27,
97
+ 104,
98
+ 19,
99
+ 16,
100
+ 18,
101
+ 9
102
+ ],
103
+ [
104
+ 7,
105
+ 10,
106
+ 10,
107
+ 18,
108
+ 13,
109
+ 80,
110
+ 11,
111
+ 15,
112
+ 16
113
+ ],
114
+ [
115
+ 10,
116
+ 10,
117
+ 9,
118
+ 14,
119
+ 17,
120
+ 13,
121
+ 88,
122
+ 10,
123
+ 9
124
+ ],
125
+ [
126
+ 6,
127
+ 17,
128
+ 12,
129
+ 22,
130
+ 16,
131
+ 9,
132
+ 9,
133
+ 82,
134
+ 7
135
+ ],
136
+ [
137
+ 13,
138
+ 13,
139
+ 11,
140
+ 14,
141
+ 12,
142
+ 3,
143
+ 10,
144
+ 10,
145
+ 94
146
+ ]
147
+ ],
148
+ "per_class_recall": [
149
+ 0.4444444444444444,
150
+ 0.4166666666666667,
151
+ 0.4777777777777778,
152
+ 0.37777777777777777,
153
+ 0.43333333333333335,
154
+ 0.4444444444444444,
155
+ 0.4888888888888889,
156
+ 0.45555555555555555,
157
+ 0.5222222222222223
158
+ ],
159
+ "balanced_accuracy": 0.45123456790123456,
160
+ "accuracy": 0.4505952380952381,
161
+ "weighted_f1": 0.45280743688486585,
162
+ "macro_f1": 0.45342776046542965,
163
+ "kappa": 0.3811747240380241,
164
+ "samples": 1680,
165
+ "reward": 0.45123456790123456,
166
+ "subjects": 20
167
+ },
168
+ "tuev": {
169
+ "class_counts": [
170
+ 119,
171
+ 291,
172
+ 669,
173
+ 86,
174
+ 500,
175
+ 13822
176
+ ],
177
+ "predicted_class_counts": [
178
+ 85,
179
+ 611,
180
+ 72,
181
+ 100,
182
+ 2140,
183
+ 12479
184
+ ],
185
+ "confusion_matrix": [
186
+ [
187
+ 31,
188
+ 19,
189
+ 6,
190
+ 0,
191
+ 0,
192
+ 63
193
+ ],
194
+ [
195
+ 0,
196
+ 12,
197
+ 0,
198
+ 0,
199
+ 279,
200
+ 0
201
+ ],
202
+ [
203
+ 10,
204
+ 113,
205
+ 0,
206
+ 0,
207
+ 545,
208
+ 1
209
+ ],
210
+ [
211
+ 0,
212
+ 26,
213
+ 0,
214
+ 52,
215
+ 0,
216
+ 8
217
+ ],
218
+ [
219
+ 0,
220
+ 1,
221
+ 0,
222
+ 0,
223
+ 468,
224
+ 31
225
+ ],
226
+ [
227
+ 44,
228
+ 440,
229
+ 66,
230
+ 48,
231
+ 848,
232
+ 12376
233
+ ]
234
+ ],
235
+ "per_class_recall": [
236
+ 0.2605042016806723,
237
+ 0.041237113402061855,
238
+ 0.0,
239
+ 0.6046511627906976,
240
+ 0.936,
241
+ 0.8953841701635075
242
+ ],
243
+ "balanced_accuracy": 0.4562961080061565,
244
+ "accuracy": 0.8354749144443727,
245
+ "weighted_f1": 0.8573138858544057,
246
+ "macro_f1": 0.3642198746460232,
247
+ "kappa": 0.4025401653746039,
248
+ "samples": 15487,
249
+ "reward": 0.4562961080061565,
250
+ "subjects": 58
251
+ },
252
+ "ad65": {
253
+ "class_counts": [
254
+ 464,
255
+ 393,
256
+ 486
257
+ ],
258
+ "predicted_class_counts": [
259
+ 516,
260
+ 321,
261
+ 506
262
+ ],
263
+ "confusion_matrix": [
264
+ [
265
+ 320,
266
+ 109,
267
+ 35
268
+ ],
269
+ [
270
+ 131,
271
+ 187,
272
+ 75
273
+ ],
274
+ [
275
+ 65,
276
+ 25,
277
+ 396
278
+ ]
279
+ ],
280
+ "per_class_recall": [
281
+ 0.6896551724137931,
282
+ 0.4758269720101781,
283
+ 0.8148148148148148
284
+ ],
285
+ "balanced_accuracy": 0.6600989864129287,
286
+ "accuracy": 0.6723752792256142,
287
+ "weighted_f1": 0.6678285033899227,
288
+ "macro_f1": 0.658419281691171,
289
+ "kappa": 0.5043266149732082,
290
+ "samples": 1343,
291
+ "subject_metrics": {
292
+ "class_counts": [
293
+ 7,
294
+ 5,
295
+ 6
296
+ ],
297
+ "predicted_class_counts": [
298
+ 8,
299
+ 4,
300
+ 6
301
+ ],
302
+ "confusion_matrix": [
303
+ [
304
+ 5,
305
+ 2,
306
+ 0
307
+ ],
308
+ [
309
+ 2,
310
+ 2,
311
+ 1
312
+ ],
313
+ [
314
+ 1,
315
+ 0,
316
+ 5
317
+ ]
318
+ ],
319
+ "per_class_recall": [
320
+ 0.7142857142857143,
321
+ 0.4,
322
+ 0.8333333333333334
323
+ ],
324
+ "balanced_accuracy": 0.6492063492063492,
325
+ "accuracy": 0.6666666666666666,
326
+ "weighted_f1": 0.6604938271604939,
327
+ "macro_f1": 0.6481481481481483,
328
+ "kappa": 0.49056603773584906
329
+ },
330
+ "reward": 0.6492063492063492,
331
+ "subjects": 18
332
+ },
333
+ "openbmi": {
334
+ "class_counts": [
335
+ 2200,
336
+ 2200
337
+ ],
338
+ "predicted_class_counts": [
339
+ 1969,
340
+ 2431
341
+ ],
342
+ "confusion_matrix": [
343
+ [
344
+ 1637,
345
+ 563
346
+ ],
347
+ [
348
+ 332,
349
+ 1868
350
+ ]
351
+ ],
352
+ "per_class_recall": [
353
+ 0.7440909090909091,
354
+ 0.8490909090909091
355
+ ],
356
+ "balanced_accuracy": 0.7965909090909091,
357
+ "accuracy": 0.7965909090909091,
358
+ "weighted_f1": 0.7960287132317542,
359
+ "macro_f1": 0.7960287132317541,
360
+ "kappa": 0.5931818181818183,
361
+ "samples": 4400,
362
+ "subject_scores": {
363
+ "19": 0.8575,
364
+ "35": 0.96,
365
+ "34": 0.6425000000000001,
366
+ "51": 0.735,
367
+ "20": 0.79,
368
+ "44": 0.925,
369
+ "24": 0.58,
370
+ "15": 0.8925000000000001,
371
+ "31": 0.885,
372
+ "26": 0.8025,
373
+ "23": 0.6924999999999999
374
+ },
375
+ "reward": 0.796590909090909,
376
+ "subjects": 11
377
+ },
378
+ "longitudinal": {
379
+ "class_counts": [
380
+ 4260,
381
+ 4158
382
+ ],
383
+ "predicted_class_counts": [
384
+ 4511,
385
+ 3907
386
+ ],
387
+ "confusion_matrix": [
388
+ [
389
+ 3583,
390
+ 677
391
+ ],
392
+ [
393
+ 928,
394
+ 3230
395
+ ]
396
+ ],
397
+ "per_class_recall": [
398
+ 0.8410798122065728,
399
+ 0.7768157768157768
400
+ ],
401
+ "balanced_accuracy": 0.8089477945111748,
402
+ "accuracy": 0.8093371347113328,
403
+ "weighted_f1": 0.8090983200093413,
404
+ "macro_f1": 0.8090012718037511,
405
+ "kappa": 0.618342456635853,
406
+ "samples": 8418,
407
+ "subject_scores": {
408
+ "sub-G2021": 0.8230489841436236,
409
+ "sub-G2007": 0.7226128486994896,
410
+ "sub-G2019": 0.8258893699942211,
411
+ "sub-G2031": 0.7963056838653667,
412
+ "sub-G2015": 0.8526445481984531,
413
+ "sub-CTR002": 0.9934852728970376,
414
+ "sub-G2011": 0.7666994969943414,
415
+ "sub-G2035": 0.9409862780838013,
416
+ "sub-CTR003": 0.5660173160173161
417
+ },
418
+ "reward": 0.8097433109881833,
419
+ "subjects": 9
420
+ }
421
+ },
422
+ "losses": {
423
+ "faced": 1.3396710085868835,
424
+ "tuev": 0.788370543718338,
425
+ "ad65": 0.3727912467718124,
426
+ "openbmi": 0.4478912004828453,
427
+ "longitudinal": 0.23062818482518196
428
+ },
429
+ "seconds": 66.61602520942688
430
+ },
431
+ {
432
+ "epoch": 2,
433
+ "validation": {
434
+ "faced": {
435
+ "class_counts": [
436
+ 180,
437
+ 180,
438
+ 180,
439
+ 180,
440
+ 240,
441
+ 180,
442
+ 180,
443
+ 180,
444
+ 180
445
+ ],
446
+ "predicted_class_counts": [
447
+ 161,
448
+ 192,
449
+ 162,
450
+ 245,
451
+ 249,
452
+ 152,
453
+ 174,
454
+ 180,
455
+ 165
456
+ ],
457
+ "confusion_matrix": [
458
+ [
459
+ 79,
460
+ 14,
461
+ 6,
462
+ 26,
463
+ 19,
464
+ 6,
465
+ 10,
466
+ 10,
467
+ 10
468
+ ],
469
+ [
470
+ 11,
471
+ 80,
472
+ 8,
473
+ 21,
474
+ 22,
475
+ 9,
476
+ 14,
477
+ 6,
478
+ 9
479
+ ],
480
+ [
481
+ 8,
482
+ 7,
483
+ 88,
484
+ 22,
485
+ 17,
486
+ 5,
487
+ 7,
488
+ 11,
489
+ 15
490
+ ],
491
+ [
492
+ 16,
493
+ 20,
494
+ 6,
495
+ 73,
496
+ 19,
497
+ 8,
498
+ 14,
499
+ 17,
500
+ 7
501
+ ],
502
+ [
503
+ 14,
504
+ 19,
505
+ 13,
506
+ 30,
507
+ 109,
508
+ 19,
509
+ 12,
510
+ 18,
511
+ 6
512
+ ],
513
+ [
514
+ 6,
515
+ 11,
516
+ 12,
517
+ 20,
518
+ 14,
519
+ 79,
520
+ 11,
521
+ 13,
522
+ 14
523
+ ],
524
+ [
525
+ 9,
526
+ 10,
527
+ 8,
528
+ 15,
529
+ 18,
530
+ 13,
531
+ 89,
532
+ 10,
533
+ 8
534
+ ],
535
+ [
536
+ 5,
537
+ 16,
538
+ 11,
539
+ 22,
540
+ 17,
541
+ 10,
542
+ 8,
543
+ 85,
544
+ 6
545
+ ],
546
+ [
547
+ 13,
548
+ 15,
549
+ 10,
550
+ 16,
551
+ 14,
552
+ 3,
553
+ 9,
554
+ 10,
555
+ 90
556
+ ]
557
+ ],
558
+ "per_class_recall": [
559
+ 0.4388888888888889,
560
+ 0.4444444444444444,
561
+ 0.4888888888888889,
562
+ 0.40555555555555556,
563
+ 0.45416666666666666,
564
+ 0.4388888888888889,
565
+ 0.49444444444444446,
566
+ 0.4722222222222222,
567
+ 0.5
568
+ ],
569
+ "balanced_accuracy": 0.45972222222222214,
570
+ "accuracy": 0.4595238095238095,
571
+ "weighted_f1": 0.4627178697155556,
572
+ "macro_f1": 0.4633441696694226,
573
+ "kappa": 0.3910565016406792,
574
+ "samples": 1680,
575
+ "reward": 0.45972222222222214,
576
+ "subjects": 20
577
+ },
578
+ "tuev": {
579
+ "class_counts": [
580
+ 119,
581
+ 291,
582
+ 669,
583
+ 86,
584
+ 500,
585
+ 13822
586
+ ],
587
+ "predicted_class_counts": [
588
+ 107,
589
+ 622,
590
+ 120,
591
+ 177,
592
+ 2165,
593
+ 12296
594
+ ],
595
+ "confusion_matrix": [
596
+ [
597
+ 31,
598
+ 19,
599
+ 10,
600
+ 0,
601
+ 0,
602
+ 59
603
+ ],
604
+ [
605
+ 0,
606
+ 12,
607
+ 0,
608
+ 0,
609
+ 279,
610
+ 0
611
+ ],
612
+ [
613
+ 10,
614
+ 126,
615
+ 0,
616
+ 0,
617
+ 533,
618
+ 0
619
+ ],
620
+ [
621
+ 0,
622
+ 24,
623
+ 0,
624
+ 55,
625
+ 0,
626
+ 7
627
+ ],
628
+ [
629
+ 0,
630
+ 1,
631
+ 1,
632
+ 1,
633
+ 468,
634
+ 29
635
+ ],
636
+ [
637
+ 66,
638
+ 440,
639
+ 109,
640
+ 121,
641
+ 885,
642
+ 12201
643
+ ]
644
+ ],
645
+ "per_class_recall": [
646
+ 0.2605042016806723,
647
+ 0.041237113402061855,
648
+ 0.0,
649
+ 0.6395348837209303,
650
+ 0.936,
651
+ 0.8827231949066705
652
+ ],
653
+ "balanced_accuracy": 0.4599998989517225,
654
+ "accuracy": 0.8243688254665203,
655
+ "weighted_f1": 0.8501158634946686,
656
+ "macro_f1": 0.3340653161928278,
657
+ "kappa": 0.38522232593871697,
658
+ "samples": 15487,
659
+ "reward": 0.4599998989517225,
660
+ "subjects": 58
661
+ },
662
+ "ad65": {
663
+ "class_counts": [
664
+ 464,
665
+ 393,
666
+ 486
667
+ ],
668
+ "predicted_class_counts": [
669
+ 524,
670
+ 331,
671
+ 488
672
+ ],
673
+ "confusion_matrix": [
674
+ [
675
+ 327,
676
+ 110,
677
+ 27
678
+ ],
679
+ [
680
+ 135,
681
+ 191,
682
+ 67
683
+ ],
684
+ [
685
+ 62,
686
+ 30,
687
+ 394
688
+ ]
689
+ ],
690
+ "per_class_recall": [
691
+ 0.7047413793103449,
692
+ 0.4860050890585242,
693
+ 0.8106995884773662
694
+ ],
695
+ "balanced_accuracy": 0.6671486856154117,
696
+ "accuracy": 0.6790766939687267,
697
+ "weighted_f1": 0.6758667305200454,
698
+ "macro_f1": 0.6662008456092859,
699
+ "kappa": 0.5149154167316148,
700
+ "samples": 1343,
701
+ "subject_metrics": {
702
+ "class_counts": [
703
+ 7,
704
+ 5,
705
+ 6
706
+ ],
707
+ "predicted_class_counts": [
708
+ 8,
709
+ 5,
710
+ 5
711
+ ],
712
+ "confusion_matrix": [
713
+ [
714
+ 5,
715
+ 2,
716
+ 0
717
+ ],
718
+ [
719
+ 2,
720
+ 3,
721
+ 0
722
+ ],
723
+ [
724
+ 1,
725
+ 0,
726
+ 5
727
+ ]
728
+ ],
729
+ "per_class_recall": [
730
+ 0.7142857142857143,
731
+ 0.6,
732
+ 0.8333333333333334
733
+ ],
734
+ "balanced_accuracy": 0.7158730158730159,
735
+ "accuracy": 0.7222222222222222,
736
+ "weighted_f1": 0.7289562289562289,
737
+ "macro_f1": 0.7252525252525253,
738
+ "kappa": 0.5774647887323943
739
+ },
740
+ "reward": 0.7158730158730159,
741
+ "subjects": 18
742
+ },
743
+ "openbmi": {
744
+ "class_counts": [
745
+ 2200,
746
+ 2200
747
+ ],
748
+ "predicted_class_counts": [
749
+ 1970,
750
+ 2430
751
+ ],
752
+ "confusion_matrix": [
753
+ [
754
+ 1640,
755
+ 560
756
+ ],
757
+ [
758
+ 330,
759
+ 1870
760
+ ]
761
+ ],
762
+ "per_class_recall": [
763
+ 0.7454545454545455,
764
+ 0.85
765
+ ],
766
+ "balanced_accuracy": 0.7977272727272727,
767
+ "accuracy": 0.7977272727272727,
768
+ "weighted_f1": 0.7971730606875191,
769
+ "macro_f1": 0.7971730606875191,
770
+ "kappa": 0.5954545454545455,
771
+ "samples": 4400,
772
+ "subject_scores": {
773
+ "19": 0.8625,
774
+ "35": 0.9550000000000001,
775
+ "34": 0.64,
776
+ "51": 0.7275,
777
+ "20": 0.8025,
778
+ "44": 0.9299999999999999,
779
+ "24": 0.58,
780
+ "15": 0.895,
781
+ "31": 0.8875,
782
+ "26": 0.7975000000000001,
783
+ "23": 0.6975
784
+ },
785
+ "reward": 0.7977272727272727,
786
+ "subjects": 11
787
+ },
788
+ "longitudinal": {
789
+ "class_counts": [
790
+ 4260,
791
+ 4158
792
+ ],
793
+ "predicted_class_counts": [
794
+ 4464,
795
+ 3954
796
+ ],
797
+ "confusion_matrix": [
798
+ [
799
+ 3574,
800
+ 686
801
+ ],
802
+ [
803
+ 890,
804
+ 3268
805
+ ]
806
+ ],
807
+ "per_class_recall": [
808
+ 0.8389671361502348,
809
+ 0.785954785954786
810
+ ],
811
+ "balanced_accuracy": 0.8124609610525104,
812
+ "accuracy": 0.8127821335234022,
813
+ "weighted_f1": 0.8126169923801826,
814
+ "macro_f1": 0.8125344218085727,
815
+ "kappa": 0.6252891935659897,
816
+ "samples": 8418,
817
+ "subject_scores": {
818
+ "sub-G2021": 0.833632490611855,
819
+ "sub-G2007": 0.7304617356912722,
820
+ "sub-G2019": 0.8176766410930747,
821
+ "sub-G2031": 0.7973040680359799,
822
+ "sub-G2015": 0.8429774626319118,
823
+ "sub-CTR002": 0.9934852728970376,
824
+ "sub-G2011": 0.771485259745841,
825
+ "sub-G2035": 0.9467055869397201,
826
+ "sub-CTR003": 0.5882034632034632
827
+ },
828
+ "reward": 0.8135479978722395,
829
+ "subjects": 9
830
+ }
831
+ },
832
+ "losses": {
833
+ "faced": 1.3266721785068512,
834
+ "tuev": 0.7402228504419327,
835
+ "ad65": 0.36885406374931334,
836
+ "openbmi": 0.44960359126329424,
837
+ "longitudinal": 0.22761556178331374
838
+ },
839
+ "seconds": 85.07392573356628
840
+ }
841
+ ],
842
+ "parameters": 6868247
843
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S010/config.json ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ },
10
+ "initialization": {
11
+ "initialization": "continue joint training from a complete shared-model checkpoint",
12
+ "parent": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
13
+ "parent_initialization": {
14
+ "initialization": "jointly trained parent plus audited pretrained BIOT in a single coupled backbone",
15
+ "parent": "/workspace/research/runs/hybrid_wide1/epoch-004/weights.pt",
16
+ "audited_biot": {
17
+ "initialization": "pretrained",
18
+ "repo": "braindecode/biot-pretrained-six-datasets-18chs",
19
+ "revision": "7e9aabf302870012f73773276803aab97993951c",
20
+ "sha256": "a218f4054ae29962c6fd9d23d94c446d354c4f53e805a6771c85749ccc20baaa",
21
+ "license": "BSD-3-Clause",
22
+ "source_braindecode": "1.3.0",
23
+ "loaded_core_tensors": 56,
24
+ "skipped_classifier_tensors": 3
25
+ },
26
+ "neural_channel_indices": {
27
+ "faced": [
28
+ 0,
29
+ 1,
30
+ 2,
31
+ 3,
32
+ 4,
33
+ 5,
34
+ 6,
35
+ 7,
36
+ 8,
37
+ 9,
38
+ 10,
39
+ 11,
40
+ 12,
41
+ 13,
42
+ 14,
43
+ 15,
44
+ 16,
45
+ 17
46
+ ],
47
+ "tuev": [
48
+ 0,
49
+ 1,
50
+ 2,
51
+ 3,
52
+ 4,
53
+ 5,
54
+ 6,
55
+ 7,
56
+ 8,
57
+ 9,
58
+ 10,
59
+ 11,
60
+ 12,
61
+ 13,
62
+ 14,
63
+ 15
64
+ ],
65
+ "ad65": [
66
+ 0,
67
+ 1,
68
+ 2,
69
+ 3,
70
+ 4,
71
+ 5,
72
+ 6,
73
+ 7,
74
+ 8,
75
+ 9,
76
+ 10,
77
+ 11,
78
+ 12,
79
+ 13,
80
+ 14,
81
+ 15,
82
+ 16,
83
+ 17
84
+ ],
85
+ "openbmi": [
86
+ 0,
87
+ 1,
88
+ 3,
89
+ 5,
90
+ 12,
91
+ 14,
92
+ 23,
93
+ 25,
94
+ 28,
95
+ 30,
96
+ 2,
97
+ 6,
98
+ 11,
99
+ 15,
100
+ 22,
101
+ 26,
102
+ 4,
103
+ 13
104
+ ],
105
+ "longitudinal": [
106
+ 0,
107
+ 2,
108
+ 7,
109
+ 11,
110
+ 23,
111
+ 27,
112
+ 41,
113
+ 45,
114
+ 55,
115
+ 57,
116
+ 5,
117
+ 13,
118
+ 21,
119
+ 29,
120
+ 39,
121
+ 47,
122
+ 9,
123
+ 25
124
+ ]
125
+ },
126
+ "rebase": "incumbent waveform, fusion and four heads; joint BIOT and TUEV head from readout epoch 9; zero initialized neural interaction",
127
+ "jointly_finetuned_neural_parent": "/workspace/research/runs/hybrid_biot_readout1/epoch-009/weights.pt",
128
+ "tuev_high_dimensional_spectral_projection_disabled": true,
129
+ "frozen_prior_representation": true,
130
+ "nonclinical_head_updates": "only the 256 added BIOT columns; original columns and biases fixed",
131
+ "faced_openbmi_neural_path": "common nonlinear fusion only; direct head columns masked",
132
+ "retention_teacher": "/workspace/research/runs/hybrid_wide1/epoch-004",
133
+ "retention_loss": {
134
+ "split": "train",
135
+ "temperature": 2.0,
136
+ "kl_weight": 1.0,
137
+ "tracks": [
138
+ "faced",
139
+ "ad65",
140
+ "openbmi",
141
+ "longitudinal"
142
+ ]
143
+ }
144
+ },
145
+ "joint_covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
146
+ "frozen_prior_representation": true,
147
+ "head_updates": "one linear head per track; added 128 shared covariance columns trainable; AD head initialized from the joint covariance parent",
148
+ "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",
149
+ "head_arithmetic": "one linear head evaluated in fixed feature blocks to preserve original bfloat16 accumulation dimensions",
150
+ "retention_teacher": {
151
+ "ad65": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
152
+ "other_tracks": "/workspace/research/runs/hybrid_wide1/epoch-004"
153
+ },
154
+ "retention_loss": {
155
+ "split": "train",
156
+ "temperature": 2.0,
157
+ "kl_weight": 1.0,
158
+ "tracks": [
159
+ "faced",
160
+ "ad65",
161
+ "openbmi",
162
+ "longitudinal"
163
+ ]
164
+ }
165
+ },
166
+ "loader_scale": 0.01,
167
+ "tracks": [
168
+ "faced",
169
+ "tuev",
170
+ "ad65",
171
+ "openbmi",
172
+ "longitudinal"
173
+ ],
174
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
175
+ "head_refinement": {
176
+ "source": "/workspace/research/runs/hybrid_biot_csp_bf16head/epoch-001",
177
+ "source_weights_sha256": "68bc5b4b986520fa912f362a76830c2c5b8cad628a52af9421680276944a1216",
178
+ "shared_backbone_unchanged": true,
179
+ "selected_head_epochs": {
180
+ "faced": 0,
181
+ "tuev": 0,
182
+ "ad65": 0,
183
+ "openbmi": 0,
184
+ "longitudinal": 16
185
+ }
186
+ }
187
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S011/config.json ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ },
10
+ "initialization": {
11
+ "initialization": "continue joint training from a complete shared-model checkpoint",
12
+ "parent": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
13
+ "parent_initialization": {
14
+ "initialization": "jointly trained parent plus audited pretrained BIOT in a single coupled backbone",
15
+ "parent": "/workspace/research/runs/hybrid_wide1/epoch-004/weights.pt",
16
+ "audited_biot": {
17
+ "initialization": "pretrained",
18
+ "repo": "braindecode/biot-pretrained-six-datasets-18chs",
19
+ "revision": "7e9aabf302870012f73773276803aab97993951c",
20
+ "sha256": "a218f4054ae29962c6fd9d23d94c446d354c4f53e805a6771c85749ccc20baaa",
21
+ "license": "BSD-3-Clause",
22
+ "source_braindecode": "1.3.0",
23
+ "loaded_core_tensors": 56,
24
+ "skipped_classifier_tensors": 3
25
+ },
26
+ "neural_channel_indices": {
27
+ "faced": [
28
+ 0,
29
+ 1,
30
+ 2,
31
+ 3,
32
+ 4,
33
+ 5,
34
+ 6,
35
+ 7,
36
+ 8,
37
+ 9,
38
+ 10,
39
+ 11,
40
+ 12,
41
+ 13,
42
+ 14,
43
+ 15,
44
+ 16,
45
+ 17
46
+ ],
47
+ "tuev": [
48
+ 0,
49
+ 1,
50
+ 2,
51
+ 3,
52
+ 4,
53
+ 5,
54
+ 6,
55
+ 7,
56
+ 8,
57
+ 9,
58
+ 10,
59
+ 11,
60
+ 12,
61
+ 13,
62
+ 14,
63
+ 15
64
+ ],
65
+ "ad65": [
66
+ 0,
67
+ 1,
68
+ 2,
69
+ 3,
70
+ 4,
71
+ 5,
72
+ 6,
73
+ 7,
74
+ 8,
75
+ 9,
76
+ 10,
77
+ 11,
78
+ 12,
79
+ 13,
80
+ 14,
81
+ 15,
82
+ 16,
83
+ 17
84
+ ],
85
+ "openbmi": [
86
+ 0,
87
+ 1,
88
+ 3,
89
+ 5,
90
+ 12,
91
+ 14,
92
+ 23,
93
+ 25,
94
+ 28,
95
+ 30,
96
+ 2,
97
+ 6,
98
+ 11,
99
+ 15,
100
+ 22,
101
+ 26,
102
+ 4,
103
+ 13
104
+ ],
105
+ "longitudinal": [
106
+ 0,
107
+ 2,
108
+ 7,
109
+ 11,
110
+ 23,
111
+ 27,
112
+ 41,
113
+ 45,
114
+ 55,
115
+ 57,
116
+ 5,
117
+ 13,
118
+ 21,
119
+ 29,
120
+ 39,
121
+ 47,
122
+ 9,
123
+ 25
124
+ ]
125
+ },
126
+ "rebase": "incumbent waveform, fusion and four heads; joint BIOT and TUEV head from readout epoch 9; zero initialized neural interaction",
127
+ "jointly_finetuned_neural_parent": "/workspace/research/runs/hybrid_biot_readout1/epoch-009/weights.pt",
128
+ "tuev_high_dimensional_spectral_projection_disabled": true,
129
+ "frozen_prior_representation": true,
130
+ "nonclinical_head_updates": "only the 256 added BIOT columns; original columns and biases fixed",
131
+ "faced_openbmi_neural_path": "common nonlinear fusion only; direct head columns masked",
132
+ "retention_teacher": "/workspace/research/runs/hybrid_wide1/epoch-004",
133
+ "retention_loss": {
134
+ "split": "train",
135
+ "temperature": 2.0,
136
+ "kl_weight": 1.0,
137
+ "tracks": [
138
+ "faced",
139
+ "ad65",
140
+ "openbmi",
141
+ "longitudinal"
142
+ ]
143
+ }
144
+ },
145
+ "joint_covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
146
+ "frozen_prior_representation": true,
147
+ "head_updates": "one linear head per track; added 128 shared covariance columns trainable; AD head initialized from the joint covariance parent",
148
+ "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",
149
+ "head_arithmetic": "one linear head evaluated in fixed feature blocks to preserve original bfloat16 accumulation dimensions",
150
+ "retention_teacher": {
151
+ "ad65": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
152
+ "other_tracks": "/workspace/research/runs/hybrid_wide1/epoch-004"
153
+ },
154
+ "retention_loss": {
155
+ "split": "train",
156
+ "temperature": 2.0,
157
+ "kl_weight": 1.0,
158
+ "tracks": [
159
+ "faced",
160
+ "ad65",
161
+ "openbmi",
162
+ "longitudinal"
163
+ ]
164
+ }
165
+ },
166
+ "loader_scale": 0.01,
167
+ "tracks": [
168
+ "faced",
169
+ "tuev",
170
+ "ad65",
171
+ "openbmi",
172
+ "longitudinal"
173
+ ],
174
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
175
+ "head_refinement": {
176
+ "source": "/workspace/research/runs/hybrid_biot_csp_bf16head/epoch-001",
177
+ "source_weights_sha256": "68bc5b4b986520fa912f362a76830c2c5b8cad628a52af9421680276944a1216",
178
+ "shared_backbone_unchanged": true,
179
+ "selected_head_epochs": {
180
+ "faced": 0,
181
+ "tuev": 0,
182
+ "ad65": 0,
183
+ "openbmi": 0,
184
+ "longitudinal": 16
185
+ }
186
+ },
187
+ "clinical_spectral_refinement": {
188
+ "source": "/workspace/research/runs/head_dropout1/epoch-016",
189
+ "zero_initialized_input_adapter": true,
190
+ "backbone_unchanged": true
191
+ }
192
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S011/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/S011/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/S011/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/S011/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/S011/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/S011/training.json ADDED
@@ -0,0 +1,2530 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "history": [
3
+ {
4
+ "epoch": 7,
5
+ "validation": {
6
+ "faced": {
7
+ "class_counts": [
8
+ 180,
9
+ 180,
10
+ 180,
11
+ 180,
12
+ 240,
13
+ 180,
14
+ 180,
15
+ 180,
16
+ 180
17
+ ],
18
+ "predicted_class_counts": [
19
+ 157,
20
+ 194,
21
+ 179,
22
+ 214,
23
+ 244,
24
+ 162,
25
+ 180,
26
+ 173,
27
+ 177
28
+ ],
29
+ "confusion_matrix": [
30
+ [
31
+ 78,
32
+ 14,
33
+ 5,
34
+ 23,
35
+ 19,
36
+ 9,
37
+ 13,
38
+ 9,
39
+ 10
40
+ ],
41
+ [
42
+ 11,
43
+ 88,
44
+ 9,
45
+ 13,
46
+ 19,
47
+ 11,
48
+ 13,
49
+ 6,
50
+ 10
51
+ ],
52
+ [
53
+ 6,
54
+ 7,
55
+ 94,
56
+ 20,
57
+ 17,
58
+ 5,
59
+ 7,
60
+ 10,
61
+ 14
62
+ ],
63
+ [
64
+ 14,
65
+ 18,
66
+ 9,
67
+ 71,
68
+ 21,
69
+ 8,
70
+ 16,
71
+ 15,
72
+ 8
73
+ ],
74
+ [
75
+ 13,
76
+ 13,
77
+ 16,
78
+ 26,
79
+ 113,
80
+ 17,
81
+ 13,
82
+ 18,
83
+ 11
84
+ ],
85
+ [
86
+ 6,
87
+ 12,
88
+ 12,
89
+ 15,
90
+ 12,
91
+ 83,
92
+ 10,
93
+ 14,
94
+ 16
95
+ ],
96
+ [
97
+ 8,
98
+ 12,
99
+ 8,
100
+ 14,
101
+ 16,
102
+ 14,
103
+ 90,
104
+ 9,
105
+ 9
106
+ ],
107
+ [
108
+ 8,
109
+ 16,
110
+ 15,
111
+ 17,
112
+ 15,
113
+ 10,
114
+ 10,
115
+ 83,
116
+ 6
117
+ ],
118
+ [
119
+ 13,
120
+ 14,
121
+ 11,
122
+ 15,
123
+ 12,
124
+ 5,
125
+ 8,
126
+ 9,
127
+ 93
128
+ ]
129
+ ],
130
+ "per_class_recall": [
131
+ 0.43333333333333335,
132
+ 0.4888888888888889,
133
+ 0.5222222222222223,
134
+ 0.39444444444444443,
135
+ 0.4708333333333333,
136
+ 0.46111111111111114,
137
+ 0.5,
138
+ 0.46111111111111114,
139
+ 0.5166666666666667
140
+ ],
141
+ "balanced_accuracy": 0.472067901234568,
142
+ "accuracy": 0.4720238095238095,
143
+ "weighted_f1": 0.4732298815998091,
144
+ "macro_f1": 0.47346276059386383,
145
+ "kappa": 0.40521122712903535,
146
+ "samples": 1680,
147
+ "reward": 0.472067901234568,
148
+ "subjects": 20
149
+ },
150
+ "tuev": {
151
+ "class_counts": [
152
+ 119,
153
+ 291,
154
+ 669,
155
+ 86,
156
+ 500,
157
+ 13822
158
+ ],
159
+ "predicted_class_counts": [
160
+ 594,
161
+ 724,
162
+ 187,
163
+ 475,
164
+ 1457,
165
+ 12050
166
+ ],
167
+ "confusion_matrix": [
168
+ [
169
+ 21,
170
+ 38,
171
+ 23,
172
+ 4,
173
+ 0,
174
+ 33
175
+ ],
176
+ [
177
+ 0,
178
+ 224,
179
+ 0,
180
+ 39,
181
+ 28,
182
+ 0
183
+ ],
184
+ [
185
+ 115,
186
+ 154,
187
+ 120,
188
+ 55,
189
+ 225,
190
+ 0
191
+ ],
192
+ [
193
+ 5,
194
+ 0,
195
+ 0,
196
+ 80,
197
+ 0,
198
+ 1
199
+ ],
200
+ [
201
+ 2,
202
+ 0,
203
+ 1,
204
+ 24,
205
+ 422,
206
+ 51
207
+ ],
208
+ [
209
+ 451,
210
+ 308,
211
+ 43,
212
+ 273,
213
+ 782,
214
+ 11965
215
+ ]
216
+ ],
217
+ "per_class_recall": [
218
+ 0.17647058823529413,
219
+ 0.7697594501718213,
220
+ 0.17937219730941703,
221
+ 0.9302325581395349,
222
+ 0.844,
223
+ 0.8656489654174504
224
+ ],
225
+ "balanced_accuracy": 0.6275806265455862,
226
+ "accuracy": 0.8285658939755924,
227
+ "weighted_f1": 0.8618635180906945,
228
+ "macro_f1": 0.40367911279847074,
229
+ "kappa": 0.42983741832596223,
230
+ "samples": 15487,
231
+ "reward": 0.6275806265455862,
232
+ "subjects": 58
233
+ },
234
+ "ad65": {
235
+ "class_counts": [
236
+ 464,
237
+ 393,
238
+ 486
239
+ ],
240
+ "predicted_class_counts": [
241
+ 440,
242
+ 309,
243
+ 594
244
+ ],
245
+ "confusion_matrix": [
246
+ [
247
+ 287,
248
+ 86,
249
+ 91
250
+ ],
251
+ [
252
+ 96,
253
+ 185,
254
+ 112
255
+ ],
256
+ [
257
+ 57,
258
+ 38,
259
+ 391
260
+ ]
261
+ ],
262
+ "per_class_recall": [
263
+ 0.6185344827586207,
264
+ 0.4707379134860051,
265
+ 0.8045267489711934
266
+ ],
267
+ "balanced_accuracy": 0.6312663817386064,
268
+ "accuracy": 0.6425912137006702,
269
+ "weighted_f1": 0.6356338206725993,
270
+ "macro_f1": 0.6286984511173302,
271
+ "kappa": 0.4579978610488933,
272
+ "samples": 1343,
273
+ "subject_metrics": {
274
+ "class_counts": [
275
+ 7,
276
+ 5,
277
+ 6
278
+ ],
279
+ "predicted_class_counts": [
280
+ 5,
281
+ 6,
282
+ 7
283
+ ],
284
+ "confusion_matrix": [
285
+ [
286
+ 5,
287
+ 2,
288
+ 0
289
+ ],
290
+ [
291
+ 0,
292
+ 4,
293
+ 1
294
+ ],
295
+ [
296
+ 0,
297
+ 0,
298
+ 6
299
+ ]
300
+ ],
301
+ "per_class_recall": [
302
+ 0.7142857142857143,
303
+ 0.8,
304
+ 1.0
305
+ ],
306
+ "balanced_accuracy": 0.8380952380952381,
307
+ "accuracy": 0.8333333333333334,
308
+ "weighted_f1": 0.8337865837865839,
309
+ "macro_f1": 0.8278943278943279,
310
+ "kappa": 0.7511520737327189
311
+ },
312
+ "reward": 0.8380952380952381,
313
+ "subjects": 18
314
+ },
315
+ "openbmi": {
316
+ "class_counts": [
317
+ 2200,
318
+ 2200
319
+ ],
320
+ "predicted_class_counts": [
321
+ 2040,
322
+ 2360
323
+ ],
324
+ "confusion_matrix": [
325
+ [
326
+ 1690,
327
+ 510
328
+ ],
329
+ [
330
+ 350,
331
+ 1850
332
+ ]
333
+ ],
334
+ "per_class_recall": [
335
+ 0.7681818181818182,
336
+ 0.8409090909090909
337
+ ],
338
+ "balanced_accuracy": 0.8045454545454546,
339
+ "accuracy": 0.8045454545454546,
340
+ "weighted_f1": 0.8042866600463423,
341
+ "macro_f1": 0.8042866600463423,
342
+ "kappa": 0.6090909090909091,
343
+ "samples": 4400,
344
+ "subject_scores": {
345
+ "19": 0.8574999999999999,
346
+ "35": 0.9525,
347
+ "34": 0.6475,
348
+ "51": 0.75,
349
+ "20": 0.815,
350
+ "44": 0.935,
351
+ "24": 0.595,
352
+ "15": 0.8975,
353
+ "31": 0.8825000000000001,
354
+ "26": 0.7925,
355
+ "23": 0.725
356
+ },
357
+ "reward": 0.8045454545454546,
358
+ "subjects": 11
359
+ },
360
+ "longitudinal": {
361
+ "class_counts": [
362
+ 4260,
363
+ 4158
364
+ ],
365
+ "predicted_class_counts": [
366
+ 4574,
367
+ 3844
368
+ ],
369
+ "confusion_matrix": [
370
+ [
371
+ 3658,
372
+ 602
373
+ ],
374
+ [
375
+ 916,
376
+ 3242
377
+ ]
378
+ ],
379
+ "per_class_recall": [
380
+ 0.8586854460093897,
381
+ 0.7797017797017797
382
+ ],
383
+ "balanced_accuracy": 0.8191936128555847,
384
+ "accuracy": 0.819672131147541,
385
+ "weighted_f1": 0.8193389120476722,
386
+ "macro_f1": 0.819230668900581,
387
+ "kappa": 0.6389648996053923,
388
+ "samples": 8418,
389
+ "subject_scores": {
390
+ "sub-G2021": 0.8368421735781668,
391
+ "sub-G2007": 0.7651266214233094,
392
+ "sub-G2019": 0.8242345047591977,
393
+ "sub-G2031": 0.788678938415735,
394
+ "sub-G2015": 0.8446221994740171,
395
+ "sub-CTR002": 0.9869493251846193,
396
+ "sub-G2011": 0.765938925240826,
397
+ "sub-G2035": 0.9573204820205594,
398
+ "sub-CTR003": 0.5773809523809523
399
+ },
400
+ "reward": 0.8163437913863759,
401
+ "subjects": 9
402
+ }
403
+ },
404
+ "clinical_training_loss": 0.6892783784866333
405
+ }
406
+ ],
407
+ "settings": {
408
+ "source": "/workspace/research/runs/head_dropout1/epoch-016",
409
+ "cache": "/workspace/research/clinical_fusion_v1",
410
+ "output": "/workspace/research/runs/clinical_spectral_adapter1",
411
+ "epochs": 30,
412
+ "steps": 100,
413
+ "batch_size": 128,
414
+ "lr": 0.0001,
415
+ "head_lr": 1e-05,
416
+ "retention": 1.0,
417
+ "seed": 7
418
+ },
419
+ "parent_training_receipt": {
420
+ "settings": {
421
+ "source": "/workspace/research/runs/hybrid_biot_csp_bf16head/epoch-001",
422
+ "features": "/workspace/research/head_features_v1",
423
+ "incumbent": "/workspace/research/runs/head_refinement1/epoch-012",
424
+ "output": "/workspace/research/runs/head_dropout1",
425
+ "epochs": 30,
426
+ "steps": 200,
427
+ "batch_size": 256,
428
+ "lr": 1e-05,
429
+ "clinical_lr": 0.0001,
430
+ "retention": 2.0,
431
+ "dropout": 0.2,
432
+ "seed": 7
433
+ },
434
+ "history": [
435
+ {
436
+ "epoch": 14,
437
+ "validation": {
438
+ "faced": {
439
+ "class_counts": [
440
+ 180,
441
+ 180,
442
+ 180,
443
+ 180,
444
+ 240,
445
+ 180,
446
+ 180,
447
+ 180,
448
+ 180
449
+ ],
450
+ "predicted_class_counts": [
451
+ 157,
452
+ 194,
453
+ 179,
454
+ 214,
455
+ 244,
456
+ 162,
457
+ 180,
458
+ 173,
459
+ 177
460
+ ],
461
+ "confusion_matrix": [
462
+ [
463
+ 78,
464
+ 14,
465
+ 5,
466
+ 23,
467
+ 19,
468
+ 9,
469
+ 13,
470
+ 9,
471
+ 10
472
+ ],
473
+ [
474
+ 11,
475
+ 88,
476
+ 9,
477
+ 13,
478
+ 19,
479
+ 11,
480
+ 13,
481
+ 6,
482
+ 10
483
+ ],
484
+ [
485
+ 6,
486
+ 7,
487
+ 94,
488
+ 20,
489
+ 17,
490
+ 5,
491
+ 7,
492
+ 10,
493
+ 14
494
+ ],
495
+ [
496
+ 14,
497
+ 18,
498
+ 9,
499
+ 71,
500
+ 21,
501
+ 8,
502
+ 16,
503
+ 15,
504
+ 8
505
+ ],
506
+ [
507
+ 13,
508
+ 13,
509
+ 16,
510
+ 26,
511
+ 113,
512
+ 17,
513
+ 13,
514
+ 18,
515
+ 11
516
+ ],
517
+ [
518
+ 6,
519
+ 12,
520
+ 12,
521
+ 15,
522
+ 12,
523
+ 83,
524
+ 10,
525
+ 14,
526
+ 16
527
+ ],
528
+ [
529
+ 8,
530
+ 12,
531
+ 8,
532
+ 14,
533
+ 16,
534
+ 14,
535
+ 90,
536
+ 9,
537
+ 9
538
+ ],
539
+ [
540
+ 8,
541
+ 16,
542
+ 15,
543
+ 17,
544
+ 15,
545
+ 10,
546
+ 10,
547
+ 83,
548
+ 6
549
+ ],
550
+ [
551
+ 13,
552
+ 14,
553
+ 11,
554
+ 15,
555
+ 12,
556
+ 5,
557
+ 8,
558
+ 9,
559
+ 93
560
+ ]
561
+ ],
562
+ "per_class_recall": [
563
+ 0.43333333333333335,
564
+ 0.4888888888888889,
565
+ 0.5222222222222223,
566
+ 0.39444444444444443,
567
+ 0.4708333333333333,
568
+ 0.46111111111111114,
569
+ 0.5,
570
+ 0.46111111111111114,
571
+ 0.5166666666666667
572
+ ],
573
+ "balanced_accuracy": 0.472067901234568,
574
+ "accuracy": 0.4720238095238095,
575
+ "weighted_f1": 0.4732298815998091,
576
+ "macro_f1": 0.47346276059386383,
577
+ "kappa": 0.40521122712903535,
578
+ "samples": 1680,
579
+ "reward": 0.472067901234568,
580
+ "subjects": 20
581
+ },
582
+ "tuev": {
583
+ "class_counts": [
584
+ 119,
585
+ 291,
586
+ 669,
587
+ 86,
588
+ 500,
589
+ 13822
590
+ ],
591
+ "predicted_class_counts": [
592
+ 995,
593
+ 658,
594
+ 146,
595
+ 706,
596
+ 1616,
597
+ 11366
598
+ ],
599
+ "confusion_matrix": [
600
+ [
601
+ 42,
602
+ 38,
603
+ 18,
604
+ 4,
605
+ 0,
606
+ 17
607
+ ],
608
+ [
609
+ 0,
610
+ 185,
611
+ 0,
612
+ 78,
613
+ 28,
614
+ 0
615
+ ],
616
+ [
617
+ 110,
618
+ 127,
619
+ 128,
620
+ 61,
621
+ 243,
622
+ 0
623
+ ],
624
+ [
625
+ 6,
626
+ 0,
627
+ 0,
628
+ 79,
629
+ 0,
630
+ 1
631
+ ],
632
+ [
633
+ 2,
634
+ 0,
635
+ 0,
636
+ 25,
637
+ 420,
638
+ 53
639
+ ],
640
+ [
641
+ 835,
642
+ 308,
643
+ 0,
644
+ 459,
645
+ 925,
646
+ 11295
647
+ ]
648
+ ],
649
+ "per_class_recall": [
650
+ 0.35294117647058826,
651
+ 0.6357388316151202,
652
+ 0.19133034379671152,
653
+ 0.9186046511627907,
654
+ 0.84,
655
+ 0.8171755172912748
656
+ ],
657
+ "balanced_accuracy": 0.6259650867227476,
658
+ "accuracy": 0.7844643894879576,
659
+ "weighted_f1": 0.8358334233956254,
660
+ "macro_f1": 0.3787874146773398,
661
+ "kappa": 0.36546485724249755,
662
+ "samples": 15487,
663
+ "reward": 0.6259650867227476,
664
+ "subjects": 58
665
+ },
666
+ "ad65": {
667
+ "class_counts": [
668
+ 464,
669
+ 393,
670
+ 486
671
+ ],
672
+ "predicted_class_counts": [
673
+ 440,
674
+ 309,
675
+ 594
676
+ ],
677
+ "confusion_matrix": [
678
+ [
679
+ 287,
680
+ 86,
681
+ 91
682
+ ],
683
+ [
684
+ 96,
685
+ 185,
686
+ 112
687
+ ],
688
+ [
689
+ 57,
690
+ 38,
691
+ 391
692
+ ]
693
+ ],
694
+ "per_class_recall": [
695
+ 0.6185344827586207,
696
+ 0.4707379134860051,
697
+ 0.8045267489711934
698
+ ],
699
+ "balanced_accuracy": 0.6312663817386064,
700
+ "accuracy": 0.6425912137006702,
701
+ "weighted_f1": 0.6356338206725993,
702
+ "macro_f1": 0.6286984511173302,
703
+ "kappa": 0.4579978610488933,
704
+ "samples": 1343,
705
+ "subject_metrics": {
706
+ "class_counts": [
707
+ 7,
708
+ 5,
709
+ 6
710
+ ],
711
+ "predicted_class_counts": [
712
+ 5,
713
+ 6,
714
+ 7
715
+ ],
716
+ "confusion_matrix": [
717
+ [
718
+ 5,
719
+ 2,
720
+ 0
721
+ ],
722
+ [
723
+ 0,
724
+ 4,
725
+ 1
726
+ ],
727
+ [
728
+ 0,
729
+ 0,
730
+ 6
731
+ ]
732
+ ],
733
+ "per_class_recall": [
734
+ 0.7142857142857143,
735
+ 0.8,
736
+ 1.0
737
+ ],
738
+ "balanced_accuracy": 0.8380952380952381,
739
+ "accuracy": 0.8333333333333334,
740
+ "weighted_f1": 0.8337865837865839,
741
+ "macro_f1": 0.8278943278943279,
742
+ "kappa": 0.7511520737327189
743
+ },
744
+ "reward": 0.8380952380952381,
745
+ "subjects": 18
746
+ },
747
+ "openbmi": {
748
+ "class_counts": [
749
+ 2200,
750
+ 2200
751
+ ],
752
+ "predicted_class_counts": [
753
+ 2040,
754
+ 2360
755
+ ],
756
+ "confusion_matrix": [
757
+ [
758
+ 1690,
759
+ 510
760
+ ],
761
+ [
762
+ 350,
763
+ 1850
764
+ ]
765
+ ],
766
+ "per_class_recall": [
767
+ 0.7681818181818182,
768
+ 0.8409090909090909
769
+ ],
770
+ "balanced_accuracy": 0.8045454545454546,
771
+ "accuracy": 0.8045454545454546,
772
+ "weighted_f1": 0.8042866600463423,
773
+ "macro_f1": 0.8042866600463423,
774
+ "kappa": 0.6090909090909091,
775
+ "samples": 4400,
776
+ "subject_scores": {
777
+ "19": 0.8574999999999999,
778
+ "35": 0.9525,
779
+ "34": 0.6475,
780
+ "51": 0.75,
781
+ "20": 0.815,
782
+ "44": 0.935,
783
+ "24": 0.595,
784
+ "15": 0.8975,
785
+ "31": 0.8825000000000001,
786
+ "26": 0.7925,
787
+ "23": 0.725
788
+ },
789
+ "reward": 0.8045454545454546,
790
+ "subjects": 11
791
+ },
792
+ "longitudinal": {
793
+ "class_counts": [
794
+ 4260,
795
+ 4158
796
+ ],
797
+ "predicted_class_counts": [
798
+ 4576,
799
+ 3842
800
+ ],
801
+ "confusion_matrix": [
802
+ [
803
+ 3659,
804
+ 601
805
+ ],
806
+ [
807
+ 917,
808
+ 3241
809
+ ]
810
+ ],
811
+ "per_class_recall": [
812
+ 0.8589201877934273,
813
+ 0.7794612794612794
814
+ ],
815
+ "balanced_accuracy": 0.8191907336273534,
816
+ "accuracy": 0.819672131147541,
817
+ "weighted_f1": 0.8193351694632243,
818
+ "macro_f1": 0.8192264033499321,
819
+ "kappa": 0.6389628187072087,
820
+ "samples": 8418,
821
+ "subject_scores": {
822
+ "sub-G2021": 0.837643455629449,
823
+ "sub-G2007": 0.7651266214233094,
824
+ "sub-G2019": 0.8242345047591977,
825
+ "sub-G2031": 0.788678938415735,
826
+ "sub-G2015": 0.8446221994740171,
827
+ "sub-CTR002": 0.9869493251846193,
828
+ "sub-G2011": 0.765938925240826,
829
+ "sub-G2035": 0.9564871486872261,
830
+ "sub-CTR003": 0.5773809523809523
831
+ },
832
+ "reward": 0.8163402301328146,
833
+ "subjects": 9
834
+ }
835
+ },
836
+ "selected_head_epochs": {
837
+ "faced": 0,
838
+ "tuev": 0,
839
+ "ad65": 0,
840
+ "openbmi": 0,
841
+ "longitudinal": 14
842
+ }
843
+ },
844
+ {
845
+ "epoch": 16,
846
+ "validation": {
847
+ "faced": {
848
+ "class_counts": [
849
+ 180,
850
+ 180,
851
+ 180,
852
+ 180,
853
+ 240,
854
+ 180,
855
+ 180,
856
+ 180,
857
+ 180
858
+ ],
859
+ "predicted_class_counts": [
860
+ 157,
861
+ 194,
862
+ 179,
863
+ 214,
864
+ 244,
865
+ 162,
866
+ 180,
867
+ 173,
868
+ 177
869
+ ],
870
+ "confusion_matrix": [
871
+ [
872
+ 78,
873
+ 14,
874
+ 5,
875
+ 23,
876
+ 19,
877
+ 9,
878
+ 13,
879
+ 9,
880
+ 10
881
+ ],
882
+ [
883
+ 11,
884
+ 88,
885
+ 9,
886
+ 13,
887
+ 19,
888
+ 11,
889
+ 13,
890
+ 6,
891
+ 10
892
+ ],
893
+ [
894
+ 6,
895
+ 7,
896
+ 94,
897
+ 20,
898
+ 17,
899
+ 5,
900
+ 7,
901
+ 10,
902
+ 14
903
+ ],
904
+ [
905
+ 14,
906
+ 18,
907
+ 9,
908
+ 71,
909
+ 21,
910
+ 8,
911
+ 16,
912
+ 15,
913
+ 8
914
+ ],
915
+ [
916
+ 13,
917
+ 13,
918
+ 16,
919
+ 26,
920
+ 113,
921
+ 17,
922
+ 13,
923
+ 18,
924
+ 11
925
+ ],
926
+ [
927
+ 6,
928
+ 12,
929
+ 12,
930
+ 15,
931
+ 12,
932
+ 83,
933
+ 10,
934
+ 14,
935
+ 16
936
+ ],
937
+ [
938
+ 8,
939
+ 12,
940
+ 8,
941
+ 14,
942
+ 16,
943
+ 14,
944
+ 90,
945
+ 9,
946
+ 9
947
+ ],
948
+ [
949
+ 8,
950
+ 16,
951
+ 15,
952
+ 17,
953
+ 15,
954
+ 10,
955
+ 10,
956
+ 83,
957
+ 6
958
+ ],
959
+ [
960
+ 13,
961
+ 14,
962
+ 11,
963
+ 15,
964
+ 12,
965
+ 5,
966
+ 8,
967
+ 9,
968
+ 93
969
+ ]
970
+ ],
971
+ "per_class_recall": [
972
+ 0.43333333333333335,
973
+ 0.4888888888888889,
974
+ 0.5222222222222223,
975
+ 0.39444444444444443,
976
+ 0.4708333333333333,
977
+ 0.46111111111111114,
978
+ 0.5,
979
+ 0.46111111111111114,
980
+ 0.5166666666666667
981
+ ],
982
+ "balanced_accuracy": 0.472067901234568,
983
+ "accuracy": 0.4720238095238095,
984
+ "weighted_f1": 0.4732298815998091,
985
+ "macro_f1": 0.47346276059386383,
986
+ "kappa": 0.40521122712903535,
987
+ "samples": 1680,
988
+ "reward": 0.472067901234568,
989
+ "subjects": 20
990
+ },
991
+ "tuev": {
992
+ "class_counts": [
993
+ 119,
994
+ 291,
995
+ 669,
996
+ 86,
997
+ 500,
998
+ 13822
999
+ ],
1000
+ "predicted_class_counts": [
1001
+ 995,
1002
+ 658,
1003
+ 146,
1004
+ 706,
1005
+ 1616,
1006
+ 11366
1007
+ ],
1008
+ "confusion_matrix": [
1009
+ [
1010
+ 42,
1011
+ 38,
1012
+ 18,
1013
+ 4,
1014
+ 0,
1015
+ 17
1016
+ ],
1017
+ [
1018
+ 0,
1019
+ 185,
1020
+ 0,
1021
+ 78,
1022
+ 28,
1023
+ 0
1024
+ ],
1025
+ [
1026
+ 110,
1027
+ 127,
1028
+ 128,
1029
+ 61,
1030
+ 243,
1031
+ 0
1032
+ ],
1033
+ [
1034
+ 6,
1035
+ 0,
1036
+ 0,
1037
+ 79,
1038
+ 0,
1039
+ 1
1040
+ ],
1041
+ [
1042
+ 2,
1043
+ 0,
1044
+ 0,
1045
+ 25,
1046
+ 420,
1047
+ 53
1048
+ ],
1049
+ [
1050
+ 835,
1051
+ 308,
1052
+ 0,
1053
+ 459,
1054
+ 925,
1055
+ 11295
1056
+ ]
1057
+ ],
1058
+ "per_class_recall": [
1059
+ 0.35294117647058826,
1060
+ 0.6357388316151202,
1061
+ 0.19133034379671152,
1062
+ 0.9186046511627907,
1063
+ 0.84,
1064
+ 0.8171755172912748
1065
+ ],
1066
+ "balanced_accuracy": 0.6259650867227476,
1067
+ "accuracy": 0.7844643894879576,
1068
+ "weighted_f1": 0.8358334233956254,
1069
+ "macro_f1": 0.3787874146773398,
1070
+ "kappa": 0.36546485724249755,
1071
+ "samples": 15487,
1072
+ "reward": 0.6259650867227476,
1073
+ "subjects": 58
1074
+ },
1075
+ "ad65": {
1076
+ "class_counts": [
1077
+ 464,
1078
+ 393,
1079
+ 486
1080
+ ],
1081
+ "predicted_class_counts": [
1082
+ 440,
1083
+ 309,
1084
+ 594
1085
+ ],
1086
+ "confusion_matrix": [
1087
+ [
1088
+ 287,
1089
+ 86,
1090
+ 91
1091
+ ],
1092
+ [
1093
+ 96,
1094
+ 185,
1095
+ 112
1096
+ ],
1097
+ [
1098
+ 57,
1099
+ 38,
1100
+ 391
1101
+ ]
1102
+ ],
1103
+ "per_class_recall": [
1104
+ 0.6185344827586207,
1105
+ 0.4707379134860051,
1106
+ 0.8045267489711934
1107
+ ],
1108
+ "balanced_accuracy": 0.6312663817386064,
1109
+ "accuracy": 0.6425912137006702,
1110
+ "weighted_f1": 0.6356338206725993,
1111
+ "macro_f1": 0.6286984511173302,
1112
+ "kappa": 0.4579978610488933,
1113
+ "samples": 1343,
1114
+ "subject_metrics": {
1115
+ "class_counts": [
1116
+ 7,
1117
+ 5,
1118
+ 6
1119
+ ],
1120
+ "predicted_class_counts": [
1121
+ 5,
1122
+ 6,
1123
+ 7
1124
+ ],
1125
+ "confusion_matrix": [
1126
+ [
1127
+ 5,
1128
+ 2,
1129
+ 0
1130
+ ],
1131
+ [
1132
+ 0,
1133
+ 4,
1134
+ 1
1135
+ ],
1136
+ [
1137
+ 0,
1138
+ 0,
1139
+ 6
1140
+ ]
1141
+ ],
1142
+ "per_class_recall": [
1143
+ 0.7142857142857143,
1144
+ 0.8,
1145
+ 1.0
1146
+ ],
1147
+ "balanced_accuracy": 0.8380952380952381,
1148
+ "accuracy": 0.8333333333333334,
1149
+ "weighted_f1": 0.8337865837865839,
1150
+ "macro_f1": 0.8278943278943279,
1151
+ "kappa": 0.7511520737327189
1152
+ },
1153
+ "reward": 0.8380952380952381,
1154
+ "subjects": 18
1155
+ },
1156
+ "openbmi": {
1157
+ "class_counts": [
1158
+ 2200,
1159
+ 2200
1160
+ ],
1161
+ "predicted_class_counts": [
1162
+ 2040,
1163
+ 2360
1164
+ ],
1165
+ "confusion_matrix": [
1166
+ [
1167
+ 1690,
1168
+ 510
1169
+ ],
1170
+ [
1171
+ 350,
1172
+ 1850
1173
+ ]
1174
+ ],
1175
+ "per_class_recall": [
1176
+ 0.7681818181818182,
1177
+ 0.8409090909090909
1178
+ ],
1179
+ "balanced_accuracy": 0.8045454545454546,
1180
+ "accuracy": 0.8045454545454546,
1181
+ "weighted_f1": 0.8042866600463423,
1182
+ "macro_f1": 0.8042866600463423,
1183
+ "kappa": 0.6090909090909091,
1184
+ "samples": 4400,
1185
+ "subject_scores": {
1186
+ "19": 0.8574999999999999,
1187
+ "35": 0.9525,
1188
+ "34": 0.6475,
1189
+ "51": 0.75,
1190
+ "20": 0.815,
1191
+ "44": 0.935,
1192
+ "24": 0.595,
1193
+ "15": 0.8975,
1194
+ "31": 0.8825000000000001,
1195
+ "26": 0.7925,
1196
+ "23": 0.725
1197
+ },
1198
+ "reward": 0.8045454545454546,
1199
+ "subjects": 11
1200
+ },
1201
+ "longitudinal": {
1202
+ "class_counts": [
1203
+ 4260,
1204
+ 4158
1205
+ ],
1206
+ "predicted_class_counts": [
1207
+ 4574,
1208
+ 3844
1209
+ ],
1210
+ "confusion_matrix": [
1211
+ [
1212
+ 3658,
1213
+ 602
1214
+ ],
1215
+ [
1216
+ 916,
1217
+ 3242
1218
+ ]
1219
+ ],
1220
+ "per_class_recall": [
1221
+ 0.8586854460093897,
1222
+ 0.7797017797017797
1223
+ ],
1224
+ "balanced_accuracy": 0.8191936128555847,
1225
+ "accuracy": 0.819672131147541,
1226
+ "weighted_f1": 0.8193389120476722,
1227
+ "macro_f1": 0.819230668900581,
1228
+ "kappa": 0.6389648996053923,
1229
+ "samples": 8418,
1230
+ "subject_scores": {
1231
+ "sub-G2021": 0.8368421735781668,
1232
+ "sub-G2007": 0.7651266214233094,
1233
+ "sub-G2019": 0.8242345047591977,
1234
+ "sub-G2031": 0.788678938415735,
1235
+ "sub-G2015": 0.8446221994740171,
1236
+ "sub-CTR002": 0.9869493251846193,
1237
+ "sub-G2011": 0.765938925240826,
1238
+ "sub-G2035": 0.9573204820205594,
1239
+ "sub-CTR003": 0.5773809523809523
1240
+ },
1241
+ "reward": 0.8163437913863759,
1242
+ "subjects": 9
1243
+ }
1244
+ },
1245
+ "selected_head_epochs": {
1246
+ "faced": 0,
1247
+ "tuev": 0,
1248
+ "ad65": 0,
1249
+ "openbmi": 0,
1250
+ "longitudinal": 16
1251
+ }
1252
+ }
1253
+ ],
1254
+ "shared_backbone_training": "inherited joint training on all five training splits; frozen during final linear-head refinement",
1255
+ "parent_training_receipt": {
1256
+ "all_tracks_update_shared_backbone": true,
1257
+ "parameters": 10427373,
1258
+ "source_training_settings": {
1259
+ "output": "/workspace/research/runs/hybrid_biot_csp_stable1",
1260
+ "epochs": 30,
1261
+ "steps": 100,
1262
+ "batch_size": 64,
1263
+ "seed": 7,
1264
+ "hidden": 32,
1265
+ "dropout": 0.5,
1266
+ "lr": 1e-06,
1267
+ "head_lr": 1e-07,
1268
+ "weight_decay": 0.05,
1269
+ "init": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
1270
+ "mixup": 0.0,
1271
+ "clinical_lr": 0.0001,
1272
+ "neural_lr": 1e-05,
1273
+ "covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
1274
+ "ad_pool": 8
1275
+ },
1276
+ "parent_training_history": [
1277
+ {
1278
+ "epoch": 1,
1279
+ "validation": {
1280
+ "faced": {
1281
+ "class_counts": [
1282
+ 180,
1283
+ 180,
1284
+ 180,
1285
+ 180,
1286
+ 240,
1287
+ 180,
1288
+ 180,
1289
+ 180,
1290
+ 180
1291
+ ],
1292
+ "predicted_class_counts": [
1293
+ 157,
1294
+ 190,
1295
+ 178,
1296
+ 212,
1297
+ 242,
1298
+ 166,
1299
+ 182,
1300
+ 175,
1301
+ 178
1302
+ ],
1303
+ "confusion_matrix": [
1304
+ [
1305
+ 77,
1306
+ 14,
1307
+ 5,
1308
+ 22,
1309
+ 19,
1310
+ 9,
1311
+ 14,
1312
+ 10,
1313
+ 10
1314
+ ],
1315
+ [
1316
+ 12,
1317
+ 86,
1318
+ 9,
1319
+ 13,
1320
+ 19,
1321
+ 11,
1322
+ 14,
1323
+ 6,
1324
+ 10
1325
+ ],
1326
+ [
1327
+ 6,
1328
+ 7,
1329
+ 93,
1330
+ 20,
1331
+ 17,
1332
+ 5,
1333
+ 7,
1334
+ 10,
1335
+ 15
1336
+ ],
1337
+ [
1338
+ 14,
1339
+ 18,
1340
+ 9,
1341
+ 71,
1342
+ 21,
1343
+ 8,
1344
+ 16,
1345
+ 15,
1346
+ 8
1347
+ ],
1348
+ [
1349
+ 13,
1350
+ 13,
1351
+ 17,
1352
+ 26,
1353
+ 111,
1354
+ 17,
1355
+ 14,
1356
+ 18,
1357
+ 11
1358
+ ],
1359
+ [
1360
+ 6,
1361
+ 11,
1362
+ 11,
1363
+ 15,
1364
+ 11,
1365
+ 86,
1366
+ 10,
1367
+ 14,
1368
+ 16
1369
+ ],
1370
+ [
1371
+ 8,
1372
+ 11,
1373
+ 9,
1374
+ 13,
1375
+ 17,
1376
+ 14,
1377
+ 89,
1378
+ 10,
1379
+ 9
1380
+ ],
1381
+ [
1382
+ 8,
1383
+ 16,
1384
+ 14,
1385
+ 17,
1386
+ 15,
1387
+ 11,
1388
+ 10,
1389
+ 83,
1390
+ 6
1391
+ ],
1392
+ [
1393
+ 13,
1394
+ 14,
1395
+ 11,
1396
+ 15,
1397
+ 12,
1398
+ 5,
1399
+ 8,
1400
+ 9,
1401
+ 93
1402
+ ]
1403
+ ],
1404
+ "per_class_recall": [
1405
+ 0.42777777777777776,
1406
+ 0.4777777777777778,
1407
+ 0.5166666666666667,
1408
+ 0.39444444444444443,
1409
+ 0.4625,
1410
+ 0.4777777777777778,
1411
+ 0.49444444444444446,
1412
+ 0.46111111111111114,
1413
+ 0.5166666666666667
1414
+ ],
1415
+ "balanced_accuracy": 0.46990740740740744,
1416
+ "accuracy": 0.46964285714285714,
1417
+ "weighted_f1": 0.4707562771324448,
1418
+ "macro_f1": 0.471133142475755,
1419
+ "kappa": 0.4025575937544903,
1420
+ "samples": 1680,
1421
+ "reward": 0.46990740740740744,
1422
+ "subjects": 20
1423
+ },
1424
+ "tuev": {
1425
+ "class_counts": [
1426
+ 119,
1427
+ 291,
1428
+ 669,
1429
+ 86,
1430
+ 500,
1431
+ 13822
1432
+ ],
1433
+ "predicted_class_counts": [
1434
+ 1415,
1435
+ 660,
1436
+ 126,
1437
+ 754,
1438
+ 1618,
1439
+ 10914
1440
+ ],
1441
+ "confusion_matrix": [
1442
+ [
1443
+ 45,
1444
+ 38,
1445
+ 15,
1446
+ 0,
1447
+ 4,
1448
+ 17
1449
+ ],
1450
+ [
1451
+ 17,
1452
+ 164,
1453
+ 0,
1454
+ 61,
1455
+ 49,
1456
+ 0
1457
+ ],
1458
+ [
1459
+ 130,
1460
+ 126,
1461
+ 111,
1462
+ 89,
1463
+ 213,
1464
+ 0
1465
+ ],
1466
+ [
1467
+ 7,
1468
+ 2,
1469
+ 0,
1470
+ 76,
1471
+ 0,
1472
+ 1
1473
+ ],
1474
+ [
1475
+ 4,
1476
+ 0,
1477
+ 0,
1478
+ 24,
1479
+ 435,
1480
+ 37
1481
+ ],
1482
+ [
1483
+ 1212,
1484
+ 330,
1485
+ 0,
1486
+ 504,
1487
+ 917,
1488
+ 10859
1489
+ ]
1490
+ ],
1491
+ "per_class_recall": [
1492
+ 0.37815126050420167,
1493
+ 0.563573883161512,
1494
+ 0.16591928251121077,
1495
+ 0.8837209302325582,
1496
+ 0.87,
1497
+ 0.7856316017942411
1498
+ ],
1499
+ "balanced_accuracy": 0.6078328263672873,
1500
+ "accuracy": 0.7548266287854329,
1501
+ "weighted_f1": 0.8168597460216521,
1502
+ "macro_f1": 0.3587540627106629,
1503
+ "kappa": 0.32929623559334475,
1504
+ "samples": 15487,
1505
+ "reward": 0.6078328263672873,
1506
+ "subjects": 58
1507
+ },
1508
+ "ad65": {
1509
+ "class_counts": [
1510
+ 464,
1511
+ 393,
1512
+ 486
1513
+ ],
1514
+ "predicted_class_counts": [
1515
+ 440,
1516
+ 309,
1517
+ 594
1518
+ ],
1519
+ "confusion_matrix": [
1520
+ [
1521
+ 287,
1522
+ 86,
1523
+ 91
1524
+ ],
1525
+ [
1526
+ 96,
1527
+ 185,
1528
+ 112
1529
+ ],
1530
+ [
1531
+ 57,
1532
+ 38,
1533
+ 391
1534
+ ]
1535
+ ],
1536
+ "per_class_recall": [
1537
+ 0.6185344827586207,
1538
+ 0.4707379134860051,
1539
+ 0.8045267489711934
1540
+ ],
1541
+ "balanced_accuracy": 0.6312663817386064,
1542
+ "accuracy": 0.6425912137006702,
1543
+ "weighted_f1": 0.6356338206725993,
1544
+ "macro_f1": 0.6286984511173302,
1545
+ "kappa": 0.4579978610488933,
1546
+ "samples": 1343,
1547
+ "subject_metrics": {
1548
+ "class_counts": [
1549
+ 7,
1550
+ 5,
1551
+ 6
1552
+ ],
1553
+ "predicted_class_counts": [
1554
+ 5,
1555
+ 6,
1556
+ 7
1557
+ ],
1558
+ "confusion_matrix": [
1559
+ [
1560
+ 5,
1561
+ 2,
1562
+ 0
1563
+ ],
1564
+ [
1565
+ 0,
1566
+ 4,
1567
+ 1
1568
+ ],
1569
+ [
1570
+ 0,
1571
+ 0,
1572
+ 6
1573
+ ]
1574
+ ],
1575
+ "per_class_recall": [
1576
+ 0.7142857142857143,
1577
+ 0.8,
1578
+ 1.0
1579
+ ],
1580
+ "balanced_accuracy": 0.8380952380952381,
1581
+ "accuracy": 0.8333333333333334,
1582
+ "weighted_f1": 0.8337865837865839,
1583
+ "macro_f1": 0.8278943278943279,
1584
+ "kappa": 0.7511520737327189
1585
+ },
1586
+ "reward": 0.8380952380952381,
1587
+ "subjects": 18
1588
+ },
1589
+ "openbmi": {
1590
+ "class_counts": [
1591
+ 2200,
1592
+ 2200
1593
+ ],
1594
+ "predicted_class_counts": [
1595
+ 2059,
1596
+ 2341
1597
+ ],
1598
+ "confusion_matrix": [
1599
+ [
1600
+ 1696,
1601
+ 504
1602
+ ],
1603
+ [
1604
+ 363,
1605
+ 1837
1606
+ ]
1607
+ ],
1608
+ "per_class_recall": [
1609
+ 0.7709090909090909,
1610
+ 0.835
1611
+ ],
1612
+ "balanced_accuracy": 0.8029545454545455,
1613
+ "accuracy": 0.8029545454545455,
1614
+ "weighted_f1": 0.8027519892716276,
1615
+ "macro_f1": 0.8027519892716275,
1616
+ "kappa": 0.605909090909091,
1617
+ "samples": 4400,
1618
+ "subject_scores": {
1619
+ "19": 0.8425,
1620
+ "35": 0.9525,
1621
+ "34": 0.64,
1622
+ "51": 0.7475,
1623
+ "20": 0.82,
1624
+ "44": 0.94,
1625
+ "24": 0.5974999999999999,
1626
+ "15": 0.9,
1627
+ "31": 0.8825000000000001,
1628
+ "26": 0.79,
1629
+ "23": 0.72
1630
+ },
1631
+ "reward": 0.8029545454545456,
1632
+ "subjects": 11
1633
+ },
1634
+ "longitudinal": {
1635
+ "class_counts": [
1636
+ 4260,
1637
+ 4158
1638
+ ],
1639
+ "predicted_class_counts": [
1640
+ 4572,
1641
+ 3846
1642
+ ],
1643
+ "confusion_matrix": [
1644
+ [
1645
+ 3656,
1646
+ 604
1647
+ ],
1648
+ [
1649
+ 916,
1650
+ 3242
1651
+ ]
1652
+ ],
1653
+ "per_class_recall": [
1654
+ 0.8582159624413146,
1655
+ 0.7797017797017797
1656
+ ],
1657
+ "balanced_accuracy": 0.8189588710715472,
1658
+ "accuracy": 0.8194345450225707,
1659
+ "weighted_f1": 0.8191046137658184,
1660
+ "macro_f1": 0.8189967516241878,
1661
+ "kappa": 0.6384913111521573,
1662
+ "samples": 8418,
1663
+ "subject_scores": {
1664
+ "sub-G2021": 0.837643455629449,
1665
+ "sub-G2007": 0.7644167136410334,
1666
+ "sub-G2019": 0.8242345047591977,
1667
+ "sub-G2031": 0.788678938415735,
1668
+ "sub-G2015": 0.8429774626319118,
1669
+ "sub-CTR002": 0.9869493251846193,
1670
+ "sub-G2011": 0.765938925240826,
1671
+ "sub-G2035": 0.9564871486872261,
1672
+ "sub-CTR003": 0.5773809523809523
1673
+ },
1674
+ "reward": 0.8160786029523278,
1675
+ "subjects": 9
1676
+ }
1677
+ },
1678
+ "losses": {
1679
+ "faced": 1.1245228350162506,
1680
+ "tuev": 0.8237144947052002,
1681
+ "ad65": 0.5528117254376411,
1682
+ "openbmi": 0.41377417743206024,
1683
+ "longitudinal": 0.23846278339624405
1684
+ },
1685
+ "seconds": 33.64874625205994
1686
+ }
1687
+ ],
1688
+ "history": [
1689
+ {
1690
+ "epoch": 1,
1691
+ "validation": {
1692
+ "faced": {
1693
+ "class_counts": [
1694
+ 180,
1695
+ 180,
1696
+ 180,
1697
+ 180,
1698
+ 240,
1699
+ 180,
1700
+ 180,
1701
+ 180,
1702
+ 180
1703
+ ],
1704
+ "predicted_class_counts": [
1705
+ 158,
1706
+ 189,
1707
+ 178,
1708
+ 213,
1709
+ 242,
1710
+ 166,
1711
+ 182,
1712
+ 176,
1713
+ 176
1714
+ ],
1715
+ "confusion_matrix": [
1716
+ [
1717
+ 77,
1718
+ 14,
1719
+ 5,
1720
+ 22,
1721
+ 19,
1722
+ 9,
1723
+ 14,
1724
+ 10,
1725
+ 10
1726
+ ],
1727
+ [
1728
+ 12,
1729
+ 86,
1730
+ 9,
1731
+ 13,
1732
+ 19,
1733
+ 11,
1734
+ 14,
1735
+ 6,
1736
+ 10
1737
+ ],
1738
+ [
1739
+ 6,
1740
+ 7,
1741
+ 93,
1742
+ 21,
1743
+ 17,
1744
+ 5,
1745
+ 7,
1746
+ 10,
1747
+ 14
1748
+ ],
1749
+ [
1750
+ 14,
1751
+ 18,
1752
+ 9,
1753
+ 71,
1754
+ 21,
1755
+ 8,
1756
+ 16,
1757
+ 15,
1758
+ 8
1759
+ ],
1760
+ [
1761
+ 13,
1762
+ 13,
1763
+ 17,
1764
+ 26,
1765
+ 111,
1766
+ 17,
1767
+ 14,
1768
+ 18,
1769
+ 11
1770
+ ],
1771
+ [
1772
+ 6,
1773
+ 11,
1774
+ 11,
1775
+ 15,
1776
+ 11,
1777
+ 86,
1778
+ 10,
1779
+ 14,
1780
+ 16
1781
+ ],
1782
+ [
1783
+ 8,
1784
+ 11,
1785
+ 9,
1786
+ 13,
1787
+ 17,
1788
+ 14,
1789
+ 89,
1790
+ 10,
1791
+ 9
1792
+ ],
1793
+ [
1794
+ 8,
1795
+ 16,
1796
+ 14,
1797
+ 17,
1798
+ 15,
1799
+ 11,
1800
+ 10,
1801
+ 84,
1802
+ 5
1803
+ ],
1804
+ [
1805
+ 14,
1806
+ 13,
1807
+ 11,
1808
+ 15,
1809
+ 12,
1810
+ 5,
1811
+ 8,
1812
+ 9,
1813
+ 93
1814
+ ]
1815
+ ],
1816
+ "per_class_recall": [
1817
+ 0.42777777777777776,
1818
+ 0.4777777777777778,
1819
+ 0.5166666666666667,
1820
+ 0.39444444444444443,
1821
+ 0.4625,
1822
+ 0.4777777777777778,
1823
+ 0.49444444444444446,
1824
+ 0.4666666666666667,
1825
+ 0.5166666666666667
1826
+ ],
1827
+ "balanced_accuracy": 0.4705246913580247,
1828
+ "accuracy": 0.47023809523809523,
1829
+ "weighted_f1": 0.4714215675991068,
1830
+ "macro_f1": 0.47182307333007106,
1831
+ "kappa": 0.40322812395229657,
1832
+ "samples": 1680,
1833
+ "reward": 0.4705246913580247,
1834
+ "subjects": 20
1835
+ },
1836
+ "tuev": {
1837
+ "class_counts": [
1838
+ 119,
1839
+ 291,
1840
+ 669,
1841
+ 86,
1842
+ 500,
1843
+ 13822
1844
+ ],
1845
+ "predicted_class_counts": [
1846
+ 1415,
1847
+ 660,
1848
+ 126,
1849
+ 754,
1850
+ 1684,
1851
+ 10848
1852
+ ],
1853
+ "confusion_matrix": [
1854
+ [
1855
+ 45,
1856
+ 38,
1857
+ 15,
1858
+ 0,
1859
+ 4,
1860
+ 17
1861
+ ],
1862
+ [
1863
+ 17,
1864
+ 164,
1865
+ 0,
1866
+ 61,
1867
+ 49,
1868
+ 0
1869
+ ],
1870
+ [
1871
+ 130,
1872
+ 126,
1873
+ 111,
1874
+ 89,
1875
+ 213,
1876
+ 0
1877
+ ],
1878
+ [
1879
+ 7,
1880
+ 2,
1881
+ 0,
1882
+ 76,
1883
+ 0,
1884
+ 1
1885
+ ],
1886
+ [
1887
+ 4,
1888
+ 0,
1889
+ 0,
1890
+ 24,
1891
+ 435,
1892
+ 37
1893
+ ],
1894
+ [
1895
+ 1212,
1896
+ 330,
1897
+ 0,
1898
+ 504,
1899
+ 983,
1900
+ 10793
1901
+ ]
1902
+ ],
1903
+ "per_class_recall": [
1904
+ 0.37815126050420167,
1905
+ 0.563573883161512,
1906
+ 0.16591928251121077,
1907
+ 0.8837209302325582,
1908
+ 0.87,
1909
+ 0.7808566054116626
1910
+ ],
1911
+ "balanced_accuracy": 0.6070369936368575,
1912
+ "accuracy": 0.7505649899916058,
1913
+ "weighted_f1": 0.8137799723660881,
1914
+ "macro_f1": 0.3561849045209278,
1915
+ "kappa": 0.32441309326581047,
1916
+ "samples": 15487,
1917
+ "reward": 0.6070369936368575,
1918
+ "subjects": 58
1919
+ },
1920
+ "ad65": {
1921
+ "class_counts": [
1922
+ 464,
1923
+ 393,
1924
+ 486
1925
+ ],
1926
+ "predicted_class_counts": [
1927
+ 440,
1928
+ 309,
1929
+ 594
1930
+ ],
1931
+ "confusion_matrix": [
1932
+ [
1933
+ 287,
1934
+ 86,
1935
+ 91
1936
+ ],
1937
+ [
1938
+ 96,
1939
+ 185,
1940
+ 112
1941
+ ],
1942
+ [
1943
+ 57,
1944
+ 38,
1945
+ 391
1946
+ ]
1947
+ ],
1948
+ "per_class_recall": [
1949
+ 0.6185344827586207,
1950
+ 0.4707379134860051,
1951
+ 0.8045267489711934
1952
+ ],
1953
+ "balanced_accuracy": 0.6312663817386064,
1954
+ "accuracy": 0.6425912137006702,
1955
+ "weighted_f1": 0.6356338206725993,
1956
+ "macro_f1": 0.6286984511173302,
1957
+ "kappa": 0.4579978610488933,
1958
+ "samples": 1343,
1959
+ "subject_metrics": {
1960
+ "class_counts": [
1961
+ 7,
1962
+ 5,
1963
+ 6
1964
+ ],
1965
+ "predicted_class_counts": [
1966
+ 5,
1967
+ 6,
1968
+ 7
1969
+ ],
1970
+ "confusion_matrix": [
1971
+ [
1972
+ 5,
1973
+ 2,
1974
+ 0
1975
+ ],
1976
+ [
1977
+ 0,
1978
+ 4,
1979
+ 1
1980
+ ],
1981
+ [
1982
+ 0,
1983
+ 0,
1984
+ 6
1985
+ ]
1986
+ ],
1987
+ "per_class_recall": [
1988
+ 0.7142857142857143,
1989
+ 0.8,
1990
+ 1.0
1991
+ ],
1992
+ "balanced_accuracy": 0.8380952380952381,
1993
+ "accuracy": 0.8333333333333334,
1994
+ "weighted_f1": 0.8337865837865839,
1995
+ "macro_f1": 0.8278943278943279,
1996
+ "kappa": 0.7511520737327189
1997
+ },
1998
+ "reward": 0.8380952380952381,
1999
+ "subjects": 18
2000
+ },
2001
+ "openbmi": {
2002
+ "class_counts": [
2003
+ 2200,
2004
+ 2200
2005
+ ],
2006
+ "predicted_class_counts": [
2007
+ 2061,
2008
+ 2339
2009
+ ],
2010
+ "confusion_matrix": [
2011
+ [
2012
+ 1698,
2013
+ 502
2014
+ ],
2015
+ [
2016
+ 363,
2017
+ 1837
2018
+ ]
2019
+ ],
2020
+ "per_class_recall": [
2021
+ 0.7718181818181818,
2022
+ 0.835
2023
+ ],
2024
+ "balanced_accuracy": 0.803409090909091,
2025
+ "accuracy": 0.803409090909091,
2026
+ "weighted_f1": 0.8032127000298179,
2027
+ "macro_f1": 0.8032127000298179,
2028
+ "kappa": 0.6068181818181818,
2029
+ "samples": 4400,
2030
+ "subject_scores": {
2031
+ "19": 0.8425,
2032
+ "35": 0.9525,
2033
+ "34": 0.6425000000000001,
2034
+ "51": 0.7475,
2035
+ "20": 0.82,
2036
+ "44": 0.94,
2037
+ "24": 0.5974999999999999,
2038
+ "15": 0.9,
2039
+ "31": 0.8825000000000001,
2040
+ "26": 0.7925,
2041
+ "23": 0.72
2042
+ },
2043
+ "reward": 0.803409090909091,
2044
+ "subjects": 11
2045
+ },
2046
+ "longitudinal": {
2047
+ "class_counts": [
2048
+ 4260,
2049
+ 4158
2050
+ ],
2051
+ "predicted_class_counts": [
2052
+ 4573,
2053
+ 3845
2054
+ ],
2055
+ "confusion_matrix": [
2056
+ [
2057
+ 3657,
2058
+ 603
2059
+ ],
2060
+ [
2061
+ 916,
2062
+ 3242
2063
+ ]
2064
+ ],
2065
+ "per_class_recall": [
2066
+ 0.8584507042253521,
2067
+ 0.7797017797017797
2068
+ ],
2069
+ "balanced_accuracy": 0.8190762419635659,
2070
+ "accuracy": 0.8195533380850558,
2071
+ "weighted_f1": 0.8192217642599872,
2072
+ "macro_f1": 0.8191137114479841,
2073
+ "kappa": 0.6387281046963751,
2074
+ "samples": 8418,
2075
+ "subject_scores": {
2076
+ "sub-G2021": 0.837643455629449,
2077
+ "sub-G2007": 0.7644167136410334,
2078
+ "sub-G2019": 0.82505149822325,
2079
+ "sub-G2031": 0.788678938415735,
2080
+ "sub-G2015": 0.8429774626319118,
2081
+ "sub-CTR002": 0.9869493251846193,
2082
+ "sub-G2011": 0.765938925240826,
2083
+ "sub-G2035": 0.9564871486872261,
2084
+ "sub-CTR003": 0.5773809523809523
2085
+ },
2086
+ "reward": 0.8161693800038893,
2087
+ "subjects": 9
2088
+ }
2089
+ },
2090
+ "validation_method": "complete portable infer.sh on all five validation splits"
2091
+ }
2092
+ ],
2093
+ "averaged_validation": {
2094
+ "faced": {
2095
+ "class_counts": [
2096
+ 180,
2097
+ 180,
2098
+ 180,
2099
+ 180,
2100
+ 240,
2101
+ 180,
2102
+ 180,
2103
+ 180,
2104
+ 180
2105
+ ],
2106
+ "predicted_class_counts": [
2107
+ 158,
2108
+ 189,
2109
+ 178,
2110
+ 213,
2111
+ 242,
2112
+ 166,
2113
+ 182,
2114
+ 176,
2115
+ 176
2116
+ ],
2117
+ "confusion_matrix": [
2118
+ [
2119
+ 77,
2120
+ 14,
2121
+ 5,
2122
+ 22,
2123
+ 19,
2124
+ 9,
2125
+ 14,
2126
+ 10,
2127
+ 10
2128
+ ],
2129
+ [
2130
+ 12,
2131
+ 86,
2132
+ 9,
2133
+ 13,
2134
+ 19,
2135
+ 11,
2136
+ 14,
2137
+ 6,
2138
+ 10
2139
+ ],
2140
+ [
2141
+ 6,
2142
+ 7,
2143
+ 93,
2144
+ 21,
2145
+ 17,
2146
+ 5,
2147
+ 7,
2148
+ 10,
2149
+ 14
2150
+ ],
2151
+ [
2152
+ 14,
2153
+ 18,
2154
+ 9,
2155
+ 71,
2156
+ 21,
2157
+ 8,
2158
+ 16,
2159
+ 15,
2160
+ 8
2161
+ ],
2162
+ [
2163
+ 13,
2164
+ 13,
2165
+ 17,
2166
+ 26,
2167
+ 111,
2168
+ 17,
2169
+ 14,
2170
+ 18,
2171
+ 11
2172
+ ],
2173
+ [
2174
+ 6,
2175
+ 11,
2176
+ 11,
2177
+ 15,
2178
+ 11,
2179
+ 86,
2180
+ 10,
2181
+ 14,
2182
+ 16
2183
+ ],
2184
+ [
2185
+ 8,
2186
+ 11,
2187
+ 9,
2188
+ 13,
2189
+ 17,
2190
+ 14,
2191
+ 89,
2192
+ 10,
2193
+ 9
2194
+ ],
2195
+ [
2196
+ 8,
2197
+ 16,
2198
+ 14,
2199
+ 17,
2200
+ 15,
2201
+ 11,
2202
+ 10,
2203
+ 84,
2204
+ 5
2205
+ ],
2206
+ [
2207
+ 14,
2208
+ 13,
2209
+ 11,
2210
+ 15,
2211
+ 12,
2212
+ 5,
2213
+ 8,
2214
+ 9,
2215
+ 93
2216
+ ]
2217
+ ],
2218
+ "per_class_recall": [
2219
+ 0.42777777777777776,
2220
+ 0.4777777777777778,
2221
+ 0.5166666666666667,
2222
+ 0.39444444444444443,
2223
+ 0.4625,
2224
+ 0.4777777777777778,
2225
+ 0.49444444444444446,
2226
+ 0.4666666666666667,
2227
+ 0.5166666666666667
2228
+ ],
2229
+ "balanced_accuracy": 0.4705246913580247,
2230
+ "accuracy": 0.47023809523809523,
2231
+ "weighted_f1": 0.4714215675991068,
2232
+ "macro_f1": 0.47182307333007106,
2233
+ "kappa": 0.40322812395229657,
2234
+ "samples": 1680,
2235
+ "reward": 0.4705246913580247,
2236
+ "subjects": 20
2237
+ },
2238
+ "tuev": {
2239
+ "class_counts": [
2240
+ 119,
2241
+ 291,
2242
+ 669,
2243
+ 86,
2244
+ 500,
2245
+ 13822
2246
+ ],
2247
+ "predicted_class_counts": [
2248
+ 1415,
2249
+ 660,
2250
+ 126,
2251
+ 754,
2252
+ 1684,
2253
+ 10848
2254
+ ],
2255
+ "confusion_matrix": [
2256
+ [
2257
+ 45,
2258
+ 38,
2259
+ 15,
2260
+ 0,
2261
+ 4,
2262
+ 17
2263
+ ],
2264
+ [
2265
+ 17,
2266
+ 164,
2267
+ 0,
2268
+ 61,
2269
+ 49,
2270
+ 0
2271
+ ],
2272
+ [
2273
+ 130,
2274
+ 126,
2275
+ 111,
2276
+ 89,
2277
+ 213,
2278
+ 0
2279
+ ],
2280
+ [
2281
+ 7,
2282
+ 2,
2283
+ 0,
2284
+ 76,
2285
+ 0,
2286
+ 1
2287
+ ],
2288
+ [
2289
+ 4,
2290
+ 0,
2291
+ 0,
2292
+ 24,
2293
+ 435,
2294
+ 37
2295
+ ],
2296
+ [
2297
+ 1212,
2298
+ 330,
2299
+ 0,
2300
+ 504,
2301
+ 983,
2302
+ 10793
2303
+ ]
2304
+ ],
2305
+ "per_class_recall": [
2306
+ 0.37815126050420167,
2307
+ 0.563573883161512,
2308
+ 0.16591928251121077,
2309
+ 0.8837209302325582,
2310
+ 0.87,
2311
+ 0.7808566054116626
2312
+ ],
2313
+ "balanced_accuracy": 0.6070369936368575,
2314
+ "accuracy": 0.7505649899916058,
2315
+ "weighted_f1": 0.8137799723660881,
2316
+ "macro_f1": 0.3561849045209278,
2317
+ "kappa": 0.32441309326581047,
2318
+ "samples": 15487,
2319
+ "reward": 0.6070369936368575,
2320
+ "subjects": 58
2321
+ },
2322
+ "ad65": {
2323
+ "class_counts": [
2324
+ 464,
2325
+ 393,
2326
+ 486
2327
+ ],
2328
+ "predicted_class_counts": [
2329
+ 440,
2330
+ 309,
2331
+ 594
2332
+ ],
2333
+ "confusion_matrix": [
2334
+ [
2335
+ 287,
2336
+ 86,
2337
+ 91
2338
+ ],
2339
+ [
2340
+ 96,
2341
+ 185,
2342
+ 112
2343
+ ],
2344
+ [
2345
+ 57,
2346
+ 38,
2347
+ 391
2348
+ ]
2349
+ ],
2350
+ "per_class_recall": [
2351
+ 0.6185344827586207,
2352
+ 0.4707379134860051,
2353
+ 0.8045267489711934
2354
+ ],
2355
+ "balanced_accuracy": 0.6312663817386064,
2356
+ "accuracy": 0.6425912137006702,
2357
+ "weighted_f1": 0.6356338206725993,
2358
+ "macro_f1": 0.6286984511173302,
2359
+ "kappa": 0.4579978610488933,
2360
+ "samples": 1343,
2361
+ "subject_metrics": {
2362
+ "class_counts": [
2363
+ 7,
2364
+ 5,
2365
+ 6
2366
+ ],
2367
+ "predicted_class_counts": [
2368
+ 5,
2369
+ 6,
2370
+ 7
2371
+ ],
2372
+ "confusion_matrix": [
2373
+ [
2374
+ 5,
2375
+ 2,
2376
+ 0
2377
+ ],
2378
+ [
2379
+ 0,
2380
+ 4,
2381
+ 1
2382
+ ],
2383
+ [
2384
+ 0,
2385
+ 0,
2386
+ 6
2387
+ ]
2388
+ ],
2389
+ "per_class_recall": [
2390
+ 0.7142857142857143,
2391
+ 0.8,
2392
+ 1.0
2393
+ ],
2394
+ "balanced_accuracy": 0.8380952380952381,
2395
+ "accuracy": 0.8333333333333334,
2396
+ "weighted_f1": 0.8337865837865839,
2397
+ "macro_f1": 0.8278943278943279,
2398
+ "kappa": 0.7511520737327189
2399
+ },
2400
+ "reward": 0.8380952380952381,
2401
+ "subjects": 18
2402
+ },
2403
+ "openbmi": {
2404
+ "class_counts": [
2405
+ 2200,
2406
+ 2200
2407
+ ],
2408
+ "predicted_class_counts": [
2409
+ 2061,
2410
+ 2339
2411
+ ],
2412
+ "confusion_matrix": [
2413
+ [
2414
+ 1698,
2415
+ 502
2416
+ ],
2417
+ [
2418
+ 363,
2419
+ 1837
2420
+ ]
2421
+ ],
2422
+ "per_class_recall": [
2423
+ 0.7718181818181818,
2424
+ 0.835
2425
+ ],
2426
+ "balanced_accuracy": 0.803409090909091,
2427
+ "accuracy": 0.803409090909091,
2428
+ "weighted_f1": 0.8032127000298179,
2429
+ "macro_f1": 0.8032127000298179,
2430
+ "kappa": 0.6068181818181818,
2431
+ "samples": 4400,
2432
+ "subject_scores": {
2433
+ "19": 0.8425,
2434
+ "35": 0.9525,
2435
+ "34": 0.6425000000000001,
2436
+ "51": 0.7475,
2437
+ "20": 0.82,
2438
+ "44": 0.94,
2439
+ "24": 0.5974999999999999,
2440
+ "15": 0.9,
2441
+ "31": 0.8825000000000001,
2442
+ "26": 0.7925,
2443
+ "23": 0.72
2444
+ },
2445
+ "reward": 0.803409090909091,
2446
+ "subjects": 11
2447
+ },
2448
+ "longitudinal": {
2449
+ "class_counts": [
2450
+ 4260,
2451
+ 4158
2452
+ ],
2453
+ "predicted_class_counts": [
2454
+ 4573,
2455
+ 3845
2456
+ ],
2457
+ "confusion_matrix": [
2458
+ [
2459
+ 3657,
2460
+ 603
2461
+ ],
2462
+ [
2463
+ 916,
2464
+ 3242
2465
+ ]
2466
+ ],
2467
+ "per_class_recall": [
2468
+ 0.8584507042253521,
2469
+ 0.7797017797017797
2470
+ ],
2471
+ "balanced_accuracy": 0.8190762419635659,
2472
+ "accuracy": 0.8195533380850558,
2473
+ "weighted_f1": 0.8192217642599872,
2474
+ "macro_f1": 0.8191137114479841,
2475
+ "kappa": 0.6387281046963751,
2476
+ "samples": 8418,
2477
+ "subject_scores": {
2478
+ "sub-G2021": 0.837643455629449,
2479
+ "sub-G2007": 0.7644167136410334,
2480
+ "sub-G2019": 0.82505149822325,
2481
+ "sub-G2031": 0.788678938415735,
2482
+ "sub-G2015": 0.8429774626319118,
2483
+ "sub-CTR002": 0.9869493251846193,
2484
+ "sub-G2011": 0.765938925240826,
2485
+ "sub-G2035": 0.9564871486872261,
2486
+ "sub-CTR003": 0.5773809523809523
2487
+ },
2488
+ "reward": 0.8161693800038893,
2489
+ "subjects": 9
2490
+ }
2491
+ },
2492
+ "settings": {
2493
+ "source": "/workspace/research/runs/hybrid_biot_csp_stable1/epoch-001",
2494
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
2495
+ "weights_unchanged": true
2496
+ }
2497
+ },
2498
+ "selected_head_epochs": {
2499
+ "faced": 0,
2500
+ "tuev": 0,
2501
+ "ad65": 0,
2502
+ "openbmi": 0,
2503
+ "longitudinal": 16
2504
+ },
2505
+ "incumbent_heads": "/workspace/research/runs/head_refinement1/epoch-012",
2506
+ "clinical_training_teacher": {
2507
+ "source": "/workspace/research/runs/hybrid_biot_readout1/epoch-009",
2508
+ "weights_sha256": "3216b27a1cfb7c1e927da0d91a61c7d516f71236a8adf89d84bc9cfbb932313f",
2509
+ "manifest_sha256": "49b7880052e6d093633e6e03d52bfd7df9084271ebf8e4f60e4fbe12da398354",
2510
+ "split": "train",
2511
+ "count": 68445,
2512
+ "source_trained_jointly_on_all_five_tracks": true
2513
+ },
2514
+ "no_prediction_ensemble": true
2515
+ },
2516
+ "shared_backbone_training": "inherited joint training on all five training splits; fixed during input-adapter/head refinement",
2517
+ "updated_parameters": [
2518
+ "adapters.tuev.spectral",
2519
+ "heads.tuev"
2520
+ ],
2521
+ "initialization_maximum_logit_error": 0.0,
2522
+ "training_target_provenance": {
2523
+ "source": "/workspace/research/runs/hybrid_biot_readout1/epoch-009",
2524
+ "weights_sha256": "3216b27a1cfb7c1e927da0d91a61c7d516f71236a8adf89d84bc9cfbb932313f",
2525
+ "manifest_sha256": "49b7880052e6d093633e6e03d52bfd7df9084271ebf8e4f60e4fbe12da398354",
2526
+ "split": "train",
2527
+ "count": 68445,
2528
+ "source_trained_jointly_on_all_five_tracks": true
2529
+ }
2530
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/config.json ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ },
13
+ "initialization": {
14
+ "initialization": "continue joint training from a complete shared-model checkpoint",
15
+ "parent": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
16
+ "parent_initialization": {
17
+ "initialization": "jointly trained parent plus audited pretrained BIOT in a single coupled backbone",
18
+ "parent": "/workspace/research/runs/hybrid_wide1/epoch-004/weights.pt",
19
+ "audited_biot": {
20
+ "initialization": "pretrained",
21
+ "repo": "braindecode/biot-pretrained-six-datasets-18chs",
22
+ "revision": "7e9aabf302870012f73773276803aab97993951c",
23
+ "sha256": "a218f4054ae29962c6fd9d23d94c446d354c4f53e805a6771c85749ccc20baaa",
24
+ "license": "BSD-3-Clause",
25
+ "source_braindecode": "1.3.0",
26
+ "loaded_core_tensors": 56,
27
+ "skipped_classifier_tensors": 3
28
+ },
29
+ "neural_channel_indices": {
30
+ "faced": [
31
+ 0,
32
+ 1,
33
+ 2,
34
+ 3,
35
+ 4,
36
+ 5,
37
+ 6,
38
+ 7,
39
+ 8,
40
+ 9,
41
+ 10,
42
+ 11,
43
+ 12,
44
+ 13,
45
+ 14,
46
+ 15,
47
+ 16,
48
+ 17
49
+ ],
50
+ "tuev": [
51
+ 0,
52
+ 1,
53
+ 2,
54
+ 3,
55
+ 4,
56
+ 5,
57
+ 6,
58
+ 7,
59
+ 8,
60
+ 9,
61
+ 10,
62
+ 11,
63
+ 12,
64
+ 13,
65
+ 14,
66
+ 15
67
+ ],
68
+ "ad65": [
69
+ 0,
70
+ 1,
71
+ 2,
72
+ 3,
73
+ 4,
74
+ 5,
75
+ 6,
76
+ 7,
77
+ 8,
78
+ 9,
79
+ 10,
80
+ 11,
81
+ 12,
82
+ 13,
83
+ 14,
84
+ 15,
85
+ 16,
86
+ 17
87
+ ],
88
+ "openbmi": [
89
+ 0,
90
+ 1,
91
+ 3,
92
+ 5,
93
+ 12,
94
+ 14,
95
+ 23,
96
+ 25,
97
+ 28,
98
+ 30,
99
+ 2,
100
+ 6,
101
+ 11,
102
+ 15,
103
+ 22,
104
+ 26,
105
+ 4,
106
+ 13
107
+ ],
108
+ "longitudinal": [
109
+ 0,
110
+ 2,
111
+ 7,
112
+ 11,
113
+ 23,
114
+ 27,
115
+ 41,
116
+ 45,
117
+ 55,
118
+ 57,
119
+ 5,
120
+ 13,
121
+ 21,
122
+ 29,
123
+ 39,
124
+ 47,
125
+ 9,
126
+ 25
127
+ ]
128
+ },
129
+ "rebase": "incumbent waveform, fusion and four heads; joint BIOT and TUEV head from readout epoch 9; zero initialized neural interaction",
130
+ "jointly_finetuned_neural_parent": "/workspace/research/runs/hybrid_biot_readout1/epoch-009/weights.pt",
131
+ "tuev_high_dimensional_spectral_projection_disabled": true,
132
+ "frozen_prior_representation": true,
133
+ "nonclinical_head_updates": "only the 256 added BIOT columns; original columns and biases fixed",
134
+ "faced_openbmi_neural_path": "common nonlinear fusion only; direct head columns masked",
135
+ "retention_teacher": "/workspace/research/runs/hybrid_wide1/epoch-004",
136
+ "retention_loss": {
137
+ "split": "train",
138
+ "temperature": 2.0,
139
+ "kl_weight": 1.0,
140
+ "tracks": [
141
+ "faced",
142
+ "ad65",
143
+ "openbmi",
144
+ "longitudinal"
145
+ ]
146
+ }
147
+ },
148
+ "joint_covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
149
+ "frozen_prior_representation": true,
150
+ "head_updates": "one linear head per track; added 128 shared covariance columns trainable; AD head initialized from the joint covariance parent",
151
+ "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",
152
+ "head_arithmetic": "one linear head evaluated in fixed feature blocks to preserve original bfloat16 accumulation dimensions",
153
+ "retention_teacher": {
154
+ "ad65": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
155
+ "other_tracks": "/workspace/research/runs/hybrid_wide1/epoch-004"
156
+ },
157
+ "retention_loss": {
158
+ "split": "train",
159
+ "temperature": 2.0,
160
+ "kl_weight": 1.0,
161
+ "tracks": [
162
+ "faced",
163
+ "ad65",
164
+ "openbmi",
165
+ "longitudinal"
166
+ ]
167
+ }
168
+ },
169
+ "loader_scale": 0.01,
170
+ "tracks": [
171
+ "faced",
172
+ "tuev",
173
+ "ad65",
174
+ "openbmi",
175
+ "longitudinal"
176
+ ],
177
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
178
+ "head_refinement": {
179
+ "source": "/workspace/research/runs/residual_heads1/epoch-018",
180
+ "source_weights_sha256": "e0b609137391b47f99438ccadaa22fc0bc10d2c10ead0ddf0a3c25be2c907c85",
181
+ "shared_backbone_unchanged": true,
182
+ "selected_head_epochs": {
183
+ "faced": 5,
184
+ "tuev": 24,
185
+ "ad65": 0,
186
+ "openbmi": 0,
187
+ "longitudinal": 0
188
+ }
189
+ },
190
+ "clinical_spectral_refinement": {
191
+ "source": "/workspace/research/runs/head_dropout1/epoch-016",
192
+ "zero_initialized_input_adapter": true,
193
+ "backbone_unchanged": true
194
+ },
195
+ "head_estimation": {
196
+ "method": "class/subject-balanced Gaussian linear discriminant; covariance augmented by class-conditional subject/session mean variation before shrinkage",
197
+ "selected_shrinkage": {
198
+ "faced": "inherited",
199
+ "tuev": "inherited",
200
+ "ad65": "inherited",
201
+ "openbmi": "inherited",
202
+ "longitudinal": {
203
+ "shrinkage": 0.9,
204
+ "domain_strength": 1.0
205
+ }
206
+ },
207
+ "feature_scaling": "fitted on training data and folded into linear coefficients"
208
+ },
209
+ "clinical_asymmetry_refinement": {
210
+ "source": "/workspace/research/runs/domain_lda_heads1/epoch-001",
211
+ "zero_initialized_input_adapter": true,
212
+ "backbone_unchanged": true
213
+ }
214
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/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/S018/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/S018/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/S018/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/S018/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/S018/model.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
8
+ def clinical_asymmetry_features(features):
9
+ """Bipolar homologous-channel amplitude and coherence, invariant to mirroring."""
10
+ bands=len(EDGES)-1;per_channel=4*bands+4
11
+ block=features[:,:16*per_channel].reshape(-1,16,per_channel)
12
+ left=torch.tensor([0,1,2,3,8,9,10,11],device=features.device);right=left+4
13
+ pair_power=(block[:,left,:bands]-block[:,right,:bands]).abs().flatten(1)
14
+ pair_rms=(block[:,left,4*bands]-block[:,right,4*bands]).abs()
15
+ hemisphere=(block[:,left,:bands].mean(1)-block[:,right,:bands].mean(1)).abs()
16
+ index=left*(32-left-1)//2+(right-left-1)
17
+ correlations=features[:,16*per_channel:].reshape(-1,len(COV_BANDS),120)[:,:,index].flatten(1)
18
+ return torch.cat([pair_power,pair_rms,hemisphere,correlations],1)
19
+
20
+ class InputAdapter(nn.Module):
21
+ def __init__(self,c,width,channels,spectral_enabled=True,asymmetry=False):
22
+ super().__init__()
23
+ self.signal=nn.Conv1d(c,channels,1,bias=False)
24
+ self.neural=nn.Conv1d(c,18,1,bias=False)
25
+ self.normalizer=Standardize(feature_dim(c))
26
+ self.spectral=nn.Linear(feature_dim(c),width)
27
+ self.dropout=nn.Dropout(.1)
28
+ self.register_buffer("spectral_enabled",torch.tensor(float(spectral_enabled)))
29
+ self.spatial_weight=nn.Parameter(torch.randn(len(BANDS),24,c)/c**.5)
30
+ self.asymmetry_projection=nn.Linear(316,width,bias=False) if asymmetry else None
31
+ if asymmetry:
32
+ nn.init.zeros_(self.asymmetry_projection.weight)
33
+ self.asymmetry_normalizer=Standardize(316)
34
+ self.asymmetry_dropout=nn.Dropout(.1)
35
+ def spectral_features(self,features):
36
+ value=self.spectral_enabled*self.spectral(self.dropout(self.normalizer(features)))
37
+ if self.asymmetry_projection is not None:
38
+ extra=self.asymmetry_dropout(self.asymmetry_normalizer(clinical_asymmetry_features(features)))
39
+ value=value+self.asymmetry_projection(extra)
40
+ return value
41
+ def spatial_features(self,covariances):
42
+ with torch.autocast(covariances.device.type,enabled=False):
43
+ w=self.spatial_weight.float()/self.spatial_weight.float().norm(dim=-1,keepdim=True).clamp_min(1e-6)
44
+ power=torch.einsum('bfc,nbcd,bfd->nbf',w,covariances.float(),w).clamp_min(1e-8).log()
45
+ return torch.cat([power,power-power.mean(1,keepdim=True)],1).flatten(1)
46
+ def forward(self,x,features,covariance_features):
47
+ return self.signal(x).unsqueeze(1),self.spectral_features(features),self.neural(x),covariance_features
48
+
49
+ class SharedBackbone(nn.Module):
50
+ def __init__(self,channels,width,depth,dropout,wave_filters):
51
+ super().__init__()
52
+ self.waveform=nn.Sequential(
53
+ nn.Conv2d(1,wave_filters,(1,64),padding=(0,32),bias=False),nn.GroupNorm(1,wave_filters),
54
+ nn.Conv2d(wave_filters,2*wave_filters,(channels,1),groups=wave_filters,bias=False),nn.GroupNorm(1,2*wave_filters),nn.ELU(),
55
+ nn.AvgPool2d((1,4)),nn.Dropout(.35),
56
+ 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),
57
+ nn.GroupNorm(1,2*wave_filters),nn.ELU(),nn.AvgPool2d((1,8)),nn.Dropout(.35))
58
+ self.wave_summary=nn.Sequential(nn.AdaptiveAvgPool2d((1,8)),nn.Flatten(),nn.Linear(2*wave_filters*8,width))
59
+ self.fusion=nn.Sequential(nn.LayerNorm(width),nn.GELU(),nn.Dropout(dropout),
60
+ *[Residual(width,dropout) for _ in range(depth)],nn.LayerNorm(width))
61
+ # Both representations interact before the shared residual stack.
62
+ self.wave_gain=nn.Parameter(torch.tensor(.1))
63
+ self.biot=BIOT(n_chans=18,n_outputs=2,n_times=400,sfreq=200)
64
+ self.biot.final_layer=nn.Identity()
65
+ self.biot_projection=nn.Sequential(nn.LayerNorm(256),nn.Linear(256,width),nn.Dropout(.2))
66
+ nn.init.normal_(self.biot_projection[1].weight,std=.001);nn.init.zeros_(self.biot_projection[1].bias)
67
+ self.covariance_encoder=nn.Sequential(nn.LayerNorm(len(BANDS)*24*2),nn.Linear(len(BANDS)*24*2,width),nn.GELU(),nn.Dropout(.4),
68
+ *[Residual(width,.4) for _ in range(2)],nn.LayerNorm(width))
69
+ self.covariance_projection=nn.Linear(width,width)
70
+ nn.init.zeros_(self.covariance_projection.weight);nn.init.zeros_(self.covariance_projection.bias)
71
+ def forward(self,signal,spectral,neural_signal,covariance_features):
72
+ wave=self.waveform(signal)
73
+ neural=self.biot(neural_signal.float())
74
+ neural=self.biot_projection[0](neural)
75
+ projected=self.biot_projection[2](self.biot_projection[1](neural))
76
+ with torch.autocast(signal.device.type,enabled=False):
77
+ covariance_embedding=self.covariance_encoder(covariance_features.float())
78
+ original=spectral+self.wave_gain*self.wave_summary(wave)+.01*projected
79
+ coupled=.001*self.covariance_projection(covariance_embedding).to(original.dtype)
80
+ fused=self.fusion(original+coupled)
81
+ return torch.cat([wave.flatten(1),fused,neural,covariance_embedding],-1)
82
+
83
+ class ResidualHead(nn.Module):
84
+ """A small nonlinear classifier correction around an inherited linear readout."""
85
+ def __init__(self,features,classes,width=64,dropout=.3,full_precision=False):
86
+ super().__init__();self.full_precision=full_precision
87
+ self.base=nn.Linear(features,classes)
88
+ self.delta=nn.Sequential(nn.LayerNorm(features),nn.Linear(features,width),nn.GELU(),nn.Dropout(dropout),nn.Linear(width,classes))
89
+ nn.init.zeros_(self.delta[-1].weight);nn.init.zeros_(self.delta[-1].bias)
90
+ def forward(self,x):
91
+ if self.full_precision:
92
+ with torch.autocast(x.device.type,enabled=False):return self.base(x.float())+self.delta(x.float())
93
+ prior=nn.functional.linear(x[:,:-128].contiguous(),self.base.weight[:,:-128].contiguous(),self.base.bias)
94
+ added=nn.functional.linear(x[:,-128:].contiguous(),self.base.weight[:,-128:].contiguous())
95
+ value=prior+added
96
+ return value+self.delta(x).to(value.dtype)
97
+
98
+ class HybridModel(nn.Module):
99
+ def __init__(self,channels=32,width=128,depth=2,dropout=.5,wave_filters=32,head_width=64,head_dropout=.3,clinical_asymmetry=True):
100
+ super().__init__()
101
+ self.adapters=nn.ModuleDict({t:InputAdapter(c,width,channels,spectral_enabled=t not in ("faced","tuev","openbmi"),asymmetry=clinical_asymmetry and t=="tuev") for t,(c,s,k) in SPECS.items()})
102
+ self.backbone=SharedBackbone(channels,width,depth,dropout,wave_filters)
103
+ 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()})
104
+ def forward(self,t,x,features=None,covariances=None,covariance_features=None):
105
+ if features is None:features=extract_features(t,x)
106
+ if covariance_features is None:
107
+ if covariances is None:covariances=extract_covariances(t,x)
108
+ covariance_features=self.adapters[t].spatial_features(covariances)
109
+ signal=x.flatten(2);signal=signal-signal.mean(-1,keepdim=True)
110
+ if t in ('faced','tuev'):signal=signal/signal.std(-1,keepdim=True,correction=0).clamp_min(1e-6)
111
+ else:signal=signal-signal.mean(1,keepdim=True)
112
+ signal=signal.clamp(-20,20)
113
+ adapted=self.adapters[t](signal,features,covariance_features)
114
+ representation=self.backbone(*adapted)
115
+ if t in ('faced','openbmi'):
116
+ representation=torch.cat([representation[:,:-384],torch.zeros_like(representation[:,-384:-128]),representation[:,-128:]],-1)
117
+ return self.heads[t](representation)
118
+
119
+ def widen_state_dict(state,multiplier=2):
120
+ """Duplicate temporal features and divide downstream sums to preserve outputs."""
121
+ result={}
122
+ for key,value in state.items():
123
+ if key.startswith('backbone.waveform.'):
124
+ layer=int(key.split('.')[2])
125
+ if layer in (0,2,7):value=value.repeat(multiplier,1,1,1)
126
+ elif layer in (1,3,9):value=value.repeat(multiplier)
127
+ elif layer==8:value=value.repeat(multiplier,multiplier,1,1)/multiplier
128
+ elif key=='backbone.wave_summary.2.weight':value=value.repeat(1,multiplier)/multiplier
129
+ elif key.startswith('heads.') and key.endswith('.weight'):
130
+ raw=value[:,:-128]/multiplier
131
+ value=torch.cat([raw]*multiplier+[value[:,-128:]],1)
132
+ result[key]=value
133
+ return result
134
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S018/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/S023/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/S023/config.json ADDED
@@ -0,0 +1,615 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": 1,
606
+ "ad65": 0,
607
+ "openbmi": 10,
608
+ "longitudinal": 2
609
+ }
610
+ },
611
+ "private_track_selection": {
612
+ "track": "tuev",
613
+ "donor": "/workspace/research/replicates/frequency_head_control1/epoch-001"
614
+ }
615
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S023/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/S023/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/S023/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/S023/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/S023/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/S023/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/S023/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/S023/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/S024/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/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/S027/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/S030/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/S030/config.json ADDED
@@ -0,0 +1,669 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ },
381
+ "initialization": {
382
+ "initialization": "continue joint training from a complete shared-model checkpoint",
383
+ "parent": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
384
+ "parent_initialization": {
385
+ "initialization": "jointly trained parent plus audited pretrained BIOT in a single coupled backbone",
386
+ "parent": "/workspace/research/runs/hybrid_wide1/epoch-004/weights.pt",
387
+ "audited_biot": {
388
+ "initialization": "pretrained",
389
+ "repo": "braindecode/biot-pretrained-six-datasets-18chs",
390
+ "revision": "7e9aabf302870012f73773276803aab97993951c",
391
+ "sha256": "a218f4054ae29962c6fd9d23d94c446d354c4f53e805a6771c85749ccc20baaa",
392
+ "license": "BSD-3-Clause",
393
+ "source_braindecode": "1.3.0",
394
+ "loaded_core_tensors": 56,
395
+ "skipped_classifier_tensors": 3
396
+ },
397
+ "neural_channel_indices": {
398
+ "faced": [
399
+ 0,
400
+ 1,
401
+ 2,
402
+ 3,
403
+ 4,
404
+ 5,
405
+ 6,
406
+ 7,
407
+ 8,
408
+ 9,
409
+ 10,
410
+ 11,
411
+ 12,
412
+ 13,
413
+ 14,
414
+ 15,
415
+ 16,
416
+ 17
417
+ ],
418
+ "tuev": [
419
+ 0,
420
+ 1,
421
+ 2,
422
+ 3,
423
+ 4,
424
+ 5,
425
+ 6,
426
+ 7,
427
+ 8,
428
+ 9,
429
+ 10,
430
+ 11,
431
+ 12,
432
+ 13,
433
+ 14,
434
+ 15
435
+ ],
436
+ "ad65": [
437
+ 0,
438
+ 1,
439
+ 2,
440
+ 3,
441
+ 4,
442
+ 5,
443
+ 6,
444
+ 7,
445
+ 8,
446
+ 9,
447
+ 10,
448
+ 11,
449
+ 12,
450
+ 13,
451
+ 14,
452
+ 15,
453
+ 16,
454
+ 17
455
+ ],
456
+ "openbmi": [
457
+ 0,
458
+ 1,
459
+ 3,
460
+ 5,
461
+ 12,
462
+ 14,
463
+ 23,
464
+ 25,
465
+ 28,
466
+ 30,
467
+ 2,
468
+ 6,
469
+ 11,
470
+ 15,
471
+ 22,
472
+ 26,
473
+ 4,
474
+ 13
475
+ ],
476
+ "longitudinal": [
477
+ 0,
478
+ 2,
479
+ 7,
480
+ 11,
481
+ 23,
482
+ 27,
483
+ 41,
484
+ 45,
485
+ 55,
486
+ 57,
487
+ 5,
488
+ 13,
489
+ 21,
490
+ 29,
491
+ 39,
492
+ 47,
493
+ 9,
494
+ 25
495
+ ]
496
+ },
497
+ "rebase": "incumbent waveform, fusion and four heads; joint BIOT and TUEV head from readout epoch 9; zero initialized neural interaction",
498
+ "jointly_finetuned_neural_parent": "/workspace/research/runs/hybrid_biot_readout1/epoch-009/weights.pt",
499
+ "tuev_high_dimensional_spectral_projection_disabled": true,
500
+ "frozen_prior_representation": true,
501
+ "nonclinical_head_updates": "only the 256 added BIOT columns; original columns and biases fixed",
502
+ "faced_openbmi_neural_path": "common nonlinear fusion only; direct head columns masked",
503
+ "retention_teacher": "/workspace/research/runs/hybrid_wide1/epoch-004",
504
+ "retention_loss": {
505
+ "split": "train",
506
+ "temperature": 2.0,
507
+ "kl_weight": 1.0,
508
+ "tracks": [
509
+ "faced",
510
+ "ad65",
511
+ "openbmi",
512
+ "longitudinal"
513
+ ]
514
+ }
515
+ },
516
+ "joint_covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
517
+ "frozen_prior_representation": true,
518
+ "head_updates": "one linear head per track; added 128 shared covariance columns trainable; AD head initialized from the joint covariance parent",
519
+ "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",
520
+ "head_arithmetic": "one linear head evaluated in fixed feature blocks to preserve original bfloat16 accumulation dimensions",
521
+ "retention_teacher": {
522
+ "ad65": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
523
+ "other_tracks": "/workspace/research/runs/hybrid_wide1/epoch-004"
524
+ },
525
+ "retention_loss": {
526
+ "split": "train",
527
+ "temperature": 2.0,
528
+ "kl_weight": 1.0,
529
+ "tracks": [
530
+ "faced",
531
+ "ad65",
532
+ "openbmi",
533
+ "longitudinal"
534
+ ]
535
+ }
536
+ },
537
+ "loader_scale": 0.01,
538
+ "tracks": [
539
+ "faced",
540
+ "tuev",
541
+ "ad65",
542
+ "openbmi",
543
+ "longitudinal"
544
+ ],
545
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
546
+ "head_refinement": {
547
+ "source": "/workspace/research/runs/residual_heads1/epoch-018",
548
+ "source_weights_sha256": "e0b609137391b47f99438ccadaa22fc0bc10d2c10ead0ddf0a3c25be2c907c85",
549
+ "shared_backbone_unchanged": true,
550
+ "selected_head_epochs": {
551
+ "faced": 5,
552
+ "tuev": 24,
553
+ "ad65": 0,
554
+ "openbmi": 0,
555
+ "longitudinal": 0
556
+ }
557
+ },
558
+ "clinical_spectral_refinement": {
559
+ "source": "/workspace/research/runs/head_dropout1/epoch-016",
560
+ "zero_initialized_input_adapter": true,
561
+ "backbone_unchanged": true
562
+ },
563
+ "head_estimation": {
564
+ "method": "class/subject-balanced Gaussian linear discriminant; covariance augmented by class-conditional subject/session mean variation before shrinkage",
565
+ "selected_shrinkage": {
566
+ "faced": "inherited",
567
+ "tuev": "inherited",
568
+ "ad65": "inherited",
569
+ "openbmi": "inherited",
570
+ "longitudinal": {
571
+ "shrinkage": 0.9,
572
+ "domain_strength": 1.0
573
+ }
574
+ },
575
+ "feature_scaling": "fitted on training data and folded into linear coefficients"
576
+ },
577
+ "clinical_asymmetry_refinement": {
578
+ "source": "/workspace/research/runs/domain_lda_heads1/epoch-001",
579
+ "zero_initialized_input_adapter": true,
580
+ "backbone_unchanged": true
581
+ },
582
+ "alpha_rhythm_adapter": {
583
+ "training_normalization_only": true,
584
+ "regions": [
585
+ "occipital",
586
+ "parietal",
587
+ "central",
588
+ "frontal",
589
+ "left_posterior",
590
+ "right_posterior"
591
+ ],
592
+ "features": "per-window alpha prominence relative to adjacent frequencies",
593
+ "shared_backbone_unchanged": true
594
+ },
595
+ "clinical_envelope_refinement": {
596
+ "source": "/workspace/research/runs/clinical_asymmetry1/epoch-001",
597
+ "zero_initialized_input_adapter": true,
598
+ "backbone_unchanged": true
599
+ },
600
+ "independent_adapter_merge": {
601
+ "alpha_source": "/workspace/research/runs/alpha_calibrated1/epoch-003",
602
+ "clinical_source": "/workspace/research/runs/clinical_envelope1/epoch-002",
603
+ "all_shared_and_head_tensors_equal": true
604
+ },
605
+ "frequency_montage_refinement": {
606
+ "six_frequency_bands": true,
607
+ "shared_encoder_unchanged": true,
608
+ "selected_track_epochs": {
609
+ "faced": 0,
610
+ "tuev": 1,
611
+ "ad65": 0,
612
+ "openbmi": 10,
613
+ "longitudinal": 2
614
+ }
615
+ },
616
+ "private_track_selection": {
617
+ "track": "tuev",
618
+ "donor": "/workspace/research/replicates/frequency_head_control1/epoch-001"
619
+ },
620
+ "clinical_sampling_refinement": {
621
+ "subject_exponent": 0.0,
622
+ "class_balanced": true,
623
+ "only_clinical_head_updated": true
624
+ },
625
+ "temporal_statistics_readout": {
626
+ "statistics": [
627
+ "mean",
628
+ "standard deviation",
629
+ "maximum",
630
+ "minimum"
631
+ ],
632
+ "shared_encoder_and_prior_heads_unchanged": true,
633
+ "selected_pool_epochs": {
634
+ "faced": 2,
635
+ "tuev": 0,
636
+ "ad65": 0,
637
+ "openbmi": 33,
638
+ "longitudinal": 3
639
+ }
640
+ },
641
+ "temporal_evidence_readout": {
642
+ "pooling": "log mean exp of per-patch class evidence",
643
+ "temperature": 0.25,
644
+ "shared_encoder_and_prior_heads_unchanged": true,
645
+ "selected_evidence_epochs": {
646
+ "faced": 0,
647
+ "tuev": 0,
648
+ "ad65": 0,
649
+ "openbmi": 6,
650
+ "longitudinal": 8
651
+ }
652
+ },
653
+ "fourier_basis_readout": {
654
+ "basis_functions": 256,
655
+ "bandwidths": [
656
+ 0.5,
657
+ 1.0,
658
+ 2.0
659
+ ],
660
+ "shared_encoder_and_prior_heads_unchanged": true,
661
+ "selected_fourier_epochs": {
662
+ "faced": 21,
663
+ "tuev": 0,
664
+ "ad65": 0,
665
+ "openbmi": 0,
666
+ "longitudinal": 2
667
+ }
668
+ }
669
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S030/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/S030/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/S030/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/S030/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/S030/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/S030/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/S030/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/S030/model.py ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 TemporalEvidenceHead(nn.Module):
143
+ """Pool class evidence over the shared waveform time axis."""
144
+ def __init__(self,prior,channels=64,temperature=.25):
145
+ super().__init__();self.prior=prior;self.channels=channels;self.temperature=temperature
146
+ self.register_buffer('evidence_output_scale',torch.ones(()))
147
+ self.register_buffer('evidence_mean',torch.zeros(channels))
148
+ self.register_buffer('evidence_scale',torch.ones(channels))
149
+ self.evidence_projection=nn.Linear(channels,prior.prior.base.out_features,bias=False)
150
+ nn.init.zeros_(self.evidence_projection.weight)
151
+ def patches(self,x):
152
+ with torch.autocast(x.device.type,enabled=False):
153
+ wave=x[:,:-512].float().reshape(len(x),self.channels,-1).transpose(1,2)
154
+ return ((wave-self.evidence_mean)/self.evidence_scale).clamp(-8,8)
155
+ def evidence(self,patches):
156
+ with torch.autocast(patches.device.type,enabled=False):
157
+ values=self.evidence_projection(patches.float())/self.temperature
158
+ maximum=values.amax(1,keepdim=True)
159
+ pooled=self.temperature*((values-maximum).exp().mean(1).log()+maximum.squeeze(1))
160
+ return self.evidence_output_scale*pooled
161
+ def forward(self,x):
162
+ prior=self.prior(x)
163
+ return prior+self.evidence(self.patches(x)).to(prior.dtype)
164
+
165
+ class FourierResidualHead(nn.Module):
166
+ """A fixed random Fourier basis and trainable linear classifier correction."""
167
+ def __init__(self,prior,features,classes,basis=256):
168
+ super().__init__();self.prior=prior
169
+ self.register_buffer('rff_mean',torch.zeros(features));self.register_buffer('rff_scale',torch.ones(features))
170
+ self.register_buffer('rff_frequency',torch.randn(features,basis)/features**.5)
171
+ self.register_buffer('rff_phase',torch.rand(basis)*2*torch.pi)
172
+ self.register_buffer('rff_output_scale',torch.ones(()))
173
+ self.rff_projection=nn.Linear(3*basis,classes);nn.init.zeros_(self.rff_projection.weight);nn.init.zeros_(self.rff_projection.bias)
174
+ def basis(self,x):
175
+ with torch.autocast(x.device.type,enabled=False):
176
+ values=((x.float()-self.rff_mean)/self.rff_scale).clamp(-8,8)@self.rff_frequency
177
+ return 2**.5*torch.cat([(values/sigma+self.rff_phase).cos() for sigma in (.5,1.,2.)],-1)
178
+ def forward(self,x):
179
+ prior=self.prior(x)
180
+ with torch.autocast(x.device.type,enabled=False):added=self.rff_output_scale*self.rff_projection(self.basis(x))
181
+ return prior+added.to(prior.dtype)
182
+
183
+ class HybridModel(nn.Module):
184
+ 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,temporal_evidence=False,evidence_temperature=.25,random_fourier=False,fourier_features=256):
185
+ super().__init__()
186
+ 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()})
187
+ self.backbone=SharedBackbone(channels,width,depth,dropout,wave_filters)
188
+ 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()})
189
+ if temporal_pool:self.heads=nn.ModuleDict({t:TemporalPoolHead(head,wave_filters*2) for t,head in self.heads.items()})
190
+ if temporal_evidence:self.heads=nn.ModuleDict({t:TemporalEvidenceHead(head,wave_filters*2,evidence_temperature) for t,head in self.heads.items()})
191
+ if random_fourier:self.heads=nn.ModuleDict({t:FourierResidualHead(head,2*wave_filters*(((SPECS[t][1]*200+1)//4+1)//8)+width+256+width,SPECS[t][2],fourier_features) for t,head in self.heads.items()})
192
+ def forward(self,t,x,features=None,covariances=None,covariance_features=None):
193
+ if features is None:features=extract_features(t,x)
194
+ if covariance_features is None:
195
+ if covariances is None:covariances=extract_covariances(t,x)
196
+ covariance_features=self.adapters[t].spatial_features(covariances)
197
+ signal=x.flatten(2);signal=signal-signal.mean(-1,keepdim=True)
198
+ if t in ('faced','tuev'):signal=signal/signal.std(-1,keepdim=True,correction=0).clamp_min(1e-6)
199
+ else:signal=signal-signal.mean(1,keepdim=True)
200
+ signal=signal.clamp(-20,20)
201
+ adapted=self.adapters[t](signal,features,covariance_features)
202
+ representation=self.backbone(*adapted)
203
+ if t in ('faced','openbmi'):
204
+ representation=torch.cat([representation[:,:-384],torch.zeros_like(representation[:,-384:-128]),representation[:,-128:]],-1)
205
+ return self.heads[t](representation)
206
+
207
+ def widen_state_dict(state,multiplier=2):
208
+ """Duplicate temporal features and divide downstream sums to preserve outputs."""
209
+ result={}
210
+ for key,value in state.items():
211
+ if key.startswith('backbone.waveform.'):
212
+ layer=int(key.split('.')[2])
213
+ if layer in (0,2,7):value=value.repeat(multiplier,1,1,1)
214
+ elif layer in (1,3,9):value=value.repeat(multiplier)
215
+ elif layer==8:value=value.repeat(multiplier,multiplier,1,1)/multiplier
216
+ elif key=='backbone.wave_summary.2.weight':value=value.repeat(1,multiplier)/multiplier
217
+ elif key.startswith('heads.') and key.endswith('.weight'):
218
+ raw=value[:,:-128]/multiplier
219
+ value=torch.cat([raw]*multiplier+[value[:,-128:]],1)
220
+ result[key]=value
221
+ return result
222
+
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S031/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/S031/config.json ADDED
@@ -0,0 +1,669 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ },
381
+ "initialization": {
382
+ "initialization": "continue joint training from a complete shared-model checkpoint",
383
+ "parent": "/workspace/research/runs/hybrid_biot_fusionshrink0100/epoch-001/weights.pt",
384
+ "parent_initialization": {
385
+ "initialization": "jointly trained parent plus audited pretrained BIOT in a single coupled backbone",
386
+ "parent": "/workspace/research/runs/hybrid_wide1/epoch-004/weights.pt",
387
+ "audited_biot": {
388
+ "initialization": "pretrained",
389
+ "repo": "braindecode/biot-pretrained-six-datasets-18chs",
390
+ "revision": "7e9aabf302870012f73773276803aab97993951c",
391
+ "sha256": "a218f4054ae29962c6fd9d23d94c446d354c4f53e805a6771c85749ccc20baaa",
392
+ "license": "BSD-3-Clause",
393
+ "source_braindecode": "1.3.0",
394
+ "loaded_core_tensors": 56,
395
+ "skipped_classifier_tensors": 3
396
+ },
397
+ "neural_channel_indices": {
398
+ "faced": [
399
+ 0,
400
+ 1,
401
+ 2,
402
+ 3,
403
+ 4,
404
+ 5,
405
+ 6,
406
+ 7,
407
+ 8,
408
+ 9,
409
+ 10,
410
+ 11,
411
+ 12,
412
+ 13,
413
+ 14,
414
+ 15,
415
+ 16,
416
+ 17
417
+ ],
418
+ "tuev": [
419
+ 0,
420
+ 1,
421
+ 2,
422
+ 3,
423
+ 4,
424
+ 5,
425
+ 6,
426
+ 7,
427
+ 8,
428
+ 9,
429
+ 10,
430
+ 11,
431
+ 12,
432
+ 13,
433
+ 14,
434
+ 15
435
+ ],
436
+ "ad65": [
437
+ 0,
438
+ 1,
439
+ 2,
440
+ 3,
441
+ 4,
442
+ 5,
443
+ 6,
444
+ 7,
445
+ 8,
446
+ 9,
447
+ 10,
448
+ 11,
449
+ 12,
450
+ 13,
451
+ 14,
452
+ 15,
453
+ 16,
454
+ 17
455
+ ],
456
+ "openbmi": [
457
+ 0,
458
+ 1,
459
+ 3,
460
+ 5,
461
+ 12,
462
+ 14,
463
+ 23,
464
+ 25,
465
+ 28,
466
+ 30,
467
+ 2,
468
+ 6,
469
+ 11,
470
+ 15,
471
+ 22,
472
+ 26,
473
+ 4,
474
+ 13
475
+ ],
476
+ "longitudinal": [
477
+ 0,
478
+ 2,
479
+ 7,
480
+ 11,
481
+ 23,
482
+ 27,
483
+ 41,
484
+ 45,
485
+ 55,
486
+ 57,
487
+ 5,
488
+ 13,
489
+ 21,
490
+ 29,
491
+ 39,
492
+ 47,
493
+ 9,
494
+ 25
495
+ ]
496
+ },
497
+ "rebase": "incumbent waveform, fusion and four heads; joint BIOT and TUEV head from readout epoch 9; zero initialized neural interaction",
498
+ "jointly_finetuned_neural_parent": "/workspace/research/runs/hybrid_biot_readout1/epoch-009/weights.pt",
499
+ "tuev_high_dimensional_spectral_projection_disabled": true,
500
+ "frozen_prior_representation": true,
501
+ "nonclinical_head_updates": "only the 256 added BIOT columns; original columns and biases fixed",
502
+ "faced_openbmi_neural_path": "common nonlinear fusion only; direct head columns masked",
503
+ "retention_teacher": "/workspace/research/runs/hybrid_wide1/epoch-004",
504
+ "retention_loss": {
505
+ "split": "train",
506
+ "temperature": 2.0,
507
+ "kl_weight": 1.0,
508
+ "tracks": [
509
+ "faced",
510
+ "ad65",
511
+ "openbmi",
512
+ "longitudinal"
513
+ ]
514
+ }
515
+ },
516
+ "joint_covariance_parent": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
517
+ "frozen_prior_representation": true,
518
+ "head_updates": "one linear head per track; added 128 shared covariance columns trainable; AD head initialized from the joint covariance parent",
519
+ "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",
520
+ "head_arithmetic": "one linear head evaluated in fixed feature blocks to preserve original bfloat16 accumulation dimensions",
521
+ "retention_teacher": {
522
+ "ad65": "/workspace/research/runs/filterbank1/epoch-002/weights.pt",
523
+ "other_tracks": "/workspace/research/runs/hybrid_wide1/epoch-004"
524
+ },
525
+ "retention_loss": {
526
+ "split": "train",
527
+ "temperature": 2.0,
528
+ "kl_weight": 1.0,
529
+ "tracks": [
530
+ "faced",
531
+ "ad65",
532
+ "openbmi",
533
+ "longitudinal"
534
+ ]
535
+ }
536
+ },
537
+ "loader_scale": 0.01,
538
+ "tracks": [
539
+ "faced",
540
+ "tuev",
541
+ "ad65",
542
+ "openbmi",
543
+ "longitudinal"
544
+ ],
545
+ "head_arithmetic": "same linear head in fixed feature blocks, sum in bfloat16 on GPU for non-AD tracks; AD remains float32",
546
+ "head_refinement": {
547
+ "source": "/workspace/research/runs/residual_heads1/epoch-018",
548
+ "source_weights_sha256": "e0b609137391b47f99438ccadaa22fc0bc10d2c10ead0ddf0a3c25be2c907c85",
549
+ "shared_backbone_unchanged": true,
550
+ "selected_head_epochs": {
551
+ "faced": 5,
552
+ "tuev": 24,
553
+ "ad65": 0,
554
+ "openbmi": 0,
555
+ "longitudinal": 0
556
+ }
557
+ },
558
+ "clinical_spectral_refinement": {
559
+ "source": "/workspace/research/runs/head_dropout1/epoch-016",
560
+ "zero_initialized_input_adapter": true,
561
+ "backbone_unchanged": true
562
+ },
563
+ "head_estimation": {
564
+ "method": "class/subject-balanced Gaussian linear discriminant; covariance augmented by class-conditional subject/session mean variation before shrinkage",
565
+ "selected_shrinkage": {
566
+ "faced": "inherited",
567
+ "tuev": "inherited",
568
+ "ad65": "inherited",
569
+ "openbmi": "inherited",
570
+ "longitudinal": {
571
+ "shrinkage": 0.9,
572
+ "domain_strength": 1.0
573
+ }
574
+ },
575
+ "feature_scaling": "fitted on training data and folded into linear coefficients"
576
+ },
577
+ "clinical_asymmetry_refinement": {
578
+ "source": "/workspace/research/runs/domain_lda_heads1/epoch-001",
579
+ "zero_initialized_input_adapter": true,
580
+ "backbone_unchanged": true
581
+ },
582
+ "alpha_rhythm_adapter": {
583
+ "training_normalization_only": true,
584
+ "regions": [
585
+ "occipital",
586
+ "parietal",
587
+ "central",
588
+ "frontal",
589
+ "left_posterior",
590
+ "right_posterior"
591
+ ],
592
+ "features": "per-window alpha prominence relative to adjacent frequencies",
593
+ "shared_backbone_unchanged": true
594
+ },
595
+ "clinical_envelope_refinement": {
596
+ "source": "/workspace/research/runs/clinical_asymmetry1/epoch-001",
597
+ "zero_initialized_input_adapter": true,
598
+ "backbone_unchanged": true
599
+ },
600
+ "independent_adapter_merge": {
601
+ "alpha_source": "/workspace/research/runs/alpha_calibrated1/epoch-003",
602
+ "clinical_source": "/workspace/research/runs/clinical_envelope1/epoch-002",
603
+ "all_shared_and_head_tensors_equal": true
604
+ },
605
+ "frequency_montage_refinement": {
606
+ "six_frequency_bands": true,
607
+ "shared_encoder_unchanged": true,
608
+ "selected_track_epochs": {
609
+ "faced": 0,
610
+ "tuev": 1,
611
+ "ad65": 0,
612
+ "openbmi": 10,
613
+ "longitudinal": 2
614
+ }
615
+ },
616
+ "private_track_selection": {
617
+ "track": "tuev",
618
+ "donor": "/workspace/research/replicates/frequency_head_control1/epoch-001"
619
+ },
620
+ "clinical_sampling_refinement": {
621
+ "subject_exponent": 0.0,
622
+ "class_balanced": true,
623
+ "only_clinical_head_updated": true
624
+ },
625
+ "temporal_statistics_readout": {
626
+ "statistics": [
627
+ "mean",
628
+ "standard deviation",
629
+ "maximum",
630
+ "minimum"
631
+ ],
632
+ "shared_encoder_and_prior_heads_unchanged": true,
633
+ "selected_pool_epochs": {
634
+ "faced": 2,
635
+ "tuev": 0,
636
+ "ad65": 0,
637
+ "openbmi": 33,
638
+ "longitudinal": 3
639
+ }
640
+ },
641
+ "temporal_evidence_readout": {
642
+ "pooling": "log mean exp of per-patch class evidence",
643
+ "temperature": 0.25,
644
+ "shared_encoder_and_prior_heads_unchanged": true,
645
+ "selected_evidence_epochs": {
646
+ "faced": 0,
647
+ "tuev": 0,
648
+ "ad65": 0,
649
+ "openbmi": 6,
650
+ "longitudinal": 8
651
+ }
652
+ },
653
+ "fourier_basis_readout": {
654
+ "basis_functions": 256,
655
+ "bandwidths": [
656
+ 0.5,
657
+ 1.0,
658
+ 2.0
659
+ ],
660
+ "shared_encoder_and_prior_heads_unchanged": true,
661
+ "selected_fourier_epochs": {
662
+ "faced": 21,
663
+ "tuev": 0,
664
+ "ad65": 0,
665
+ "openbmi": 0,
666
+ "longitudinal": 2
667
+ }
668
+ }
669
+ }
tasks/brain-computer-interface-decoding/brain-computer-interface-decoding-astra-xhigh-1h100-48h-20261031a/submissions/S031/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
+