medsci-skills 5.16.0 → 5.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/README.md +7 -4
  2. package/metadata/distribution_files.json +70 -10
  3. package/metadata/distribution_manifest.json +2 -1
  4. package/metadata/skills_catalog.json +12 -2
  5. package/package.json +1 -1
  6. package/skills/architecture-zoo/SKILL.md +6 -3
  7. package/skills/architecture-zoo/references/graph.md +110 -0
  8. package/skills/architecture-zoo/references/index.md +5 -1
  9. package/skills/architecture-zoo/skill.yml +1 -1
  10. package/skills/model-scaffold/SKILL.md +4 -1
  11. package/skills/model-scaffold/references/mlops_guide.md +77 -0
  12. package/skills/model-scaffold/references/training_guide.md +3 -1
  13. package/skills/uncertainty-imaging/SKILL.md +133 -0
  14. package/skills/uncertainty-imaging/references/uncertainty_guide.md +93 -0
  15. package/skills/uncertainty-imaging/scripts/check_uncertainty_reporting.py +261 -0
  16. package/skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/expected/strong.txt +9 -0
  17. package/skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/expected/weak.txt +11 -0
  18. package/skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/fixture/uncertainty_strong.json +12 -0
  19. package/skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/fixture/uncertainty_weak.json +9 -0
  20. package/skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/problem.md +38 -0
  21. package/skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/verify.sh +38 -0
  22. package/skills/uncertainty-imaging/skill.yml +47 -0
  23. package/skills/uncertainty-imaging/tests/test_uncertainty_reporting.sh +80 -0
package/README.md CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  # MedSci Skills
4
4
 
5
- **54 skills that actually work.** Built by a physician-researcher, tested on real publications.
5
+ **55 skills that actually work.** Built by a physician-researcher, tested on real publications.
6
6
 
7
7
  *MedSci Skills is an end-to-end research tool for physician and medical-engineering researchers — design → scaffold → validate → publish — for the clinical manuscript and the medical-AI model behind it. Its moat is the compliance layer — 44 reporting guidelines and risk-of-bias tools, reference/citation verification, and deterministic integrity gates before peer review — now extended by a model-engineering lane that scaffolds reproducible, leakage-safe training repos and audits model validation. Clinical AI model research engineering is in scope; a general AI-scientist platform is not. It competes on clinical submission reliability, not skill count.*
