This is a package to generate structured and morphometric trees to simulate microvascular adaptation in svZeroDPlus.
-
Clone the repository with
git clone https://github.com/ncdorn/svZeroDTrees.git
-
In desired python environment run
cd svZeroDTrees
pip install -e .
clone and install:
standard packages:
- scipy
- numpy
- vtk
- pandas
- matplotlib
- networkx
Generate structured trees at the outlet of 0d models created in SimVascular based on outflow boundary conditions to simulate microvasculature. Adapt these trees to changes in flow at the outlet based on upstream changes, such as stenosis relief. There are currently two microvascular adaptation schemes:
- constant wall shear stress assumption (Yang et al. 2016)
- Pries and Secomb model (Pries et al. 1998)
[] document all code
[] robustify documentation
[] add clinical targets to json file
interface.py
: highest level commands for building trees and computing adaptation
preop.py
: build trees
operation.py
: perform repairs in zerod
adaptation.py
: compute adaptation of trees
post_processing
: methods for post processing data, most are called automatically through the interface
ConfigHandler
: data handler for the 0D solver json config, with additional classes for each 0d element type
ResultHandler
: data handler for the simulation result data
StructuredTreeBC
: class for handling structured trees
TreeVessel
: class for handling vessels of the structured tree
A simple tree with resistance 100.0 can be built with the following methods. steady through the tree is computed easily as well
tree = StructuredTree(name='simple tree')
tree.optimize_tree_diameter(resistance=100.0)
# compute pressure and flow in the tree with inlet flow 10.0 cm3/s and distal pressure 100.0 dyn/cm2
tree_result = tree.simulate(Q_in = [10.0, 10.0], Pd=100.0)
the json config file requires the following keys
- name: name of the experiment
- model: name of svZeroDSolver model config to build trees
- adapt: type of adaptation, either
cwss
(constant wall shear stress) orps
(pries and secomb) - optimized: True if the boundary conditions have been optimized, False if the package should optimize boundary conditions
- is_full_pa_tree: True if the model is a pulmonary arterial tree. A different optimization algorithm must be used
- trees_exist: True if structured trees already exist for the pre-operative model
- mesh_surfaces_path: path to outlet mesh surfaces, required for PA tree optimization
- task: task to be run, either
repair
,optimize_stent
,threed_adaptation
The highest level command is run_from_file(config.json)
examples of config.json
are provided below:
{ "name": "foo_exp",
"model": "foo",
"adapt": "cwss",
"optimized": false,
"is_full_pa_tree": true,
"trees_exist": false,
"mesh_surfaces_path": "/foo/bar/Meshes/1.6M_elements/mesh-surfaces",
"task": "construct_trees",
"construct_trees": {
"tree_type": "cwss"
}
}
see more information here and example code here
{ "name": "foo_exp",
"model": "foo",
"adapt": "cwss",
"optimized": false,
"is_full_pa_tree": true,
"trees_exist": false,
"mesh_surfaces_path": "/foo/bar/Meshes/1.6M_elements/mesh-surfaces",
"task": "repair",
"repair": {
"type": "stent",
"location": "proximal",
"value": [0.5, 0.5]
}
}
{ "name": "foo_stent_opt",
"model": "foo",
"adapt": "ps",
"optimized": true,
"is_full_pa_tree": true,
"trees_exist": true,
"mesh_surfaces_path": "/foo/bar/Meshes/1.6M_elements/mesh-surfaces",
"repair": {
"type": "optimize_stent",
"location": "proximal",
"value": [0.5, 0.5],
"objective": "flow split"
}
}
{ "name": "foo_3d_coupling",
"model": "foo",
"adapt": "ps",
"optimized": false,
"is_full_pa_tree": true,
"trees_exist": false,
"mesh_surfaces_path": "/foo/bar/Meshes/1.6M_elements/mesh-surfaces",
"task": "threed_adaptation",
"threed_adaptation":
{
"preop_dir": "/foo/bar/threed_model/preop",
"postop_dir": "/foo/bar/threed_model/postop",
"adapted_dir": "/foo/bar/threed_model/adapted"
}
}