Skip to content

About

Multiple sclerosis lesion segmentation from multimodal MRI, with inference code and five-fold development results on 93 scans from 53 patients.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

169 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphMS-Net

GraphMS-Net segments multiple sclerosis lesions from FLAIR, T1 and T2 MRI using a hybrid convolutional and graph neural network. The pipeline also derives lesion features for downstream disability-score and risk modeling.

Five-fold development cross-validation on 93 scans from 53 patients yielded a mean Dice score of 0.748. A separate single-case CUDA replay reproduced the stored segmentation voxel for voxel. Independent external validation remains pending.

Run the worked example in Colab · Evaluation protocol · Architecture

Development evaluation

GraphMS v3.5.1 Hybrid. Values are means and standard deviations across five development folds.

Segmentation metric Mean ± SD
Dice 0.748 ± 0.032
Intersection over union 0.611 ± 0.037
Sensitivity 0.746 ± 0.061
Specificity 0.99969 ± 0.00021
95th-percentile Hausdorff distance 8.64 ± 2.27 mm
Precision 0.778 ± 0.039
Lesion F1, any overlap 0.744 ± 0.030
Lesion F1, IoU ≥ 0.10 0.730 ± 0.033

The downstream Stage13 out-of-fold classification and regression evaluations yielded ROC-AUC 0.7475 and RMSE 1.6711, respectively. The evaluation notebook includes per-fold and per-scan results.

To reproduce the aggregate from the stored evaluation records:

python scripts/run_pipeline.py --mode evaluation-replay

Reproducibility notebook

Notebook source: notebooks/GraphMS_Evaluator_Colab.ipynb

The notebook runs with the bundled MSLesSeg_P10_T1 case. It verifies the FLAIR, T1 and T2 inputs, displays the stored cohort results, and downloads the matching development-fold weights from the assets-v1 release. It then segments the case and exports the predictions and verification records.

The research package also includes the individual scan and fold metrics, downstream classification and regression results, post-processing settings, and training records.

For an independent MRI case, set USE_BUNDLED_DEMO = False in the notebook and provide a co-registered FLAIR/T1/T2 NIfTI triplet. Cases outside the frozen development registry require an explicitly selected fold because no new-patient five-fold ensemble rule was validated.

Segmentation cohort evaluation

For qualitative and quantitative analysis of the finalized segmentation behavior, use the dedicated no-retraining notebook:

Open Segmentation Cohort Evaluation in Google Colab

It deterministically renders best/median/worst OOF cases as FLAIR | expert ground truth | frozen prediction | TP/FP/FN error map, adds a six-case qualitative diversity panel and an HD95-driven boundary-focused panel, then computes DSC/HD95 distributions, fold-wise DSC, lesion-burden quartiles, worst-case error direction, and a compact diagnostics bundle. The frozen 93-case record shows a residual low-lesion-burden / missed-lesion sensitivity weakness; see docs/SEGMENTATION_COHORT_DIAGNOSTICS.md. No model or Stage11 retuning is performed.

Stage-level implementation evidence is summarized in docs/STAGE_IMPLEMENTATION_MATRIX.md, including the same-cohort CNN/CATMIL/GAT/Hybrid comparison, morphology disposition, and the complete 16-stage implementation matrix. This adds no retraining or scientific-result changes. The final evaluation also reports Stage16 segmentation precision and lesion-level F1 (any-overlap and IoU≥0.10 component matching) from the same finalized 93-case masks.

Scientific configuration

Component Frozen specification
Final segmentation system GraphMS v3.5.1 Hybrid
Protocol SHA 8944f1a0deef8a7d0eb57118b4b45e3eed0bc803a2c0e93d63d9c9eaba6578a3
Stage5/6 runtime implementation v6-stage56-hardened-provenance-reuse-validate-20260919
Stage7 implementation v3.4.1-gat-fp32-dice-bce-adamw-cosine-baseline-preserving-selection
Hybrid fusion implementation v3.5-concat-se-self-multiscale-dice-bce-adamw-cosine-250iter
Final Stage11 cross-fitted Stage11-v1; 26-connectivity; no morphology
Stage13 classifier MRI_SPATIAL_SVM, C=30, mri_spatial
Stage13 regressor MRI_SPATIAL_RIDGE, alpha=30, mri_spatial
Stage14 status IMPLEMENTED_EVALUATED_AUXILIARY_NOT_PROMOTED
Scientific claim scope development five-fold cross-validation

Final inference architecture

The patient-level runtime executes the selected finalized path:

FLAIR + T1 + T2
    ↓
input and geometry validation
    ↓
frozen nnU-Net preprocessing
    ↓
ResEncM-250 CNN
    ↓
Stage5/6 graph-feature construction
    ↓
Stage7 TrueGAT
    ↓
CNN + GNN concatenation
    ↓
SE + self-attention + multi-scale hybrid fusion
    ↓
transposed-convolution decoder + CNN-logit skip
    ↓
1×1×1 lesion head
    ↓
cross-fitted Stage11-v1
    ↓
final lesion mask in input FLAIR geometry
    ↓
canonical Stage12 v2.1 lesion/MRI-spatial features
    ↓
