# jpedrofontes/phenotype-classifier architecture

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

- Interactive diagram: https://gitdiagram.com/jpedrofontes/phenotype-classifier
- Repository: https://github.com/jpedrofontes/phenotype-classifier

## Overview

This repository is a breast-cancer phenotype classifier, with a primary 3D workflow for preparing MRI volumes, training a model, and evaluating predictions. It also contains autoencoder/latent-space functionality and a separate legacy 2D classifier. The graph follows documented imports and visible calls; some internal orchestration is only partially excerpted, so uncertain links are omitted.

Main entry points: [`train_and_evaluate.py`](https://github.com/jpedrofontes/phenotype-classifier/blob/main/train_and_evaluate.py) (3D training workflow), [`datasets/duke_dataset.py`](https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/duke_dataset.py) (Duke volumes), [`legacy/cross_validation.py`](https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/cross_validation.py) (Cross-validation), [`datasets/generator.py`](https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/generator.py) (Batch generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["3D data preparation"]
  node_duke["Duke volumes<br/>[duke_dataset.py]"]
  node_bc["BC collection"]
  node_dataset_base["Volume processing<br/>[dataset.py]"]
  node_generator["Batch generator<br/>[generator.py]"]
  node_latent_generator["Latent batches"]
end

subgraph group_models["Modeling"]
  node_cnn3d["3D CNN<br/>[cnn3d.py]"]
  node_autoencoder["3D autoencoder<br/>[autoencoder.py]"]
end

subgraph group_workflow["Training and evaluation"]
  node_settings["Run settings<br/>[settings.py]"]
  node_train["3D training workflow"]
  node_crossval["Cross-validation"]
end

subgraph group_legacy["Legacy 2D workflow"]
  node_slice_dataset["2D slice dataset"]
  node_slice_generator["2D batch generator<br/>[generator.py]"]
  node_custom2d["Custom 2D model<br/>[custom_model.py]"]
  node_train2d["2D training workflow"]
end

node_user(("Researcher"))
node_duke_external[("MRI dataset files")]

node_user -->|"runs"| node_train
node_train -->|"reads settings"| node_settings
node_train -->|"creates dataset"| node_duke
node_train -->|"creates dataset"| node_bc
node_duke -->|"inherits processing"| node_dataset_base
node_bc -->|"uses base"| node_dataset_base
node_duke -->|"reads volumes"| node_duke_external
node_train -->|"builds batches"| node_generator
node_generator -->|"processes scans"| node_duke
node_generator -->|"uses dataset"| node_dataset_base
node_train -->|"selects model"| node_cnn3d
node_train -->|"trains model"| node_autoencoder
node_train -.->|"extracts latent values"| node_latent_generator
node_user -->|"runs folds"| node_crossval
node_crossval -->|"loads dataset"| node_duke
node_crossval -->|"creates batches"| node_generator
node_crossval -->|"builds model"| node_cnn3d
node_user -->|"runs"| node_train2d
node_train2d -->|"creates dataset"| node_slice_dataset
node_slice_dataset -->|"creates batches"| node_slice_generator
node_train2d -->|"builds model"| node_custom2d

click node_settings "https://github.com/jpedrofontes/phenotype-classifier/blob/main/settings.py"
click node_duke "https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/duke_dataset.py"
click node_bc "https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/bc_collection_dataset.py"
click node_dataset_base "https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/dataset.py"
click node_generator "https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/generator.py"
click node_latent_generator "https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/latent_space_generator.py"
click node_cnn3d "https://github.com/jpedrofontes/phenotype-classifier/blob/main/models/cnn3d.py"
click node_autoencoder "https://github.com/jpedrofontes/phenotype-classifier/blob/main/models/autoencoder.py"
click node_train "https://github.com/jpedrofontes/phenotype-classifier/blob/main/train_and_evaluate.py"
click node_crossval "https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/cross_validation.py"
click node_slice_dataset "https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/legacy_2d/load_dataset/slice_dataset_2d.py"
click node_slice_generator "https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/legacy_2d/load_dataset/generator.py"
click node_custom2d "https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/legacy_2d/models/custom_model.py"
click node_train2d "https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/legacy_2d/train_and_evaluate_2d.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_duke,node_bc,node_dataset_base,node_generator,node_latent_generator toneBlue
class node_cnn3d,node_autoencoder,node_duke_external toneAmber
class node_settings,node_train,node_crossval toneMint
class node_slice_dataset,node_slice_generator,node_custom2d,node_train2d toneRose
class node_user toneIndigo
```

## Components

### 3D data preparation

- [Duke volumes](https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/duke_dataset.py): `datasets/duke_dataset.py`
- [BC collection](https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/bc_collection_dataset.py): `datasets/bc_collection_dataset.py`
- [Volume processing](https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/dataset.py): `datasets/dataset.py`
- [Batch generator](https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/generator.py): `datasets/generator.py`
- [Latent batches](https://github.com/jpedrofontes/phenotype-classifier/blob/main/datasets/latent_space_generator.py): `datasets/latent_space_generator.py`

### Modeling

- [3D CNN](https://github.com/jpedrofontes/phenotype-classifier/blob/main/models/cnn3d.py): `models/cnn3d.py`
- [3D autoencoder](https://github.com/jpedrofontes/phenotype-classifier/blob/main/models/autoencoder.py): `models/autoencoder.py`

### Training and evaluation

- [Run settings](https://github.com/jpedrofontes/phenotype-classifier/blob/main/settings.py): `settings.py`
- [3D training workflow](https://github.com/jpedrofontes/phenotype-classifier/blob/main/train_and_evaluate.py): `train_and_evaluate.py`
- [Cross-validation](https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/cross_validation.py): `legacy/cross_validation.py`

### Legacy 2D workflow

- [2D slice dataset](https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/legacy_2d/load_dataset/slice_dataset_2d.py): `legacy/legacy_2d/load_dataset/slice_dataset_2d.py`
- [2D batch generator](https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/legacy_2d/load_dataset/generator.py): `legacy/legacy_2d/load_dataset/generator.py`
- [Custom 2D model](https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/legacy_2d/models/custom_model.py): `legacy/legacy_2d/models/custom_model.py`
- [2D training workflow](https://github.com/jpedrofontes/phenotype-classifier/blob/main/legacy/legacy_2d/train_and_evaluate_2d.py): `legacy/legacy_2d/train_and_evaluate_2d.py`

### Other components

- **Researcher**
- **MRI dataset files**

## Connections

- Researcher → 3D training workflow: runs (evidence: `train_and_evaluate.py`)
- 3D training workflow → Run settings: reads settings (evidence: `train_and_evaluate.py`)
- 3D training workflow → Duke volumes: creates dataset (evidence: `train_and_evaluate.py`)
- 3D training workflow → BC collection: creates dataset (evidence: `train_and_evaluate.py`)
- Duke volumes → Volume processing: inherits processing (evidence: `datasets/duke_dataset.py`)
- BC collection → Volume processing: uses base (evidence: `datasets/bc_collection_dataset.py`)
- Duke volumes → MRI dataset files: reads volumes (evidence: `datasets/duke_dataset.py`)
- 3D training workflow → Batch generator: builds batches (evidence: `train_and_evaluate.py`)
- Batch generator → Duke volumes: processes scans (evidence: `datasets/generator.py`)
- Batch generator → Volume processing: uses dataset (evidence: `datasets/generator.py`)
- 3D training workflow → 3D CNN: selects model (evidence: `train_and_evaluate.py`)
- 3D training workflow → 3D autoencoder: trains model (evidence: `train_and_evaluate.py`)
- 3D training workflow → Latent batches: extracts latent values
- Researcher → Cross-validation: runs folds (evidence: `legacy/cross_validation.py`)
- Cross-validation → Duke volumes: loads dataset (evidence: `legacy/cross_validation.py`)
- Cross-validation → Batch generator: creates batches (evidence: `legacy/cross_validation.py`)
- Cross-validation → 3D CNN: builds model (evidence: `legacy/cross_validation.py`)
- Researcher → 2D training workflow: runs (evidence: `legacy/legacy_2d/train_and_evaluate_2d.py`)
- 2D training workflow → 2D slice dataset: creates dataset (evidence: `legacy/legacy_2d/train_and_evaluate_2d.py`)
- 2D slice dataset → 2D batch generator: creates batches (evidence: `legacy/legacy_2d/load_dataset/slice_dataset_2d.py`)
- 2D training workflow → Custom 2D model: builds model (evidence: `legacy/legacy_2d/train_and_evaluate_2d.py`)
