Open-source vascular microbot simulation platform for autonomous surgical microbot navigation
Project description
VascularSim
Open-source simulation platform for autonomous surgical microbot navigation through vascular networks.
VascularSim provides a complete stack for training RL agents to navigate blood vessel graphs: TubeTK data ingestion, Gymnasium environments with physics-based observations, analytical hemodynamics and magnetic field models, a neural flow surrogate, and a benchmark suite across 5 difficulty tiers.
Installation
pip install vascularsim
With RL training support (requires PyTorch):
pip install "vascularsim[train]"
Development (includes pytest):
pip install "vascularsim[dev]"
Quick Start
1. Load a vascular graph and explore it
from vascularsim import VascularGraph
from vascularsim.benchmarks import make_benchmark_graph
# Create a benchmark vascular graph (tier 1 = straight vessel, 20 nodes)
graph = make_benchmark_graph(tier=1, seed=42)
print(f"Nodes: {graph.num_nodes}")
print(f"Edges: {graph.num_edges}")
# Access node properties
for node in graph.nodes[:3]:
pos = graph.get_node_pos(node)
radius = graph.get_node_radius(node)
print(f" {node}: pos={pos}, radius={radius:.4f}")
2. Run the RL environment
import gymnasium as gym
from vascularsim import VascularGraph
from vascularsim.benchmarks import make_benchmark_graph
# Create a graph and pass it to the environment
graph = make_benchmark_graph(tier=1, seed=42)
env = gym.make("VascularNav-v0", graph=graph)
obs, info = env.reset()
print(f"Observation keys: {list(obs.keys())}")
# Step through the environment
for _ in range(10):
action = env.action_space.sample()
obs, reward, terminated, truncated, info = env.step(action)
if terminated:
print(f"Reached target!")
break
env.close()
# Physics-aware environments (use default graph if none provided)
flow_env = gym.make("FlowAwareNav-v0")
mag_env = gym.make("MagneticNav-v0")
3. Train a PPO agent and evaluate
# Train PPO for 200k steps (CPU, ~68 seconds)
python -m vascularsim.training.train --timesteps 200000 --output-dir ./checkpoints
# Evaluate trained agent vs random baseline
python -m vascularsim.training.evaluate --model-path ./checkpoints/ppo_vascularnav.zip
# Run benchmark suite across all 5 difficulty tiers
python -m vascularsim.benchmarks.runner --agent random --tiers 1 2 3 4 5 --output results.json
Physics Modules
Hemodynamics
Analytical Hagen-Poiseuille flow with Murray's law bifurcation distribution:
from vascularsim.physics import compute_hemodynamics
result = compute_hemodynamics(graph)
# result.edge_velocities — flow velocity per edge (mm/s)
# result.edge_pressures — pressure drop per edge (Pa)
# result.edge_wall_shear — wall shear stress per edge (Pa)
# result.node_pressures — pressure at each node (Pa)
Magnetic Fields
Helmholtz coil pairs with gradient-based force and torque on magnetic microbots:
from vascularsim.physics import CoilSystem, magnetic_force, magnetic_torque
import numpy as np
coils = CoilSystem.three_axis(coil_radius=0.05, current=1.0)
point = np.array([0.0, 0.0, 0.0])
field = coils.field_at(point) # Tesla
gradient = coils.gradient_at(point) # T/m (3x3 Jacobian)
moment = np.array([0.0, 0.0, 1e-12]) # A*m^2
force = magnetic_force(gradient, moment)
torque = magnetic_torque(field, moment)
Neural Flow Surrogate
Pure NumPy MLP trained in log-space for fast flow prediction (<10% MRE):
from vascularsim.physics import FlowSurrogate
surrogate = FlowSurrogate.from_graph(graph)
predicted_velocities = surrogate.predict(features)
Benchmark Tiers
| Tier | Name | Nodes | Topology |
|---|---|---|---|
| 1 | Straight | 20 | Linear vessel |
| 2 | Bifurcation | 35 | Single branch point |
| 3 | Tree | 50 | Two-level branching |
| 4 | Ring | 43 | Vessel loops |
| 5 | Dense Mesh | 147 | Sub-branches and dead-ends |
Architecture
vascularsim/
data/ TubeTK .tre parser + Girder API downloader
graph.py VascularGraph (NetworkX DiGraph wrapper)
envs/ Gymnasium environments
vascular_nav.py VascularNav-v0 (base discrete navigation)
flow_nav.py FlowAwareNav-v0 (+ hemodynamic observations)
magnetic_nav.py MagneticNav-v0 (+ magnetic field observations)
wrappers.py FlatNavObservation (Dict→Box for SB3)
physics/ Analytical physics models
hemodynamics.py Poiseuille flow + Murray's law + WSS
magnetic.py Helmholtz coils + force/torque
surrogate.py Neural MLP flow surrogate
training/ RL training pipeline
train.py PPO training CLI
evaluate.py Evaluation + comparison CLI
benchmarks/ Benchmark suite
environments.py 5 difficulty tier generators
runner.py Benchmark runner CLI
Test Suite
pytest tests/ -v # 139 tests, ~2 seconds
Citation
If you use VascularSim in your research, please cite:
@article{dhia2026vascularsim,
title={VascularSim: An Open-Source Platform for Reinforcement Learning-Based Microbot Navigation in Vascular Networks},
author={Dhia, Hass},
year={2026},
note={Smart Technology Investments Research Institute}
}
Contact
Smart Technology Investments Research Institute partners@smarttechinvest.com
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vascularsim-0.2.1.tar.gz.
File metadata
- Download URL: vascularsim-0.2.1.tar.gz
- Upload date:
- Size: 42.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d90687d96b3717813f0e85470b2a997bc9357873b9d49e2ea5f412960a9fd084
|
|
| MD5 |
788899b63a754e3e469d306332c6ca3e
|
|
| BLAKE2b-256 |
581d5954bf5b6327284f0ecd941390db4fc5603cc4adc5fbca7df1b3e985235e
|
File details
Details for the file vascularsim-0.2.1-py3-none-any.whl.
File metadata
- Download URL: vascularsim-0.2.1-py3-none-any.whl
- Upload date:
- Size: 37.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
050994e9daab8f2dba8fbfadbfb5a55eba993107e67616e139b895a3fde14c5c
|
|
| MD5 |
2ccc9c9c4d6448d5144313250c25ca42
|
|
| BLAKE2b-256 |
f50ea8caa17e759101dc107f342c9b5d1a57ada5dbb3b830a05199ea74a538e2
|