File size: 1,825 Bytes
fe8202e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# 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`