# epics-lab/untrained-cnn architecture

> Architecture diagram of the GitHub repository epics-lab/untrained-cnn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/epics-lab/untrained-cnn
- Repository: https://github.com/epics-lab/untrained-cnn
- Video tour (about a minute): https://gitdiagram.com/epics-lab/untrained-cnn/video

## Overview

un-CNN is a Python library that converts structural MRI scans into fixed-length feature vectors using a randomly initialized, untrained 3D CNN. The principal workflow loads and resizes each NIfTI scan, constructs one of two three-channel preprocessing variants, batches scans, and runs the frozen model to produce a NumPy feature matrix for downstream analysis. The README also documents preprocessing with TurboPrep and experimental architecture evaluation; the implementation details for those notebook experiments were not sampled.

Main entry points: [`uncnn.py`](https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py) (Dataset and loader), [`Untrained CNN Project.ipynb`](https://github.com/epics-lab/untrained-cnn/blob/main/Untrained%20CNN%20Project.ipynb) (Architecture experiments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_preprocessing["MRI preprocessing"]
  node_resize["Load and resize<br/>[uncnn.py]"]
  node_robust["Robust channels<br/>[uncnn.py]"]
  node_ranksobel["Rank-Sobel channels<br/>[uncnn.py]"]
end

subgraph group_inference["Feature extraction"]
  node_extract["extract_features<br/>[uncnn.py]"]
  node_dataset["Dataset and loader<br/>[uncnn.py]"]
  node_loadmodel["load_model<br/>[uncnn.py]"]
  node_uncnn["UnCNN<br/>[uncnn.py]"]
  node_features["Feature matrix<br/>[uncnn.py]"]
end

subgraph group_research["Research evaluation"]
  node_notebook["Architecture experiments"]
  node_evaluation["Random Forest evaluation"]
end

node_user(("Library user"))
node_mri["MRI scans"]
node_turboprep["TurboPrep"]
node_downstream["Downstream ML"]

node_user -->|"calls"| node_extract
node_mri -->|"loads"| node_resize
node_turboprep -.->|"preprocesses"| node_mri
node_extract -->|"creates"| node_dataset
node_dataset -->|"selects config"| node_robust
node_dataset -->|"selects config"| node_ranksobel
node_robust -->|"loads volume"| node_resize
node_ranksobel -->|"loads volume"| node_resize
node_dataset -->|"loads if needed"| node_loadmodel
node_dataset -->|"batches inputs"| node_uncnn
node_loadmodel -->|"initializes"| node_uncnn
node_uncnn -->|"extracts features"| node_features
node_extract -->|"returns matrix"| node_features
node_features -->|"provides features"| node_downstream
node_notebook -->|"evaluates designs"| node_evaluation
node_evaluation -->|"uses models"| node_downstream

click node_extract "https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py"
click node_resize "https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py"
click node_robust "https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py"
click node_ranksobel "https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py"
click node_dataset "https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py"
click node_loadmodel "https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py"
click node_uncnn "https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py"
click node_features "https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py"
click node_notebook "https://github.com/epics-lab/untrained-cnn/blob/main/Untrained%20CNN%20Project.ipynb"

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_resize,node_robust,node_ranksobel,node_user toneBlue
class node_extract,node_dataset,node_loadmodel,node_uncnn,node_features toneAmber
class node_notebook,node_evaluation toneMint
class node_mri,node_turboprep,node_downstream toneIndigo
```

## Components

### MRI preprocessing

- [Load and resize](https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py): `uncnn.py`
- [Robust channels](https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py): `uncnn.py`
- [Rank-Sobel channels](https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py): `uncnn.py`

### Feature extraction

- [extract_features](https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py): `uncnn.py`
- [Dataset and loader](https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py): `uncnn.py`
- [load_model](https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py): `uncnn.py`
- [UnCNN](https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py): `uncnn.py`
- [Feature matrix](https://github.com/epics-lab/untrained-cnn/blob/main/uncnn.py): `uncnn.py`

### Research evaluation

- [Architecture experiments](https://github.com/epics-lab/untrained-cnn/blob/main/Untrained%20CNN%20Project.ipynb): `Untrained CNN Project.ipynb`
- **Random Forest evaluation**

### Other components

- **Library user**
- **MRI scans**
- **TurboPrep**
- **Downstream ML**

## Connections

- Library user → extract_features: calls
- MRI scans → Load and resize: loads
- TurboPrep → MRI scans: preprocesses
- extract_features → Dataset and loader: creates
- Dataset and loader → Robust channels: selects config
- Dataset and loader → Rank-Sobel channels: selects config
- Robust channels → Load and resize: loads volume
- Rank-Sobel channels → Load and resize: loads volume
- Dataset and loader → load_model: loads if needed
- Dataset and loader → UnCNN: batches inputs
- load_model → UnCNN: initializes
- UnCNN → Feature matrix: extracts features
- extract_features → Feature matrix: returns matrix
- Feature matrix → Downstream ML: provides features
- Architecture experiments → Random Forest evaluation: evaluates designs
- Random Forest evaluation → Downstream ML: uses models
