Skip to content

14930/VR_Medical_Field

Repository files navigation

๐Ÿฉบ Medical VR Simulation Suite 2.0

Python Unity License Platform


๐Ÿ’ก Immersive medical training platform with realistic surgical simulations and advanced physics


Comprehensive VR training for medical students and surgical trainees. Interactive simulations powered by real-time physics engines.
Screenshot 2025-12-01 144601

๐Ÿ“‹ Table of Contents


โœจ Features

๐ŸŽฎ Core Capabilities

  • ๐Ÿ–ฑ๏ธ Dual Interaction Systems: Mouse-based precision controls and VR hand emulation (WASD+QE movement)
  • โšก Real-Time Physics Engine: Advanced soft-body deformation using spring-mass dynamics
  • ๐ŸŽจ High-Fidelity Rendering: PBR materials with dynamic lighting and shadow mapping
  • ๐Ÿ“ Medical Documentation: Integrated note-taking system with persistent storage for clinical observations
  • ๐Ÿ”Š Immersive Audio: Realistic surgical soundscapes and haptic feedback simulation
  • ๐Ÿ’พ Data Persistence: Patient record management with export capabilities

๐Ÿ—๏ธ Six Specialized Training Modules

Each module targets specific surgical skills and anatomical understanding:

  1. โค๏ธ Cardiac Surgery (Heart) - Rhythmic deformation animation simulating cardiac cycles
  2. ๐ŸŸค Hepatic Procedures (Liver) - Interactive soft-tissue manipulation with force feedback
  3. ๐Ÿ‘ƒ ENT Surgery (Nose) - Internal cavity exploration with zoom navigation
  4. ๐Ÿ’ง Vascular Flow - Dynamic blood flow visualization with clotting mechanics
  5. ๐Ÿ’ช Orthopedic Trauma (Abdomen) - Multi-layer tissue cutting with depth visualization
  6. ๐Ÿฆท Dental Training (Teeth) - Tooth extraction and replacement procedures

๐Ÿ—๏ธ System Architecture

Medical-VR-Suite/
โ”œโ”€โ”€ ๐Ÿ“„ main.py                    # Application launcher and menu interface
โ”œโ”€โ”€  liver.py                   # Hepatic simulation module (Panda3D)
โ”œโ”€โ”€ โœ‚๏ธ cutting.py                 # Surgical cutting mechanics (NumPy)
โ”œโ”€โ”€ ๐Ÿ“ note.py                    # Medical notes documentation system
โ”œโ”€โ”€  Patient_Records/           # Clinical data storage
โ”‚   โ””โ”€โ”€ Patient_Log.txt
โ”œโ”€โ”€ ๐ŸŽฎ Unity Scripts/             # VR interaction controllers
โ”‚   โ”œโ”€โ”€ MeshDeformer.cs          # Tissue deformation physics
โ”‚   โ”œโ”€โ”€ VRKnife.cs               # Surgical instrument controller
โ”‚   โ”œโ”€โ”€ ThrustingKnife.cs        # Advanced cutting mechanics
โ”‚   โ”œโ”€โ”€ PowerKnife.cs            # Force-feedback cutting tool
โ”‚   โ””โ”€โ”€ SimpleExtraction.cs      # Dental extraction mechanics
โ”œโ”€โ”€ ๐Ÿ“ models/                    # 3D anatomical assets (Git LFS)
โ”‚   โ”œโ”€โ”€ NasalBlender.obj         # Nasal cavity model (70.8 MB)
โ”‚   โ””โ”€โ”€ hepatitis liver.obj      # Liver pathology model (8.3 MB)
โ”œโ”€โ”€ ๐Ÿ”Š sounds/                    # Audio feedback assets
โ”‚   โ””โ”€โ”€ squash-sound.wav
โ””โ”€โ”€ ๐Ÿ“– README.md

๐Ÿ› ๏ธ Technology Stack

Component Technology Purpose
Graphics Engine Panda3D 3D rendering and physics simulation
Game Engine Unity 2021.3+ VR interaction and haptics
Scientific Computing NumPy, Trimesh Mesh manipulation and analysis
UI Framework Tkinter Cross-platform menu interface
Version Control Git LFS Large 3D model asset management

