\section{Method}
\label{sec:method}
To derive graph representations from raw 3D vascular images, we first predict voxel-wise direction vectors capturing local structure, subsequently assembled into a tree-structured skeleton using a modified TEASAR algorithm~\cite{sato2000teasar}.  \figureref{fig:vessel_tree_prediction} illustrates our approach. 
\sectionref{sec:direction_vector_prediction} describes  direction vector generation and prediction, \sectionref{sec:teasar} the adaptation of TEASAR for vector-based skeletonization.
%Further postprocessing leverages direction vectors to handle falsely split components, as described in Suppl.\ \sectionref{sec:False split handling}.

We formally represent vessel trees as directed acyclic graphs (DAG) \cite{diestel2017graph}:
Nodes correspond to 3D coordinates marking either branching points or sampled points along vessel segments, while edges denote the segments connecting them.
Each edge is assigned a radius characterizing the local vessel thickness. Edge directions follow a parent–child relationship, where the parent is the one closer to the vessel root.

\subsection{Direction Vector Generation and Prediction}
\label{sec:direction_vector_prediction}
%
We train a 3D U-Net~\cite{unet_ronneberger2015} to jointly predict a foreground mask and voxel-wise direction vectors (x, y, z components) from 3D grayscale images.
These vectors point toward the vessel centerline and are additionally biased rootward by a fixed stepsize, such that iterative following of the vectors eventually converges at the root.
%
Given a ground-truth foreground mask and a corresponding graph, we obtain training vectors as follows:
For each foreground voxel, we first identify the nearest edge in the ground-truth graph within the local vessel radius.
From the closest point on that edge, we then step a fixed distance toward the root, which defines the target point for the direction vector.
The resulting vectors point from each voxel to this upstream centerline point, yielding smaller magnitudes for pixels close to the centerline and larger ones near the vessel boundary.
%
Suppl.\ \figureref{fig:direction_vectors}a and \algorithmref{alg:vector_generation} provide details of the direction vectors and their generation.
During training, we use Binary Cross-Entropy (BCE) loss for the foreground mask and Mean Squared Error (MSE) loss for the direction vectors. 

\subsection{TEASAR-based Centerline Generation}
\label{sec:teasar}
TEASAR~\cite{sato2000teasar} extracts tree-shaped skeletons from volumetric tubular segmentation masks by placing centerlines in regions that lie maximally far from the object boundary.
It implements this by iteratively tracing shortest paths from a root to any voxel within the mask, applying a penalty that discourages paths from approaching the boundary.
%
This penalty depends solely on boundary distance, thus it may produce incorrect skeletons when vessels run in parallel, as shown in \figureref{fig:our_approach_summary}.
To address this, we propose a modified TEASAR variant that incorporates predicted voxel-wise direction vectors.
These vectors exhibit minimal magnitude and smallest angle relative to the centerline direction at voxels closest to the centerline.
We therefore augment the penalty term with components based on both \textit{vector magnitude} and \textit{angular deviation}. This additional penalty helps disambiguate vessels that are spatially tangent but semantically distinct.

\paragraph{Extended Penalty Term.}
\label{sec:teasar_flow_vectors}
Formally, let \( \Omega \subset \mathbb{R}^3 \) be the 3D object (foreground mask) and \( \partial \Omega \) be the object boundary (vessel surface).
Let \( p \in \Omega \) be the voxel inside the object located at the end of the shortest path $P$, constructed in a previous iteration step.
%(in the first step TEASAR select two distant points).
By \(N \subseteq \Omega \) we denote the set of all those adjacent voxels of \(p\) are lying within the object.
%
For each neighboring voxel $n\in N$, the \emph{distance from boundary field (DBF)} of \( n \), as leveraged by the original TEASAR, refers to the shortest Euclidean distance from voxel \( n \in N\) to the nearest boundary point \( b \in \partial \Omega \): 
\begin{equation}
    \text{DBF}(n) := \min_{b \in \partial \Omega} || n - b ||
