# ghanshyamdhamat/medgemma_impact_challenge architecture

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

- Interactive diagram: https://gitdiagram.com/ghanshyamdhamat/medgemma_impact_challenge
- Repository: https://github.com/ghanshyamdhamat/medgemma_impact_challenge

## Overview

UniRad3s is a Gradio radiology application for MRI patient review, lesion diagnosis and segmentation, analysis, and report generation. Its documented workflow runs from NIfTI upload and patient selection through interactive MedSAM2 prompts and slice propagation to measurement, parcellation, and clinical and patient reports. The README supplies the product-level workflow; SOURCE INDEX references support selected model relationships. The large UI and pipeline sources were not excerpted, so internal wiring beyond those references is represented only where documented.

Main entry points: [`unirad3s/app_unirad3s.py`](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py) (Gradio Application), [`sam2/modeling/sam2_base.py`](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/modeling/sam2_base.py) (SAM2 Model Core), [`sam2/sam2_video_predictor.py`](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/sam2_video_predictor.py) (Slice Propagation), [`unirad3s/medsgilip_finetuning.py`](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/medsgilip_finetuning.py) (Scan Diagnosis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Radiology Workflow"]
  node_ui["Gradio Application<br/>[app_unirad3s.py]"]
  node_patient_records[("Patient Records<br/>[app_unirad3s.py]")]
  node_pipeline["Batch Pipeline<br/>[pipeline.py]"]
  node_volume_video["Volume to Video<br/>[app_unirad3s.py]"]
  node_prompting["Interactive Prompts<br/>[app_unirad3s.py]"]
  node_tracking["Slice Propagation"]
end

subgraph group_models["AI Models"]
  node_diagnosis["Scan Diagnosis"]
end

subgraph group_analysis["Analysis and Reporting"]
  node_lesion_analysis["Lesion Measurements<br/>[app_unirad3s.py]"]
  node_parcellation["Parcellation"]
  node_mask_export["NIfTI Mask Export<br/>[app_unirad3s.py]"]
  node_reporting["Report Generation<br/>[simplify_report.py]"]
end

subgraph group_segmentation_core["Segmentation Engine"]
  node_sam_builder["SAM2 Builder<br/>[build_sam.py]"]
  node_sam_base["SAM2 Model Core<br/>[sam2_base.py]"]
  node_prompt_encoder["Prompt Encoder<br/>[prompt_encoder.py]"]
  node_mask_decoder["Mask Decoder<br/>[mask_decoder.py]"]
  node_efficienttam_builder["EfficientTAM Builder"]
  node_efficienttam_model["EfficientTAM Model"]
  node_efficienttam_video["EfficientTAM Video Tracker"]
end

node_clinician(("Clinician"))
node_mri["NIfTI Scans"]
node_medsiglip{{"MedSigLIP"}}
node_medgemma{{"MedGemma"}}

node_clinician -->|"uses"| node_ui
node_mri -->|"uploads"| node_ui
node_ui -->|"organizes"| node_patient_records
node_ui -->|"requests diagnosis"| node_diagnosis
node_diagnosis -->|"analyzes scans"| node_medsiglip
node_ui -->|"prepares volume"| node_volume_video
node_ui -->|"accepts prompts"| node_prompting
node_prompting -->|"starts propagation"| node_tracking
node_tracking -->|"uses model"| node_sam_builder
node_sam_builder -->|"builds"| node_sam_base
node_sam_base -->|"uses"| node_prompt_encoder
node_sam_base -->|"uses"| node_mask_decoder
node_ui -->|"shows measurements"| node_lesion_analysis
node_ui -->|"requests grounding"| node_parcellation
node_ui -->|"exports masks"| node_mask_export
node_ui -->|"requests reports"| node_reporting
node_reporting -->|"generates reports"| node_medgemma
node_ui -->|"offers batch workflow"| node_pipeline
node_efficienttam_video -->|"loads model"| node_efficienttam_builder
node_efficienttam_builder -->|"constructs"| node_efficienttam_model

click node_ui "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py"
click node_patient_records "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py"
click node_pipeline "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/pipeline.py"
click node_diagnosis "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/medsgilip_finetuning.py"
click node_volume_video "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py"
click node_prompting "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py"
click node_tracking "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/sam2_video_predictor.py"
click node_sam_builder "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/build_sam.py"
click node_sam_base "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/modeling/sam2_base.py"
click node_prompt_encoder "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/modeling/sam/prompt_encoder.py"
click node_mask_decoder "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/modeling/sam/mask_decoder.py"
click node_lesion_analysis "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py"
click node_parcellation "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/parcellations/parcellation_by_registration.py"
click node_mask_export "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py"
click node_reporting "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/simplify_report.py"
click node_efficienttam_builder "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/efficient_track_anything/build_efficienttam.py"
click node_efficienttam_model "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/efficient_track_anything/modeling/efficienttam_base.py"
click node_efficienttam_video "https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/efficient_track_anything/efficienttam_video_predictor.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_ui,node_patient_records,node_pipeline,node_volume_video,node_prompting,node_tracking toneBlue
class node_diagnosis toneAmber
class node_lesion_analysis,node_parcellation,node_mask_export,node_reporting toneMint
class node_sam_builder,node_sam_base,node_prompt_encoder,node_mask_decoder,node_efficienttam_builder,node_efficienttam_model,node_efficienttam_video toneRose
class node_clinician,node_mri,node_medsiglip,node_medgemma toneIndigo
```

## Components

### Radiology Workflow

- [Gradio Application](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py): `unirad3s/app_unirad3s.py`
- [Patient Records](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py): `unirad3s/app_unirad3s.py`
- [Batch Pipeline](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/pipeline.py): `unirad3s/pipeline.py`
- [Volume to Video](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py): `unirad3s/app_unirad3s.py`
- [Interactive Prompts](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py): `unirad3s/app_unirad3s.py`
- [Slice Propagation](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/sam2_video_predictor.py): `sam2/sam2_video_predictor.py`

### AI Models

- [Scan Diagnosis](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/medsgilip_finetuning.py): `unirad3s/medsgilip_finetuning.py`

### Analysis and Reporting

- [Lesion Measurements](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py): `unirad3s/app_unirad3s.py`
- [Parcellation](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/parcellations/parcellation_by_registration.py): `parcellations/parcellation_by_registration.py`
- [NIfTI Mask Export](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/app_unirad3s.py): `unirad3s/app_unirad3s.py`
- [Report Generation](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/unirad3s/simplify_report.py): `unirad3s/simplify_report.py`

### Segmentation Engine

- [SAM2 Builder](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/build_sam.py): `sam2/build_sam.py`
- [SAM2 Model Core](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/modeling/sam2_base.py): `sam2/modeling/sam2_base.py`
- [Prompt Encoder](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/modeling/sam/prompt_encoder.py): `sam2/modeling/sam/prompt_encoder.py`
- [Mask Decoder](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/sam2/modeling/sam/mask_decoder.py): `sam2/modeling/sam/mask_decoder.py`
- [EfficientTAM Builder](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/efficient_track_anything/build_efficienttam.py): `efficient_track_anything/build_efficienttam.py`
- [EfficientTAM Model](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/efficient_track_anything/modeling/efficienttam_base.py): `efficient_track_anything/modeling/efficienttam_base.py`
- [EfficientTAM Video Tracker](https://github.com/ghanshyamdhamat/medgemma_impact_challenge/blob/main/efficient_track_anything/efficienttam_video_predictor.py): `efficient_track_anything/efficienttam_video_predictor.py`

### Other components

- **Clinician**
- **NIfTI Scans**
- **MedSigLIP**
- **MedGemma**

## Connections

- Clinician → Gradio Application: uses (evidence: `README.md`)
- NIfTI Scans → Gradio Application: uploads (evidence: `README.md`)
- Gradio Application → Patient Records: organizes (evidence: `README.md`)
- Gradio Application → Scan Diagnosis: requests diagnosis (evidence: `README.md`)
- Scan Diagnosis → MedSigLIP: analyzes scans (evidence: `README.md`)
- Gradio Application → Volume to Video: prepares volume (evidence: `README.md`)
- Gradio Application → Interactive Prompts: accepts prompts (evidence: `README.md`)
- Interactive Prompts → Slice Propagation: starts propagation (evidence: `README.md`)
- Slice Propagation → SAM2 Builder: uses model (evidence: `sam2/sam2_video_predictor.py`)
- SAM2 Builder → SAM2 Model Core: builds (evidence: `sam2/build_sam.py`)
- SAM2 Model Core → Prompt Encoder: uses (evidence: `sam2/modeling/sam2_base.py`)
- SAM2 Model Core → Mask Decoder: uses (evidence: `sam2/modeling/sam2_base.py`)
- Gradio Application → Lesion Measurements: shows measurements (evidence: `README.md`)
- Gradio Application → Parcellation: requests grounding (evidence: `README.md`)
- Gradio Application → NIfTI Mask Export: exports masks (evidence: `README.md`)
- Gradio Application → Report Generation: requests reports (evidence: `README.md`)
- Report Generation → MedGemma: generates reports (evidence: `README.md`)
- Gradio Application → Batch Pipeline: offers batch workflow (evidence: `README.md`)
- EfficientTAM Video Tracker → EfficientTAM Builder: loads model (evidence: `efficient_track_anything/efficienttam_video_predictor.py`)
- EfficientTAM Builder → EfficientTAM Model: constructs (evidence: `efficient_track_anything/build_efficienttam.py`)