๐Ÿ“Š Supported File Formats

Format Import Export Notes
OBJ โœ… โŒ Primary 3D model format
STL โœ… โŒ Requires trimesh library
PLY โœ… โŒ Point cloud and mesh data
FBX โœ… โŒ Animation-compatible format
GLTF/GLB โœ… โŒ Modern web-ready format
TXT โœ… โœ… Medical notes export only

๐Ÿš€ Installation

๐Ÿ“‹ Prerequisites

# Python Version
Python 3.8 or higher

# System Requirements
- OS: Windows 10/11, Linux (Ubuntu 20.04+), macOS 10.15+
- RAM: 8GB minimum, 16GB recommended for complex models
- GPU: Dedicated graphics card with OpenGL 3.3+ support
- Storage: 2GB available space

๐Ÿ”ง Setup Instructions

1๏ธโƒฃ Clone the Repository

git clone https://github.com/yourusername/medical-vr-suite.git
cd medical-vr-suite

2๏ธโƒฃ Install Python Dependencies

pip install numpy panda3d trimesh

3๏ธโƒฃ Configure Git LFS (for 3D models)

git lfs install
git lfs pull

๐Ÿ“Œ Important: This repository uses Git LFS to manage large 3D model files. GitHub's file size limitations require this approach for anatomical meshes.

4๏ธโƒฃ Verify Audio Configuration Edit liver.py line 47 to match your system's audio file path:

SOUND_FILE_PATH = r"path/to/your/sounds/squash-sound.wav"

5๏ธโƒฃ Launch Application

python main.py

๐ŸŽฏ Module Overview

1. โค๏ธ Cardiac Surgery Module

๐ŸŽฏ Training Objectives:

  • Understanding cardiac anatomy and rhythm
  • Observing myocardial contraction patterns
  • Recognizing abnormal heartbeat variations

โœจ Features:

  • ๐Ÿซ€ Realistic heartbeat animation with rhythmic deformation
  • ๐Ÿ“Š Multiple cardiac cycle phase visualization
  • ๐Ÿ’“ Adjustable heart rate simulation
  • ๐Ÿ”„ Dynamic muscle tissue response

๐ŸŽฎ Controls:

  • Observation Mode: Automatic beating animation
  • Parameter Adjustment: UI sliders for rate control

๐Ÿ“น Demo:

video_2025-11-27_10-24-03.mp4

2. ๐ŸŸค Hepatic Procedures Module

๐ŸŽฏ Training Objectives:

  • Soft tissue manipulation techniques
  • Force application and tactile feedback
  • Organ handling and positioning skills

โœจ Features:

  • โšก Dual interaction modes: Precision mouse control and 3D VR hand emulation
  • โš–๏ธ Adjustable compression force (0-200N) with real-time visual feedback
  • ๐Ÿงฑ Two tissue density presets: Hard (bone-like) and Soft (flesh-like)
  • ๐Ÿ”„ Spring-mass physics with natural recovery dynamics
  • ๐ŸŽฏ Volumetric interaction radius for realistic contact

๐ŸŽฎ Controls:

Mode Control Action
VR Hand W/A/S/D Move hand in X/Z plane
VR Hand Q/E Push forward/pull back (depth)
VR Hand Auto Continuous squeeze on contact
Mouse Left Click Apply compression force
Mouse Right Click + Drag Rotate organ view
UI Force Slider Adjust compression strength (0-200N)
UI Reset Button Restore original mesh geometry

๐Ÿ”ฌ Technical Physics:

# Soft-Body Dynamics Parameters
user_force: 0-200N        # Adjustable via UI slider
recovery_speed: 8.0       # Spring constant (k)
damping: 10.0            # Velocity damping coefficient
interaction_radius: 2.0   # Hard tissue mode
interaction_radius: 4.0   # Soft tissue mode

๐Ÿ“น Demo:

Liver.2.mp4

3. ๐Ÿ‘ƒ ENT Surgery Module

๐ŸŽฏ Training Objectives:

  • Nasal cavity anatomy exploration
  • Endoscopic navigation techniques
  • Internal structure identification

