# Genesis EEG

Extends Nick Kouns' Genesis mobility benchmark (https://github.com/nicholaskouns-create/Genesis) to public motor-imagery EEG.
Local only: nothing here has been pushed to GitHub and no repo was created.

## Definitions (reused from Genesis, not reimplemented)
`Genesis_upstream/` is a read-only clone of the Genesis repo (HEAD 178e26c). `run_genesis.py` imports it directly:
- fractal intent signature: `genesis/fractal.py` (Higuchi, Katz, Petrosian, DFA per channel in mu 8-13 / beta 13-30 / broad 8-32 Hz, plus Grassberger-Procaccia D2)
- `OMEGA_C = 47/125 = 0.376`, `CoherenceProjection` (Fisher), `occupancy(x) = |Px|^2/|x|^2`, gate `occupancy >= 47/125`: `genesis/coherence.py`
- preprocessing as in `benchmark/run.py`: 8-32 Hz, 128 Hz; 5-fold stratified CV (random_state 47)
Occupancy is always out-of-fold (scaler and projection fitted on training trials only).

## Datasets
| key | source | how it is fetched |
|---|---|---|
| BNCI2014_001 | MOABB (BCI Competition IV 2a), left vs right hand | `moabb` (1.7.2 pulls it from NEMAR nm000139) |
| ds005342 | OpenNeuro ds005342 v1.0.3, sit-to-stand MI vs idle, CC0, 32 subjects, doi:10.18112/openneuro.ds005342.v1.0.3 | `openneuro-py`, one subject per call (~70 MB) |
| nm000309 | NEMAR nm000309 v1.0.1, PardoGarcia2026, chronic MCA stroke, pinch vs fist, CC-BY-4.0, doi:10.82901/nemar.nm000309 | annex pointer from github.com/nemarDatasets/nm000309, object from the public NEMAR S3 bucket, SHA-256 verified (~140-170 MB per recording) |
| synthetic | MOABB FakeDataset noise | SYNTHETIC, a chance baseline only |

## Run
```
python3 -m venv venv && venv/bin/pip install -r Genesis_upstream/requirements.txt matplotlib openneuro-py
venv/bin/python run_genesis.py --dataset BNCI2014_001 --subjects 1 2 3
venv/bin/python run_genesis.py --dataset ds005342 --subjects 1 2 3
venv/bin/python run_genesis.py --dataset nm000309 --subjects 1 11       # 1 = stroke, 11 = healthy control per README
venv/bin/python run_genesis.py --dataset synthetic
venv/bin/python run_genesis.py --aggregate                              # results.csv, summary.png, viz_data.json
```
Outputs: `results/results.csv`, `results/summary.png`, `results/viz_data.json` (full per-trial and per-channel data), `results/runs/*.json`.

## Caveat
Genesis' own ledger marks the claim that occupancy-gated trials decode better as FALSIFIED (E47-Kartekeya `ledger/FAILURE_LEDGER.md`, F-008: 0.603 vs 0.592, p=0.285). This extension reports occupancy and gate pass/fail as measurements; it does not claim gating improves decoding.

## Backlinks
- Public App Index: https://gem-sunny-beacon-mountain.grok.me/
- Instruments: https://nicholaskouns-create.github.io/instruments/
- E47 Identity: https://nicholaskouns-create.github.io/e47-identity/
- E47-Kartekeya: https://github.com/nicholaskouns-create/E47-Kartekeya
