Download scripts/validate_pipeline.py from arushsinghal/setu-neural-eeg: direct link, hf CLI and curl.
- Browser
- Download file 930 Bytes
-
https://huggingface.co/arushsinghal/setu-neural-eeg/resolve/main/scripts/validate_pipeline.py
- Command line
-
hf download hf://arushsinghal/setu-neural-eeg/scripts/validate_pipeline.py
-
curl -L -o validate_pipeline.py https://huggingface.co/arushsinghal/setu-neural-eeg/resolve/main/scripts/validate_pipeline.py
930 Bytes
| import sys,json,inspect | |
| import numpy as np | |
| from bci_data import cached,preprocess,montage | |
| x,y,names=cached(1,'train');p=preprocess(x[:2]);assert p.shape==(2,64,400) | |
| changed=x[:2].copy();changed[:,:,:128]+=1e6;changed[:,:,640:]-=1e6 | |
| assert np.array_equal(preprocess(changed),p),'Outside-window contamination' | |
| for k in ['distributed','language']: | |
| for n in [64,32,16,8]: | |
| idx=montage(names,n,k);assert len(idx)==n and len(set(idx))==n and min(idx)>=0 and max(idx)<64 | |
| assert preprocess(x[:2],idx).shape==(2,n,400) | |
| try:cached(1,'test') | |
| except PermissionError:pass | |
| else:raise AssertionError('Test gate failed') | |
| assert np.isfinite(p).all() | |
| # CAR commutes with independent linear filtering to numerical tolerance. | |
| assert abs(p.mean(1)).max()<1e-4 | |
| json.dump({'strict_crop':True,'test_gate':True,'montages':True,'finite_signals':True,'shape':[2,64,400]},open('reports/pipeline_tests.json','w'),indent=2) | |
| print('Pipeline checks passed') | |