A real-time EEG monitoring system for detecting and predicting dementia episodes and agitation in elderly patients.
This 24-hour hackathon MVP streams 8-channel EEG data at 250 Hz, performs on-device preprocessing, and uses machine learning to predict frustration and dementia episodes. A web-based dashboard provides real-time visualization for clinicians.
EEG Device (8ch @ 250Hz)
│
▼
Edge Processor (Mobile/Raspberry Pi)
│
▼
Backend API (FastAPI)
│
▼
Prediction Engine (ML Model)
│
▼
Dashboard (React)
.
├── backend/ # FastAPI backend service
│ ├── app/
│ │ ├── api/ # API routes
│ │ ├── models/ # Pydantic schemas
│ │ └── database/ # Database connection & schema
│ ├── main.py # Application entry point
│ └── requirements.txt
│
├── edge-processor/ # Edge device preprocessing
│ ├── filters/ # Signal filtering
│ ├── features/ # Feature extraction
│ ├── utils/ # Configuration
│ ├── main.py # Edge processor main
│ └── requirements.txt
│
├── prediction-engine/ # ML prediction service
│ ├── models/ # Trained models
│ ├── training/ # Training scripts
│ ├── predictor.py # Prediction logic
│ └── requirements.txt
│
├── dashboard/ # React web dashboard
│ ├── src/
│ │ ├── components/ # React components
│ │ └── App.jsx # Main application
│ └── package.json
│
├── docker-compose.yml # Docker orchestration
└── ARCHITECTURE.md # Detailed architecture docs
- Docker & Docker Compose
- Python 3.11+
- Node.js 18+
- Clone the repository:
git clone <repo-url>
cd hob-empathy- Start all services:
docker-compose up -d- Access the services:
- Dashboard: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Database: localhost:5432
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reloadcd dashboard
npm install
npm run devcd edge-processor
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python main.pycd prediction-engine
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python predictor.pyPOST /api/v1/ingest- Receive EEG features from edge deviceGET /api/v1/patient/{id}/state- Get latest patient stateGET /api/v1/history/{id}- Get historical dataWS /api/v1/stream- WebSocket for real-time updates
- Band-pass filter (1-40 Hz)
- Notch filter (50/60 Hz)
- Feature extraction:
- Bandpower (Delta, Theta, Alpha, Beta)
- Spectral entropy
- Hjorth parameters
- Signal variance
- Rule-based risk assessment (MVP)
- Support for ML models (Random Forest, LightGBM)
- Risk levels:
- 0.0-0.3: Normal
- 0.3-0.6: Mild agitation
- 0.6-1.0: Elevated risk
- Real-time EEG visualization
- Risk gauge
- Alert notifications
- Patient information
- Historical trends
Copy .env.example to .env and configure:
cp .env.example .envEdit .env with your settings:
- Database credentials
- Backend URL
- Sampling rate and filter settings
- Patient ID
- Backend routes:
backend/app/api/routes.py - Data models:
backend/app/models/schemas.py - Signal processing:
edge-processor/filters/andedge-processor/features/ - ML models:
prediction-engine/training/ - UI components:
dashboard/src/components/
See backend/app/database/schema.sql for the complete schema.
Tables:
patients- Patient informationfeatures- EEG feature historypredictions- Risk predictionsalerts- Alert history
- Set up proper authentication (JWT)
- Configure HTTPS/WSS
- Use production database (managed PostgreSQL)
- Enable CORS properly
- Set up monitoring and logging
- Use environment-specific configs
- Backend: Docker (AWS ECS, GCP Cloud Run, Azure Container Instances)
- Database: AWS RDS, GCP Cloud SQL, Azure Database for PostgreSQL
- Dashboard: Vercel, Netlify, AWS Amplify
- Edge: Android/iOS app or Raspberry Pi
# Backend tests
cd backend
pytest
# Frontend tests
cd dashboard
npm test# Clean up and restart
docker-compose down -v
docker-compose up --buildCheck if PostgreSQL is running:
docker-compose ps
docker-compose logs dbEnsure backend is running and accessible. Check browser console for errors.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License
MVP developed for 24-hour hackathon
- EEG signal processing based on research in dementia detection
- Frontend UI inspired by clinical monitoring systems