Metadata-Version: 2.4
Name: mm-neuro
Version: 0.1.1
Summary: Lightweight, config-driven evaluation harness for neuroimaging phenotype prediction
Author: Sheethal Bhat
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/sheethalb/mmneuro
Project-URL: Repository, https://github.com/sheethalb/mmneuro
Project-URL: Citation, https://github.com/sheethalb/mmneuro/blob/main/CITATION.cff
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: scipy
Requires-Dist: scikit-learn
Requires-Dist: pyyaml
Requires-Dist: matplotlib
Provides-Extra: combat
Requires-Dist: neuroCombat; extra == "combat"
Provides-Extra: graph
Requires-Dist: networkx; extra == "graph"
Provides-Extra: neural
Requires-Dist: torch; extra == "neural"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# mm-neuro

A lightweight, config-driven evaluation harness for neuroimaging phenotype prediction.

One YAML file per experiment names every part by `type`: dataset, harmonizer, feature extractors,
model, task and protocol. The same file also sets the output, log and figure folders. Each part
sits behind a small interface, so any one of them can be replaced by writing one class. The runner
enforces leakage safety: harmonizers and group-fitted features are estimated on each split's
training subjects only.

## Install

Into an existing environment that has numpy, pandas, scipy, scikit-learn, pyyaml and matplotlib
(plus `neuroCombat` for ComBat):

    pip install --no-deps --no-build-isolation -e .

## Use

    mm-neuro list                       # every registered part, figure and stat
    mm-neuro check configs/examples/adni_cpm_kfold_stratified.yaml   # build parts, load first split
    mm-neuro run   configs/examples/adni_cpm_kfold_stratified.yaml
    mm-neuro stratify work_dirs/<run> --by age --bins 0 65 75 120 --covariates demographics.csv

On a cluster, run these through the batch system; the login node is for editing and reading
results.

## An experiment config

```yaml
dataset:    {file: configs/datasets/adni_full.yaml}          # paths, columns, tables
harmonizer: {type: combat, batch_column: tr, batch_rule: tr_group, protected: [diagnosis]}
features:   []                                                # optional extractors
model:      {type: cpm, p_thresh: 0.01}
task:       {type: regression, targets: [mmse_mmscore, adas_total13]}
protocol:   {type: kfold, splits: "splits/split_cv_fold{fold}.csv"}
stratify:   [{column: protocol_field_strength, bins: [0, 2.0, 10], labels: ["1.5T", "3T"]}]
stats:      [bootstrap_ci]
figures:    [group_metrics, pred_vs_true, strata]
output_dir: work_dirs/cpm_adni_kfold     # log_dir and fig_dir default to logs/ and figures/ inside
```

Relative paths resolve against this project's root. Paths inside a dataset (manifests, split files
and per-subject files) resolve against the dataset's `path_root`.

## What a run writes

| File | Contents |
|---|---|
| `config.yaml` | the configuration as run |
| `predictions.csv` | one row per test prediction (target, group, split, subject, y_true, y_pred, stratify columns) |
| `per_group_metrics.csv` | task metrics per group: a fold, a site, a power-curve draw, or the pooled leave-one-out set |
| `summary.json` | per target: mean, `sd_pop`, `sd_sample` and n of every metric; stats; strata; git commit |
| `stratified_metrics.csv` | when `stratify:` is set: metrics per (column, target, stratum) |
| `logs/run.log`, `figures/*.pdf` and `*.png` | log and configured figures |

## Parts available

| Part | Implementations |
|---|---|
| dataset | `manifest`: a features CSV listing one `.npy` vector per subject, plus target and covariate tables |
| harmonizer | `none`, `combat` (batch rules `tr_group`, `tr_group_merged`) |
| model | `cpm`, `cpm_faithful`, `plsr`, `plsr_faithful`, `svr`, `gica_llsr`, `curvature`, `ridge`, `logistic` |
| task | `regression`, `classification` |
| protocol | `kfold` (versioned split files), `loocv`, `loso`, `power_curve` |
| figures | `group_metrics`, `pred_vs_true`, `strata`, `level_curve` |
| stats | `bootstrap_ci`, `permutation_pearson` (pooled out-of-fold predictions; 10,000 resamples by default) |

To add a part, see `docs/adding_a_component.md`.

## Reproducing the rsfmri benchmark paper

`sbatch tools/run_anchors.sh` reruns the paper's numbers through mm-neuro and compares each one
with its published value:
- CPM, PLSR, SVR and Ricci 5-fold;
- faithful CPM leave-one-out;
- ABIDE leave-one-site-out regression and diagnosis;
- in-fold ComBat against the stored harmonized features.

Every check must print `ok`. Run it after any change to the core.

## Citation

If you use mm-neuro in your research, please cite:

```bibtex
@software{bhat_mmneuro_2026,
  author  = {Bhat, Sheethal},
  title   = {mm-neuro},
  year    = {2026},
  version = {0.1.1},
  url     = {https://github.com/sheethalb/mmneuro}
}
```

A paper describing mm-neuro is in preparation.

## License

Apache-2.0. See `LICENSE` and `NOTICE`. Copyright 2026 Sheethal Bhat, Pattern Recognition Lab, FAU Erlangen-Nürnberg.