\end{equation}
To incorporate directional guidance, we additionally consider 
%
the \emph{vector magnitude field (VMF)}, defined at each voxel $n$ as the magnitude of its direction vector $v_n$:  $\text{VMF}(n) := \left|| \vec{v}_n |\right|$. 
Note that $\text{VMF}(n)$ is minimal if the voxel lies on the centerline.
Furthermore we denote by $\theta(p,n)\in[0,180]$
% \begin{equation}
% \theta(p,n):=\arccos\frac{\langle\vec{v}_p, \vec{r}\rangle}{||\vec{v}_p||\cdot||\vec{r}||} \in[0,180]
% \end{equation}
the angle (in degrees) between the direction vector $\vec{v}_p$ of \(p\) and the relative direction vector $\vec{r}:= n-p$ from $p$ to $n$ as shown in Suppl.\ \figureref{fig:direction_vectors}b.
Again $\theta(p,n)$ is minimal if $n$ is located in direction of the predicted direction vector $\vec{v}_p$. % w.r.t. to $p$.
The adapted penalty value we propose is given by:
\begin{equation}
\label{eq:pv_flow}
\text{PV}_{\text{flow}}(p,n) = 1{,}000{,}000 \cdot \Bigg( 
\left(1 - \frac{\text{DBF}(n)}{M_1}\right)^{16} + \\
\left(\frac{\text{VMF}(n)}{M_2}\right)^{16} + 
\left(\frac{\theta(p, n)}{M_3}\right)^{16} 
\Bigg)
\end{equation}
where 
\begin{equation}
    M_1 = \max_{p\in \Omega}(\text{DBF}(p))^{1.01},~ M_2 = \max_{p\in \Omega}(\text{VMF}(p))^{1.01},~ M_3 =180
\end{equation}

This directly adopts the original TEASAR penalty, augmenting it with VMF- and $\theta$- based terms of analogous form. Given this penalty, skeleton tracing proceeds as usual, starting from a most root-distant end point determined analogously as in original TEASAR, and appending the minimum-penalty neighboring node to the path until the root is reached.

\paragraph{Multi-root Processing and Adaptive Masking.}

\begin{figure}[t]
\centering
\includegraphics[width=\textwidth]{figures/teasar/teaser_complete_v2.pdf}
\caption[Schematic of the modified TEASAR to address topological errors.]{
\label{fig:teasar}
\textbf{Addressing topological errors with the modified TEASAR algorithm.}
(a) Predicted foreground mask with distinct ground-truth (GT) trees having different colors.
(b) The algorithm selects one connected component and identifies its roots and endpoints.
(c) For each endpoint, paths are traced to all candidate roots, and the optimal path (with the lowest penalty) is chosen.
(d) Voxels within a specified radius around the traced path are marked as processed and excluded from subsequent tracing.
(e) After a component is fully processed, the algorithm proceeds to the next one; once all components are processed, disconnected fragments are evaluated for merging.
(f) Final output with complete centerlines.
}
\vspace{-15pt}
\end{figure}

Original TEASAR generates one skeleton per connected component of the binary mask.
However, segmentation errors may merge distinct vessels into a single component, producing structures with multiple trees and therefore multiple roots.
To address this, we extend TEASAR to support multiple roots within a component, as illustrated in \figureref{fig:teasar}.
Root locations in the datasets are provided either by manual annotation or automatically using the predicted direction vectors, effectively speeding up the annotation process.
Details on automated root detection are provided in Suppl.\ \sectionref{sec:automated_root_detection}.

Once the best path is established (\figureref{fig:teasar}(c) and (d)), original TEASAR applies a simple linear thresholding using a fixed scale and constant value $d = scale \cdot r + const$,
where $r$ is the vessel radius and $d$ is the masking distance used to exclude already processed regions. We extend this with an adaptive masking scheme in which both parameters vary smoothly with the local vessel radius.
This makes the method more robust across vessels of different radius and effectively suppresses spurious small branches in larger vessels.
Further details are provided in  Suppl.\ \sectionref{sec:adaptive masking}.

\paragraph{False Split Postprocessing.}
Finally, components without an assigned root are evaluated for potential merging with nearby trees. 
For each node in a disconnected component (the current node), we first identify neighboring nodes within a spatial distance of 5 voxels. Among these candidates, we retain only those that belong to a different tree and then compute their radius difference and angular deviation (based on the direction vectors) with respect to the current node. If the radius difference is below 3 and the angular difference is below 100 degrees, and adding an edge between the two nodes does not introduce a cycle, we connect them. In cases with multiple valid neighbors, we select the closest one. This step helps to reduce false splits introduced by the segmentation. However, very small or isolated components that do not meet these criteria may remain disconnected.