โœจ Features:

  • ๐Ÿ”ฌ High-resolution nasal cavity model (70.8MB detailed mesh)
  • ๐Ÿ” Dynamic camera zoom for internal exploration
  • ๐Ÿงญ Free navigation through nasal passages and sinus cavities
  • ๐Ÿงฑ Squeeze mechanics functional on internal and tissues
  • ๐Ÿ‘๏ธ Real-time tissue response during cavity exploration

๐ŸŽฎ Controls:

  • Zoom: Mouse scroll wheel or designated keys
  • Navigate: W/A/S/D for camera movement inside cavity
  • Squeeze: Left-click on internal structures
  • Rotate View: Right-click and drag

๐Ÿฅ Clinical Applications:

  • ๐Ÿงญ Turbinate structure visualization
  • ๐Ÿ” Sinus cavity exploration
  • ๐Ÿ”„ Endoscopic procedure practice
  • ๐Ÿ“‹ Septal deviation assessment

๐Ÿ“น Demo:

Nose.mp4

4. ๐Ÿฉธ Vascular Flow Simulation

๐ŸŽฏ Training Objectives:

  • Understanding hemodynamic principles
  • Visualizing blood flow patterns
  • Recognizing thrombotic events

โœจ Features:

  • ๐ŸŒŠ Particle-based blood flow visualization
  • ๐Ÿ’จ Laminar and turbulent flow pattern simulation
  • ๐Ÿฉธ Interactive clotting mechanism
  • ๐Ÿงฑ Vessel wall interaction dynamics
  • โšก Adjustable flow velocity parameters

๐ŸŽฎ Controls:

  • ** Flow Rate Slider**: Adjust blood velocity
  • ** Clotting Button**: Introduce thrombotic factors
  • ** Camera Controls**: Observe flow from multiple angles

๐Ÿฅ Medical Applications:

  • ๐Ÿซ€ Thrombosis visualization and progression
  • ๐Ÿš‘ Embolism event simulation
  • ๐Ÿฉบ Vascular occlusion training scenarios
  • ๐Ÿ“š Hemodynamic principle demonstration

๐Ÿ“น Demo:

BloodFlow.mp4

5. ๐Ÿ’ช Orthopedic Trauma Module (Abdomen)

๐ŸŽฏ Training Objectives:

  • Surgical incision techniques
  • Multi-layer tissue identification
  • Depth perception and control

โœจ Features:

  • โœ‚๏ธ Multi-layer tissue cutting simulation
  • ๐ŸŽจ Depth-based color mapping system:
    • ๐ŸŸค Beige: Superficial skin layer (intensity โ‰ค 0.2)
    • ๐Ÿ”ด Red: Intermediate muscle tissue (0.2 < intensity โ‰ค 0.6)
    • โšช White: Deep bone structure (intensity > 0.6)
  • ๐Ÿ“ Adjustable cutting position (0.0 - 5.0 height units)
  • โš–๏ธ Variable incision depth strength (0.5 - 2.0 multiplier)
  • ๐Ÿ’พ PLY file generation for external 3D analysis

๐Ÿ”ฌ Technical Implementation:

# Layer Classification Algorithm
if intensity > 0.6:   โ†’ Bone (white)
elif intensity > 0.2: โ†’ Muscle (red)
else:                 โ†’ Skin (beige)

# Deformation Formula
push_vector = normal ร— (-1) ร— intensity ร— depth_factor
new_position = original_position + push_vector

๐ŸŽฎ Controls & Usage:

python cutting.py

# Interactive Prompts:
Enter cutter height (0.0 to 5.0) [default 2.5]: 3.0
Enter cut depth strength (0.5 to 2.0) [default 1.2]: 1.5

# Output: cut_simulation.ply

๐Ÿ“Š Output File:

  • Opens in Windows 3D Viewer, Blender, or MeshLab
  • Displays color-coded anatomical layers
  • Suitable for surgical planning review

๐Ÿ“น Demo:

Abdomen.mp4

6. ๐Ÿฆท Dental Training Module

๐ŸŽฏ Training Objectives:

  • Tooth extraction procedures
  • Grip force calibration
  • Dental anatomy understanding

