# Data schema

All web data is plain JSON, either as a `window.*` global (loaded via `<script>`) or as
a lazy-fetched `.json` file. Values are numeric derived features; `null` denotes
"not available / not comparable" (e.g. amplitude markers for ADHD-200).

## `clinic/clinic_data.js` → `window.ASD_CLINIC`

Single bundle that drives the 1-page summary for all 1257 subjects.
(`clinic/clinic_matched.js` → `window.ASD_MATCHED` holds the age/sex-matched reference.)

| Key | Type | Meaning |
|---|---|---|
| `meta` | object | model card: atlas, cohort, AUC, version |
| `subjects` | object[] | per-subject records (id, site, dx, score, percentile, net7 deviations, nodal values) |
| `mesh`, `coords` | object | brain geometry + ROI coordinates for the surface/connectome panels |
| `net_names`, `roi_net` | array | 7-network labels and per-ROI network assignment |
| `standards`, `group_net7`, `group_nodal` | object | Normal/ASD group reference means (same colorscale as the subject) |
| `score_dist`, `centile_ref` | object | score distribution + age/sex centile reference curves |
| `reliability`, `subgroup_auc` | object | reliability notes + per-subgroup AUC |
| `references_html` | string | literature references block |

## `braintwin/data/braintwin_data.js` → `window.BT_DATA`

Inlined artifacts so the SPA runs offline. Keys:

| Key | Meaning |
|---|---|
| `meta` | model card: `dataset {name, pipeline:"C-PAC", atlas:"CC200", n_roi:200}`, `cohort {n:937, asd:424, td:513, sites:20, qc}`, `validation {loso_auc:0.6261, cv_auc, per_site_auc{...}}`, `evidence_legend {A..D, Unavailable}`, `marker_registry {available[], unavailable[]}` |
| `reference` | `td_median_fc`, `asd_median_fc`, `asd_delta_fc`, `subtypes`, `marker_meta`, `likeness_coef` — the reference space a subject is projected into |
| `subjects` | object[] — **16 curated** subjects, fully inlined (no fetch needed) |
| `conditioned` | normative model: `loso_auc:0.6374`, `knots_td_fmri`, `trajectories` (age/sex norms) |
| `sensitivity`, `dynamic` | leave-one-out sensitivity + dynamic-FC summaries |
| `surface_mesh`, `pial_mesh` | cortical surface geometry for the 3D / surface tabs |

## `braintwin/data/subject_index.js` → `window.BT_INDEX`

Light list (this repo: **40** entries) that populates the browse sidebar. Heavy detail
is lazy-fetched per subject. Each entry:

```jsonc
{
  "subject_id": "50772",
  "cohort": "ABIDE",            // "ABIDE" | "ADHD-200"
  "qc_tier": "strict",         // "strict" | "relaxed"
  "site": "NYU",
  "dx": "ASD",                  // "ASD" | "Normal"
  "asd_likeness": { "index": 0.61, ... }   // sort key for the browse list
}
```

## `braintwin/data/subjects/<id>.json` (lazy)

Heavy per-subject record fetched on demand when a non-curated subject is opened
(this repo: **24** files). Holds the subject's functional-connectivity vector, per-ROI
deviation z-scores, marker values, per-subject normative-trajectory points, and the
decision-support inputs the SPA needs to render every tab. `null` fields mean the
marker is not available/comparable for that subject's cohort.

## `braintwin/data/dss_data.js` → `window.BT_DSS`

Decision-support pack: conformal quantiles, continuum bins, and behavior-anchor copy
used to synthesize the verdict band and "recommended next step" for any subject.

## Conventions

- **Color semantics (load-bearing):** warm/red `#DC2626` = ASD-leaning (excess/high),
  cool/blue `#1D4ED8` = Normal-leaning (deficit/low). Never repurpose these fills.
- **z-scores** are relative to the strict-QC Normal reference.
- **Evidence levels** A (replicated/external) → D (exploratory/simulation), plus
  `Unavailable` (not derivable in the ABIDE I-only build, e.g. all DTI markers).
