# matteo-dunnhofer/mrpyrnet architecture

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

- Interactive diagram: https://gitdiagram.com/matteo-dunnhofer/mrpyrnet
- Repository: https://github.com/matteo-dunnhofer/mrpyrnet

## Overview

MRPyrNet adapts knee-MRI diagnosis pipelines for ACL and meniscal tears. In the MRNet variant, scans are loaded by view-specific datasets, trained and evaluated by per-view trainers, then per-view predictions are combined by logistic regression. The ELNet variant trains individual task/view models without the documented three-view ensemble. Both model implementations use pyramidal detail pooling; the MRNet model also uses an AlexNet backbone. The graph includes README-documented workflows where orchestration scripts are not shown; unsampled implementation details are not inferred.

Main entry points: [`MRNet+MRPyrNet/train_mrpyrnet_mrnet.py`](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/train_mrpyrnet_mrnet.py) (View training), [`ELNet+MRPyrNet/train_mrpyrnet_mrnet.py`](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/ELNet%2BMRPyrNet/train_mrpyrnet_mrnet.py) (Task training), [`MRNet+MRPyrNet/mrnetdataset.py`](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/mrnetdataset.py) (MRNet dataset), [`MRNet+MRPyrNet/mrpyrnet.py`](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/mrpyrnet.py) (MRNet MRPyrNet)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["MRI data"]
  node_mr_dataset["MRNet dataset<br/>[mrnetdataset.py]"]
  node_el_dataset["ELNet dataset<br/>[mrnetdataset.py]"]
end

subgraph group_mrnet["MRNet pipeline"]
  node_mr_train["View training"]
  node_mr_model["MRNet MRPyrNet<br/>[mrpyrnet.py]"]
  node_ensemble["Prediction ensemble"]
end

subgraph group_elnet["ELNet pipeline"]
  node_el_train["Task training"]
  node_el_model["ELNet MRPyrNet<br/>[mrpyrnet.py]"]
end

subgraph group_network["Network components"]
  node_alexnet["AlexNet backbone<br/>[alexnet.py]"]
  node_pdp["Detail pooling<br/>[pdp.py]"]
end

subgraph group_support["Shared support"]
  node_utils["MRI utilities<br/>[utils.py]"]
end

node_researcher(("Researcher"))
node_mrnet_scans[("MRNet scans")]
node_results["Diagnosis metrics"]

node_researcher -.->|"starts experiment"| node_mr_train
node_researcher -.->|"starts experiment"| node_el_train
node_mrnet_scans -.->|"provides scans"| node_mr_dataset
node_mrnet_scans -.->|"provides scans"| node_el_dataset
node_mr_train -->|"loads splits"| node_mr_dataset
node_mr_train -->|"trains model"| node_mr_model
node_mr_dataset -->|"augments scans"| node_utils
node_mr_model -->|"extracts features"| node_alexnet
node_mr_model -->|"pools details"| node_pdp
node_mr_train -.->|"supplies view models"| node_ensemble
node_ensemble -->|"loads evaluation data"| node_mr_dataset
node_ensemble -->|"writes metrics"| node_results
node_el_train -->|"loads splits"| node_el_dataset
node_el_train -->|"trains model"| node_el_model
node_el_dataset -->|"augments scans"| node_utils
node_el_model -->|"pools details"| node_pdp
node_el_train -->|"records metrics"| node_results