โœจ Features:

  • ๐Ÿฆท Individual tooth and molar selection
  • ๐Ÿ’ช Extraction mechanics with realistic resistance simulation
  • ๐Ÿ”„ Replacement and repositioning capabilities
  • ๐ŸŒณ Root structure visualization
  • ๐Ÿ“Š Force feedback during extraction process

๐ŸŽฎ Controls:

  • ๐ŸŽฏ Select Tooth: Left-click on desired tooth
  • โฌ†๏ธ Extract: Click and drag upward motion
  • โฌ‡๏ธ Replace: Drag tooth back to original socket
  • ๐Ÿ”„ Rotate View: Right-click and drag

๐Ÿฅ Clinical Applications:

  • Simple extraction practice
  • Forceps grip technique training
  • Socket preservation procedures
  • Post-extraction assessment

๐Ÿ“น Demo:

Teath.mp4

๐Ÿ“– Usage Guide

๐Ÿš€ Launching the Application

1๏ธโƒฃ Start Main Menu

python main.py

2๏ธโƒฃ Navigate Interface

  • ๐ŸŽฏ Click any module card to launch simulation
  • ๐Ÿ“ Use "Notes/Whiteboard" button for clinical documentation
  • โ„น๏ธ Access "Records & Info" for patient history management

๐Ÿ•น๏ธ VR Hand Emulation System

The VR hand emulator provides 3D spatial control without requiring physical VR hardware:

๐ŸŽฎ Movement Controls:

Key Axis Action
W +Z Move hand upward
S -Z Move hand downward
A -X Move hand left
D +X Move hand right
Q +Y Push hand forward (into scene)
E -Y Pull hand backward (toward camera)

๐Ÿ‘๏ธ Visual Feedback:

  • ๐ŸŸข Green Wireframe Sphere: VR hand boundary volume
  • โšช White Center Marker: Precise interaction point
  • ๐Ÿ‘ป 30% Transparency: Maintains visibility of underlying anatomy

โšก Interaction Mechanics:

  • ๐Ÿคฒ Hand exerts continuous force upon contact (no button press required)
  • โš–๏ธ Force magnitude controlled by UI slider (0-200N)
  • ๐Ÿ”„ Tissue responds with spring-mass physics in real-time
  • ๐ŸŽฏ Volumetric interaction radius adapts to tissue density

๐Ÿ“ Medical Documentation System

โœจ Features:

  • ๐Ÿ–Š๏ธ Digital whiteboard for surgical annotations
  • ๐Ÿ“‹ Patient record creation with timestamping
  • ๐Ÿ’พ Persistent local storage (no cloud upload)
  • ๐Ÿ” Search and filter capabilities for record retrieval
  • ๐Ÿ“ค Export functionality: Save notes as .txt files

๐Ÿš€ Access Method: Click "๐Ÿ“ Notes / Whiteboard" button on main menu

๐Ÿ“ Storage Location:

Medical-VR-Suite/
โ””โ”€โ”€ Patient_Records/
    โ”œโ”€โ”€ Patient_Log.txt
    โ”œโ”€โ”€ patient_001_notes.txt
    โ”œโ”€โ”€ patient_002_notes.txt
    โ””โ”€โ”€ ...

๐Ÿ’ก Use Cases:

  • โœ๏ธ Document surgical observations during simulation
  • ๐Ÿ“Š Track training progress and skill development
  • ๐ŸŽ“ Create study notes for anatomy review
  • ๐Ÿ“ Log clinical decision-making rationale

๐ŸŽฅ Demo Videos

All demonstration videos are embedded throughout the module descriptions above. Each video showcases:

  • โœ… Real-time interaction mechanics
  • โœ… Physics-based deformation behavior
  • โœ… User interface and control schemes
  • โœ… Clinical training applications

๐Ÿ’ป Technical Documentation

โš™๏ธ Physics Engine Architecture

๐Ÿ”ฌ Soft-Body Deformation Algorithm:

The system uses a spring-mass model with Verlet integration:

# Force Calculations
F_spring = -k ร— displacement              # Hooke's Law
F_damping = -c ร— velocity                 # Viscous damping
F_external = user_force ร— influence_factor # User interaction

