File size: 4,444 Bytes
e5e4b98
3b4c87c
e5e4b98
3b4c87c
 
 
 
 
e5e4b98
 
 
 
 
 
 
 
3b4c87c
e5e4b98
3b4c87c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e5e4b98
3b4c87c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e5e4b98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b4c87c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e5e4b98
 
 
 
 
 
 
 
 
 
 
3b4c87c
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# SegMamba & GliomaSAM3-MoE: Complete Reproduction Package

This repository contains **everything needed to reproduce** our brain tumor segmentation experiments on BraTS 2023 dataset, including source code, pre-trained weights, and evaluation results.

## Repository Structure

```
.
├── source_code/
│   ├── gliomasam3_moe/        # GliomaSAM3-MoE source code
│   ├── SegMamba/              # SegMamba source code (with mamba/monai)
│   └── sam3/                  # SAM3 dependency module

├── pretrained_weights/
│   └── sam3.pt                # SAM3 pretrained weights (3.3GB)

├── gliomasam3_moe/
│   ├── checkpoints/           # GliomaSAM3-MoE trained weights
│   │   ├── ckpt_step2000.pt
│   │   ├── ckpt_step2600.pt
│   │   └── ckpt_step3000.pt   # Best checkpoint
│   ├── configs/
│   │   └── train.yaml         # Training configuration
│   ├── eval_results/
│   │   ├── table4_et_absent.json   # ET presence classification results
│   │   └── table7_boundary_dice.json # Boundary-band Dice results
│   └── vis_res/               # Visualization results
│       ├── method_comparison/ # Side-by-side comparisons
│       ├── boundary/          # Boundary analysis figures
│       ├── moe_routing/       # MoE routing visualizations
│       └── ...

├── segmamba/
│   ├── checkpoints/           # SegMamba trained weights
│   │   ├── tmp_model_ep599_0.8295.pt
│   │   └── tmp_model_ep799_0.8498.pt  # Best checkpoint (Dice=0.8498)
│   └── prediction_results/
│       ├── segmamba_brats23_ep799/    # Prediction NIfTI files
│       └── result_metrics/            # Evaluation metrics

└── README.md
```

## Model Performance

### GliomaSAM3-MoE (ckpt_step3000)

**Boundary-band Dice (3-voxel band):**
| Region | Dice |
|--------|------|
| WT | 0.789 ± 0.057 |
| TC | 0.766 ± 0.154 |
| ET | 0.697 ± 0.161 |
| **Mean** | **0.750** |

**ET Presence Classification:**
| Metric | Value |
|--------|-------|
| AUROC | 0.896 |
| Accuracy | 0.795 |
| Sensitivity | 0.792 |
| Specificity | 1.000 |

### SegMamba (ep799)

- Mean Dice: 0.8498
- Trained for 800 epochs on BraTS 2023

## Quick Start: Reproduction

### 1. Download this repository

```bash
# Clone the dataset
git clone https://huggingface.co/datasets/ChipYTY/segmamba
cd segmamba
```

### 2. Prepare BraTS 2023 Data

Download BraTS 2023 GLI Challenge data from [Synapse](https://www.synapse.org/#!Synapse:syn51514105) and preprocess:

```bash
cd source_code/SegMamba
python 2_preprocessing_mri.py --input_dir /path/to/BraTS2023 --output_dir /path/to/processed
```

### 3. Run GliomaSAM3-MoE Inference

```bash
cd source_code/gliomasam3_moe

# Set SAM3 path
export PYTHONPATH=/path/to/source_code/sam3:$PYTHONPATH
export SAM3_CKPT=/path/to/pretrained_weights/sam3.pt

# Run inference
python infer.py \
    --config configs/train.yaml \
    --checkpoint /path/to/gliomasam3_moe/checkpoints/ckpt_step3000.pt \
    --data_dir /path/to/processed \
    --output_dir ./predictions
```

### 4. Run SegMamba Inference

```bash
cd source_code/SegMamba

python 4_predict.py \
    --checkpoint /path/to/segmamba/checkpoints/tmp_model_ep799_0.8498.pt \
    --data_dir /path/to/processed \
    --output_dir ./predictions
```

## Usage

### Loading GliomaSAM3-MoE

```python
import torch

# Load checkpoint
ckpt = torch.load("gliomasam3_moe/checkpoints/ckpt_step3000.pt", map_location="cpu")

# Model state dict is in ckpt["model"]
model.load_state_dict(ckpt["model"])
```

### Loading SegMamba

```python
import torch

# Load checkpoint
ckpt = torch.load("segmamba/checkpoints/tmp_model_ep799_0.8498.pt", map_location="cpu")

# Model state dict
model.load_state_dict(ckpt["model"])
```

## Data

Models were trained and evaluated on BraTS 2023 GLI Challenge dataset.

- **Download**: [Synapse BraTS 2023](https://www.synapse.org/#!Synapse:syn51514105)
- **Preprocessing**: Use `source_code/SegMamba/2_preprocessing_mri.py`

## Requirements

- Python 3.10+
- PyTorch 2.0+
- CUDA 11.8+ (for SegMamba's Mamba CUDA kernels)
- See `source_code/gliomasam3_moe/requirements.txt` for full list

## Citation

If you use these models, please cite the relevant papers.

## License

Please refer to the original model repositories for licensing information.