# vanithamagesh/bifam-next architecture

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

- Interactive diagram: https://gitdiagram.com/vanithamagesh/bifam-next
- Repository: https://github.com/vanithamagesh/bifam-next

## Overview

BiFAM-Next is a research pipeline for brain-tumor MRI classification and attention localization. Its main workflow prepares and partitions MRI slices, trains/evaluates the classifier (with mask-supervised attention during training), and saves predictions and metrics; analysis then examines attention and redraws paper figures. The model and local driver are sampled, while notebook workflows and several analysis capabilities are documented but not fully inspected, so those links rely on the README. Results files are retained as artifacts, not a runtime database.

Main entry points: [`results`](https://github.com/vanithamagesh/bifam-next/tree/main/results) (Predictions and metrics), [`src/run_local.py`](https://github.com/vanithamagesh/bifam-next/blob/main/src/run_local.py) (Local experiment driver), [`figures`](https://github.com/vanithamagesh/bifam-next/tree/main/figures) (Paper figures), [`src/jobs_core.py`](https://github.com/vanithamagesh/bifam-next/blob/main/src/jobs_core.py) (Experiment jobs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_prep["Data preparation"]
end

subgraph group_model["Model and training"]
  node_model_impl["BiFAM-Next model<br/>[bifamnet.py]"]
  node_job_definitions["Experiment jobs<br/>[jobs_core.py]"]
  node_local_driver["Local experiment driver<br/>[run_local.py]"]
  node_training["Training and evaluation<br/>[bifamnet.py]"]
end

subgraph group_analysis["Evaluation and analysis"]
  node_attention_analysis["Attention localization"]
  node_attention_gallery["Attention gallery"]
  node_ablation_plot["Ablation figure<br/>[fig_ablation.py]"]
  node_ensemble_plot["Ensemble figure<br/>[fig_ensemble8.py]"]
  node_localization_plot["Localization figure"]
end

subgraph group_artifacts["Research outputs"]
  node_run_artifacts["Predictions and metrics"]
  node_paper_figures["Paper figures"]
end

node_researcher(("Researcher"))
node_datasets["MRI datasets"]

node_researcher -->|"prepares data"| node_prep
node_datasets -->|"provides images"| node_prep
node_prep -->|"supplies partitions"| node_training
node_researcher -->|"selects jobs"| node_job_definitions
node_job_definitions -->|"uses model"| node_model_impl
node_job_definitions -->|"invokes driver"| node_local_driver
node_researcher -->|"runs experiments"| node_local_driver
node_local_driver -->|"imports module"| node_model_impl
node_local_driver -->|"calls training"| node_training
node_training -->|"saves results"| node_run_artifacts
node_run_artifacts -->|"provides checkpoints"| node_attention_analysis
node_run_artifacts -->|"provides checkpoints"| node_attention_gallery
node_run_artifacts -->|"provides metrics"| node_ablation_plot
node_run_artifacts -->|"provides predictions"| node_ensemble_plot
node_run_artifacts -->|"provides localization data"| node_localization_plot
node_attention_analysis -->|"writes analysis"| node_run_artifacts
node_attention_gallery -->|"creates figures"| node_paper_figures
node_ablation_plot -->|"writes figure"| node_paper_figures
node_ensemble_plot -->|"writes figure"| node_paper_figures
node_localization_plot -->|"writes figure"| node_paper_figures

click node_prep "https://github.com/vanithamagesh/bifam-next/blob/main/notebooks/BiFAM_Next_jobs.ipynb"
click node_model_impl "https://github.com/vanithamagesh/bifam-next/blob/main/src/bifamnet.py"
click node_job_definitions "https://github.com/vanithamagesh/bifam-next/blob/main/src/jobs_core.py"
click node_local_driver "https://github.com/vanithamagesh/bifam-next/blob/main/src/run_local.py"
click node_training "https://github.com/vanithamagesh/bifam-next/blob/main/src/bifamnet.py"
click node_run_artifacts "https://github.com/vanithamagesh/bifam-next/tree/main/results"
click node_attention_analysis "https://github.com/vanithamagesh/bifam-next/blob/main/notebooks/Paper1_localization.ipynb"
click node_attention_gallery "https://github.com/vanithamagesh/bifam-next/blob/main/notebooks/Attention_gallery.ipynb"
click node_ablation_plot "https://github.com/vanithamagesh/bifam-next/blob/main/analysis/fig_ablation.py"
click node_ensemble_plot "https://github.com/vanithamagesh/bifam-next/blob/main/analysis/fig_ensemble8.py"
click node_localization_plot "https://github.com/vanithamagesh/bifam-next/blob/main/analysis/fig_localization.py"
click node_paper_figures "https://github.com/vanithamagesh/bifam-next/tree/main/figures"

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_prep toneBlue
class node_model_impl,node_job_definitions,node_local_driver,node_training toneAmber
class node_attention_analysis,node_attention_gallery,node_ablation_plot,node_ensemble_plot,node_localization_plot toneMint
class node_run_artifacts,node_paper_figures toneRose
class node_researcher,node_datasets toneIndigo
```

## Components

### Data preparation

- [Data preparation](https://github.com/vanithamagesh/bifam-next/blob/main/notebooks/BiFAM_Next_jobs.ipynb): `notebooks/BiFAM_Next_jobs.ipynb`

### Model and training

- [BiFAM-Next model](https://github.com/vanithamagesh/bifam-next/blob/main/src/bifamnet.py): `src/bifamnet.py`
- [Experiment jobs](https://github.com/vanithamagesh/bifam-next/blob/main/src/jobs_core.py): `src/jobs_core.py`
- [Local experiment driver](https://github.com/vanithamagesh/bifam-next/blob/main/src/run_local.py): `src/run_local.py`
- [Training and evaluation](https://github.com/vanithamagesh/bifam-next/blob/main/src/bifamnet.py): `src/bifamnet.py`

### Evaluation and analysis

- [Attention localization](https://github.com/vanithamagesh/bifam-next/blob/main/notebooks/Paper1_localization.ipynb): `notebooks/Paper1_localization.ipynb`
- [Attention gallery](https://github.com/vanithamagesh/bifam-next/blob/main/notebooks/Attention_gallery.ipynb): `notebooks/Attention_gallery.ipynb`
- [Ablation figure](https://github.com/vanithamagesh/bifam-next/blob/main/analysis/fig_ablation.py): `analysis/fig_ablation.py`
- [Ensemble figure](https://github.com/vanithamagesh/bifam-next/blob/main/analysis/fig_ensemble8.py): `analysis/fig_ensemble8.py`
- [Localization figure](https://github.com/vanithamagesh/bifam-next/blob/main/analysis/fig_localization.py): `analysis/fig_localization.py`

### Research outputs

- [Predictions and metrics](https://github.com/vanithamagesh/bifam-next/tree/main/results): `results`
- [Paper figures](https://github.com/vanithamagesh/bifam-next/tree/main/figures): `figures`

### Other components

- **Researcher**
- **MRI datasets**

## Connections

- Researcher → Data preparation: prepares data (evidence: `README.md`)
- MRI datasets → Data preparation: provides images (evidence: `README.md`)
- Data preparation → Training and evaluation: supplies partitions (evidence: `README.md`)
- Researcher → Experiment jobs: selects jobs (evidence: `README.md`)
- Experiment jobs → BiFAM-Next model: uses model (evidence: `src/jobs_core.py`)
- Experiment jobs → Local experiment driver: invokes driver (evidence: `src/jobs_core.py`)
- Researcher → Local experiment driver: runs experiments (evidence: `README.md`)
- Local experiment driver → BiFAM-Next model: imports module (evidence: `src/run_local.py`)
- Local experiment driver → Training and evaluation: calls training (evidence: `src/run_local.py`)
- Training and evaluation → Predictions and metrics: saves results (evidence: `README.md`)
- Predictions and metrics → Attention localization: provides checkpoints (evidence: `README.md`)
- Predictions and metrics → Attention gallery: provides checkpoints (evidence: `README.md`)
- Predictions and metrics → Ablation figure: provides metrics (evidence: `analysis/fig_ablation.py`)
- Predictions and metrics → Ensemble figure: provides predictions (evidence: `analysis/fig_ensemble8.py`)
- Predictions and metrics → Localization figure: provides localization data (evidence: `analysis/fig_localization.py`)
- Attention localization → Predictions and metrics: writes analysis (evidence: `README.md`)
- Attention gallery → Paper figures: creates figures (evidence: `README.md`)
- Ablation figure → Paper figures: writes figure (evidence: `analysis/fig_ablation.py`)
- Ensemble figure → Paper figures: writes figure (evidence: `analysis/fig_ensemble8.py`)
- Localization figure → Paper figures: writes figure (evidence: `analysis/fig_localization.py`)