8
8
 
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
10
10
  [![Release](https://img.shields.io/github/v/release/Aperivue/medsci-skills?style=flat-square&color=blue)](https://github.com/Aperivue/medsci-skills/releases/latest)
11
11
  [![CI](https://img.shields.io/github/actions/workflow/status/Aperivue/medsci-skills/validate.yml?branch=main&style=flat-square&label=CI)](https://github.com/Aperivue/medsci-skills/actions/workflows/validate.yml)
12
- ![Skills](https://img.shields.io/badge/Skills-54-brightgreen?style=flat-square)
12
+ ![Skills](https://img.shields.io/badge/Skills-55-brightgreen?style=flat-square)
13
13
  [![npm](https://img.shields.io/npm/v/medsci-skills?style=flat-square&label=npm&color=cb3837)](https://www.npmjs.com/package/medsci-skills)
14
14
  [![Watch the 2-min intro](https://img.shields.io/badge/▶_Watch-2--min_intro-FF0000?style=flat-square&logo=youtube&logoColor=white)](https://youtu.be/MclQ_RIofpE)
15
15
  [![good first issues](https://img.shields.io/github/issues/Aperivue/medsci-skills/good%20first%20issue?style=flat-square&label=good%20first%20issues&color=7057ff)](https://github.com/Aperivue/medsci-skills/contribute)
@@ -285,6 +285,8 @@ The E2E pipeline (`orchestrate --e2e`) produces everything up to `qc/`. The `sub
285
285
 
286
286
  ## What's New
287
287
 
288
+ **v5.17** — model-engineering produce-side depth, **completion**. Deployment safety + the final roadmap/candidate items: a new **`uncertainty-imaging`** skill + `check_uncertainty_reporting` gate (calibrated per-case uncertainty / OOD guard on a held-out set / abstention at a pre-specified target / calibration-under-shift — for a deployment-framed model), an **MLOps wiring reference** for `model-scaffold` (experiment tracking, config/data/environment versioning, CI-for-ML — pointing to W&B / MLflow / nnU-Net, reimplementing nothing), and an **`architecture-zoo` graph-neural-net family card** (GCN / GraphSAGE / GAT / GIN / BrainGNN for brain connectomes) that closes the last candidate gap. The six-item produce-side depth roadmap and its candidate list are now complete. Additive and backward-compatible; **55 skills / 44 guidelines / 50 integrity detectors / 22 domain-probe modules**. (See the [CHANGELOG](CHANGELOG.md) for v5.0–v5.16.)
289
+
288
290
  **v5.16** — model-engineering produce-side depth, clinical fine-tuning focus (Items 3–4 of the [produce-side depth roadmap](docs/roadmap_model_engineering_depth.md)). A new **`radiomics-ml`** skill + `check_radiomics_ml` gate for the most common solo-doable clinical-ML workflow — radiomics / tabular features → any classical learner (LASSO / SVM / random forest / XGBoost / …) → a clinical outcome, no GPU — with a learner-agnostic nested-CV / calibration / stability gate; plus a **`model-scaffold` fine-tuning mode** (`--task finetune` + `--from-pretrained`) that adapts a pretrained backbone on collected clinical data with a frozen→unfrozen schedule, discriminative learning rates, and a pretrained-weight provenance record (`PRETRAINED.md` + a `PRETRAINED_PROVENANCE_MISSING` verdict on the existing `check_training_hygiene`, plus a MedSAM-adaptation + train-only diffusion-augmentation guide). Additive and backward-compatible; **54 skills / 44 guidelines / 49 integrity detectors / 22 domain-probe modules**. (See the [CHANGELOG](CHANGELOG.md) for v5.0–v5.15.)
289
291
 
290
292
  **v5.15** — model-engineering produce-side depth. Two new skills that *produce* what the review lane previously only audited: **`preprocess-imaging`** (DICOM/NIfTI data prep + a `check_preprocessing_leakage` gate that extends the split-leakage moat upstream to the data stage) and **`explainability`** (Grad-CAM / saliency held to the reviewer bar — Adebayo sanity checks, quantitative localisation vs ground truth, attribution-not-validation framing, via `check_explainability_report`). Plus a by-stage skill index, multi-host README/About (Claude Code · Codex · Cursor · Copilot), copy-paste citation ergonomics, and a real-project precision fix. Additive and backward-compatible; **53 skills / 44 guidelines / 48 integrity detectors / 22 domain-probe modules**. (See the [CHANGELOG](CHANGELOG.md) for v5.0–v5.14.)
@@ -455,14 +457,14 @@ ma-scout -> search-lit -> fulltext-retrieval -> design-study ──> write-proto
455
457
 
456
458
  ### By research stage
457
459
 
458
- All 54 skills, grouped by where they fit in the clinical-manuscript and medical-AI lifecycle. Full descriptions are in the table below; one page per skill lives in the [per-skill reference](docs/skills/).
460
+ All 55 skills, grouped by where they fit in the clinical-manuscript and medical-AI lifecycle. Full descriptions are in the table below; one page per skill lives in the [per-skill reference](docs/skills/).
459
461
 
460
462
  | Stage | Skills |
461
463
  |-------|--------|
462
464
  | 🔭 **Discover & scope** | `ma-scout` · `find-cohort-gap` · `search-lit` · `fulltext-retrieval` · `lit-sync` · `author-strategy` |
463
465
  | 📐 **Design & plan** | `design-study` · `calc-sample-size` · `define-variables` · `write-protocol` · `fill-protocol` · `design-ai-benchmarking` |
464
466
  | 🧹 **Data & analysis** | `deidentify` · `clean-data` · `generate-codebook` · `version-dataset` · `analyze-stats` · `batch-cohort` · `cross-national` · `replicate-study` |
465
- | 🤖 **Medical-AI model engineering** | `preprocess-imaging` · `architecture-zoo` · `model-scaffold` · `model-validation` · `model-evaluation` · `explainability` · `radiomics-ml` · `model-card` · `mllm-eval` |
467
+ | 🤖 **Medical-AI model engineering** | `preprocess-imaging` · `architecture-zoo` · `model-scaffold` · `model-validation` · `model-evaluation` · `uncertainty-imaging` · `explainability` · `radiomics-ml` · `model-card` · `mllm-eval` |
466
468
  | ✍️ **Write & visualize** | `write-paper` · `make-figures` · `review-paper` · `present-paper` · `humanize` · `polish-language` · `academic-aio` |
467
469
  | ✅ **Comply & verify** | `check-reporting` · `self-review` · `verify-refs` · `manage-refs` |
468
470
  | 📤 **Submit & respond** | `find-journal` · `add-journal` · `sync-submission` · `revise` · `peer-review` · `fill-icmje-coi` |
@@ -491,6 +493,7 @@ All 54 skills, grouped by where they fit in the clinical-manuscript and medical-
491
493
  | **model-evaluation** | Compute and report task-correct held-out metrics for a trained medical-imaging model — segmentation (Dice + a boundary metric HD95/NSD, per structure), classification (AUROC + AUPRC + sensitivity/specificity with bootstrap CIs at the deployment prevalence), or detection (FROC/mAP with a stated IoU criterion) — plus calibration and subgroup slices. Emits a per-case table for analyze-stats and gates the metric choice against Metrics Reloaded / CLAIM 2024 (`check_metric_reporting`). Numbers come only from executed code. |
492
494
  | **explainability** | Produce or audit the interpretability/explainability analysis of a medical-imaging model — Grad-CAM / Grad-CAM++ / attention-rollout / saliency / integrated-gradients — so it clears the rigor bar: mandatory Adebayo sanity checks (model- and data-randomisation), a quantitative localisation metric against ground truth (IoU / pointing game / Dice) instead of eyeballed examples, a cohort-level result, and attribution framing rather than "proof the model is correct". Emits an explainability-report manifest + a deterministic gate (`check_explainability_report`): `SALIENCY_AS_VALIDATION`, `NO_SANITY_CHECK`, `NO_LOCALIZATION_METRIC` (Major); `INSUFFICIENT_SANITY`, `CHERRY_PICKED_EXAMPLES`, `MISSING_METHOD` (Minor). Integrates captum / pytorch-grad-cam; never reimplements them or touches real patient data. |
493
495
  | **radiomics-ml** | Produce or audit a radiomics / tabular clinical-ML study — features → random forest / XGBoost / regularised logistic → clinical outcome — the most common solo-doable clinical-ML workflow (no GPU, no engineer). Emits a pipeline manifest + a deterministic rigor gate (`check_radiomics_ml`): `NO_NESTED_CV`, `HIGH_DIM_LOW_EVENTS`, `SELECTION_OUTSIDE_CV` (Major); `NO_FEATURE_STABILITY`, `NO_CALIBRATION`, `NO_EXTERNAL_VALIDATION` (Minor). pyradiomics/IBSI settings, nested CV with in-fold selection, ICC stability, SHAP, calibration + decision curve, CLEAR/TRIPOD+AI/PROBAST-AI reporting. Integrates scikit-learn / xgboost / pyradiomics; never reimplements them. |
496
+ | **uncertainty-imaging** | Design or audit the uncertainty / out-of-distribution / selective-prediction layer of a deployment-framed medical-imaging model — so a clinical-use claim carries calibrated per-case uncertainty (MC-dropout / deep ensemble / conformal / Bayesian), an OOD guard validated on a held-out OOD set, an abstention rule at a pre-specified operating point, and calibration checked under distribution shift. Emits an uncertainty manifest + a deterministic gate (`check_uncertainty_reporting`): `POINT_PREDICTION_NO_UNCERTAINTY`, `CONFORMAL_NO_COVERAGE_VALIDATION`, `OOD_NO_HELDOUT_SET` (Major); `ENSEMBLE_NOT_INDEPENDENT`, `MCDROPOUT_DISABLED_AT_INFERENCE`, `SELECTIVE_NO_TARGET`, `NO_CALIBRATION_UNDER_SHIFT` (Minor). Integrates MAPIE / captum / OOD scorers; never reimplements them or touches real patient data. |
494
497
  | **mllm-eval** | Model-agnostic evaluation harness (closed API or open weights) for an LLM/MLLM on a clinical task — radiology report generation, VQA, clinical text extraction — covering the adjudicated reference standard, clinical-efficacy metrics (RadGraph-F1 / CheXbert-F1 beyond BLEU/ROUGE), faithfulness/hallucination, pretraining-contamination, prompt sensitivity, and a reader study; gates the plan with `check_mllm_eval_completeness` and routes the reviewer audit to the MLLM probe. |
495
498
  | **intake-project** | Classifies new research projects, summarizes current state, identifies missing inputs, and recommends next steps. |
496
499
  | **grant-builder** | Structures grant proposals: significance, innovation, approach, milestones, and consortium roles. |
@@ -423,8 +423,8 @@
423
423
  },
424
424
  {
425
425
  "path": "skills/architecture-zoo/SKILL.md",
426
- "size": 5712,
427
- "sha256": "ffb9a52d417f309a3b22c8d0f74e6700b67350c0d7a2a2e2c785f0cb4cb066bc"
426
+ "size": 6094,
427
+ "sha256": "abb4656f36e0ef068508269ce2ec87c832b7c8fb13c4cbc44af27b2dc8058bff"
428
428
  },
429
429
  {
430
430
  "path": "skills/architecture-zoo/references/classification.md",
@@ -441,10 +441,15 @@
441
441
  "size": 5267,
442
442
  "sha256": "495453b025f1cb13d5ba0bac9be6d3b0d63dd958ea48d2b9e55bc222e9c26786"
443
443
  },
444
+ {
445
+ "path": "skills/architecture-zoo/references/graph.md",
446
+ "size": 6913,
447
+ "sha256": "d6bea2d61a2f1d515810d1bf96bef80f156d816998134a3c911e6c4585728c2e"
448
+ },
444
449
  {
445
450
  "path": "skills/architecture-zoo/references/index.md",
446
- "size": 4024,
447
- "sha256": "d2360eb8635347f0f22be0b0e337a540db865aafdc12678455cf32bc49fd9d3d"
451
+ "size": 4334,
452
+ "sha256": "f812ec9afe2ba06c42da8de851cea08632d61eb98e87cd3edd7cdd17f39e226e"
448
453
  },
449
454
  {
450
455
  "path": "skills/architecture-zoo/references/segmentation.md",
@@ -458,8 +463,8 @@
458
463
  },
459
464
  {
460
465
  "path": "skills/architecture-zoo/skill.yml",
461
- "size": 2836,
462
- "sha256": "7d7c727a9fc75383e775feac14faf1c4caad90307ed8ca20859ef499ac17deb0"
466
+ "size": 2851,
467
+ "sha256": "c9e03a47973bab737587d22ebac4cd7b27b5c5af55a271efb8f71abba7fa70cf"
463
468
  },
464
469
  {
465
470
  "path": "skills/author-strategy/SKILL.md",
@@ -2868,18 +2873,23 @@
2868
2873
  },
2869
2874
  {
2870
2875
  "path": "skills/model-scaffold/SKILL.md",
2871
- "size": 9237,
2872
- "sha256": "d7e736178cb60d2d13cef9174474297bd54bc6d4d1f3862023d802ff0c034a95"
2876
+ "size": 9527,
2877
+ "sha256": "8fcf4060f064a1924d4bec278e0c0c628c99caf6ea75f617f8b9748cbb207ed8"
2873
2878
  },
2874
2879
  {
2875
2880
  "path": "skills/model-scaffold/references/finetuning_guide.md",
2876
2881
  "size": 6208,
2877
2882
  "sha256": "b7817d53eeeb506b573beaae1889fa863dd81286d474ab99b46b38ad046b32e7"
2878
2883
  },
2884
+ {
2885
+ "path": "skills/model-scaffold/references/mlops_guide.md",
2886
+ "size": 5171,
2887
+ "sha256": "cc9b62ed588daf97b40b6d7a8e27f9b6de96b9f5752ad2baa8e180e01d3d4973"
2888
+ },
2879
2889
  {
2880
2890
  "path": "skills/model-scaffold/references/training_guide.md",
2881
- "size": 2661,
2882
- "sha256": "4a3197a89b8d3473071051f67a7bcf40f71ecf007e942f81e9c40dc48fce1a9c"
2891
+ "size": 2840,
2892
+ "sha256": "9a7f7b5dda65e71d8007cb6539cda0cfb9c6b1f2c877aedee4646f368686e96f"
2883
2893
  },
2884
2894
  {
2885
2895
  "path": "skills/model-scaffold/scripts/check_training_hygiene.py",
@@ -4031,6 +4041,56 @@
4031
4041
  "size": 1911,
4032
4042
  "sha256": "7f549269905cad97493d7699dad0068e410e8a8d771814988911bec5b0648d4c"
4033
4043
  },
4044
+ {
4045
+ "path": "skills/uncertainty-imaging/SKILL.md",
4046
+ "size": 8224,
4047
+ "sha256": "0ff26311b9b372a074751d9b64c5fc20ec7440aabe76fd17c3f2e09d54d4a080"
4048
+ },
4049
+ {
4050
+ "path": "skills/uncertainty-imaging/references/uncertainty_guide.md",
4051
+ "size": 5574,
4052
+ "sha256": "fb63c7b48b00fc371dca2ed1a7bdb9932b318ceba6334bae5097f4da3b08b38a"
4053
+ },
4054
+ {
4055
+ "path": "skills/uncertainty-imaging/scripts/check_uncertainty_reporting.py",
4056
+ "size": 13042,
4057
+ "sha256": "2f14f78da71254d82977c8edc9f8c32bcde2e6d6d8e9c971af8114219ce558b5"
4058
+ },
4059
+ {
4060
+ "path": "skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/expected/strong.txt",
4061
+ "size": 414,
4062
+ "sha256": "2d3f1cbeb88b00d1ef8968c276f17d276c152eafbf445d3879315bd727a16c61"
4063
+ },
4064
+ {
4065
+ "path": "skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/expected/weak.txt",
4066
+ "size": 1077,
4067
+ "sha256": "b37379da88b17881678d50534ad993823a9a7c3b96a9942ca45be21caed39aaf"
4068
+ },
4069
+ {
4070
+ "path": "skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/fixture/uncertainty_strong.json",
4071
+ "size": 323,
4072
+ "sha256": "39a64a9e327bf00151d3bb7e1394e7ba87c04ed0df6523256f22d55c127320bf"
4073
+ },
4074
+ {
4075
+ "path": "skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/fixture/uncertainty_weak.json",
4076
+ "size": 204,
4077
+ "sha256": "5748d22600c8f68485f3ab665c32eace4a4dfc827df7f98c1c09640d82f304c2"
4078
+ },
4079
+ {
4080
+ "path": "skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/problem.md",
4081
+ "size": 2460,
4082
+ "sha256": "fb3350f915b3b4a36a91718f93837f4331410d209f66fbd7e7d751fd35af4cc9"
4083
+ },
4084
+ {
4085
+ "path": "skills/uncertainty-imaging/scripts/check_uncertainty_reporting_challenge/verify.sh",
4086
+ "size": 2117,
4087
+ "sha256": "5ff542ed3c4b0a479a6c2f906cefbb75494cb1ca8118e121afaf45f07f31bb80"
4088
+ },
4089
+ {
4090
+ "path": "skills/uncertainty-imaging/skill.yml",
4091
+ "size": 3753,
4092
+ "sha256": "a229c56e3133db1ed616880f76903bbf825ee59591eb26534d4ddb172cf0945c"
4093
+ },
4034
4094
  {
4035
4095
  "path": "skills/verify-refs/SKILL.md",
4036
4096
  "size": 11846,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "version": "5.16.0",
3
+ "version": "5.17.0",
4
4
  "owned_skills": [
5
5
  "academic-aio",
6
6
  "add-journal",
@@ -52,6 +52,7 @@
52
52
  "self-review",
53
53
  "setup-medsci",
54
54
  "sync-submission",
55
+ "uncertainty-imaging",
55
56
  "verify-refs",
56
57
  "version-dataset",
57
58
  "write-paper",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "_comment": "AUTO-GENERATED by scripts/gen_skills_catalog_json.py from each skills/<slug>/SKILL.md + skill.yml. Machine-readable skill catalog (single source of truth) consumed by external surfaces such as the aperivue.com storefront to gate skill-list completeness. Do not hand-edit; CI gate: python3 scripts/gen_skills_catalog_json.py --check.",
3
- "skill_count": 54,
3
+ "skill_count": 55,
4
4
  "categories": [
5
5
  {
6
6
  "key": "literature_references",
@@ -39,7 +39,8 @@
39
39
  "model-scaffold",
40
40
  "model-validation",
41
41
  "preprocess-imaging",
42
- "radiomics-ml"
42
+ "radiomics-ml",
43
+ "uncertainty-imaging"
43
44
  ]
44
45
  },
45
46
  {
@@ -562,6 +563,15 @@
562
563
  "maturity": "official",
563
564
  "description": "Audit SSOT-to-submission drift and create journal submission manifests from canonical manuscript artifacts."
564
565
  },
566
+ {
567
+ "slug": "uncertainty-imaging",
568
+ "category": "model_engineering",
569
+ "category_label": "Model Engineering & Validation",
570
+ "layer": "D",
571
+ "owner_domain": "model_validation",
572
+ "maturity": "official",
573
+ "description": "Design or audit the uncertainty-quantification, out-of-distribution (OOD) detection, and selective-prediction layer of a medical-imaging model framed for deployment — so a clinical-use claim carries c…"
574
+ },
565
575
  {
566
576
  "slug": "verify-refs",
567
577
  "category": "literature_references",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "medsci-skills",
3
- "version": "5.16.0",
3
+ "version": "5.17.0",
4
4
  "description": "MedSci Skills — a medical/scientific research skill suite for AI coding agents (Claude Code, Codex, Cursor, Copilot). The npm package is a terminal-friendly installer shortcut; the canonical distribution remains the GitHub repository and the Claude Code plugin marketplace.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://github.com/Aperivue/medsci-skills#readme",
@@ -7,9 +7,10 @@ description: >
7
7
  when-to-use, a medical-imaging use, a reference implementation, the typical validation setup, and the
8
8
  matching model-scaffold template. Covers the foundational curriculum (ResNet, DenseNet, EfficientNet,
9
9
  ViT, Swin; U-Net, 3-D U-Net, Attention/Residual U-Net, nnU-Net, Mask R-CNN; SAM/MedSAM,
10
- TotalSegmentator, BiomedCLIP, DINO/MAE/SimCLR). It teaches archetypes and the task-to-architecture
11
- logic, not a live SOTA leaderboard.
12
- triggers: architecture zoo, which architecture, choose a model, model selection, ResNet vs ViT, U-Net vs nnU-Net, what backbone, foundation model for, transfer learning choice, MedSAM, TotalSegmentator, DINO, MAE, self-supervised, paper to architecture, reference implementation, when to use ViT, segmentation architecture, classification backbone
10
+ TotalSegmentator, BiomedCLIP, DINO/MAE/SimCLR; and graph neural nets GCN/GraphSAGE/GAT/GIN/BrainGNN —
11
+ for brain connectomes). It teaches archetypes and the task-to-architecture logic, not a live SOTA
12
+ leaderboard.
13
+ triggers: architecture zoo, which architecture, choose a model, model selection, ResNet vs ViT, U-Net vs nnU-Net, what backbone, foundation model for, transfer learning choice, MedSAM, TotalSegmentator, DINO, MAE, self-supervised, graph neural network, GNN, brain connectome, GCN, GAT, GraphSAGE, BrainGNN, population graph, paper to architecture, reference implementation, when to use ViT, segmentation architecture, classification backbone
13
14
  tools: Read, Write, Edit, Grep, Glob
14
15
  model: inherit
15
16
  ---
@@ -62,6 +63,8 @@ a family card.
62
63
  VAE / fastMRI reconstruction.
63
64
  - `${CLAUDE_SKILL_DIR}/references/foundation_models.md` — SAM / MedSAM / MedSAM2 / TotalSegmentator /
64
65
  SegVol / BiomedCLIP / DINO / MAE / SimCLR / MoCo.
66
+ - `${CLAUDE_SKILL_DIR}/references/graph.md` — GCN / GraphSAGE / GAT / GIN / BrainGNN for brain
67
+ connectomes & population graphs (integrate PyTorch Geometric / DGL; not scaffolded by model-scaffold).
65
68
  Each card gives the paper, core idea, when-to-use, medical-imaging use, reference implementation, and the
66
69
  **typical validation/experiment setup** for that architecture class.
67
70
 
@@ -0,0 +1,110 @@
1
+ # Graph neural networks — brain connectomes & population graphs (architecture-zoo)
2
+
3
+ For when the data is a **graph, not an image grid**: a brain **connectome** (nodes = ROIs /
4
+ parcels, edges = structural connectivity from DTI tractography or functional connectivity
5
+ from fMRI correlation), or a **population graph** (nodes = subjects, edges = phenotypic /
6
+ imaging similarity). The task is usually **graph-level classification** (diagnose a subject
7
+ from their connectome), **node-level** (flag abnormal ROIs, or classify subjects on a
8
+ population graph), or **link prediction** (connectivity changes).
9
+
10
+ This is a distinct family because a CNN/U-Net assumes a regular pixel grid; a connectome has
11
+ no grid — permuting the ROI order must not change the prediction, which is exactly the
12
+ symmetry a GNN respects. Each card: **paper → core idea → when to use → medical use →
13
+ reference impl → validation/experiment setup.**
14
+
15
+ ---
16
+
17
+ ## The general-purpose message-passing GNNs
18
+
19
+ ### GCN (graph convolutional network)
20
+ - **Paper**: Kipf & Welling, "Semi-Supervised Classification with Graph Convolutional
21
+ Networks", *ICLR* 2017.
22
+ - **Core idea**: each layer averages a node's features with its neighbours' (a first-order
23
+ spectral-graph approximation), stacking to widen the receptive field over the graph.
24
+ - **When to use**: the transparent baseline for any connectome / population-graph task — try
25
+ it before anything fancier.
26
+ - **Medical use**: connectome classification; **Parisot et al.** (*Medical Image Analysis*
27
+ 2018) put subjects on a **population graph** (phenotypic-similarity edges) for autism
28
+ (ABIDE) and Alzheimer's (ADNI) prediction — a semi-supervised node-classification framing.
29
+ - **Reference impl**: **PyTorch Geometric** (`GCNConv`) or **DGL**; do not reimplement.
30
+ - **Validation setup**: split at the **subject level** (a subject's graph — or, on a
31
+ population graph, a subject node's label — never spans train/test); with a small cohort,
32
+ report a **permutation test** and cross-validated CIs, not a single split.
33
+
34
+ ### GraphSAGE (inductive aggregation)
35
+ - **Paper**: Hamilton, Ying & Leskovec, "Inductive Representation Learning on Large Graphs",
36
+ *NeurIPS* 2017.
37
+ - **Core idea**: learn an **aggregator** over a sampled neighbourhood so the model generalises
38
+ to **unseen** nodes/graphs (inductive), unlike transductive GCN.
39
+ - **When to use**: a **new subject** must be classified without retraining (the realistic
40
+ clinical setting), or the graph is too large to process whole.
41
+ - **Medical use**: inductive connectome classification where test subjects are genuinely held
42
+ out (the honest deployment framing for a population-graph model).
43
+ - **Reference impl**: PyTorch Geometric (`SAGEConv`) / DGL.
44
+ - **Validation setup**: exploit the inductive setup to keep the test subjects fully out of
45
+ message passing during training (transductive leakage is a real trap on population graphs).
46
+
47
+ ### GAT (graph attention)
48
+ - **Paper**: Veličković et al., "Graph Attention Networks", *ICLR* 2018.
49
+ - **Core idea**: learn **attention weights** over neighbours, so the model decides which
50
+ connections matter instead of averaging uniformly.
51
+ - **When to use**: when *which edges/connections drive the prediction* is itself a finding
52
+ (edge importance is a built-in interpretability signal).
53
+ - **Medical use**: connectome studies that report the most-attended edges/ROIs as candidate
54
+ biomarkers.
55
+ - **Reference impl**: PyTorch Geometric (`GATConv` / `GATv2Conv`) / DGL.
56
+ - **Validation setup**: treat attention as a **hypothesis-generating** attribution, not proof
57
+ — sanity-check it (does it survive label permutation?) as `/explainability` requires of any
58
+ saliency.
59
+
60
+ ### GIN (graph isomorphism network)
61
+ - **Paper**: Xu et al., "How Powerful are Graph Neural Networks?", *ICLR* 2019.
62
+ - **Core idea**: an aggregation as discriminative as the Weisfeiler-Lehman test — the most
63
+ **expressive** simple GNN for **graph-level** classification.
64
+ - **When to use**: graph-level diagnosis where subtle topology differences separate classes
65
+ and GCN/GAT underfit.
66
+ - **Reference impl**: PyTorch Geometric (`GINConv`).
67
+ - **Validation setup**: expressiveness raises overfitting risk on small connectome cohorts —
68
+ pair with heavy regularisation and nested CV (as `/radiomics-ml` does for the p ≫ n regime).
69
+
70
+ ---
71
+
72
+ ## The brain-specific model
73
+
74
+ ### BrainGNN (ROI-aware, interpretable)
75
+ - **Paper**: Li et al., "BrainGNN: Interpretable Brain Graph Neural Network for fMRI Analysis",
76
+ *Medical Image Analysis* 2021.
77
+ - **Core idea**: ROI-aware convolution + a pooling layer that scores and selects the most
78
+ informative ROIs, so the model is **interpretable at the region level** by construction.
79
+ - **When to use**: fMRI connectome classification where you must report **which ROIs** drove
80
+ the decision (the usual neuroimaging reviewer demand).
81
+ - **Medical use**: task-fMRI / resting-state connectome diagnosis (ASD, disorders) with a
82
+ salient-ROI readout.
83
+ - **Reference impl**: the authors' released BrainGNN repo (on PyTorch Geometric).
84
+ - **Validation setup**: report salient ROIs with **stability across folds** (not one split);
85
+ keep site-harmonisation (**ComBat**) fit on the **training** fold only.
86
+
87
+ ---
88
+
89
+ ## Connectome-specific validation traps (read before publishing)
90
+ - **Subject-level split.** A subject's connectome must not appear in more than one split; on a
91
+ population graph, hold test-subject **labels** out of training and (ideally, inductive)
92
+ their **nodes** out of message passing. This is `/model-validation`'s split-leakage discipline
93
+ at the subject level.
94
+ - **Site / scanner harmonisation leakage.** Multi-site connectome data (ABIDE, ADNI) is
95
+ harmonised with **ComBat** — fit it on the **training** fold only, never the whole cohort
96
+ (the graph analogue of `/preprocess-imaging`'s `NORMALIZATION_LEAKAGE`).
97
+ - **p ≫ n.** A connectome has thousands of edges on tens–hundreds of subjects; treat it like
98
+ radiomics — nested CV, regularisation, a **permutation test** for tiny cohorts, and don't
99
+ over-read a single fold (`/radiomics-ml`).
100
+ - **Interpretability ≠ proof.** Attention / ROI-saliency is hypothesis-generating; sanity-check
101
+ it (`/explainability`).
102
+
103
+ ## Boundary — this family is not scaffolded by `/model-scaffold`
104
+ `/model-scaffold` builds **image-grid** repos (CNN / U-Net / transformer); it has **no graph
105
+ task template**. For GNNs, **integrate PyTorch Geometric / DGL directly** — they own the graph
106
+ layers, loaders, and training loop; the lane does not reimplement them. The lane's
107
+ **subject-level** gates still apply: `/model-validation` (split leakage), `/radiomics-ml`
108
+ (nested-CV rigor for p ≫ n), `/explainability` (attribution sanity), `/uncertainty-imaging`
109
+ (deployment uncertainty), and `/check-reporting` (TRIPOD+AI). Record the choice + paper in the
110
+ decision note; validate the built model with `/model-validation`.
@@ -14,12 +14,16 @@ per-paper detail and the `/model-scaffold` template to instantiate.
14
14
  | "I have few labels / want to pretrain on unlabelled scans" | **self-supervised pretraining → fine-tune** | `foundation_models.md` |
15
15
  | "adapt a released medical foundation model" | **transfer / prompt a foundation model** | `foundation_models.md` |
16
16
  | "synthesise / translate a modality" (MRI→CT, denoise) | **image-to-image / generative** | `synthesis.md` |
17
+ | "classify from a brain connectome / graph" (ROI connectivity, DTI/fMRI) | **graph neural network** | `graph.md` |
17
18
  | "generate a report / answer a visual question" | **multimodal LLM** | *(use `/mllm-eval`; not a CNN choice)* |
18
19
 
19
20
  ## Step 2 — let the constraints narrow it
20
21
  - **Modality / dimensionality**: 2-D (CXR, fundus, path tiles, single CT/MR slices) →
21
22
  2-D backbones / 2-D U-Net. 3-D volumes (CT, MR) → **3-D U-Net / SegResNet / nnU-Net**
22
- (3-D context matters; do not collapse to slices if the structure is volumetric).
23
+ (3-D context matters; do not collapse to slices if the structure is volumetric). A
24
+ **graph** (brain connectome, ROI-connectivity matrix — no pixel grid) → a **GNN**
25
+ (`graph.md`); integrate PyTorch Geometric / DGL directly (`/model-scaffold` has no graph
26
+ template).
23
27
  - **Labelled data scale** (events/structures, not just images):
24
28
  - **small** (hundreds) → a **pretrained** backbone fine-tuned (ImageNet / a medical
25
29
  foundation model), strong augmentation, heavy regularisation; prefer **nnU-Net**
@@ -29,7 +29,7 @@ safety_boundaries:
29
29
  - "Advisory only: it writes a decision note, never code or weights; the build is /model-scaffold."
30
30
  - "Every recommendation names its source paper; benchmark numbers are cited, never invented; the zoo describes archetypes, not a live leaderboard."
31
31
  known_limitations:
32
- - "The literature moves fast; this is a curated archetype map (classification, segmentation, detection, synthesis, foundation/SSL families), not an exhaustive or current SOTA ranking."
32
+ - "The literature moves fast; this is a curated archetype map (classification, segmentation, detection, synthesis, foundation/SSL, and graph/GNN families), not an exhaustive or current SOTA ranking."
33
33
  - "A sound architecture choice is necessary, not sufficient; validity still depends on the split, validation design, and metrics (/model-validation, /model-evaluation)."
34
34
  validation_commands:
35
35
  - "carry the decision note into /model-scaffold to instantiate the chosen template, then /model-validation"
@@ -100,7 +100,10 @@ adaptation and train-only diffusion augmentation). Run `python train.py` (best m
100
100
  ### Phase 5 — Validate, evaluate, publish
101
101
  Hand off to `/model-validation` (validation-tier + comparator + metric-selection audit),
102
102
  `/model-evaluation` + `/analyze-stats` (Dice + HD95/NSD with CIs), `/make-figures`, and `/write-paper`
103
- (fill the `methods_stub.md` `[VERIFY]` placeholders) + `/check-reporting` (CLAIM 2024 / TRIPOD+AI).
103
+ (fill the `methods_stub.md` `[VERIFY]` placeholders) + `/check-reporting` (CLAIM 2024 / TRIPOD+AI). For
104
+ reproducibility-safe wiring of experiment tracking (W&B / MLflow), config / data / environment
105
+ versioning, and the MLOps reporting checklist, see `${CLAUDE_SKILL_DIR}/references/mlops_guide.md`
106
+ (a wiring + reporting reference — it points to the frameworks, it does not replace them).
104
107
 
105
108
  ## Runnability — honest contract
106
109
  The generated repo is **runnable**, but runnability is **not a CI guarantee**. The default gates prove
@@ -0,0 +1,77 @@
1
+ # MLOps wiring guide (model-scaffold)
2
+
3
+ Load-on-demand notes for taking a scaffolded repo through a **reproducible, reportable**
4
+ training run. This is a **wiring and reporting** reference, **not** a training-loop,
5
+ hyperparameter-search, or experiment-tracking reimplementation. Training and tracking stay
6
+ with the frameworks — MONAI / nnU-Net / timm for the model, Weights & Biases / MLflow /
7
+ TensorBoard for tracking, DVC / git-lfs for data — and this guide covers how to wire them so
8
+ the run is reproducible and what to record so a reviewer can trust it. Everything here points
9
+ to a framework; nothing here replaces one (the [ROADMAP out-of-scope clause](../../../ROADMAP.md)).
10
+
11
+ ## The reproducibility contract (what a run must be able to reproduce)
12
+ A training run is reproducible when, from the recorded artifacts alone, someone else can
13
+ re-derive the same result. That needs five things pinned, all of which the scaffold already
14
+ emits a slot for:
15
+ 1. **Code** — the git commit of the repo (dirty trees are not reproducible; commit first).
16
+ 2. **Config** — `config.yaml` as the single source of truth (task, arch, channels, split
17
+ fractions, seed). Do not scatter hyperparameters across the CLI and the code.
18
+ 3. **Data** — a content hash of the exact dataset (see `/version-dataset`), not just a path.
19
+ 4. **Seed + determinism** — the scaffold's `seed_everything` seeds Python / NumPy / torch /
20
+ CUDA and sets cuDNN deterministic; record the seed in the tracker and `REPRODUCIBILITY.md`.
21
+ 5. **Environment** — a pinned `requirements.txt` (exact versions), CUDA / driver, GPU model.
22
+
23
+ ## Experiment tracking (integrate, don't build one)
24
+ Log to **W&B**, **MLflow**, or **TensorBoard** — pick one, do not write a tracker. At run
25
+ start, log the whole `config.yaml`, the git commit, the dataset hash, and the seed as the run
26
+ config; during training log per-epoch train/val loss + the val metric; at the end log the best
27
+ checkpoint as an artifact. The tracker's run URL / ID becomes part of the Methods record. Keep
28
+ the scaffold's contract intact — the best model is still selected on the **val** split, the
29
+ **test** split is still touched once by `evaluate.py`.
30
+
31
+ ## Config management
32
+ The emitted `config.yaml` is the SSOT for one run. For sweeps, drive them with **Hydra /
33
+ OmegaConf** (or the tracker's sweep feature) that *reads* this config — never hand-edit values
34
+ into `train.py`. A hyperparameter that isn't in the config isn't reproducible.
35
+
36
+ ## Data & model versioning
37
+ - **Data** — hash the training set with `/version-dataset` and record the manifest hash in the
38
+ run config, so "trained on dataset X" is verifiable, not asserted. For large data use **DVC**
39
+ or **git-lfs**; commit the pointer, not the pixels.
40
+ - **Model** — document the trained model with `/model-card` (Model Card + Datasheet); for a
41
+ fine-tune, the pretrained-weight provenance lives in `PRETRAINED.md`
42
+ (see `references/finetuning_guide.md`).
43
+
44
+ ## Environment capture
45
+ Pin `requirements.txt` to exact versions before publishing (`pip freeze`, or a `conda env
46
+ export`). For a hard reproducibility guarantee, a Dockerfile / container digest removes "works
47
+ on my machine". Record the CUDA / driver / GPU — some GPU ops are non-deterministic even with
48
+ cuDNN deterministic set, which is why metrics are reported as **mean ± SD over ≥ 3 seeds**, not
49
+ a single run.
50
+
51
+ ## Pipeline orchestration — use the framework's, not a new one
52
+ For segmentation, **nnU-Net** owns preprocessing → training → inference as a pipeline; build
53
+ its `dataset.json` folds from the scaffold's `splits/split_assignment.csv` so the patient-level
54
+ split is preserved end to end. **MONAI bundles** package a model + transforms + metadata the
55
+ same way. Orchestrate with the framework's own pipeline; do not rebuild one.
56
+
57
+ ## CI for an ML repo (what is worth gating)
58
+ CI should gate the **network-free, deterministic** properties — not full training. The scaffold
59
+ already ships these: `check_training_hygiene` (seeds, eval-mode inference, train-only loaders,
60
+ pretrained provenance) and the split-leakage proof (`/model-validation`). Add a **forward-pass
61
+ smoke** (build the model, one batch, check output shape) as a fast job. Do **not** put a real
62
+ training run in CI — it is slow, non-deterministic, and not what CI is for.
63
+
64
+ ## What to report (the MLOps reporting checklist)
65
+ State, in Methods or a reproducibility appendix: the **compute environment** (framework +
66
+ versions, CUDA / driver, GPU), the **seed(s)** and that metrics are mean ± SD over ≥ 3 seeds,
67
+ the **config** (as a supplement or a tracker link), the **dataset version** (`/version-dataset`
68
+ hash), and the **tracking run** URL / ID. This is the reproducibility half of TRIPOD+AI /
69
+ CLAIM 2024; `/check-reporting` covers the items.
70
+
71
+ ## Hand-offs
72
+ - Dataset hash / reproducibility-lock → `/version-dataset`.
73
+ - Model + dataset documentation → `/model-card`.
74
+ - Split / validation-design audit → `/model-validation`.
75
+ - Held-out metrics + CIs → `/model-evaluation` → `/analyze-stats`.
76
+ - Deployment uncertainty / OOD / monitoring → `/uncertainty-imaging`.
77
+ - Reporting fit → `/check-reporting` (TRIPOD+AI / CLAIM / DECIDE-AI).
@@ -34,7 +34,9 @@ with cuDNN deterministic set).
34
34
  Before publishing, complete `REPRODUCIBILITY.md`: pinned `requirements.txt`
35
35
  (torch/monai/... exact versions), CUDA/driver, GPU model, the git commit of the repo,
36
36
  and the seed. Pair with `/version-dataset` to hash the exact dataset the model trained
37
- on.
37
+ on. For reproducibility-safe wiring of experiment tracking (W&B / MLflow), config / data
38
+ / environment versioning, CI-for-ML, and the MLOps reporting checklist, see
39
+ `mlops_guide.md`.
38
40
 
39
41
  ## Hand-offs
40
42
  - Split / validation-design audit → `/model-validation` (run `check_split_leakage.py`