Skip to main content

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

vascularsim-0.2.0.tar.gz (582.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vascularsim-0.2.0-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file vascularsim-0.2.0.tar.gz.

File metadata

  • Download URL: vascularsim-0.2.0.tar.gz
  • Upload date:
  • Size: 582.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for vascularsim-0.2.0.tar.gz
Algorithm Hash digest
SHA256 364cddc940dab9d92cad1fab341542d4c98ef0fa8c0c991e95e62ecc7cd664a3
MD5 738be53110ea5497df181d8838471db8
BLAKE2b-256 50b8c92ab911930f47d5c5167aeb4cb2c9d5b89aeda62a4e1f67228a664f103d

See more details on using hashes here.

File details

Details for the file vascularsim-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vascularsim-0.2.0-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

Hashes for vascularsim-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 949ceb8402a30b254090035f63afdb5926376bad261b110b2a5cb9df2db3c2ff
MD5 f5af573a9b0fbb835c5db32440fd0339
BLAKE2b-256 3846ec455fc83b92d225effc9a6b952659e0c83aaa0dd6ee2f6fc1676f38ad39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page