Lumbar puncture (spinal tap) is one of the most critical — and most feared — procedures in medicine. It diagnoses meningitis, detects subarachnoid hemorrhage, and measures intracranial pressure. Yet in many medical schools worldwide, a student's first lumbar puncture is performed on a real patient, because:
- Physical simulation manikins cost $2,000–$5,000 per unit, plus consumable replacement parts
- Expert supervision is scarce — one instructor can only watch one student at a time
- Practice opportunities are limited — students may get 1–2 supervised attempts before performing on patients
- Low-resource settings are left behind — rural and developing-world medical schools often have no simulation equipment at all
Research shows that cognitive task rehearsal improves first-attempt procedural success rates by up to 40% (Barsuk et al., Academic Medicine, 2012). The problem isn't that training doesn't work — it's that access to training is fundamentally inequitable.
Lumbera transforms any iPad into an AI-mentored lumbar puncture training station. It replaces expensive manikins and scarce instructor time with a free app + Gemma 4, providing every medical student — from Stanford to a rural clinic in sub-Saharan Africa — access to expert-level procedural coaching.
What makes Lumbera different from a tutorial or a quiz app is that Gemma 4 is not a chatbot bolted onto a simulator — it is the instructor. Through native function calling, Gemma queries the simulator's live state, analyzes the student's technique via multimodal vision, generates personalized clinical scenarios, and even controls the simulation UI to demonstrate correct positioning — all in real-time.
This is Lumbera's core innovation. When a student asks "Where should I insert the needle?", Gemma doesn't just answer in text — it calls show_target_hint(), which triggers a pulsing purple ring to appear on the 3D manikin model at the correct L3/L4 interspace. The student sees the hint appear in real-time. When asked about angle, Gemma calls show_angle_hint() to reveal the ideal insertion zone on the angle control diagram.
This is genuine agentic behavior: the AI observes the simulation state, reasons about what the student needs, and takes action in the application.
4 Native Function Calling Tools:
| Tool | What It Does | When Gemma Calls It |
|---|---|---|
get_simulator_state |
Returns real-time needle position, angle, depth, stability, and success probability | Before giving technique advice — ensures feedback is contextually accurate |
get_performance_summary |
Returns trial history, success rate, average metrics, outcome patterns | When student asks about their progress or when the AI detects a pattern |
show_target_hint |
Displays a pulsing ring on the 3D manikin at the correct insertion point | When student asks where to insert or seems lost with positioning |
show_angle_hint |
Reveals the ideal angle zone on the insertion angle diagram | When student explicitly asks about correct angulation |
After each insertion attempt, Lumbera captures a screenshot of the 3D simulation and sends it to Gemma 4 alongside numerical metrics. The AI analyzes the student's needle positioning by looking at the same view the student sees — identifying whether the needle indicator is off-midline, too lateral, or misaligned with the interspace. This visual grounding produces feedback that is far more intuitive than numbers alone.
Gemma 4 generates randomized, medically realistic patient cases using structured JSON output:
- Meningitis workup — 34F with fever, neck stiffness, and positive Kernig's sign
- Subarachnoid hemorrhage rule-out — 58M with thunderclap headache
- Multiple sclerosis evaluation — 28F with optic neuritis and paresthesias
- Intrathecal chemotherapy — 12M with ALL requiring IT methotrexate
Each scenario includes demographics, history, vitals, indication, and difficulty level. The difficulty adjusts simulation tolerances — a "challenging" scenario has tighter positioning thresholds and stricter angle requirements, mimicking real clinical complexity.
After every insertion attempt, Gemma analyzes the outcome considering both the technical metrics and the specific clinical scenario. A traumatic tap on a meningitis patient gets different feedback than on an elective procedure — because in real medicine, the urgency of CSF analysis changes how you respond to a suboptimal sample. The AI also tracks trends across trials: "Your positioning has improved by 40% since Trial 1, but your cephalad angle is consistently 5° too shallow."
At the end of a clinical simulation session, Gemma 4 generates a structured performance evaluation:
- Overall Grade (A–F) with justification
- Technique Analysis — positioning accuracy, angle control, depth management
- Strengths & Areas for Improvement — specific, actionable bullet points
- Clinical Readiness Assessment — whether the student is ready for supervised attempts
- Practice Recommendations — targeted exercises based on observed weaknesses
The report also factors in the questions the student asked during the session, assessing engagement and clinical reasoning.
The simulation models the complete LP procedure in three sequential phases:
- Position — Use a joystick to align the needle marker with the L3/L4 interspace on a 3D manikin model. Real-time edge glow provides proximity feedback.
- Angle — Set the cephalad angle (~15° toward the umbilicus) and verify the needle is level with the bed. A dual-axis angle control diagram with real-time color coding guides the student.
- Depth — Drag to advance the needle through anatomical tissue layers. Each layer provides distinct haptic resistance. Stop in the subarachnoid space.
| Layer | Depth Range | Haptic Feedback | Clinical Significance |
|---|---|---|---|
| Skin & Subcutaneous Fat | 0–12% | None | Entry point |
| Supraspinous Ligament | 12–27% | Light | First resistance |
| Interspinous Ligament | 27–45% | Medium | Increasing resistance |
| Ligamentum Flavum | 45–65% | Heavy | Maximum resistance — the "tough" layer |
| Epidural Space | 65–75% | None | Brief loss of resistance |
| Dura-Arachnoid Complex | 75–83% | Heavy + Audible "Pop" | Characteristic penetration feel |
| Subarachnoid Space / CSF | 83–95% | None | Target — stop here |
- Perfect — Clear CSF flows from the needle hub. Subarachnoid space accessed successfully.
- Traumatic Tap — Blood-tinged CSF from epidural venous plexus injury. Suboptimal but diagnostic.
- Bone Contact — Needle hits vertebral lamina. Must redirect. (Screen shake + haptic error.)
- Missed — Needle entirely off-target. Reposition and retry.
During practice, students monitor live metrics:
- Precision Tracking — Waveform visualization of positioning accuracy over time
- Coordinates — Real-time needle position vs. target (L3/L4 interspace)
- Stability — Hand steadiness score (0–100%)
- Success Probability — Dynamic probability based on position, angle, and depth
- Depth Gauge — Visual needle progression through 7 anatomical layers
- AI Feedback Card — Gemma's analysis of each trial with trend tracking
Lumbera
├── Home — 3D manikin viewer + knowledge cards
├── Learn — Interactive 3D anatomy exploration (vertebral column, spinal structures)
├── Procedure — Step-by-step LP procedure guide (11 clinical steps)
├── Free Practice — Unlimited simulation practice with AI feedback
└── Clinical Sim — Full AI-driven simulation workflow:
├── Scenario Generation (Gemma 4 structured JSON)
├── Patient Briefing Card
├── Multi-Phase Practice (Position → Angle → Depth)
├── AI Visual Feedback (Gemma 4 Vision)
├── AI Chat Tutor (Gemma 4 Function Calling)
└── Training Report (Gemma 4 Text Generation)
| Component | Technology |
|---|---|
| UI Framework | SwiftUI |
| 3D Simulation | SceneKit with USDZ models |
| AI Model | Gemma 4 (gemma-4-31b-it) via Google AI Studio API + Ollama (local deployment) |
| AI Capabilities Used | Text Generation, Multimodal Vision, Native Function Calling, Structured JSON Output |
| Local AI Runtime | Ollama — full feature parity with cloud path, zero-network offline operation |
| Haptic Engine | UIImpactFeedbackGenerator (layer-specific resistance simulation) |
| Audio Feedback | AudioToolbox (needle advancement ticks, dural penetration "pop") |
| Platform | iPad (iOS 16+), built as Swift Playground App |
Student Action Gemma 4 Capability Result
──────────────────────────────────────────────────────────────────────
Start Clinical Sim → Structured JSON Generation → Patient scenario created
Position needle → Function Calling → AI queries live state before advising
Ask "where to insert?" → Function Calling + UI Action → Purple hint ring appears on manikin
Complete a trial → Multimodal Vision + Text → Screenshot analyzed, feedback given
Ask about progress → Function Calling → AI reviews performance history
End session → Text Generation → Structured training report generated
Medical training doesn't always happen where there's good internet. A teaching hospital in rural Kenya, a field hospital during a humanitarian crisis, a military medical unit on deployment — these are exactly the places where procedural training is most needed and cloud AI is least available.
Lumbera solves this with full Ollama local deployment. Every AI capability — text generation, multimodal vision, native function calling, structured JSON output — runs identically on a local Gemma 4 instance via Ollama, with zero network dependency.
Why local matters:
- HIPAA & patient data compliance — With Ollama, nothing leaves the local network. Institutions can feed de-identified real case data into Gemma to generate training scenarios that reflect their actual patient population — rare presentations, local disease prevalence, department-specific protocols — without any data being transmitted to external servers. This eliminates compliance review entirely and unlocks training fidelity that generic cloud-based scenarios cannot match.
- Unreliable hospital networks — Hospital Wi-Fi is notoriously congested and firewalled. Many hospital IT departments block external API calls by policy. Ollama runs on
localhost— no network permissions needed. - Low-resource medical schools — A medical school in a developing country may have iPads (donated or subsidized) but no reliable broadband. Ollama on a single Mac mini can serve an entire simulation lab of 30+ students over local network, with no internet connection at all.
- Zero recurring cost — Cloud API calls cost money per request. For a training tool that students use hundreds of times, costs add up. Ollama is completely free — the only cost is the hardware already in the room.
- Disaster & field medicine training — Emergency medical training during natural disasters or in conflict zones cannot depend on cloud connectivity. Ollama makes Lumbera deployable anywhere a laptop can run.
Full feature parity — not a fallback:
| Capability | Google AI Studio | Ollama (Local) |
|---|---|---|
| Text Generation | ✅ | ✅ |
| Multimodal Vision (screenshot analysis) | ✅ | ✅ |
| Native Function Calling (4 tools) | ✅ | ✅ |
| Structured JSON Output | ✅ | ✅ |
| Network Required | Yes | No |
| API Key Required | Yes | No |
Switching between backends is a single UI toggle — no code changes, no reconfiguration. The same agentic tools (get_simulator_state, get_performance_summary, show_target_hint, show_angle_hint) work identically in both modes.
Implementation: Ollama vision uses the native images field in the chat API. Function calling uses Ollama's native tool use API with tools parameter and tool_calls response parsing. The continue-after-function flow sends proper assistant/tool role messages matching Ollama's conversation protocol.
| Dimension | Current State | With Lumbera |
|---|---|---|
| Cost | $2,000–$5,000 per manikin + consumables | Free app on a $300 iPad |
| Scale | 1 instructor : 1 student | 1 instructor : 30+ students (AI handles individual feedback) |
| Access | Concentrated in wealthy medical schools | Available globally, including low-resource settings |
| Repetition | Limited by consumables and lab availability | Unlimited practice, anywhere, anytime |
| Feedback | Only when an expert is present | AI coaching on every single attempt |
| Privacy | N/A | Designed for on-device — no data leaves the device |
- iPad running iOS 16+ (or iPad Simulator in Xcode)
- Xcode 16+ or Swift Playgrounds 4+
- Either Google AI Studio API key (free) or Ollama installed locally
- Open
Lumbera.swiftpmin Xcode or Swift Playgrounds - Build and run on an iPad or iPad Simulator
- Tap the AI brain icon (top right in Practice view) and enter your Google AI Studio API key
- Start with Clinical Sim for the full AI-powered experience, or Free Practice to explore
- Install Ollama:
brew install ollama - Pull Gemma 4:
ollama pull gemma4 - Start the server:
ollama serve - Open
Lumbera.swiftpmin Xcode, build and run on iPad Simulator - Tap the AI brain icon and switch provider to "Ollama (Local)"
- All AI features (vision, function calling, scenarios, reports) work fully offline
For the Google AI Studio path, get a free API key at Google AI Studio. The key is stored locally in UserDefaults and is only transmitted to Google's Gemini API endpoint. The Ollama path requires no API key.
- Swift 6 / SwiftUI
- SceneKit
- Gemma 4 (
gemma-4-31b-it) via Google AI Studio API - Ollama — local deployment with full feature parity (vision, function calling, structured output)
- Built for the Gemma 4 Good Hackathon on Kaggle
MIT