frozen Stage13 SVM/Ridge
    ↓
NIfTI + CSV + JSON + overlay + HTML report + provenance

Detailed module-to-implementation correspondence is provided in ARCHITECTURE_AND_REPRODUCIBILITY.md.

Patient-level inference

After installing the inference environment and confirming a CUDA-capable runtime:

python run_graphms.py \
  --case-id PATIENT_ID \
  --flair /path/to/FLAIR.nii.gz \
  --t1 /path/to/T1.nii.gz \
  --t2 /path/to/T2.nii.gz \
  --fold 0 \
  --output outputs/PATIENT_ID

For a known development case, omit --fold; the held-out fold is resolved from the frozen registry. For a case outside that registry, an explicit fold 0..4 is required. Such a run is labeled as a selected-fold research run and does not constitute external validation.

On first use, run_graphms.py automatically retrieves the required frozen ResEncM-250, GAT, and Hybrid checkpoints together with the nnU-Net metadata from the public assets-v1 release. Asset size and SHA-256 identity are verified before the files are admitted into pretrained/assets.lock.json.

A successful execution generates:

Output Description
lesion_probability.nii.gz voxelwise lesion probability volume
lesion_mask.nii.gz final binary lesion segmentation in input FLAIR geometry
features.csv canonical Stage12 feature table
lesions.csv lesion-component measurements
risk.json frozen Stage13 research outputs
overlay.png segmentation visualization
patient_report.html consolidated patient-level research report
provenance.json input, asset, execution, and output provenance
COMPLETE.json explicit successful-run completion record

Reproducibility and verification evidence

The repository includes several distinct forms of implementation evidence.

Evidence Status Scope
Versioned manifests and Stage12–16 verification records PASS repository/package integrity
CPU source-parity and inference-contract tests PASS implementation contracts and frozen primitive parity
Stage13 local inference smoke test PASS committed SVM/Ridge runtime
MSLesSeg_P10_T1 CUDA end-to-end replay PASS one development case, held-out fold 0
Exact final-mask comparison for MSLesSeg_P10_T1 PASS matching geometry; 0 mismatched voxels
Fresh-clone public-release execution without original model Drive PASS packaging/runtime reproducibility

Committed verification records:

These records demonstrate implementation and packaging reproducibility. They do not extend the scientific claim beyond development five-fold cross-validation.

Local verification

Repository-level verification:

python -m pip install -r requirements-verify.txt
python scripts/run_pipeline.py --mode verify

CUDA inference-runtime verification:

python -m pip install -r requirements-inference.txt
python scripts/check_neural_runtime.py

The verified neural environment used PyTorch 2.8.0 with CUDA 12.6 and nnunetv2==2.8.1. The full mixed-precision 3-D neural path requires CUDA; package verification and Stage16 aggregate replay remain CPU-capable.

Demonstration MRI data

The zero-upload Colab workflow uses only the three MRI volumes required for the MSLesSeg_P10_T1 reproducibility demonstration. No ground-truth lesion mask, EDSS record, or additional patient metadata is bundled.

Source:

Francesco Guarnera, Alessia Rondinella, Elena Crispino et al., MSLesSeg: baseline and benchmarking of a new Multiple Sclerosis Lesion Segmentation dataset, Scientific Data 12, 920 (2025), DOI: 10.1038/s41597-025-05250-y. Dataset record: 10.6084/m9.figshare.27919209.

MSLesSeg is distributed under CC BY 4.0. Attribution and reconstruction details are documented in demo_inputs/README.md. The demonstration files are verified by SHA-256 before use.

Repository structure

GraphMS-Net/
├── graphms/                  frozen runtime implementation
├── config/                   protocol and asset registries
├── results/                  frozen Stage12-16 research artifacts
├── evidence/acceptance/      committed reproducibility verification records
├── pretrained/               local verified asset layout
├── demo_inputs/              attributed reproducibility MRI triplet
├── notebooks/                Colab reproducibility notebook
├── scripts/                  verification, replay, asset, and inference utilities
├── tests/                    frozen source-parity and inference-contract tests
├── run_graphms.py            patient-level inference entry point
├── ARCHITECTURE_AND_REPRODUCIBILITY.md  frozen architecture and implementation map
└── docs/EVALUATOR_RUN.md     detailed execution protocol

Scope and limitations

GraphMS-Net is a research reproducibility package. The current repository should be interpreted under the following constraints:

  1. Reported segmentation performance is based on development five-fold cross-validation, not untouched external validation.
  2. The one-case CUDA replay is an implementation/reproducibility check; it is not an all-fold validation study.
  3. The Stage14 true multi-task branch was implemented and evaluated but was not promoted into the final segmentation system.
  4. Stage13 uses frozen classical SVM/Ridge models; neural training settings do not describe those downstream estimators.
  5. No unvalidated five-fold ensemble rule is introduced for a new patient. External cases require an explicitly selected fold and remain research runs.
  6. The repository and generated outputs are intended for research and reproducibility, not clinical diagnosis or treatment decision-making.

Documentation

For implementation-level detail, see:

About

Multiple sclerosis lesion segmentation from multimodal MRI, with inference code and five-fold development results on 93 scans from 53 patients.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages