CoolFace
Apppublic

Palakdwivedi1706/glaucoma-rag-agent

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
App README

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

  1. 1.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}$$
  1. 1.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).
  1. 1.Target IOP Decision Bounds: Target IOP thresholds are determined dynamically:
  2. 2.High Risk ($R \ge 8$): Target IOP is set to at least 30% below corrected baseline, capped at 14 mmHg.
  3. 3.Moderate Risk ($5 \le R < 8$): Target IOP is set to 20-25% below baseline, capped at 18 mmHg.
  4. 4.Mild/Low Risk ($R < 5$): Monitor baseline target (<20 mmHg).

๐Ÿ› ๏ธ Getting Started

๐Ÿ“‹ Prerequisites

Ensure you have Python 3.8+ installed. Install the backend dependencies:

bash
pip install fastapi uvicorn scikit-learn numpy pydantic

(Note: These dependencies are typically already present in science and medical environments).

๐Ÿš€ Running the Application

  1. 1.Navigate to the project root directory:
bash
   cd E:\glaucoma-rag-agent
  1. 1.Start the FastAPI backend server:
bash
   python backend/main.py

The server will start running on [http://localhost:8000](http://localhost:8000).

  1. 1.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.