Palakdwivedi1706/glaucoma-rag-agent
OculiRAG: Glaucoma Agentic RAG & Decision Framework
OculiRAG is an interactive clinical decision support web application and API prototype. It demonstrates how Retrieval-Augmented Generation (RAG) can be integrated into an agentic Chain-of-Thought (CoT) reasoning loop to solve complex diagnostic tasks in ophthalmology.
Specifically, it ingest patient physiological parameters (measured intraocular pressure (IOP), central corneal thickness (CCT), cup-to-disc ratio (CDR), family history, and age), performs a local TF-IDF semantic query against standard clinical guidelines (EGS & AAO consensus guidelines), runs a multi-agent logic flow to correct IOP measurements, weights risk markers, and predicts a safe Target IOP range and Glaucoma Progression Risk.
๐๏ธ Architecture & Reasoning Pipeline
The system models a clinical care team composed of four cooperative agents:
[Patient Data & Retinal Disc]
โ
โผ
โโโโโโโโโโโโโโโโ
โ Triage Agent โ โโโบ Extracts structural parameters & establishes risk alerts
โโโโโโโโฌโโโโโโโโ
โ Keywords
โผ
โโโโโโโโโโโโโโโโโโโ
โ Retrieval Agent โ โโโบ Executes TF-IDF Search on Guidelines Document Store (RAG)
โโโโโโโโฌโโโโโโโโโโโ
โ Guidelines Citations
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Clinical Reasoning Agent โ โโโบ Chain-of-Thought math (CCT correction) & risk scoring
โโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโ
โ Corrected IOP & Score
โผ
โโโโโโโโโโโโโโโโโโโ
โ Consensus Agent โ โโโบ Formulates clinical report, Target IOP, and risk class
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
[Web Dashboard]๐ฌ Core Clinical Rules & Formulations
- Central Corneal Thickness (CCT) Correction: Goldmann Applanation Tonometry assumes a baseline corneal thickness of 545 ยตm. Thinner corneas artificially underestimate pressure (masking glaucoma risk), while thicker corneas overestimate it. The framework applies a linear correction: $$\text{IOP}{\text{corrected}} = \text{IOP}{\text{measured}} + \frac{545 - \text{CCT}}{10} \times 0.6 \, \text{mmHg}$$
- Progression Risk Score ($R \in [0, 15]$): Integrates corrected IOP, vertical Cup-to-Disc ratio, CCT boundaries, family history, and systemic vasospastic indicators (e.g. Migraines, Raynaud's).
- Target IOP Decision Bounds: Target IOP thresholds are determined dynamically:
- High Risk ($R \ge 8$): Target IOP is set to at least 30% below corrected baseline, capped at 14 mmHg.
- Moderate Risk ($5 \le R < 8$): Target IOP is set to 20-25% below baseline, capped at 18 mmHg.
- Mild/Low Risk ($R < 5$): Monitor baseline target (<20 mmHg).
๐ ๏ธ Getting Started
๐ Prerequisites
Ensure you have Python 3.8+ installed. Install the backend dependencies:
pip install fastapi uvicorn scikit-learn numpy pydantic(Note: These dependencies are typically already present in science and medical environments).
๐ Running the Application
- Navigate to the project root directory:
cd E:\glaucoma-rag-agent- Start the FastAPI backend server:
python backend/main.pyThe server will start running on [http://localhost:8000](http://localhost:8000).
- Access the Web Dashboard: Open your web browser and navigate to:
http://localhost:8000/(FastAPI automatically serves the `index.html` dashboard directly from the root port).
๐ Developer & Research Resources Panel
A slide-up resources panel is built directly into the bottom footer of the web dashboard. Developers, students, or clinicians can:
- View and copy the Mermaid.js Flowchart code for the multi-agent decision pipeline.
- Retrieve LaTeX Formulas for medical manuscript typesetting or documentation.
- Read descriptive commentary describing the logical difference between traditional heuristic clinical rules and modern LLM-driven agent reasoning pipelines.
