# ntejas-1/rsna-knee-abnormality-detection architecture

> Architecture diagram of the GitHub repository ntejas-1/rsna-knee-abnormality-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ntejas-1/rsna-knee-abnormality-detection
- Repository: https://github.com/ntejas-1/rsna-knee-abnormality-detection

## Overview

This repository builds and submits an ensemble for RSNA knee MRI abnormality detection. Its main workflow turns radiology reports into training targets, preprocesses MRI series into a cache, trains two model arms, and appends their rank-based predictions to a reference ensemble before publishing a submission. It also includes OOF evaluation and per-finding blend configuration. The README documents the end-to-end stages and the notebook’s staging-file flow; unsampled implementation details are represented only where those documented relationships support them.

Main entry points: [`train/train_armA.py`](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/train/train_armA.py) (Arm A training), [`labels_ds/labels_v1_opus45.csv`](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/labels_ds/labels_v1_opus45.csv) (Extracted labels), [`cache`](https://github.com/ntejas-1/rsna-knee-abnormality-detection/tree/main/cache) (Sharded image cache), [`train/train_armB.py`](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/train/train_armB.py) (Arm B training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_labels["Report labels"]
  node_reports["Radiology reports"]
  node_cortex["Cortex extraction<br/>[02_prompt_v1.sql]"]
  node_label_data["Extracted labels"]
end

subgraph group_images["Image preparation"]
  node_cache_builder["DICOM cache builder<br/>[build_cache.py]"]
  node_dicom[("Competition MRI data")]
  node_cache_data[("Sharded image cache")]
end

subgraph group_models["Modeling and evaluation"]
  node_arm_a["Arm A training<br/>[train_armA.py]"]
  node_arm_b["Arm B training<br/>[train_armB.py]"]
  node_checkpoints["Fold checkpoints"]
  node_oof_data["OOF predictions"]
  node_oof_eval["OOF evaluation<br/>[eval_oof.py]"]
end

subgraph group_submission["Inference and submission"]
  node_blend_config["Per-label weights<br/>[blend_weights.py]"]
  node_reference["Reference ensemble"]
  node_blend["Appended arm blend<br/>[blend_cell.py]"]
  node_stage[("Prediction staging file")]
  node_publish["Submission publisher"]
end

node_competition(("Kaggle competition"))

node_reports -->|"provides text"| node_cortex
node_cortex -->|"extracts targets"| node_label_data
node_dicom -->|"provides series"| node_cache_builder
node_cache_builder -->|"writes shards"| node_cache_data
node_cache_data -->|"feeds training"| node_arm_a
node_label_data -->|"provides targets"| node_arm_a
node_cache_data -->|"feeds training"| node_arm_b
node_label_data -->|"provides targets"| node_arm_b
node_arm_a -->|"trains folds"| node_checkpoints
node_arm_b -->|"trains folds"| node_checkpoints
node_arm_a -->|"produces predictions"| node_oof_data
node_oof_data -->|"evaluated by"| node_oof_eval
node_checkpoints -->|"runs inference"| node_blend
node_reference -->|"writes predictions"| node_stage
node_blend_config -->|"configures weights"| node_blend
node_blend -->|"updates predictions"| node_stage
node_stage -->|"provides predictions"| node_publish
node_publish -->|"submits result"| node_competition

click node_cortex "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/sql/02_prompt_v1.sql"
click node_label_data "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/labels_ds/labels_v1_opus45.csv"
click node_cache_builder "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/cache/build_cache.py"
click node_cache_data "https://github.com/ntejas-1/rsna-knee-abnormality-detection/tree/main/cache"
click node_arm_a "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/train/train_armA.py"
click node_arm_b "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/train/train_armB.py"
click node_oof_data "https://github.com/ntejas-1/rsna-knee-abnormality-detection/tree/main/oof"
click node_oof_eval "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/tools/eval_oof.py"
click node_blend_config "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/submit/blend_weights.py"
click node_reference "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/ref_kernel/rsna-knee-speedy-raptors-coatnet-d4-sota.ipynb"
click node_blend "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/submit/blend_cell.py"
click node_publish "https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/push/rsna-knee-dinov2-coatnet-repro.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_reports,node_cortex,node_label_data toneBlue
class node_cache_builder,node_dicom,node_cache_data toneAmber
class node_arm_a,node_arm_b,node_checkpoints,node_oof_data,node_oof_eval toneMint
class node_blend_config,node_reference,node_blend,node_stage,node_publish toneRose
class node_competition toneIndigo
```

## Components

### Report labels

- **Radiology reports**
- [Cortex extraction](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/sql/02_prompt_v1.sql): `sql/02_prompt_v1.sql`
- [Extracted labels](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/labels_ds/labels_v1_opus45.csv): `labels_ds/labels_v1_opus45.csv`

### Image preparation

- [DICOM cache builder](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/cache/build_cache.py): `cache/build_cache.py`
- **Competition MRI data**
- [Sharded image cache](https://github.com/ntejas-1/rsna-knee-abnormality-detection/tree/main/cache): `cache`

### Modeling and evaluation

- [Arm A training](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/train/train_armA.py): `train/train_armA.py`
- [Arm B training](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/train/train_armB.py): `train/train_armB.py`
- **Fold checkpoints**
- [OOF predictions](https://github.com/ntejas-1/rsna-knee-abnormality-detection/tree/main/oof): `oof`
- [OOF evaluation](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/tools/eval_oof.py): `tools/eval_oof.py`

### Inference and submission

- [Per-label weights](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/submit/blend_weights.py): `submit/blend_weights.py`
- [Reference ensemble](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/ref_kernel/rsna-knee-speedy-raptors-coatnet-d4-sota.ipynb): `ref_kernel/rsna-knee-speedy-raptors-coatnet-d4-sota.ipynb`
- [Appended arm blend](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/submit/blend_cell.py): `submit/blend_cell.py`
- **Prediction staging file**
- [Submission publisher](https://github.com/ntejas-1/rsna-knee-abnormality-detection/blob/main/push/rsna-knee-dinov2-coatnet-repro.ipynb): `push/rsna-knee-dinov2-coatnet-repro.ipynb`

### Other components

- **Kaggle competition**

## Connections

- Radiology reports → Cortex extraction: provides text (evidence: `README.md`)
- Cortex extraction → Extracted labels: extracts targets (evidence: `README.md`)
- Competition MRI data → DICOM cache builder: provides series (evidence: `README.md`)
- DICOM cache builder → Sharded image cache: writes shards (evidence: `README.md`)
- Sharded image cache → Arm A training: feeds training (evidence: `README.md`)
- Extracted labels → Arm A training: provides targets (evidence: `README.md`)
- Sharded image cache → Arm B training: feeds training (evidence: `README.md`)
- Extracted labels → Arm B training: provides targets (evidence: `README.md`)
- Arm A training → Fold checkpoints: trains folds (evidence: `README.md`)
- Arm B training → Fold checkpoints: trains folds (evidence: `README.md`)
- Arm A training → OOF predictions: produces predictions (evidence: `README.md`)
- OOF predictions → OOF evaluation: evaluated by (evidence: `tools/eval_oof.py`)
- Fold checkpoints → Appended arm blend: runs inference (evidence: `README.md`)
- Reference ensemble → Prediction staging file: writes predictions (evidence: `README.md`)
- Per-label weights → Appended arm blend: configures weights (evidence: `submit/blend_weights.py`)
- Appended arm blend → Prediction staging file: updates predictions (evidence: `submit/blend_cell.py`)
- Prediction staging file → Submission publisher: provides predictions (evidence: `README.md`)
- Submission publisher → Kaggle competition: submits result (evidence: `README.md`)
