How china-liuxiaopeng/brats-dmfnet works
Project type and purpose
• This is a deep-learning research codebase for real-time 3D brain tumor segmentation (BraTS 2018) using a Dilated Multi-Fiber Network (DMFNet) implemented in PyTorch.
• It contains data‐preprocessing, training, testing, experiment configuration, model definition (including synchronized batch-norm), and utilities.
File structure
• Top-level scripts:
• preprocess.py → converts .nii to .pkl
• split.py → k-fold split
• train_all.py/train_fold.py → orchestrate training over GPUs/folds
• test.py → evaluation, TTA, postprocess
• predict.py → (if used for inference)
• Directories:
• data/ → data loading pipeline (data_utils, datasets, transforms, sampler)
• models/ → DMFNet class, sync_batchnorm submodule
• experiments/ → YAML config files (hyperparams, data paths)
• ckpts/ → checkpoint storage
• utils/ → argument parsing, criterions, boolean flags
• submission results/ → saved CSV results
• Config/build:
• experiments/PATH.yaml → dataset path
• utils/parser.py → reads YAML into experiment object
• Dependencies: PyTorch, nibabel, pickle, YAML parser.
Key insights from README
• Modular design: separate preprocess, split, train, test phases.
• Uses synchronized batch-norm for multi-GPU training (models/sync_batchnorm).
• Experiment driven by .yaml files in experiments/.
• Standard PyTorch training loop with DataLoader, optimizer, loss criterion.
Main components
a. External data source
• BraTS 2018 raw .nii files
b. Preprocessing pipeline
• preprocess.py
• Output: .pkl files in data/
c. Data ingestion & augmentation
• data/datasets.py, data/transforms.py, data/sampler.py
• DataLoader → batches
d. Experiment configuration
• experiments/*.yaml
• utils/parser.py → experiment hyperparams
e. Training orchestrator
• train_all.py / train_fold.py
• Builds model, DataLoaders, criterion, optimizer, scheduler
f. Model definition
• models/DMFNet_16x.py (network layers with dilated multi-fiber blocks)
• models/sync_batchnorm (distributed batch-norm)
g. Checkpointing & logging
• ckpts/DMFNet_GDL_all/
h. Testing & evaluation
• test.py (TTA, postprocess, snapshot)
• Outputs performance metrics (Dice scores) → submission results
i. Utilities
• utils/criterions.py, utils/str2bool.py
Architectural patterns & design principles
• Pipeline separation: distinct preprocessing, training, testing stages.
• Config-driven experiments: keeps code generic, hyperparams in YAML.
• Modular model code: network and sync_batchnorm submodule.
• Reusability: data utilities, parser, criterions abstract common logic.
Elements
• Clear labels on all components (e.g., “preprocess.py”, “data.datasets.DataLoader”, “models.DMFNet_16x”).
• Green for scripts (preprocess.py, train_all.py, test.py)
• Orange for external resources (raw dataset, checkpoints, YAML files)
• Annotations for technologies (PyTorch, nibabel, YAML).