# alishals28/dg-tcav-classifier-fyp architecture

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

- Interactive diagram: https://gitdiagram.com/alishals28/dg-tcav-classifier-fyp
- Repository: https://github.com/alishals28/dg-tcav-classifier-fyp

## Overview

DG-TCAV is a four-class classifier for baseline ADNI T1 MRI scans. The main workflow is to configure a run, resolve and audit the prepared cohort and volumes, train a selected 3D model with validation-based checkpoint selection, then evaluate the frozen checkpoint or export layer-4 activations. The repository also supports manifest preparation and both MedicalNet-compatible ResNet-18 and ClassifierCNN architectures. Relationships are based on the shown excerpts, SOURCE INDEX references, or README workflow; unsampled implementation details are not inferred.

Main entry points: [`src/evaluate.py`](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/evaluate.py) (Checkpoint evaluation), [`src/train.py`](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/train.py) (Training orchestration), [`src/engine.py`](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/engine.py) (Loaders and epoch loop), [`src/dataset.py`](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/dataset.py) (Cohort index and dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Cohort and volumes"]
  node_manifest["Prepared cohort inputs"]
  node_manifest_prep["Manifest preparation"]
  node_volumes[("MRI volumes")]
  node_dataset["Cohort index and dataset<br/>[dataset.py]"]
end

subgraph group_learning["Model and training"]
  node_transforms["Training augmentation<br/>[transforms.py]"]
  node_engine["Loaders and epoch loop<br/>[engine.py]"]
  node_model["Classifier architectures<br/>[model.py]"]
  node_medicalnet["MedicalNet weights<br/>[medicalnet.py]"]
  node_trainer["Training orchestration<br/>[train.py]"]
  node_checkpoint["Run checkpoint"]
end

subgraph group_analysis["Evaluation and features"]
  node_metrics["Classification metrics<br/>[metrics.py]"]
  node_plots["Training and evaluation plots<br/>[plots.py]"]
  node_evaluator["Checkpoint evaluation<br/>[evaluate.py]"]
  node_feature_export["Activation export"]
end

subgraph group_runtime["Run configuration"]
  node_config["Config loader<br/>[config.py]"]
  node_repro["Reproducibility<br/>[reproducibility.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"selects run"| node_config
node_researcher -->|"regenerates inputs"| node_manifest_prep
node_manifest_prep -->|"writes cohort files"| node_manifest
node_manifest -->|"defines cohort"| node_dataset
node_volumes -->|"provides scans"| node_dataset
node_config -->|"configures run"| node_trainer
node_trainer -->|"builds and audits"| node_dataset
node_trainer -->|"runs epochs"| node_engine
node_trainer -->|"builds model"| node_model
node_trainer -->|"loads weights"| node_medicalnet
node_trainer -->|"sets seeds"| node_repro
node_trainer -->|"plots history"| node_plots
node_engine -->|"builds augmentation"| node_transforms
node_engine -->|"creates loaders"| node_dataset
node_engine -->|"computes metrics"| node_metrics
node_trainer -->|"saves checkpoints"| node_checkpoint
node_researcher -->|"evaluates checkpoint"| node_evaluator
node_evaluator -->|"loads checkpoint"| node_checkpoint
node_evaluator -->|"loads config"| node_config
node_evaluator -->|"builds evaluation data"| node_dataset
node_evaluator -->|"runs inference"| node_engine
node_evaluator -->|"loads model"| node_model
node_evaluator -->|"summarizes predictions"| node_metrics
node_evaluator -->|"plots results"| node_plots
node_researcher -->|"exports activations"| node_feature_export
node_feature_export -->|"loads fitted model"| node_evaluator
node_feature_export -->|"loads split data"| node_dataset
node_feature_export -->|"selects device"| node_engine
node_feature_export -->|"reads checkpoint"| node_checkpoint

click node_config "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/config.py"
click node_manifest "https://github.com/alishals28/dg-tcav-classifier-fyp/tree/main/data/preprocessed_128_classifier_inputs"
click node_manifest_prep "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/scripts/prepare_preprocessed_manifest.py"
click node_dataset "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/dataset.py"
click node_transforms "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/transforms.py"
click node_engine "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/engine.py"
click node_model "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/model.py"
click node_medicalnet "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/medicalnet.py"
click node_repro "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/reproducibility.py"
click node_trainer "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/train.py"
click node_metrics "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/metrics.py"
click node_plots "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/plots.py"
click node_evaluator "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/evaluate.py"
click node_feature_export "https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/export_activations.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_manifest,node_manifest_prep,node_volumes,node_dataset toneBlue
class node_transforms,node_engine,node_model,node_medicalnet,node_trainer,node_checkpoint toneAmber
class node_metrics,node_plots,node_evaluator,node_feature_export toneMint
class node_config,node_repro toneRose
class node_researcher toneIndigo
```

## Components

### Cohort and volumes

- [Prepared cohort inputs](https://github.com/alishals28/dg-tcav-classifier-fyp/tree/main/data/preprocessed_128_classifier_inputs): `data/preprocessed_128_classifier_inputs`
- [Manifest preparation](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/scripts/prepare_preprocessed_manifest.py): `scripts/prepare_preprocessed_manifest.py`
- **MRI volumes**
- [Cohort index and dataset](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/dataset.py): `src/dataset.py`

### Model and training

- [Training augmentation](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/transforms.py): `src/transforms.py`
- [Loaders and epoch loop](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/engine.py): `src/engine.py`
- [Classifier architectures](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/model.py): `src/model.py`
- [MedicalNet weights](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/medicalnet.py): `src/medicalnet.py`
- [Training orchestration](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/train.py): `src/train.py`
- **Run checkpoint**

### Evaluation and features

- [Classification metrics](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/metrics.py): `src/metrics.py`
- [Training and evaluation plots](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/plots.py): `src/plots.py`
- [Checkpoint evaluation](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/evaluate.py): `src/evaluate.py`
- [Activation export](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/export_activations.py): `src/export_activations.py`

### Run configuration

- [Config loader](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/config.py): `src/config.py`
- [Reproducibility](https://github.com/alishals28/dg-tcav-classifier-fyp/blob/main/src/reproducibility.py): `src/reproducibility.py`

### Other components

- **Researcher**

## Connections

- Researcher → Config loader: selects run (evidence: `README.md`)
- Researcher → Manifest preparation: regenerates inputs (evidence: `README.md`)
- Manifest preparation → Prepared cohort inputs: writes cohort files (evidence: `README.md`)
- Prepared cohort inputs → Cohort index and dataset: defines cohort (evidence: `README.md`)
- MRI volumes → Cohort index and dataset: provides scans (evidence: `README.md`)
- Config loader → Training orchestration: configures run (evidence: `src/train.py`)
- Training orchestration → Cohort index and dataset: builds and audits (evidence: `src/train.py`)
- Training orchestration → Loaders and epoch loop: runs epochs (evidence: `src/train.py`)
- Training orchestration → Classifier architectures: builds model (evidence: `src/train.py`)
- Training orchestration → MedicalNet weights: loads weights (evidence: `src/train.py`)
- Training orchestration → Reproducibility: sets seeds (evidence: `src/train.py`)
- Training orchestration → Training and evaluation plots: plots history (evidence: `src/train.py`)
- Loaders and epoch loop → Training augmentation: builds augmentation (evidence: `src/engine.py`)
- Loaders and epoch loop → Cohort index and dataset: creates loaders (evidence: `src/engine.py`)
- Loaders and epoch loop → Classification metrics: computes metrics (evidence: `src/engine.py`)
- Training orchestration → Run checkpoint: saves checkpoints (evidence: `README.md`)
- Researcher → Checkpoint evaluation: evaluates checkpoint (evidence: `README.md`)
- Checkpoint evaluation → Run checkpoint: loads checkpoint (evidence: `src/evaluate.py`)
- Checkpoint evaluation → Config loader: loads config (evidence: `src/evaluate.py`)
- Checkpoint evaluation → Cohort index and dataset: builds evaluation data (evidence: `src/evaluate.py`)
- Checkpoint evaluation → Loaders and epoch loop: runs inference (evidence: `src/evaluate.py`)
- Checkpoint evaluation → Classifier architectures: loads model (evidence: `src/evaluate.py`)
- Checkpoint evaluation → Classification metrics: summarizes predictions (evidence: `src/evaluate.py`)
- Checkpoint evaluation → Training and evaluation plots: plots results (evidence: `src/evaluate.py`)
- Researcher → Activation export: exports activations (evidence: `README.md`)
- Activation export → Checkpoint evaluation: loads fitted model (evidence: `src/export_activations.py`)
- Activation export → Cohort index and dataset: loads split data (evidence: `src/export_activations.py`)
- Activation export → Loaders and epoch loop: selects device (evidence: `src/export_activations.py`)
- Activation export → Run checkpoint: reads checkpoint (evidence: `src/export_activations.py`)
