File size: 4,668 Bytes
a446f12
dc45d07
8d48081
a446f12
8d48081
a446f12
8d48081
a446f12
dc45d07
8d48081
 
 
 
 
a446f12
8d48081
225e05c
a446f12
 
8d48081
a446f12
8d48081
a446f12
8d48081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225e05c
8d48081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
title: Epilepsy Management AI Agent
emoji: 🧠
colorFrom: red
colorTo: purple
sdk: docker
app_port: 7860
tags:
- streamlit
- medical-ai
- epilepsy
- chromadb
- semantic-search
- healthcare
pinned: false
license: apache-2.0
short_description: AI-powered epilepsy device recommendations
---

# 🧠 Epilepsy Management AI Agent

AI-powered medical device recommendation system for epilepsy management using semantic search, safety filtering, and evidence-based ranking.

## 🎯 What This App Does

This Streamlit application helps clinicians and patients explore epilepsy management devices based on patient-specific descriptions. It uses:

- **Semantic Search**: ChromaDB + Sentence Transformers for intelligent device matching
- **Safety Rules**: Configurable filters for invasiveness and regulatory approvals (FDA/CE)
- **Interactive UI**: Multi-page interface with device catalog, admin tools, and recommendations

## ✨ Features

- πŸ“ **Patient Input β†’ Smart Recommendations**: Describe patient condition and receive personalized device suggestions
- πŸ” **Semantic Search**: Uses `all-MiniLM-L6-v2` embeddings for intelligent text matching
- πŸ›‘οΈ **Safety Filters**: Toggle invasive device filtering and requirement for specific approvals
- πŸ“š **Device Catalog**: Browse and search the complete knowledge base
- πŸ› οΈ **Admin Tools**: Upload CSV data and rebuild vector index
- πŸ“Š **Detailed Results**: View device specifications, approvals, indications, and source links

## πŸš€ How to Use

1. **Enter Patient Description**: Describe the patient's epilepsy characteristics (seizure type, frequency, age, lifestyle needs)
2. **Configure Filters**: 
   - Toggle "Avoid invasive devices" on/off
   - Specify required approvals (e.g., "FDA, CE")
   - Adjust top K results (1-10)
3. **Generate Recommendations**: Click the button to get AI-filtered device suggestions
4. **Explore Results**: View device details, click source links, and browse the full catalog

## πŸ“‹ Example Query

> "16-year-old with focal aware seizures 2–3 times/week, mostly nocturnal; wants non-invasive detection and caregiver alerts."

## πŸ—οΈ Architecture

```
Patient Input β†’ Semantic Search (ChromaDB) 
             β†’ Safety Rules Filtering 
             β†’ Ranked Recommendations 
             β†’ Interactive Display
```

### Technologies
- **Streamlit**: Web UI framework
- **ChromaDB**: Vector database for semantic search
- **Sentence Transformers**: Text embeddings (all-MiniLM-L6-v2)
- **Pandas**: Data manipulation
- **Python 3.11**: Runtime environment

## πŸ“ Project Structure

```
Epilepsy-Management-AI-Agent/
β”œβ”€β”€ src/
β”‚   └── app.py              # Main Streamlit application
β”œβ”€β”€ pages/
β”‚   β”œβ”€β”€ 1_πŸ“š_Device_Catalog.py    # Browse all devices
β”‚   β”œβ”€β”€ 2_πŸ› οΈ_Admin_ETL.py        # CSV upload & index rebuild
β”‚   └── 3_ℹ️_About.py            # Project information
β”œβ”€β”€ data/
β”‚   └── devices.csv          # Device catalog database
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ embeddings.py        # ChromaDB integration
β”‚   └── rules.py            # Safety rule filtering
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ Dockerfile              # Container configuration
└── README.md              # This file
```

## βš™οΈ Deployment

This app is containerized using Docker and deployed on Hugging Face Spaces.

### Local Development
```bash
# Build and run
docker build -t epilepsy-ai .
docker run -p 7860:7860 epilepsy-ai

# Or with Streamlit directly
pip install -r requirements.txt
streamlit run src/app.py
```

## πŸ“Š Data Model

The device catalog (`data/devices.csv`) includes:
- `device_id`: Unique identifier
- `name`: Device name
- `category`: Device type (wearable, implant, etc.)
- `indication`: Use case
- `invasiveness`: Invasive/Non-invasive
- `approvals`: Regulatory status (FDA, CE, etc.)
- `summary`: Description text
- `source_url`: Reference link
- `last_seen`: Timestamp

## ⚠️ Important Notice

This tool provides **informational recommendations only** and is **not a substitute for professional medical advice**. Always consult a licensed clinician for diagnosis and treatment decisions.

## πŸ”§ Configuration

- **ChromaDB**: Persists in `.chroma/` directory (rebuilds automatically on HF Spaces)
- **Model**: `sentence-transformers/all-MiniLM-L6-v2` (~80MB, downloads on first run)
- **Port**: 7860 (Hugging Face default)

## πŸ“ License

Apache 2.0

## πŸ‘₯ Contributing

Feel free to submit issues or improvements to the device catalog or codebase.

---

Built with ❀️ for epilepsy management and healthcare innovation.