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
Metadata
Release files for vascularsim 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| vascularsim-0.2.1.tar.gz | 42.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vascularsim-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 80.0 kB
Release files / vascularsim-0.2.1.tar.gz
| Download URL | vascularsim-0.2.1.tar.gz |
|---|---|
| Size | 42.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d90687d96b3717813f0e85470b2a997bc9357873b9d49e2ea5f412960a9fd084
|
|
BLAKE2b-256 checksum How to use checksums |
581d5954bf5b6327284f0ecd941390db4fc5603cc4adc5fbca7df1b3e985235e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|
Release files / vascularsim-0.2.1-py3-none-any.whl
| Download URL | vascularsim-0.2.1-py3-none-any.whl |
|---|---|
| Size | 37.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
050994e9daab8f2dba8fbfadbfb5a55eba993107e67616e139b895a3fde14c5c
|
|
BLAKE2b-256 checksum How to use checksums |
f50ea8caa17e759101dc107f342c9b5d1a57ada5dbb3b830a05199ea74a538e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|
Security for vascularsim 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.