svVascularize

svVascularize API

Complete reference for the svv module - classes, functions, and parameters

v1.0.0 stable

Quick Start

Import and basic usage

Get Started →

Core Modules

Domain, Tree, Forest

Browse Modules →

Examples

Code snippets and patterns

View Examples →

Module Reference

svv.domain

Core Module

Core domain functionality for defining computational domains and geometric operations. Provides matrix operations, I/O capabilities, and solver implementations.

Submodules

Submodule Description Key Components
domain.core Core matrix operations a_matrix(), h_matrix(), m_matrix(), n_matrix()
domain.io Input/output operations read()
domain.kernel Kernel functions and coordinate transforms Kernel, cost(), cart2sph(), sph2cart()
domain.routines Computational routines allocate(), contour(), tetrahedralize(), boolean()
domain.solver Domain-specific solvers Solver class

Main Classes

  • Domain - Main domain class for defining spatial regions
  • Patch - Individual patches for RBF interpolation

Example Usage

from svv.domain import Domain

# Create a domain from a mesh
import pyvista as pv
mesh = pv.read('tissue_geometry.stl')
domain = Domain(mesh)

# Build implicit function
domain.create()
domain.solve()
domain.build()

# Export domain
boundary, _ = domain.get_boundary(resolution=30)

Performance Note: The domain.routines module includes Cython-optimized functions (c_allocate.pyx, c_sample.pyx) for enhanced performance.

svv.forest

Core Module

Forest structures for managing collections of vascular trees and their interconnections. Supports various connection algorithms and export formats.

Connection Methods

Class Description Use Case
ForestConnection High-level connection manager Builds connections for each network
TreeConnection Per-network connection solver Assigns and optimizes tree-to-tree links
VesselConnection Single connection optimizer Generates connecting vessel segments
Curve Curve factory Supports Bezier, Catmull-Rom, and NURBS shapes

Main Classes

  • Forest - Main class for building connected vascular structures.

Example Usage

import pyvista as pv
from svv.domain import Domain
from svv.forest import Forest

# Prepare a domain and build its implicit representation
domain = Domain(pv.Cube())
domain.create()
domain.solve()
domain.build()

# Initialize a forest with two trees in one network
trees_per_network = [2]
forest = Forest(domain=domain, n_networks=1, n_trees_per_network=trees_per_network)
forest.set_domain(domain)
forest.set_roots()  # Randomize root placement
forest.add(50)      # Grow 50 vessels per tree

# Connect the trees (starting with cubic curves)
forest.connect(3)

# Export watertight solids for downstream simulation or fabrication
forest.export_solid(outdir='forest_model')

svv.tree

Core Module

Tree structures and algorithms for vascular tree generation, manipulation, and analysis. Includes branching logic, collision detection, and optimization utilities.

Key Classes

Class Module Purpose
Tree tree Main tree structure
Bifurcation tree.branch Bifurcation point management
TreeManager tree.utils Tree lifecycle management
TreeCollision tree.collision Collision detection

Main Classes

  • Tree - Main class for building bifurcating vascular structures

Performance note: The tree.utils module contains several Cython-optimized functions (c_angle, c_basis, c_close, c_extend, c_local_optimize, c_obb, c_update) for performance-critical operations.

svv.simulation

Simulation

Comprehensive simulation framework for fluid dynamics and hemodynamic modeling. Supports both 0D and 1D reduced-order models.

Simulation Types

0D Models

Lumped parameter models for rapid system-level analysis

  • zerod_forest
  • zerod_tree
  • project_solution
1D Models

One-dimensional flow models for detailed hemodynamics

  • centerlines
  • generate_1d_mesh
  • parameters

Example Usage

from svv.simulation import Simulation
from svv.simulation.fluid.rom.zero_d.zerod_tree import export_0d_simulation

# Wrap a generated tree in a Simulation container
sim = Simulation(tree, name='example_sim')

# Build CFD-ready meshes and identify boundary faces
sim.build_meshes(fluid=True, tissue=False, boundary_layer=True)
sim.extract_faces(crease_angle=60.0)

# Construct and write an svFSI configuration
sim.construct_3d_fluid_simulation()
sim.write_3d_fluid_simulation()

# Export a matching 0D model for fast hemodynamic studies
export_0d_simulation(tree, outdir='tree_0d')

svv.utils

Utilities

Utility functions for mesh operations, spatial calculations, and cross-platform support.

Platform Support: The remeshing module includes platform-specific MMG binaries for Linux, macOS, and Windows. Ensure you have the correct binary for your system.

Available Utilities

  • remeshing.remesh_surface() - Remesh surface meshes with MMG
  • remeshing.remesh_volume() - Volume remeshing helpers
  • spatial.minimum_segment_distance() - Pairwise vessel distance checks
  • spatial.minimum_self_segment_distance() - Self-collision distance utility

svv.visualize

Visualization

Visualization tools for rendering vascular trees and forests.

Example Usage

from svv.visualize.tree.show import show as show_tree
from svv.visualize.forest.show import show as show_forest

# Visualize a single tree with the enclosing domain
show_tree(tree, color='crimson', plot_domain=True)

# Visualize an entire forest and save a screenshot
plotter = show_forest(forest, colors=['red', 'royalblue'], plot_domain=True, return_plotter=True)
plotter.screenshot('forest_viz.png')

Common Examples

Generate a Vascular Tree

import pyvista as pv
from svv.domain import Domain
from svv.tree import Tree

domain = Domain(pv.Cube())
domain.create()
domain.solve()
domain.build()

tree = Tree()
tree.set_domain(domain)
tree.set_root()
tree.n_add(100)

# Export watertight geometry for printing or meshing
tree.export_solid(outdir='vascular_tree')

Run 0D Simulation

from svv.simulation.fluid.rom.zero_d.zerod_tree import export_0d_simulation

export_0d_simulation(tree, outdir='tree_0d', steady=True)

API Conventions

Naming Conventions

  • Classes: PascalCase (e.g., TreeManager)
  • Functions: snake_case (e.g., export_solid())
  • Constants: UPPER_CASE (e.g., DEFAULT_VISCOSITY)
  • Private: Leading underscore (e.g., _internal_method())

Units

  • Length: millimeters (mm)
  • Time: seconds (s)
  • Pressure: mmHg or Pa
  • Flow: mL/s