vascularsim 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vascularsim-0.1.0/.gitignore +37 -0
- vascularsim-0.1.0/LICENSE +21 -0
- vascularsim-0.1.0/PKG-INFO +206 -0
- vascularsim-0.1.0/README.md +174 -0
- vascularsim-0.1.0/pyproject.toml +52 -0
- vascularsim-0.1.0/src/vascularsim/__init__.py +24 -0
- vascularsim-0.1.0/src/vascularsim/benchmarks/__init__.py +6 -0
- vascularsim-0.1.0/src/vascularsim/benchmarks/environments.py +359 -0
- vascularsim-0.1.0/src/vascularsim/benchmarks/runner.py +190 -0
- vascularsim-0.1.0/src/vascularsim/data/__init__.py +5 -0
- vascularsim-0.1.0/src/vascularsim/data/tubetk.py +147 -0
- vascularsim-0.1.0/src/vascularsim/envs/__init__.py +18 -0
- vascularsim-0.1.0/src/vascularsim/envs/flow_nav.py +117 -0
- vascularsim-0.1.0/src/vascularsim/envs/magnetic_nav.py +92 -0
- vascularsim-0.1.0/src/vascularsim/envs/vascular_nav.py +246 -0
- vascularsim-0.1.0/src/vascularsim/envs/wrappers.py +46 -0
- vascularsim-0.1.0/src/vascularsim/graph.py +116 -0
- vascularsim-0.1.0/src/vascularsim/physics/__init__.py +34 -0
- vascularsim-0.1.0/src/vascularsim/physics/hemodynamics.py +337 -0
- vascularsim-0.1.0/src/vascularsim/physics/magnetic.py +301 -0
- vascularsim-0.1.0/src/vascularsim/physics/surrogate.py +309 -0
- vascularsim-0.1.0/src/vascularsim/py.typed +0 -0
- vascularsim-0.1.0/src/vascularsim/training/__init__.py +0 -0
- vascularsim-0.1.0/src/vascularsim/training/evaluate.py +182 -0
- vascularsim-0.1.0/src/vascularsim/training/train.py +99 -0
- vascularsim-0.1.0/src/vascularsim/viz.py +106 -0
- vascularsim-0.1.0/tests/test_benchmarks.py +241 -0
- vascularsim-0.1.0/tests/test_env.py +178 -0
- vascularsim-0.1.0/tests/test_flow_nav.py +101 -0
- vascularsim-0.1.0/tests/test_graph.py +169 -0
- vascularsim-0.1.0/tests/test_hemodynamics.py +426 -0
- vascularsim-0.1.0/tests/test_magnetic.py +345 -0
- vascularsim-0.1.0/tests/test_magnetic_nav.py +107 -0
- vascularsim-0.1.0/tests/test_surrogate.py +124 -0
- vascularsim-0.1.0/tests/test_training.py +80 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
*.egg
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
*.whl
|
|
9
|
+
|
|
10
|
+
# Virtual environments
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
env/
|
|
14
|
+
|
|
15
|
+
# IDE
|
|
16
|
+
.vscode/
|
|
17
|
+
.idea/
|
|
18
|
+
*.swp
|
|
19
|
+
*.swo
|
|
20
|
+
|
|
21
|
+
# OS
|
|
22
|
+
.DS_Store
|
|
23
|
+
Thumbs.db
|
|
24
|
+
|
|
25
|
+
# Testing
|
|
26
|
+
.pytest_cache/
|
|
27
|
+
.coverage
|
|
28
|
+
htmlcov/
|
|
29
|
+
|
|
30
|
+
# Training artifacts
|
|
31
|
+
checkpoints/
|
|
32
|
+
*.zip
|
|
33
|
+
*.pt
|
|
34
|
+
*.pth
|
|
35
|
+
|
|
36
|
+
# Build
|
|
37
|
+
*.so
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MicroBot Intelligence
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vascularsim
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Open-source vascular microbot simulation platform for autonomous surgical microbot navigation
|
|
5
|
+
Project-URL: Repository, https://github.com/HassDhia/vascularsim
|
|
6
|
+
Project-URL: Documentation, https://github.com/HassDhia/vascularsim#readme
|
|
7
|
+
Author-email: Hass <hass@microbotintelligence.dev>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: gymnasium
|
|
22
|
+
Requires-Dist: networkx
|
|
23
|
+
Requires-Dist: numpy
|
|
24
|
+
Requires-Dist: pyvista
|
|
25
|
+
Requires-Dist: requests
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: build; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
29
|
+
Provides-Extra: train
|
|
30
|
+
Requires-Dist: stable-baselines3>=2.0; extra == 'train'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# VascularSim
|
|
34
|
+
|
|
35
|
+
Open-source simulation platform for autonomous surgical microbot navigation through vascular networks.
|
|
36
|
+
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install -e .
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
With RL training support (requires PyTorch):
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install -e ".[train]"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Development (includes pytest):
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install -e ".[dev]"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
### 1. Load a vascular graph and explore it
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from vascularsim import VascularGraph
|
|
63
|
+
from vascularsim.benchmarks import make_benchmark_graph
|
|
64
|
+
|
|
65
|
+
# Create a benchmark vascular graph (tier 1 = straight vessel, 20 nodes)
|
|
66
|
+
graph = make_benchmark_graph(tier=1, seed=42)
|
|
67
|
+
|
|
68
|
+
print(f"Nodes: {graph.graph.number_of_nodes()}")
|
|
69
|
+
print(f"Edges: {graph.graph.number_of_edges()}")
|
|
70
|
+
|
|
71
|
+
# Access node properties
|
|
72
|
+
for node in list(graph.graph.nodes)[:3]:
|
|
73
|
+
pos = graph.get_node_pos(node)
|
|
74
|
+
radius = graph.get_node_radius(node)
|
|
75
|
+
print(f" {node}: pos={pos}, radius={radius:.4f}")
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 2. Run the RL environment
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import gymnasium as gym
|
|
82
|
+
from vascularsim import VascularGraph
|
|
83
|
+
from vascularsim.benchmarks import make_benchmark_graph
|
|
84
|
+
|
|
85
|
+
# Create a graph and pass it to the environment
|
|
86
|
+
graph = make_benchmark_graph(tier=1, seed=42)
|
|
87
|
+
env = gym.make("VascularNav-v0", graph=graph)
|
|
88
|
+
obs, info = env.reset()
|
|
89
|
+
print(f"Observation keys: {list(obs.keys())}")
|
|
90
|
+
|
|
91
|
+
# Step through the environment
|
|
92
|
+
for _ in range(10):
|
|
93
|
+
action = env.action_space.sample()
|
|
94
|
+
obs, reward, terminated, truncated, info = env.step(action)
|
|
95
|
+
if terminated:
|
|
96
|
+
print(f"Reached target!")
|
|
97
|
+
break
|
|
98
|
+
|
|
99
|
+
env.close()
|
|
100
|
+
|
|
101
|
+
# Physics-aware environments (use default graph if none provided)
|
|
102
|
+
flow_env = gym.make("FlowAwareNav-v0")
|
|
103
|
+
mag_env = gym.make("MagneticNav-v0")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 3. Train a PPO agent and evaluate
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Train PPO for 200k steps (CPU, ~68 seconds)
|
|
110
|
+
python -m vascularsim.training.train --timesteps 200000 --output-dir ./checkpoints
|
|
111
|
+
|
|
112
|
+
# Evaluate trained agent vs random baseline
|
|
113
|
+
python -m vascularsim.training.evaluate --model-path ./checkpoints/ppo_vascularnav.zip
|
|
114
|
+
|
|
115
|
+
# Run benchmark suite across all 5 difficulty tiers
|
|
116
|
+
python -m vascularsim.benchmarks.runner --agent random --tiers 1 2 3 4 5 --output results.json
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Physics Modules
|
|
120
|
+
|
|
121
|
+
### Hemodynamics
|
|
122
|
+
|
|
123
|
+
Analytical Hagen-Poiseuille flow with Murray's law bifurcation distribution:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from vascularsim.physics import compute_hemodynamics
|
|
127
|
+
|
|
128
|
+
result = compute_hemodynamics(graph)
|
|
129
|
+
# result.edge_velocities — flow velocity per edge (mm/s)
|
|
130
|
+
# result.edge_pressures — pressure drop per edge (Pa)
|
|
131
|
+
# result.edge_wall_shear — wall shear stress per edge (Pa)
|
|
132
|
+
# result.node_pressures — pressure at each node (Pa)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Magnetic Fields
|
|
136
|
+
|
|
137
|
+
Helmholtz coil pairs with gradient-based force and torque on magnetic microbots:
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from vascularsim.physics import CoilSystem, magnetic_force, magnetic_torque
|
|
141
|
+
import numpy as np
|
|
142
|
+
|
|
143
|
+
coils = CoilSystem.three_axis(coil_radius=0.05, current=1.0)
|
|
144
|
+
point = np.array([0.0, 0.0, 0.0])
|
|
145
|
+
|
|
146
|
+
field = coils.field_at(point) # Tesla
|
|
147
|
+
gradient = coils.gradient_at(point) # T/m (3x3 Jacobian)
|
|
148
|
+
|
|
149
|
+
moment = np.array([0.0, 0.0, 1e-12]) # A*m^2
|
|
150
|
+
force = magnetic_force(gradient, moment)
|
|
151
|
+
torque = magnetic_torque(field, moment)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Neural Flow Surrogate
|
|
155
|
+
|
|
156
|
+
Pure NumPy MLP trained in log-space for fast flow prediction (<10% MRE):
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from vascularsim.physics import FlowSurrogate
|
|
160
|
+
|
|
161
|
+
surrogate = FlowSurrogate.from_graph(graph)
|
|
162
|
+
predicted_velocities = surrogate.predict(features)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Benchmark Tiers
|
|
166
|
+
|
|
167
|
+
| Tier | Name | Nodes | Topology |
|
|
168
|
+
|------|------|-------|----------|
|
|
169
|
+
| 1 | Straight | 20 | Linear vessel |
|
|
170
|
+
| 2 | Bifurcation | 35 | Single branch point |
|
|
171
|
+
| 3 | Tree | 50 | Two-level branching |
|
|
172
|
+
| 4 | Ring | 43 | Vessel loops |
|
|
173
|
+
| 5 | Dense Mesh | 147 | Sub-branches and dead-ends |
|
|
174
|
+
|
|
175
|
+
## Architecture
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
vascularsim/
|
|
179
|
+
data/ TubeTK .tre parser + Girder API downloader
|
|
180
|
+
graph.py VascularGraph (NetworkX DiGraph wrapper)
|
|
181
|
+
envs/ Gymnasium environments
|
|
182
|
+
vascular_nav.py VascularNav-v0 (base discrete navigation)
|
|
183
|
+
flow_nav.py FlowAwareNav-v0 (+ hemodynamic observations)
|
|
184
|
+
magnetic_nav.py MagneticNav-v0 (+ magnetic field observations)
|
|
185
|
+
wrappers.py FlatNavObservation (Dict→Box for SB3)
|
|
186
|
+
physics/ Analytical physics models
|
|
187
|
+
hemodynamics.py Poiseuille flow + Murray's law + WSS
|
|
188
|
+
magnetic.py Helmholtz coils + force/torque
|
|
189
|
+
surrogate.py Neural MLP flow surrogate
|
|
190
|
+
training/ RL training pipeline
|
|
191
|
+
train.py PPO training CLI
|
|
192
|
+
evaluate.py Evaluation + comparison CLI
|
|
193
|
+
benchmarks/ Benchmark suite
|
|
194
|
+
environments.py 5 difficulty tier generators
|
|
195
|
+
runner.py Benchmark runner CLI
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Test Suite
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
pytest tests/ -v # 139 tests, ~2 seconds
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
MIT
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# VascularSim
|
|
2
|
+
|
|
3
|
+
Open-source simulation platform for autonomous surgical microbot navigation through vascular networks.
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install -e .
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
With RL training support (requires PyTorch):
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install -e ".[train]"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Development (includes pytest):
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install -e ".[dev]"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### 1. Load a vascular graph and explore it
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from vascularsim import VascularGraph
|
|
31
|
+
from vascularsim.benchmarks import make_benchmark_graph
|
|
32
|
+
|
|
33
|
+
# Create a benchmark vascular graph (tier 1 = straight vessel, 20 nodes)
|
|
34
|
+
graph = make_benchmark_graph(tier=1, seed=42)
|
|
35
|
+
|
|
36
|
+
print(f"Nodes: {graph.graph.number_of_nodes()}")
|
|
37
|
+
print(f"Edges: {graph.graph.number_of_edges()}")
|
|
38
|
+
|
|
39
|
+
# Access node properties
|
|
40
|
+
for node in list(graph.graph.nodes)[:3]:
|
|
41
|
+
pos = graph.get_node_pos(node)
|
|
42
|
+
radius = graph.get_node_radius(node)
|
|
43
|
+
print(f" {node}: pos={pos}, radius={radius:.4f}")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Run the RL environment
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import gymnasium as gym
|
|
50
|
+
from vascularsim import VascularGraph
|
|
51
|
+
from vascularsim.benchmarks import make_benchmark_graph
|
|
52
|
+
|
|
53
|
+
# Create a graph and pass it to the environment
|
|
54
|
+
graph = make_benchmark_graph(tier=1, seed=42)
|
|
55
|
+
env = gym.make("VascularNav-v0", graph=graph)
|
|
56
|
+
obs, info = env.reset()
|
|
57
|
+
print(f"Observation keys: {list(obs.keys())}")
|
|
58
|
+
|
|
59
|
+
# Step through the environment
|
|
60
|
+
for _ in range(10):
|
|
61
|
+
action = env.action_space.sample()
|
|
62
|
+
obs, reward, terminated, truncated, info = env.step(action)
|
|
63
|
+
if terminated:
|
|
64
|
+
print(f"Reached target!")
|
|
65
|
+
break
|
|
66
|
+
|
|
67
|
+
env.close()
|
|
68
|
+
|
|
69
|
+
# Physics-aware environments (use default graph if none provided)
|
|
70
|
+
flow_env = gym.make("FlowAwareNav-v0")
|
|
71
|
+
mag_env = gym.make("MagneticNav-v0")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 3. Train a PPO agent and evaluate
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Train PPO for 200k steps (CPU, ~68 seconds)
|
|
78
|
+
python -m vascularsim.training.train --timesteps 200000 --output-dir ./checkpoints
|
|
79
|
+
|
|
80
|
+
# Evaluate trained agent vs random baseline
|
|
81
|
+
python -m vascularsim.training.evaluate --model-path ./checkpoints/ppo_vascularnav.zip
|
|
82
|
+
|
|
83
|
+
# Run benchmark suite across all 5 difficulty tiers
|
|
84
|
+
python -m vascularsim.benchmarks.runner --agent random --tiers 1 2 3 4 5 --output results.json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Physics Modules
|
|
88
|
+
|
|
89
|
+
### Hemodynamics
|
|
90
|
+
|
|
91
|
+
Analytical Hagen-Poiseuille flow with Murray's law bifurcation distribution:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from vascularsim.physics import compute_hemodynamics
|
|
95
|
+
|
|
96
|
+
result = compute_hemodynamics(graph)
|
|
97
|
+
# result.edge_velocities — flow velocity per edge (mm/s)
|
|
98
|
+
# result.edge_pressures — pressure drop per edge (Pa)
|
|
99
|
+
# result.edge_wall_shear — wall shear stress per edge (Pa)
|
|
100
|
+
# result.node_pressures — pressure at each node (Pa)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Magnetic Fields
|
|
104
|
+
|
|
105
|
+
Helmholtz coil pairs with gradient-based force and torque on magnetic microbots:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from vascularsim.physics import CoilSystem, magnetic_force, magnetic_torque
|
|
109
|
+
import numpy as np
|
|
110
|
+
|
|
111
|
+
coils = CoilSystem.three_axis(coil_radius=0.05, current=1.0)
|
|
112
|
+
point = np.array([0.0, 0.0, 0.0])
|
|
113
|
+
|
|
114
|
+
field = coils.field_at(point) # Tesla
|
|
115
|
+
gradient = coils.gradient_at(point) # T/m (3x3 Jacobian)
|
|
116
|
+
|
|
117
|
+
moment = np.array([0.0, 0.0, 1e-12]) # A*m^2
|
|
118
|
+
force = magnetic_force(gradient, moment)
|
|
119
|
+
torque = magnetic_torque(field, moment)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Neural Flow Surrogate
|
|
123
|
+
|
|
124
|
+
Pure NumPy MLP trained in log-space for fast flow prediction (<10% MRE):
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from vascularsim.physics import FlowSurrogate
|
|
128
|
+
|
|
129
|
+
surrogate = FlowSurrogate.from_graph(graph)
|
|
130
|
+
predicted_velocities = surrogate.predict(features)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Benchmark Tiers
|
|
134
|
+
|
|
135
|
+
| Tier | Name | Nodes | Topology |
|
|
136
|
+
|------|------|-------|----------|
|
|
137
|
+
| 1 | Straight | 20 | Linear vessel |
|
|
138
|
+
| 2 | Bifurcation | 35 | Single branch point |
|
|
139
|
+
| 3 | Tree | 50 | Two-level branching |
|
|
140
|
+
| 4 | Ring | 43 | Vessel loops |
|
|
141
|
+
| 5 | Dense Mesh | 147 | Sub-branches and dead-ends |
|
|
142
|
+
|
|
143
|
+
## Architecture
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
vascularsim/
|
|
147
|
+
data/ TubeTK .tre parser + Girder API downloader
|
|
148
|
+
graph.py VascularGraph (NetworkX DiGraph wrapper)
|
|
149
|
+
envs/ Gymnasium environments
|
|
150
|
+
vascular_nav.py VascularNav-v0 (base discrete navigation)
|
|
151
|
+
flow_nav.py FlowAwareNav-v0 (+ hemodynamic observations)
|
|
152
|
+
magnetic_nav.py MagneticNav-v0 (+ magnetic field observations)
|
|
153
|
+
wrappers.py FlatNavObservation (Dict→Box for SB3)
|
|
154
|
+
physics/ Analytical physics models
|
|
155
|
+
hemodynamics.py Poiseuille flow + Murray's law + WSS
|
|
156
|
+
magnetic.py Helmholtz coils + force/torque
|
|
157
|
+
surrogate.py Neural MLP flow surrogate
|
|
158
|
+
training/ RL training pipeline
|
|
159
|
+
train.py PPO training CLI
|
|
160
|
+
evaluate.py Evaluation + comparison CLI
|
|
161
|
+
benchmarks/ Benchmark suite
|
|
162
|
+
environments.py 5 difficulty tier generators
|
|
163
|
+
runner.py Benchmark runner CLI
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Test Suite
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pytest tests/ -v # 139 tests, ~2 seconds
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vascularsim"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Open-source vascular microbot simulation platform for autonomous surgical microbot navigation"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Hass", email = "hass@microbotintelligence.dev" },
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Medical Science Apps.",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"numpy",
|
|
29
|
+
"networkx",
|
|
30
|
+
"gymnasium",
|
|
31
|
+
"pyvista",
|
|
32
|
+
"requests",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = ["pytest", "build"]
|
|
37
|
+
train = ["stable-baselines3>=2.0"]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Repository = "https://github.com/HassDhia/vascularsim"
|
|
41
|
+
Documentation = "https://github.com/HassDhia/vascularsim#readme"
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
vascularsim-train = "vascularsim.training.train:main"
|
|
45
|
+
vascularsim-evaluate = "vascularsim.training.evaluate:main"
|
|
46
|
+
vascularsim-benchmark = "vascularsim.benchmarks.runner:main"
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.wheel]
|
|
49
|
+
packages = ["src/vascularsim"]
|
|
50
|
+
|
|
51
|
+
[tool.pytest.ini_options]
|
|
52
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""VascularSim - Open-source vascular microbot simulation platform.
|
|
2
|
+
|
|
3
|
+
Provides tools for simulating autonomous microbot navigation through
|
|
4
|
+
vascular networks, including:
|
|
5
|
+
|
|
6
|
+
- Graph-based vascular anatomy representation
|
|
7
|
+
- Gymnasium RL environments (VascularNav-v0, FlowAwareNav-v0, MagneticNav-v0)
|
|
8
|
+
- Analytical hemodynamics (Poiseuille flow, Murray's law)
|
|
9
|
+
- Magnetic field models (Helmholtz coils, gradient force, torque)
|
|
10
|
+
- Neural flow surrogate for real-time prediction
|
|
11
|
+
- PPO training pipeline and benchmark suite
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
|
|
16
|
+
from vascularsim.graph import VascularGraph
|
|
17
|
+
|
|
18
|
+
# Register Gymnasium environments on package import
|
|
19
|
+
import vascularsim.envs # noqa: F401
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"__version__",
|
|
23
|
+
"VascularGraph",
|
|
24
|
+
]
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Benchmark environments and runner for VascularSim."""
|
|
2
|
+
|
|
3
|
+
from vascularsim.benchmarks.environments import TIER_NAMES, make_benchmark_graph
|
|
4
|
+
from vascularsim.benchmarks.runner import run_benchmark, save_results
|
|
5
|
+
|
|
6
|
+
__all__ = ["TIER_NAMES", "make_benchmark_graph", "run_benchmark", "save_results"]
|