# Verlet Integration Scheme
acceleration = (F_spring + F_damping + F_external) / mass
velocity_new = velocity_old + acceleration ร— ฮ”t
position_new = position_old + velocity_new ร— ฮ”t

๐Ÿ“Š Influence Function:

Implements cubic falloff for realistic tissue compression:

influence = (1 - distance/radius)ยณ  # Cubic distance falloff
force_vector = base_force ร— influence ร— direction_normalized

๐ŸŽจ Rendering Pipeline:

  1. Vertex Transformation: CPU-side deformation calculations
  2. Normal Recalculation: Per-frame surface normal updates
  3. PBR Shading: Physically-based rendering with Blinn-Phong model
  4. Shadow Mapping: 2048ร—2048 resolution shadow atlas
  5. Anti-Aliasing: Multi-sample anti-aliasing (MSAA 4x)

๐Ÿ› ๏ธ Unity VR Scripts Overview

The repository includes Unity C# scripts for advanced VR interactions:

Script Purpose Key Features
MeshDeformer.cs Soft-body physics Spring-mass system, collision handling
VRKnife.cs Basic cutting tool Haptic feedback, deformation on contact
ThrustingKnife.cs Motor-powered scalpel Trigger-activated thrust, enhanced cutting
PowerKnife.cs Advanced cutting Dual cutting modes, variable depth
SimpleExtraction.cs Dental extraction Velocity-based extraction detection

๐Ÿ› Troubleshooting

โŒ Issue: "Model appears black or unlit"

โœ… Solution: 
1. Update GPU drivers to the latest version
2. Verify OpenGL version: Must be 3.3 or higher
3. Check graphics card compatibility with Panda3D

โŒ Issue: "VR hand not responding to keyboard"

โœ… Solution:
1. Verify VR mode is enabled (button should display green)
2. Ensure keyboard focus is on the application window
3. Check that no other application is capturing WASD input

โŒ Issue: "Lag during tissue deformation"

โœ… Solution:
1. Reduce mesh resolution in cutting.py (mesh_res parameter)
2. Lower force slider value to reduce physics calculations
3. Close unnecessary background applications
4. Consider upgrading RAM if using complex models

โŒ Issue: "Git LFS models not downloading"

โœ… Solution:
1. Install Git LFS: git lfs install
2. Pull LFS files: git lfs pull
3. Verify .gitattributes configuration

๐Ÿ‘ฅ Development Team

This project was developed by a dedicated team of medical simulation enthusiasts:

Maryam Moustafa

Aya Sayed

Yousef Mahmoud

Rahma Ashraf


๐Ÿ—บ๏ธ Roadmap

๐Ÿ“… Version 2.1 (Q2 2025)

  • ๐ŸŽฎ Full VR headset integration (Oculus Quest, HTC Vive)
  • ๐Ÿค Multi-user collaborative training mode
  • ๐Ÿฉธ Advanced cardiovascular system simulation
  • ๐Ÿ“Š MRI/CT scan data import and visualization

๐Ÿ“… Version 3.0 (Q4 2025)

  • AI-powered surgical guidance and error detection
  • Performance assessment and skill tracking system
  • Cloud-based patient record synchronization
  • Web-based deployment for browser access

๐Ÿ“Š Performance Metrics

๐Ÿ’ป System Performance:

  • ๐ŸŽฎ Render FPS: 60+ (with recommended GPU)
  • โšก Physics Update: 120Hz refresh rate
  • โŒจ๏ธ Input Latency: <16ms response time
  • ๐Ÿ’พ Memory Usage: ~500MB base + model size

๐Ÿ—‚๏ธ Supported Model Complexity:

  • Minimum: 10,000 vertices
  • Recommended: 50,000 - 100,000 vertices
  • Maximum tested: 500,000 vertices

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for complete terms and conditions.


๐Ÿ™ Acknowledgments

Special thanks to:

  • ๐ŸŽ“ Medical education advisors for clinical accuracy review
  • ๐ŸŽจ 3D modeling community for anatomical asset resources
  • ๐Ÿ’ป Open-source contributors to Panda3D and Unity ecosystems
  • ๐Ÿฅ Medical students who provided valuable testing feedback

** Made with โค๏ธ for advancing medical education through immersive technology**

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •