# noel-mni/deepfcd architecture

> Architecture diagram of the GitHub repository noel-mni/deepfcd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/noel-mni/deepfcd
- Repository: https://github.com/noel-mni/deepfcd

## Overview

deepFCD detects focal cortical dysplasia from paired T1 and FLAIR MRI. The main user workflow supplies a patient ID, images, output directory, and preprocessing/device options to inference; inference prepares inputs, loads two CNNs, runs prediction, and writes probability and uncertainty images. The repository also includes model training, patch/HDF5 data handling, post-processing, and confidence/reporting utilities. Relationships are limited to README statements and SOURCE INDEX references; some internal runtime connections remain unverified because excerpts are incomplete.

Main entry points: [`app/inference.py`](https://github.com/noel-mni/deepfcd/blob/main/app/inference.py) (Inference CLI), [`app/utils/base.py`](https://github.com/noel-mni/deepfcd/blob/main/app/utils/base.py) (Prediction engine), [`app/train.py`](https://github.com/noel-mni/deepfcd/blob/main/app/train.py) (Training routine), [`app/models/noel_models_keras.py`](https://github.com/noel-mni/deepfcd/blob/main/app/models/noel_models_keras.py) (CNN pair loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Inference"]
  node_inference_cli["Inference CLI<br/>[inference.py]"]
  node_preprocess["MRI preprocessing<br/>[preprocess.py]"]
  node_deepmask["Brain extraction"]
  node_experiment_config["Experiment options<br/>[experiment.py]"]
end

subgraph group_models["Models"]
  node_model_loader["CNN pair loader"]
  node_cnn_architecture["3D CNN architecture<br/>[model_builder.py]"]
  node_inference_engine["Prediction engine<br/>[base.py]"]
  node_patch_dataloader["Patch inference data"]
end

subgraph group_training["Training"]
  node_train_cli["Training routine<br/>[train.py]"]
  node_patch_loader["Patch sampling<br/>[h5data.py]"]
  node_hdf5_dataset["HDF5 data handling"]
end

subgraph group_analysis["Analysis and reporting"]
  node_postprocess["Lesion post-processing<br/>[post_processor.py]"]
  node_metrics["Evaluation metrics<br/>[metrics.py]"]
  node_confidence["Confidence estimates<br/>[confidence.py]"]
  node_reporting["Results reporting<br/>[reporting.py]"]
end

node_clinician(("User"))
node_mri["T1 and FLAIR"]
node_predictions["Probability and uncertainty images"]

node_clinician -->|"runs"| node_inference_cli
node_mri -->|"provides images"| node_inference_cli
node_inference_cli -->|"loads options"| node_experiment_config
node_inference_cli -.->|"preprocesses inputs"| node_preprocess
node_inference_cli -.->|"extracts brain"| node_deepmask
node_inference_cli -->|"loads CNNs"| node_model_loader
node_inference_cli -->|"runs prediction"| node_inference_engine
node_model_loader -->|"builds models"| node_cnn_architecture
node_inference_engine -->|"uses data loader"| node_patch_dataloader
node_inference_engine -->|"post-processes"| node_postprocess
node_inference_engine -->|"writes images"| node_predictions
node_clinician -.->|"runs training"| node_train_cli
node_train_cli -->|"loads options"| node_experiment_config
node_train_cli -->|"builds CNNs"| node_model_loader
node_train_cli -->|"tests models"| node_inference_engine
node_hdf5_dataset -->|"loads patch data"| node_patch_loader
node_patch_loader -.->|"supplies patches"| node_train_cli
node_postprocess -->|"uses metrics"| node_metrics
node_reporting -->|"uses estimates"| node_confidence

click node_inference_cli "https://github.com/noel-mni/deepfcd/blob/main/app/inference.py"
click node_preprocess "https://github.com/noel-mni/deepfcd/blob/main/app/preprocess.py"
click node_deepmask "https://github.com/noel-mni/deepfcd/tree/main/app/deepMask"
click node_experiment_config "https://github.com/noel-mni/deepfcd/blob/main/app/config/experiment.py"
click node_model_loader "https://github.com/noel-mni/deepfcd/blob/main/app/models/noel_models_keras.py"
click node_cnn_architecture "https://github.com/noel-mni/deepfcd/blob/main/app/models/model_builder.py"
click node_inference_engine "https://github.com/noel-mni/deepfcd/blob/main/app/utils/base.py"
click node_train_cli "https://github.com/noel-mni/deepfcd/blob/main/app/train.py"
click node_patch_loader "https://github.com/noel-mni/deepfcd/blob/main/app/utils/h5data.py"
click node_hdf5_dataset "https://github.com/noel-mni/deepfcd/blob/main/app/utils/create_hdf5_patch_dataset.py"
click node_patch_dataloader "https://github.com/noel-mni/deepfcd/blob/main/app/utils/patch_dataloader.py"
click node_postprocess "https://github.com/noel-mni/deepfcd/blob/main/app/utils/post_processor.py"
click node_metrics "https://github.com/noel-mni/deepfcd/blob/main/app/utils/metrics.py"
click node_confidence "https://github.com/noel-mni/deepfcd/blob/main/app/utils/confidence.py"
click node_reporting "https://github.com/noel-mni/deepfcd/blob/main/app/utils/reporting.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_inference_cli,node_preprocess,node_deepmask,node_experiment_config,node_clinician toneBlue
class node_model_loader,node_cnn_architecture,node_inference_engine,node_patch_dataloader toneAmber
class node_train_cli,node_patch_loader,node_hdf5_dataset toneMint
class node_postprocess,node_metrics,node_confidence,node_reporting toneRose
class node_mri,node_predictions toneIndigo
```

## Components

### Inference

- [Inference CLI](https://github.com/noel-mni/deepfcd/blob/main/app/inference.py): `app/inference.py`
- [MRI preprocessing](https://github.com/noel-mni/deepfcd/blob/main/app/preprocess.py): `app/preprocess.py`
- [Brain extraction](https://github.com/noel-mni/deepfcd/tree/main/app/deepMask): `app/deepMask`
- [Experiment options](https://github.com/noel-mni/deepfcd/blob/main/app/config/experiment.py): `app/config/experiment.py`

### Models

- [CNN pair loader](https://github.com/noel-mni/deepfcd/blob/main/app/models/noel_models_keras.py): `app/models/noel_models_keras.py`
- [3D CNN architecture](https://github.com/noel-mni/deepfcd/blob/main/app/models/model_builder.py): `app/models/model_builder.py`
- [Prediction engine](https://github.com/noel-mni/deepfcd/blob/main/app/utils/base.py): `app/utils/base.py`
- [Patch inference data](https://github.com/noel-mni/deepfcd/blob/main/app/utils/patch_dataloader.py): `app/utils/patch_dataloader.py`

### Training

- [Training routine](https://github.com/noel-mni/deepfcd/blob/main/app/train.py): `app/train.py`
- [Patch sampling](https://github.com/noel-mni/deepfcd/blob/main/app/utils/h5data.py): `app/utils/h5data.py`
- [HDF5 data handling](https://github.com/noel-mni/deepfcd/blob/main/app/utils/create_hdf5_patch_dataset.py): `app/utils/create_hdf5_patch_dataset.py`

### Analysis and reporting

- [Lesion post-processing](https://github.com/noel-mni/deepfcd/blob/main/app/utils/post_processor.py): `app/utils/post_processor.py`
- [Evaluation metrics](https://github.com/noel-mni/deepfcd/blob/main/app/utils/metrics.py): `app/utils/metrics.py`
- [Confidence estimates](https://github.com/noel-mni/deepfcd/blob/main/app/utils/confidence.py): `app/utils/confidence.py`
- [Results reporting](https://github.com/noel-mni/deepfcd/blob/main/app/utils/reporting.py): `app/utils/reporting.py`

### Other components

- **User**
- **T1 and FLAIR**
- **Probability and uncertainty images**

## Connections

- User → Inference CLI: runs (evidence: `README.md`)
- T1 and FLAIR → Inference CLI: provides images (evidence: `README.md`)
- Inference CLI → Experiment options: loads options (evidence: `app/inference.py`)
- Inference CLI → MRI preprocessing: preprocesses inputs (evidence: `README.md`)
- Inference CLI → Brain extraction: extracts brain (evidence: `README.md`)
- Inference CLI → CNN pair loader: loads CNNs (evidence: `app/inference.py`)
- Inference CLI → Prediction engine: runs prediction (evidence: `app/inference.py`)
- CNN pair loader → 3D CNN architecture: builds models (evidence: `app/models/noel_models_keras.py`)
- Prediction engine → Patch inference data: uses data loader (evidence: `app/utils/base.py`)
- Prediction engine → Lesion post-processing: post-processes (evidence: `app/utils/base.py`)
- Prediction engine → Probability and uncertainty images: writes images (evidence: `README.md`)
- User → Training routine: runs training (evidence: `README.md`)
- Training routine → Experiment options: loads options (evidence: `app/train.py`)
- Training routine → CNN pair loader: builds CNNs (evidence: `app/train.py`)
- Training routine → Prediction engine: tests models (evidence: `app/train.py`)
- HDF5 data handling → Patch sampling: loads patch data (evidence: `app/utils/create_hdf5_patch_dataset.py`)
- Patch sampling → Training routine: supplies patches
- Lesion post-processing → Evaluation metrics: uses metrics (evidence: `app/utils/post_processor.py`)
- Results reporting → Confidence estimates: uses estimates (evidence: `app/utils/reporting.py`)
