What inspired us: The "Cocooning" Fallacy
For decades, the standard medical advice for a concussion was "cocooning"—putting the patient in a dark room and avoiding all physical and cognitive activity. However, the recent 6th International Consensus Statement on Concussion in Sport completely debunked this. Prolonged rest actually delays recovery. The new medical gold standard is active recovery: targeted autonomic conditioning and vestibular rehabilitation.
The problem? Specialized clinical tools like the Buffalo Concussion Treadmill Test (BCTT) and Vestibular/Ocular Motor Screening (VOMS) are heavily gatekept by expensive sports medicine clinics. We were inspired to build NeuroSpace, democratizing clinical-grade, AI-driven concussion recovery by bringing it directly into the browser for anyone with a webcam and an internet connection.
How we built it
NeuroSpace is a full-stack clinical platform built with a Next.js/React frontend and a FastAPI (Python) backend. It features three core engines:
- BCTT Pacing Engine: An interactive autonomic conditioning module that dynamically calculates sub-symptom heart rate thresholds based on patient demographics.
- VOMS ML Edge-Compute: A browser-based eye-tracking module using WebGazer.js that automates "Guided Saccade" physical therapy exercises using just a webcam.
- Hybrid Ensemble Medical RAG: We built a highly advanced, hallucination-free AI assistant powered by Google Gemini 3.6 Flash.
Instead of a standard RAG pipeline, we engineered a custom dual-vector architecture. The backend uses PyMuPDF for layout-aware text parsing and utilizes Gemini Vision (VLM) for zero-shot extraction of visual medical flowcharts from clinical PDFs into Markdown. When a user asks a question, the AI simultaneously queries a Parent-Child Retriever (mapping 300-character children to 1500-character broad contexts) AND a Standard Dense Retriever (500-character factual chunks). It then algorithmically deduplicates overlapping chunks in memory before feeding the optimized context to the LLM to prevent token bloat.
Challenges we ran into
Our biggest challenge was a catastrophic failure in our edge-compute Machine Learning pipeline. While building the browser-based eye-tracking, we encountered a mathematical "Matrix Singularity."
Because users were staring at a single point, feeding highly-correlated, continuous gaze data into the Ridge Regression model caused the matrix determinant to approach zero ($\det(X^T X + \lambda I) \approx 0$). This corrupted the regression weights and crashed the tracker.
To solve this, we engineered an automated "Guided Saccade" calibration sequence. By forcing the user's eyes to track a moving target to the edges of the screen, we secretly injected synthetic zero-latency click events at 9 extreme boundary nodes. This forcefully expanded the mathematical bounding box of the user's gaze, stabilizing the regression matrix and resulting in flawless, clinical-grade eye tracking.
Furthermore, processing clinical research PDFs for our RAG was destroying the two-column layouts and flowcharts. We had to discard standard libraries and custom-build our Single-Pass Hybrid Ensemble Retriever to prevent the AI from losing crucial medical context.
What we learned
We gained an immense amount of knowledge bridging the gap between medical science and advanced software engineering. We learned the deep linear algebra behind Ridge Regression and how to manually stabilize ML models during edge-compute in the browser. Furthermore, we mastered state-of-the-art vector database architectures, specifically how to engineer Parent-Child semantic retrieval pipelines, implement algorithmic deduplication, and use Vision-Language Models (VLMs) to dynamically extract complex visual data from PDFs.
Built With
- ai
- chromadb
- computer-vision
- fastapi
- huggingface
- langchain
- machine-learning
- next.js
- node.js
- python
- rag
- react
- ridge-regresssion
- sqlalchemy
- sqlite
- tailwind-css
- typescript
- webgazer.js
Log in or sign up for Devpost to join the conversation.