# GliomaSAM3-MoE (Minimal BraTS2023 3D Segmentation) This is a **minimal, fully runnable** BraTS2023 3D segmentation project with a complete `GliomaSAM3_MoE` model, synthetic data support, training, inference, and tests. ## Install ```bash pip install -r requirements.txt ``` ## Run tests ```bash pytest -q ``` ## Synthetic debug training (no real data required) ```bash python train.py --config configs/debug.yaml --synthetic true ``` ## Real BraTS data layout (expected) Each case is a folder under `data.root_dir`, containing: ``` case_id/ t1n.nii.gz t1c.nii.gz t2f.nii.gz t2w.nii.gz seg.nii.gz ``` Label values must be in `{0, 1, 2, 4}`. ## SegMamba preprocessed data (npz) If you use the SegMamba preprocessing pipeline, place `*.npz` under: ``` ./data/fullres/train ``` This project supports that format with `data.format: "segmamba_npz"` (already in configs). It will read `*.npz` and cached `*.npy` / `*_seg.npy`, and automatically map label `3 -> 4`. Recommended paths (aligned with SegMamba): - checkpoints: `./logs/segmamba/model` - predictions: `./prediction_results/segmamba` Example: ```bash python train.py --config configs/train.yaml python infer.py --config configs/train.yaml --input ./data/fullres/train --checkpoint ./logs/segmamba/model/ckpt_stepXXXX.pt --output ./prediction_results/segmamba ``` ## Inference ```bash python infer.py --config configs/train.yaml --input /path/to/case_or_root --checkpoint /path/to/ckpt.pt --output ./outputs ``` Outputs: - `*_regions_prob.nii.gz` : probability maps for [WT, TC, ET] - `*_regions_bin.nii.gz` : thresholded binary maps - `*_label.nii.gz` : final label map in `{0,1,2,4}` When `data.format: "segmamba_npz"`, `infer.py` also writes: - `{case_id}.nii.gz` : 3-channel (TC/WT/ET) mask for SegMamba `5_compute_metrics.py`