Methods

How Cortex works.

A condensed overview of training data, architecture, evaluation, and appropriate use. Read before applying to your own cohort.

1. Training data

Combined ABIDE I + ABIDE II cohort. 1,545 subjects (693 autistic, 852 typically developing) from 36 clinical research sites spanning North America, Europe, and Asia. Ages 5.6–64 years. Sex distribution: ~91% male (known ABIDE limitation; generalization to female cohorts requires caution).

fMRI preprocessing: standard CPAC pipeline (bandpass 0.01–0.1 Hz, detrending, z-scoring, global signal regression disabled). Connectivity extracted via Schaefer 100-parcel atlas. 4,950-dim upper triangle of ROI-to-ROI Fisher-z transformed correlation matrix.

Site harmonization via residualization against site dummy variables. Retains within-site age/sex variance, removes between-site offsets.

2. Architecture

Cortex is a 227M-parameter transformer encoder with three joint heads for multi-task learning:

  • Classifier head: 256 → 128 → 1, binary cross-entropy vs. ASD label
  • Subject encoder: 1024 → 512 → 256, produces interpretable embeddings for clustering
  • Reconstructor head: 256 → 1024 → 4950, MSE reconstruction of input connectivity (auxiliary regularizer + QC signal)

Backbone: 16 × TransformerEncoderLayer with pre-LayerNorm, GELU activation, dropout 0.3, 16 attention heads, d_model=1024. Input (4950-dim) projected to single token then expanded to 32 × 1024 with learned positional embeddings.

3. Training

End-to-end joint training with separate learning rates: backbone at 5×10-6, heads at 5×10-4. AdamW optimizer, weight decay 10-4. Cosine-decay schedule with 5% warmup. Batch size 32. Trained to convergence on the best-val-acc checkpoint.

Joint loss: L = BCE(classifier, y) + 0.1 · MSE(reconstructor, x). The auxiliary MSE term was found to stabilize training on small cohorts and grants the reconstructor head credibility as a QC signal.

4. Evaluation

80/20 stratified split with fixed seed (random_state=42). Metrics computed on held-out 20% (309 subjects). Reported validation accuracy: ~63%. This is useful for research applications (cohort stratification, QC, hypothesis generation) but below diagnostic-grade thresholds.

Cortex is not intended for clinical diagnosis. ADOS-2 / ADI-R remain the clinical standard.

5. Appropriate use

  • Research cohort stratification. Use Cortex embeddings (256-dim) to cluster subjects into neural subtypes. Most principled when paired with behavioral phenotyping.
  • Dataset QC at scale. Reconstruction-error scores flag preprocessing artifacts, motion, and site-specific oddities across cohorts of thousands.
  • Biomarker hypothesis generation. Integrated gradients reveal ROI-pair importance patterns consistent with published autism connectivity literature. Candidates for targeted imaging studies, not standalone claims.

6. Inappropriate use

  • Individual clinical diagnosis (accuracy too low, false-positive/negative rates not suitable for clinical decisions)
  • Treatment recommendation (no therapy-outcome data in training)
  • Prediction of IQ, cognitive ability, or traits outside binary ASD/TD
  • Application to non-rs-fMRI modalities (EEG, MEG, structural MRI) without retraining

7. Reproducibility

Training code: neuro-app/train_cortex_v1.py. Model weights on HuggingFace Hub at Ibrahim9989/neurobrain-nd-transform/cortex_v1.pt. Training metrics at cortex_v1_metrics.json.

Source data: ABIDE I + II (publicly available, standard IRB-approved release). Preprocessing scripts: neuro-app/export_training_data.py.