click node_mr_dataset "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/mrnetdataset.py"
click node_el_dataset "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/ELNet%2BMRPyrNet/mrnetdataset.py"
click node_mr_train "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/train_mrpyrnet_mrnet.py"
click node_mr_model "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/mrpyrnet.py"
click node_ensemble "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/train_logistic_regression.py"
click node_el_train "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/ELNet%2BMRPyrNet/train_mrpyrnet_mrnet.py"
click node_el_model "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/ELNet%2BMRPyrNet/mrpyrnet.py"
click node_alexnet "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/modules/alexnet.py"
click node_pdp "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/modules/pdp.py"
click node_utils "https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/modules/utils.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_mr_dataset,node_el_dataset toneBlue
class node_mr_train,node_mr_model,node_ensemble,node_mrnet_scans toneAmber
class node_el_train,node_el_model toneMint
class node_alexnet,node_pdp toneRose
class node_utils,node_researcher,node_results toneIndigo
```

## Components

### MRI data

- [MRNet dataset](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/mrnetdataset.py): `MRNet+MRPyrNet/mrnetdataset.py`
- [ELNet dataset](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/ELNet%2BMRPyrNet/mrnetdataset.py): `ELNet+MRPyrNet/mrnetdataset.py`

### MRNet pipeline

- [View training](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/train_mrpyrnet_mrnet.py): `MRNet+MRPyrNet/train_mrpyrnet_mrnet.py`
- [MRNet MRPyrNet](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/mrpyrnet.py): `MRNet+MRPyrNet/mrpyrnet.py`
- [Prediction ensemble](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/MRNet%2BMRPyrNet/train_logistic_regression.py): `MRNet+MRPyrNet/train_logistic_regression.py`

### ELNet pipeline

- [Task training](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/ELNet%2BMRPyrNet/train_mrpyrnet_mrnet.py): `ELNet+MRPyrNet/train_mrpyrnet_mrnet.py`
- [ELNet MRPyrNet](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/ELNet%2BMRPyrNet/mrpyrnet.py): `ELNet+MRPyrNet/mrpyrnet.py`

### Network components

- [AlexNet backbone](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/modules/alexnet.py): `modules/alexnet.py`
- [Detail pooling](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/modules/pdp.py): `modules/pdp.py`

### Shared support

- [MRI utilities](https://github.com/matteo-dunnhofer/mrpyrnet/blob/master/modules/utils.py): `modules/utils.py`

### Other components

- **Researcher**
- **MRNet scans**
- **Diagnosis metrics**

## Connections

- Researcher → View training: starts experiment (evidence: `README.md`)
- Researcher → Task training: starts experiment (evidence: `README.md`)
- MRNet scans → MRNet dataset: provides scans (evidence: `README.md`)
- MRNet scans → ELNet dataset: provides scans (evidence: `README.md`)
- View training → MRNet dataset: loads splits (evidence: `MRNet+MRPyrNet/train_mrpyrnet_mrnet.py`)
- View training → MRNet MRPyrNet: trains model (evidence: `MRNet+MRPyrNet/train_mrpyrnet_mrnet.py`)
- MRNet dataset → MRI utilities: augments scans (evidence: `MRNet+MRPyrNet/mrnetdataset.py`)
- MRNet MRPyrNet → AlexNet backbone: extracts features (evidence: `MRNet+MRPyrNet/mrpyrnet.py`)
- MRNet MRPyrNet → Detail pooling: pools details (evidence: `MRNet+MRPyrNet/mrpyrnet.py`)
- View training → Prediction ensemble: supplies view models (evidence: `README.md`)
- Prediction ensemble → MRNet dataset: loads evaluation data (evidence: `MRNet+MRPyrNet/train_logistic_regression.py`)
- Prediction ensemble → Diagnosis metrics: writes metrics (evidence: `MRNet+MRPyrNet/train_logistic_regression.py`)
- Task training → ELNet dataset: loads splits (evidence: `ELNet+MRPyrNet/train_mrpyrnet_mrnet.py`)
- Task training → ELNet MRPyrNet: trains model (evidence: `ELNet+MRPyrNet/train_mrpyrnet_mrnet.py`)
- ELNet dataset → MRI utilities: augments scans (evidence: `ELNet+MRPyrNet/mrnetdataset.py`)
- ELNet MRPyrNet → Detail pooling: pools details (evidence: `ELNet+MRPyrNet/mrpyrnet.py`)
- Task training → Diagnosis metrics: records metrics (evidence: `ELNet+MRPyrNet/train_mrpyrnet_mrnet.py`)
