# tranvanhuy-hichan/brain-mri-segmentation architecture

> Architecture diagram of the GitHub repository tranvanhuy-hichan/brain-mri-segmentation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tranvanhuy-hichan/brain-mri-segmentation
- Repository: https://github.com/tranvanhuy-hichan/brain-mri-segmentation

## Overview

NeuroSeg is a research scaffold for brain-MRI tumor segmentation, with a dataset-to-model workflow and a separate native review application. The documented main path validates/imports NIfTI cases, then invokes nnU-Net planning, training and prediction; evaluation is planned. A second branch supports slice and 3D review of MRI volumes and masks. Kaggle files provide CPU preprocessing and budgeted pilot-training stages. Some pipeline and integration details are documented but not excerpted, so those links cite the README; the graph does not infer unsampled calls.

Main entry points: [`scripts/pipeline.sh`](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/scripts/pipeline.sh) (Pipeline wrappers), [`desktop/app.py`](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/app.py) (Qt workspace), [`desktop/view3d.py`](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/view3d.py) (3D viewer), [`kaggle/prepare_cpu.py`](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/kaggle/prepare_cpu.py) (CPU preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Dataset preparation"]
  node_importer["NIfTI importer<br/>[prepare_dataset.py]"]
  node_rawset[("nnU-Net dataset")]
end

subgraph group_model["Model workflow"]
  node_pipeline["Pipeline wrappers<br/>[pipeline.sh]"]
  node_planning["Planning and preprocessing"]
  node_training["Fold training"]
  node_prediction["Mask prediction"]
  node_evaluation["Evaluation"]
end

subgraph group_kaggle["Kaggle pilot"]
  node_kprep["CPU preprocessing<br/>[prepare_cpu.py]"]
  node_ktrain["Budgeted training<br/>[train_budget.py]"]
  node_launcher["Kaggle launcher"]
end

subgraph group_desktop["Desktop review"]
  node_workspace["Qt workspace<br/>[app.py]"]
  node_volume["NIfTI volume<br/>[volume.py]"]
  node_slices["Slice rendering<br/>[volume.py]"]
  node_viewer3d["3D viewer<br/>[view3d.py]"]
  node_anatomy["MRI volume rendering<br/>[anatomy.py]"]
  node_surfaces["Mask surfaces<br/>[surfaces.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"prepares cases"| node_importer
node_importer -->|"writes dataset"| node_rawset
node_researcher -->|"runs stages"| node_pipeline
node_pipeline -->|"invokes planning"| node_planning
node_pipeline -->|"invokes training"| node_training
node_pipeline -->|"invokes prediction"| node_prediction
node_prediction -.->|"planned evaluation"| node_evaluation
node_researcher -->|"starts preparation"| node_kprep
node_kprep -->|"precedes pilot"| node_ktrain
node_launcher -->|"checks completion"| node_kprep
node_launcher -->|"submits kernel"| node_ktrain
node_researcher -->|"opens viewer"| node_workspace
node_workspace -->|"loads volumes"| node_volume
node_workspace -->|"hosts viewer"| node_viewer3d
node_volume -->|"renders slices"| node_slices
node_viewer3d -->|"builds anatomy"| node_anatomy
node_viewer3d -->|"builds surfaces"| node_surfaces

click node_importer "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/scripts/prepare_dataset.py"
click node_pipeline "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/scripts/pipeline.sh"
click node_kprep "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/kaggle/prepare_cpu.py"
click node_ktrain "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/kaggle/train_budget.py"
click node_launcher "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/kaggle/launch_after_prepare.py"
click node_workspace "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/app.py"
click node_volume "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/volume.py"
click node_slices "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/volume.py"
click node_viewer3d "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/view3d.py"
click node_anatomy "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/anatomy.py"
click node_surfaces "https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/surfaces.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_importer,node_rawset toneBlue
class node_pipeline,node_planning,node_training,node_prediction,node_evaluation toneAmber
class node_kprep,node_ktrain,node_launcher toneMint
class node_workspace,node_volume,node_slices,node_viewer3d,node_anatomy,node_surfaces toneRose
class node_researcher toneIndigo
```

## Components

### Dataset preparation

- [NIfTI importer](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/scripts/prepare_dataset.py): `scripts/prepare_dataset.py`
- **nnU-Net dataset**

### Model workflow

- [Pipeline wrappers](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/scripts/pipeline.sh): `scripts/pipeline.sh`
- **Planning and preprocessing**
- **Fold training**
- **Mask prediction**
- **Evaluation**

### Kaggle pilot

- [CPU preprocessing](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/kaggle/prepare_cpu.py): `kaggle/prepare_cpu.py`
- [Budgeted training](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/kaggle/train_budget.py): `kaggle/train_budget.py`
- [Kaggle launcher](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/kaggle/launch_after_prepare.py): `kaggle/launch_after_prepare.py`

### Desktop review

- [Qt workspace](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/app.py): `desktop/app.py`
- [NIfTI volume](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/volume.py): `desktop/volume.py`
- [Slice rendering](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/volume.py): `desktop/volume.py`
- [3D viewer](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/view3d.py): `desktop/view3d.py`
- [MRI volume rendering](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/anatomy.py): `desktop/anatomy.py`
- [Mask surfaces](https://github.com/tranvanhuy-hichan/brain-mri-segmentation/blob/main/desktop/surfaces.py): `desktop/surfaces.py`

### Other components

- **Researcher**

## Connections

- Researcher → NIfTI importer: prepares cases (evidence: `README.md`)
- NIfTI importer → nnU-Net dataset: writes dataset (evidence: `README.md`)
- Researcher → Pipeline wrappers: runs stages (evidence: `README.md`)
- Pipeline wrappers → Planning and preprocessing: invokes planning (evidence: `README.md`)
- Pipeline wrappers → Fold training: invokes training (evidence: `README.md`)
- Pipeline wrappers → Mask prediction: invokes prediction (evidence: `README.md`)
- Mask prediction → Evaluation: planned evaluation (evidence: `README.md`)
- Researcher → CPU preprocessing: starts preparation (evidence: `README.md`)
- CPU preprocessing → Budgeted training: precedes pilot (evidence: `README.md`)
- Kaggle launcher → CPU preprocessing: checks completion (evidence: `kaggle/launch_after_prepare.py`)
- Kaggle launcher → Budgeted training: submits kernel (evidence: `kaggle/launch_after_prepare.py`)
- Researcher → Qt workspace: opens viewer (evidence: `README.md`)
- Qt workspace → NIfTI volume: loads volumes (evidence: `desktop/app.py`)
- Qt workspace → 3D viewer: hosts viewer (evidence: `desktop/app.py`)
- NIfTI volume → Slice rendering: renders slices (evidence: `desktop/volume.py`)
- 3D viewer → MRI volume rendering: builds anatomy (evidence: `desktop/view3d.py`)
- 3D viewer → Mask surfaces: builds surfaces (evidence: `desktop/view3d.py`)
