API documentation

Manipulation of the area

manipulate_area.py

manipulate_area.change_area(voronoi, factor, line_to_change, diverging_centerline, diverging_voronoi, surface_area, centerlines, angle_asymmetric)[source]

Change the cross-sectional area of an input voronoi diagram along the corresponding area represented by a centerline.

Parameters
  • angle_asymmetric (float) – Angle defining the orientation of the asymmetry for a stenosis / bulge

  • voronoi (vtkPolyData) – Voronoi diagram.

  • factor (ndarray) – An array with a factor for changing each point along the centerline

  • line_to_change (vtkPolyData) – Centerline representing area of interest.

  • diverging_centerline (list) – List of polydata containing diverging centerlines along region of interest.

  • diverging_voronoi (list) – List of Voronoi diagram diverging off region of interest.

  • surface_area (vtkPolyData) – The surface used to compute the area.

  • centerlines (vtkPolyData) – Centerlines of the full model.

Returns

Manipulated Voronoi diagram.

Return type

new_voronoi (vtkPolyData)

manipulate_area.get_asymmetric_displacement(A, angle_asymmetric, factor_, frenet_normals_array, frenet_tangents_array, locator, point)[source]

Compute translation adding asymmetric effect to stenosis / bulge

Parameters
  • A (ndarray) – Initial position on centerline

  • vector (angle_asymmetric (Angle to rotate around Frenet tangent) –

  • factor (float) – Scaling factor for area manipulation

  • frenet_normals_array (list) – List of Frenet normal vectors

  • frenet_tangents_array (list) – List of Frenet tangent vectors

  • locator (vtkPointLocator) – Centerline locator

  • point (vtkPoint) – Current Voronoi point

Returns

Translation vector for asymmetric effect

Return type

ndarray

manipulate_area.get_factor(line_to_change, method, beta, ratio, percentage, region_of_interest, transition_length)[source]

Compute the factor determining the change in radius, used to manipulate the Voronoi diagram.

Parameters
  • line_to_change (vtkPolyData) – Centerline representing area of interest.

  • method (str) – Type of manipulation of the centerline.

  • beta (float) – Factor deciding how area will change. Ignored if ratio is given.

  • ratio (float) – Desired ratio between min and max cross-sectional area.

  • percentage (float) – Desired increase/decrease in cross-sectional area.

  • region_of_interest (str) – Method for setting the region of interest.

  • transition_length (float) – Percent of the total length of the start and end to transition the change.

Returns

Factor determining the change in radius.

Return type

factor (float)

manipulate_area.main_area()[source]
manipulate_area.manipulate_area(input_filepath, method, smooth, smooth_factor, no_smooth, no_smooth_point, region_of_interest, region_points, beta, ratio, size, percentage, output_filepath, poly_ball_size, resampling_step, angle_asymmetric, transition_length)[source]

Objective manipulation of area variation in patient-specific models of blood vessels. Manipulation is performed by looping over all Voronoi points relative to a selected centerline and change the corresponding radius.

Parameters
  • angle_asymmetric (float) – Angle defining the orientation of the asymmetry for a stenosis / bulge

  • input_filepath (str) – Path to directory with cases.

  • method (str) – Type of manipulation of the centerline.

  • smooth (bool) – Determines Voronoi smoothing or not.

  • smooth_factor (float) – Smoothing factor used for voronoi diagram smoothing.

  • no_smooth (bool) – If True, define a region where the Voronoi diagram should not be smoothed.

  • no_smooth_point (list) – A flattened list to the ‘end’ points of the regions not to smooth.

  • beta (float) – Factor determining how much the geometry will differ.

  • ratio (float) – Target ratio, A_max / A_min. Beta is ignored (and estimated) if given.

  • percentage (float) – Percentage the area of the geometry / stenosis is increase/decreased.

  • size (float) – Length of affected stenosis area. Default is MISR x 2.0 of selected point.

  • region_of_interest (str) – Method for setting the region of interest [‘manual’ | ‘commandline’ | ‘first_line’]

  • region_points (list) – If region_of_interest is ‘commandline’, this a flatten list of the start and endpoint

  • poly_ball_size (list) – Resolution of polyballs used to create surface.

  • output_filepath (str) – Path to output the manipulated surface.

  • resampling_step (float) – Resampling length for centerline resampling.

  • transition_length (float) – Percent of the total length of the start and end to transition the change.

manipulate_area.read_command_line_area(input_path=None, output_path=None)[source]

Read arguments from commandline and return all values in a dictionary. If input_path and output_path are not None, then do not parse command line, but only return default values.

Parameters
  • input_path (str) – Input file path, positional argument with default None.

  • output_path (str) – Output file path, positional argument with default None.

manipulate_area.update_factor(A, AB_length, B, P_mid, factor, tmp_id1, tmp_id2)[source]

Update values in Factor based on midpoint between A and B.

Parameters
  • P_mid (ndarray) – Midpoint

  • factor (list) – List of scaling factors for area variation

  • tmp_id1 (int) – Id at first point

  • tmp_id2 (int) – Id at second point

  • A (ndarray) – First point

  • B (ndarray) – Second point

  • AB_length (float) – Length of line AB

Returns

List of updated scaling factors

Return type

list

Manipulation of a bend

manipulate_bend.py

manipulate_bend.main_bend()[source]
manipulate_bend.manipulate_bend(input_filepath, output_filepath, smooth, smooth_factor, region_of_interest, region_points, alpha, beta, poly_ball_size, no_smooth, no_smooth_point, resampling_step)[source]

Primary script for moving a selected part of any blood vessel. Relies on an input centerline, a surface geometry of a 3D blood vessel network, and the magnitude of movement (alpha, beta) in horizontal and vertical direction respectively.

Defines in- and out-put files, computes voronoi diagram, and moves voronoi diagram in the horizontal direction based on the definitions in “Investigating the Interaction Between Morphology of the Anterior Bend and Aneurysm Initiation” (2018). Proceeds by computing the corresponding centerline in the new geometries, used for postprocessing, geometric analysis and meshing.

Continuation in the manipulate_bend_vertically-method for vertical movement.

Parameters
  • input_filepath (str) – Path to input surface.

  • output_filepath (str) – Path to output the manipulated surface.

  • smooth (bool) – Smooth the Voronoi diagram.

  • smooth_factor (float) – Smoothing factor used for Voronoi diagram smoothing.

  • region_of_interest (str) – Method for setting the region of interest [‘manual’ | ‘commandline’ | ‘landmarking’]

  • region_points (list) – If region_of_interest is ‘commandline’, this a flatten list of the start and endpoint

  • alpha (float) – Extension / Compression factor in vertical direction.

  • beta (float) – Extension / Compression factor in horizontal direction.

  • poly_ball_size (list) – Resolution of polyballs used to create surface.

  • no_smooth (bool) – True of part of the model is not to be smoothed.

  • no_smooth_point (ndarray) – Point which is untouched by smoothing.

  • resampling_step (float) – Resampling length when resampling centerline.

manipulate_bend.manipulate_bend_vertically(alpha, voronoi_remaining, voronoi_bend, centerlines, region_points, poly_ball_size)[source]

Secondary script used for vertical displacement of the blood vessel. Moves the input voronoi diagram and centerline in the vertical direction.

Parameters
  • centerlines (vtkPolyData) – Centerline through the geometry.

  • alpha (float) – Extension / Compression factor in vertical direction.

  • voronoi_remaining (vtkPolyData) – Voronoi diagram excluding bend.

  • voronoi_bend (vtkPolyData) – Voronoi diagram representing bend.

  • region_points (list) – Points defining the bend to be manipulated.

  • poly_ball_size (list) – Resolution of surface model.

Returns

New surface model.

Return type

new_surface (vtkPolyData)

Returns

New centerline.

Return type

new_centerline (vtkPolyData)

manipulate_bend.move_voronoi_horizontally(dx_p1, voronoi_clipped, centerline_clipped, id1, id2, clip_id, clip=False, diverging_centerline_ispresent=False)[source]

Iterate through voronoi diagram and move based on a profile for horizontal movement. Includes special treatment of diverging centerlines if present.

Parameters
  • dx_p1 (ndarray) – Direction to move upstream.

  • voronoi_clipped (vtkPolyData) – Voronoi diagram to be moved.

  • centerline_clipped (vtkPolyData) – Centerline corresponding voronoi diagram.

  • id1 (int) – Index of first clipping point.

  • id2 (int) – Index of second clipping point.

  • clip_id (int) – Index where diverging centerline is located (if present)

  • clip (bool) – Determines which part of geometry is being moved, True if bend.

  • diverging_centerline_ispresent (bool) – Determines presence of diverging centerline.

Returns

Manipulated Voronoi diagram.

Return type

new_dataset (vtkPolyData)

manipulate_bend.move_voronoi_vertically(voronoi_clipped, centerline_clipped, id1_0, clip_id, dx, diverging_centerline_ispresent=False)[source]

Iterate through voronoi diagram and move based on a profile for vertical movement. Includes special treatment of diverging centerline if present.

Parameters
  • voronoi_clipped (vtkPolyData) – Voronoi diagram to be moved.

  • centerline_clipped (vtkPolyData) – Centerline corresponding voronoi diagram.

  • id1_0 (int) – Index of first clipping point.

  • clip_id (int) – Index where diverging centerline is located (if present)

  • dx (ndarray) – Direction to move.

  • diverging_centerline_ispresent (bool) – Determines presence of diverging centerline.

Returns

Manipulated Voronoi diagram.

Return type

new_dataset (vtkPolyData)

manipulate_bend.read_command_line_bend(input_path=None, output_path=None)[source]

Read arguments from commandline and return all values in a dictionary. If input_path and output_path are not None, then do not parse command line, but only return default values.

Parameters
  • input_path (str) – Input file path, positional argument with default None.

  • output_path (str) – Output file path, positional argument with default None.

Manipulation of a bifurcation

manipulate_bifurcation.py

manipulate_bifurcation.get_points(data, key, bif=False)[source]

Finds specific points around the bifurcation, based on the key argument. Points can before or after rotation.

Parameters
  • data (dict) – Contains information about points and IDs of branches and bifurcation.

  • key (str) – Type of points to extract.

  • bif (true) – Gets only bifurcation points if True.

Returns

Points as VTK objects.

Return type

points (vtkPoints)

Returns

Points as numpy objects.

Return type

div_points_bif (ndarray)

manipulate_bifurcation.main_bifurcation()[source]
manipulate_bifurcation.manipulate_bifurcation(input_filepath, output_filepath, smooth, smooth_factor, angle, keep_fixed_1, keep_fixed_2, bif, lower, no_smooth, no_smooth_point, poly_ball_size, cylinder_factor, resampling_step, region_of_interest, region_points, tension, continuity, select_inlet)[source]

Objective rotation of daughter branches, by rotating centerlines and Voronoi diagram about the bifurcation center. The implementation is an extension of the original method presented by Ford et al. (2009), for aneurysm removal, which introduces the possibility to rotate the daughter branches a given angle. Includes the option to rotate only one of the daughter branches.

Parameters
  • tension (float) – Tension parameter of Kochanek splines

  • continuity (float) – Continuity parameter of Kochanek splines

  • input_filepath (str) – Path to input surface.

  • output_filepath (str) – Path to output surface.

  • smooth (bool) – Determine if the voronoi diagram should be smoothed.

  • smooth_factor (float) – Smoothing factor used for voronoi diagram smoothing.

  • angle (float) – Angle which daughter branches are moved, in radians.

  • keep_fixed_1 (bool) – Leaves first branch untouched if True.

  • keep_fixed_2 (bool) – Leaves second branch untouched if True.

  • bif (bool) – Interpolates bifurcation is True.

  • lower (bool) – Interpolates a lowered line through the bifurcation if True.

  • cylinder_factor (float) – Factor for choosing the smaller cylinder during Voronoi interpolation.

  • resampling_step (float) – Resampling step used to resample centerlines.

  • no_smooth (bool) – True of part of the model is not to be smoothed.

  • no_smooth_point (ndarray) – Point which is untouched by smoothing.

  • region_of_interest (str) – Method for setting the region of interest [‘manual’ | ‘commandline’ ]

  • region_points (list) – If region_of_interest is ‘commandline’, this is a flattened list of the start and endpoint

  • poly_ball_size (list) – Resolution of polyballs used to create surface.

  • select_inlet (bool) – Lets user manually select inlet if True

manipulate_bifurcation.merge_cl(centerline, end_point, div_point)[source]

Merge overlapping centerlines.

Parameters
  • centerline (vtkPolyData) – Centerline data consisting of multiple lines.

  • end_point (ndarray) – Point where bifurcation ends.

  • div_point (ndarray) – Point where centerlines diverge.

Returns

Merged centerline.

Return type

merge (vtkPolyData)

manipulate_bifurcation.read_command_line_bifurcation(input_path=None, output_path=None)[source]

Read arguments from commandline and return all values in a dictionary. If input_path and output_path are not None, then do not parse command line, but only return default values.

Parameters
  • input_path (str) – Input file path, positional argument with default None.

  • output_path (str) – Output file path, positional argument with default None.

manipulate_bifurcation.rotate_cl(patch_cl, div_points, rotation_matrices, R)[source]

Perform rotation of the centerline representing the daughter branches. Rotate along the bifurcation plane spanned by two vectors, preserving the angle with the rest of the vasculature. Rotation is performed using a standard rotational matrix.

Parameters
  • patch_cl (vtkPolyData) – Clipped centerline representing two daughter branches.

  • div_points (ndarray) – Contains bifurcation landmarking points.

  • rotation_matrices (dict) – Contains rotation matrices for each daughter branch.

  • R (ndarray) – Matrix containing unit vectors in the rotated coordinate system.

Returns

Rotated centerline.

Return type

centerline (vtkPolyData)

manipulate_bifurcation.rotate_voronoi(clipped_voronoi, patch_cl, div_points, m, R)[source]

Perform rotation of the voronoi diagram representing the daughter branches. Rotate along the bifurcation plane spanned by two vectors, preserving the angle with the rest of the vasculature. Rotation is performed using a standard rotational matrix m.

Parameters
  • clipped_voronoi (vtkPolyData) – Clipped voronoi diagram.

  • patch_cl (vtkPolyData) – Clipped centerline.

  • div_points (ndarray) – Contains bifurcation landmarking points.

  • R (ndarray) – Matrix containing unit vectors in the rotated coordinate system.

  • m (dict) – Contains rotation matrices for each daughter branch.

Returns

Rotated voronoi diagram.

Return type

masked_voronoi (vtkPolyData)

manipulate_bifurcation.rotation_matrix(data, angle, leave1, leave2)[source]

Compute the rotation matrices for one or both daughter branches of the vessel.

Parameters
  • data (dict) – Contains information about landmarking points.

  • angle (float) – Angle which branches are rotated.

  • leave1 (bool) – Leaves first daughter branch if True.

  • leave2 (bool) – Leaves second daughter branch if True.

Returns

Matrix containing unit vectors in the rotated coordinate system.

Return type

R (ndarray)

Returns

Contains rotation matrices for each daughter branch.

Return type

m (dict)

Manipulation of a branch

manipulate_branch.py

manipulate_branch.check_branch_number(branch_to_manipulate_number, branches_complete)[source]

Check if branch number provided by user is larger than number of centerlines. Raises RuntimeError if number exceeds limit.

Parameters
  • branch_to_manipulate_number (int) – Input number, supplied by user

  • branches_complete (list) – All centerline branches

manipulate_branch.clamp_profile(centerline_id, number_of_points)[source]

Profile used for gradually translating a branch to be clamped. Currently using a linear profile, ranging from 0 to 1.

Parameters
  • centerline_id (int) – ID at current centerline point

  • number_of_points (int) – Number of centerline points

Returns

Clamp factor, ranging from 0 to 1

Return type

float

manipulate_branch.detach_branch(voronoi_remaining, centerlines, poly_ball_size, surface, output_filepath, branch_end_points, base_path)[source]

Reconstructs the Voronoi diagram, creating a new surface, without the selected branch, utimatley removing it. Proceeds by computing the corresponding centerline in the new geometries, used for postprocessing, geometric analysis and meshing.

Parameters
  • voronoi_remaining (vtkPolyData) – Voronoi diagram of remaining surface model

  • centerlines (vtkPolyData) – Relevant centerlines in new geometry

  • poly_ball_size (list) – Resolution of polyballs used to create surface.

  • surface (vtkPolyData) – Surface model

  • output_filepath (str) – Path to output the manipulated surface.

  • branch_end_points (list) – List of the coordinates of the end points of each branch to remove

  • base_path (string) – Path to save location

manipulate_branch.filter_voronoi(voronoi, diverging_centerline_branch)[source]

Filter away voronoi points too far away from relevant branch

Parameters
  • voronoi (vtkPolyData) – Voronoi diagram to be filtered

  • diverging_centerline_branch (vtkPolyData) – Relevant centerlines of the branch

Returns

Voronoi diagram, diverging part

Return type

vtkPolyData

Returns

Voronoi diagram, remaining part

Return type

vtkPolyData

manipulate_branch.get_all_branches(centerlines)[source]

Extract and combine all branches of the surface model. Removes first part of centerlines after combining, excluding the bifurcating part.

Parameters

centerlines (list, ndarray) – List containing sorted centerlines

Returns

All possible branches in the geometry

Return type

list

manipulate_branch.get_centerline_for_splitting_voronoi(centerlines, starting_point, base_path, capped_surface, voronoi, pole_ids, resampling_step)[source]

Get a version of the centerline that extends closer to the ‘main’ centerline. The logic to create a second centerline is to reduce the effect of ‘bumb’ left after moving a branch.

Parameters
  • centerlines (vtkPolyData) – The complete centerline.

  • starting_point (list) – The starting point of the branch-clipped centerline.

  • base_path (str) – Path to the working folder and name of the case.

Returns

The new centerline for splitting the Voronoi diagram

Return type

clipping_centerline (vtkPolyData)

manipulate_branch.get_clamped_branch_rotation_factors(angle, cl_id, m, axis_of_rotation, origin, point)[source]

Gradually maniulate branch to clamp branch at endpoint, when rotating branch.

Parameters
  • angle (float) – Angle to rotate in radians

  • axis_of_rotation (ndarray) – Axis to rotate around

  • point (vtkPoint) – Voronoi point

  • cl_id (int) – Current centerline point ID

  • m (int) – Number of centerline points

  • origin (ndarray) – Origin to rotate around

Returns

Rotated Voronoi point

Return type

ndarray

manipulate_branch.get_clamped_branch_translation_factors(angle, centerline_locator, dx, normal, number_of_points, point)[source]

Gradually maniulate branch to clamp branch at endpoint, when rotating branch.

Parameters
  • dx (float) – Distance to translate branch

  • angle (float) – Angle to rotate in radians

  • normal (ndarray) – Normal vector at manipulation location

  • centerline_locator (vtkPointLocator) – Locator for centerline

  • number_of_points (int) – Number of centerline points

  • point (vtkPoint) – Voronoi point

Returns

Rotation matrix ndarray: Translation point

Return type

ndarray

manipulate_branch.get_exact_surface_normal(capped_surface, new_branch_pos_id)[source]

Compute normal out of surface at given point.

Parameters
  • capped_surface (vtkPolyData) – Capped surface model

  • new_branch_pos_id (int) – ID of point where branch is moved, on surface

Returns

Normal vector out of surface

Return type

new_normal (ndarray)

manipulate_branch.get_new_branch_position(branch_location, capped_surface)[source]

Get point on surface closest to branch_location. Returns both the point on the surface and it’s ID.

Parameters
  • branch_location (ndarray) – User selected point.

  • capped_surface (vtkPolyData) – Input surface

Returns

Point closest to branch location ID on surface. new_branch_pos (ndarray): Point closest to branch location on surface.

Return type

new_branch_pos_id (int)

manipulate_branch.get_origin(voronoi_remaining, centerlines, diverging_centerline_branch)[source]

Get the point where the centerline crosses the surface when the branch is removed

Parameters
  • voronoi_remaining (vtkPolyData) – The Voronoi diagram after the branch is removed.

  • centerlines (vtkPolyData) – All the centerlines.

  • diverging_centerline_branch (vtkPolyData) – The diverging branch.

Returns

The coordinate of the point where the centerline intersects with

the reconstructed surface.

Return type

origin (list)

manipulate_branch.get_rotation_axis(centerline, normal_vector)[source]

Compute axis of rotation for Azimuthal rotation

Parameters
  • centerline (vtkPolyData) – Centerline of branch to manipulate

  • normal_vector (vtkPolyData) – Surface normal vector at rotation origin

Returns

Axis of rotation vector

Return type

ndarray

manipulate_branch.get_rotation_axis_and_angle(new_normal, old_normal)[source]

Compute axis vector and angle between normal vectors (input)

Parameters
  • old_normal (ndarray) – Normal vector at initial position

  • new_normal (ndarray) – Normal vector at new position

Returns

Normal vector corresponding to rotation axis

Return type

u (ndarray)

Returns

Angle between normal vectors

Return type

angle (float)

manipulate_branch.get_translation_parameters(centerlines, origin_old, new_branch_pos)[source]

Get distance to translate branch, and the new position location for branch

Parameters
  • centerlines (vtkPolyData) – Relevant centerlines

  • origin_old (list) – Coordinate of the origin of the branch in the original location

  • new_branch_pos (vtkPoint) – Position where branch is moved

Returns

Distance to translate branch origin (ndarray): Adjusted origin / position of new branch position

Return type

dx (float)

manipulate_branch.main_branch()[source]
manipulate_branch.manipulate_branch(input_filepath, output_filepath, smooth, smooth_factor, poly_ball_size, no_smooth, no_smooth_point, resampling_step, polar_angle, azimuth_angle, remove_branch, branch_to_manipulate_number, branch_location, translation_method, clamp_branch)[source]

Primary script for moving or removing a selected branch of any blood vessel. Relies on a surface geometry of a 3D blood vessel network.

Defines in- and out-put files, computes voronoi diagram, and moves voronoi diagram according to user selected points. Used selects two points defining a diverging branch, and the one point defining the new location on the surface. Proceedes with either removal of a single branch, or traslationg and rotation of a single branch.

Parameters
  • clamp_branch (bool) – Clamps branch at endpoint if True

  • (bool (remove_branch) – If true, removes selected branch completely.

  • input_filepath (str) – Path to input surface.

  • output_filepath (str) – Path to output the manipulated surface.

  • smooth (bool) – Smooth the Voronoi diagram.

  • smooth_factor (float) – Smoothing factor used for Voronoi diagram smoothing.

  • poly_ball_size (list) – Resolution of polyballs used to create surface.

  • no_smooth (bool) – True of part of the model is not to be smoothed.

  • no_smooth_point (ndarray) – Point which is untouched by smoothing.

  • resampling_step (float) – Resampling length when resampling centerline.

  • azimuth_angle (float) – Angle to rotate around new surface normal vector. Default is no rotation.

  • polar_angle (float) – Angle to rotate around the axis spanned by cross product of new normal and frenet normal.

  • branch_to_manipulate_number (int) – Number of branch to manipulate, ordered from up- to down-stream.

  • branch_location (ndarray) – Point where branch to manipulate will be moved. Closest point on surface is selected.

  • translation_method (str) – Method for translating the branch to be manipulated.

manipulate_branch.manipulate_centerline_branch(centerline_branch, origin, R, dx, normal, angle, manipulation, clamp_branch, branch_normal=None)[source]

Depending on manipulation method, either translates or rotates the selected branch, represented as a centerline.

Parameters
  • clamp_branch (bool) – Clamps branch at endpoint if True

  • manipulation (str) – Type of manipulation, either ‘rotate’ or ‘translate’

  • centerline_branch (vtkPolyData) – Centerline branch to be manipulated

  • dx (float) – Distance to translate branch

  • R (ndarray) – Rotation matrix, rotation from old to new surface normal or around new surface normal

  • origin (ndarray) – Adjusted origin / position of new branch position

  • angle (float) – Angle to rotate in radians

  • normal (ndarray) – Normal vector at manipulation location

Returns

Manipulated centerline

Return type

centerline (vtkPolyData)

manipulate_branch.manipulate_voronoi_branch(voronoi, dx, R, origin, centerline, normal, angle, manipulation, clamp_branch, branch_normal=None)[source]

Depending on manipulation method, either translates or rotates the selected branch, represented as a Voronoi diagram.

Parameters
  • clamp_branch (bool) – Clamps branch at endpoint if True

  • manipulation (str) – Type of manipulation, either ‘rotate’ or ‘translate’

  • voronoi (vtkPolyData) – Voronoi diagram of surface

  • dx (float) – Distance to translate branch

  • R (ndarray) – Rotation matrix, rotation from old to new surface normal or around new surface normal

  • origin (ndarray) – Adjusted origin / position of new branch position

  • angle (float) – Angle to rotate in radians

  • normal (ndarray) – Normal vector at manipulation location

  • centerline (vtkPolyData) – Centerline of branch to be manipulated

  • branch_normal (list) – Vector the surface normal the branch location

Returns

Manipulated Voronoi diagram

Return type

new_voronoi (vtkPolyData)

manipulate_branch.move_and_rotate_branch(polar_angle, azimuth_angle, capped_surface, centerlines, centerlines_complete, diverging_centerline_branch, new_branch_pos, new_branch_pos_id, output_filepath, poly_ball_size, surface, voronoi_branch, voronoi_remaining, base_path, method, clamp_branch)[source]

Moves, and/or performs rotation of the voronoi diagram, then reconstructs the Voronoi diagram, creating a new surface. Proceeds by computing the corresponding centerline in the new geometries, used for postprocessing, geometric analysis and meshing.

Parameters
  • polar_angle (float) – Angle to rotate around the axis spanned by cross product of new normal and frenet normal.

  • azimuth_angle (float) – Angle to rotate around new surface normal vector. Default is no rotation.

  • capped_surface (vtkPolyData) – Capped surface model

  • centerlines (vtkPolyData) – Relevant centerlines in new geometry

  • centerlines_complete (vtkPolyData) – Complete set of centerlines

  • diverging_centerline_branch (vtkPolyData) – Diverging centerline

  • new_branch_pos (vtkPoint) – Point where branch is moved

  • new_branch_pos_id (int) – ID of point where branch is moved

  • output_filepath (str) – Path to output the manipulated surface.

  • poly_ball_size (list) – Resolution of polyballs used to create surface.

  • surface (vtkPolyData) – Surface model

  • voronoi_remaining (vtkPolyData) – Voronoi diagram of remaining surface model

  • voronoi_branch (vtkPolyData) – Voronoi diagram of branch

  • base_path (string) – Path to save location

  • method (str) – Translation method for selecting new branch position.

  • clamp_branch (bool) – Clamps branch at endpoint if True

manipulate_branch.move_branch(centerlines, diverging_centerline_branch, new_branch_pos, old_normal, new_normal, voronoi_branch, clamp_branch, voronoi_remaining)[source]

Translates and rotates the voronoi diagram and centerline from one point on the surface model to a selected point, defined by new branch position.

Parameters
  • centerlines (vtkPolyData) – Relevant centerlines in new geometry

  • diverging_centerline_branch (vtkPolyData) – Diverging centerline

  • new_branch_pos (vtkPoint) – Point where branch is moved

  • old_normal (ndarray) – Old surface normal

  • new_normal (ndarray) – New surface normal

  • voronoi_branch (vtkPolyData) – Voronoi diagram of branch

  • clamp_branch (bool) – Clamps branch at endpoint if True

  • voronoi_remaining (vtkPolyData) – The remaining Voronoi diagram after removing the branch

Returns

Translated Voronoi diagram vtkPolyData: Translated centerline ndarray: Origin of new position

Return type

vtkPolyData

manipulate_branch.pick_branch(capped_surface, centerlines)[source]

Select (by manually chosing) which branch is translated to on the surface.

Parameters
  • capped_surface (vtkPolyData) – Input surface

  • centerlines (vtkPolyData) – Set of valid centerline branches throughout model

Returns

Branch selected to be manipulated

Return type

branch_to_manipulate (vtkPolyData)

manipulate_branch.pick_new_branch_position(capped_surface)[source]

Select (by manually chosing) where branch is translated to on the surface.

Parameters

capped_surface (vtkPolyData) – Input surface

Returns

Point closest to branch location ID on surface. new_branch_pos (ndarray): Point closest to branch location on surface.

Return type

new_branch_pos_id (int)

manipulate_branch.read_command_line_branch(input_path=None, output_path=None)[source]

Read arguments from commandline and return all values in a dictionary. If input_path and output_path are not None, then do not parse command line, but only return default values.

Parameters
  • input_path (str) – Input file path, positional argument with default None.

  • output_path (str) – Output file path, positional argument with default None.

manipulate_branch.rotate_branch(angle, diverging_centerline_branch, voronoi_branch, origin, axis_of_rotation, clamp_branch, new_normal)[source]

Perform rotation of the voronoi diagram and the centerline around a given axis defined by the input normal vector.

Parameters
  • clamp_branch (bool) – Clamps branch at endpoint if True

  • angle (float) – Angle to rotate the branch, in radians

  • origin (ndarray) – Origin of the centerline

  • axis_of_rotation (ndarray) – Vector defing axis to rotate around

  • diverging_centerline_branch (vtkPolyData) – Diverging centerline

  • voronoi_branch (vtkPolyData) – Voronoi diagram of branch

  • new_normal (list) – Vector which is the surface normal.

Returns

Rotated Voronoi diagram vtkPolyData: Rotated centerline

Return type

vtkPolyData

manipulate_branch.rotation_profile(centerline_id, number_of_points)[source]

Profile used for gradually rotating a branch, to avoid artifacts at the base. Currently using a root function profile, ranging from 0 to 1.

Parameters
  • centerline_id (int) – ID at current centerline point

  • number_of_points (int) – Number of centerline points

Returns

Clamp factor, ranging from 0 to 1

Return type

float

manipulate_branch.set_voronoi_data(cell_array, count, points, radius, voronoi)[source]

Apply points and data to voronoi object

Parameters
  • cell_array (vtkCellArray) – Cell array

  • count (int) – Specific counter

  • points (vtkPoints) – Point array

  • radius (ndarray) – Radius array

  • voronoi (vtkPolyData) – Voronoi diagram to be filtered

manipulate_branch.set_voronoi_point_data(i, point, radius_array_data, cell_array, count, points, radius)[source]

Set point data to a single Voronoi diagram point

Parameters
  • i (int) – Counter

  • point (vtkPoint) – Single point of Voronoi diagram

  • radius_array_data (ndarray) – MISR Radius array

  • cell_array (vtkCellArray) – Cell array

  • count (int) – Specific counter

  • points (vtkPoints) – Point array

  • radius (ndarray) – Radius array

Returns

Incremented counter

Return type

int

Manipulation of a curvature

manipulate_curvature.py

manipulate_curvature.get_dx(p0, p1, smooth_line, cl_id, id_end, id_mid, id_start)[source]

Get the displacement for the Voronoi point

Parameters
  • p0 (ndarray) – Point i on the old centerline.

  • p1 (ndarray) – Point i on the new centerline.

  • smooth_line (bool) – Turn on/off increasing curvuature.

  • cl_id (int) – ID of point i

  • id_end (int) – Point ID of start transition region.

  • id_mid (int) – Point ID of start end transition.

  • id_start (int) – Point ID of end point.

Returns

Displacement

Return type

dx (float)

manipulate_curvature.main_curvature()[source]
manipulate_curvature.make_voronoi_smooth(voronoi, centerline, smoothed_centerline, smooth_line, div_voronoi, div_points)[source]

Move the voronoi diagram based on a smoothed version of the centerline, returning a manipulated version of the voronoi diagram.

Parameters
  • voronoi (vtkPolyData) – Voronoi diagram data set.

  • centerline (vtkPolyData) – Unsmoothed centerline points.

  • smoothed_centerline (vtkPolyData) – Smoothed centerline points.

  • smooth_line (bool) – Determines if model becomes smoother or sharper.

  • div_voronoi (list) – A list of diverging Voronoi diagrams.

  • div_points (list) – List of diverging points along the region of interest.

Returns

Manipulated voronoi diagram. div_offset (list): List of the offset (dx) of each diverging section.

Return type

new_dataset (vtkPolyData)

manipulate_curvature.manipulate_curvature(input_filepath, smooth, smooth_factor, smooth_factor_line, iterations, smooth_line, output_filepath, poly_ball_size, region_of_interest, region_points, resampling_step, no_smooth, no_smooth_point)[source]

Create a sharper or smoother version of the input geometry, determined by a smoothed version of the centerline.

Parameters
  • input_filepath (str) – Path to input surface.

  • output_filepath (str) – Path to output the manipulated surface.

  • smooth (bool) – Smooth the Voronoi diagram.

  • smooth_line (bool) – Smooth centerline if True, anti-smooth if False.

  • smooth_factor (float) – Smoothing factor used for Voronoi diagram smoothing.

  • smooth_factor_line (float) – Smoothing factor used for centerline smoothing.

  • iterations (int) – Smoothing iterations of centerline.

  • region_of_interest (str) – Method for setting the region of interest [‘manual’ | ‘commandline’ | ‘first_line’]

  • region_points (list) – If region_of_interest is ‘commandline’, this a flatten list of the start and endpoint

  • poly_ball_size (list) – Resolution of polyballs used to create surface.

  • resampling_step (float) – Resampling length for centerline resampling.

  • no_smooth (bool) – True of part of the model is not to be smoothed.

  • no_smooth_point (ndarray) – Point which is untouched by smoothing.

manipulate_curvature.move_all_centerlines(unsmoothed_centerline, smoothed_centerline, smooth_line, div_offset)[source]

Takes the original centerline and eventual diverging centerlines, performing manual manipulation by smoothing / sharpening the centerline based on a smoothed region of the original centerline. Returns the final complete and manipulated centerline.

Parameters
  • unsmoothed_centerline (vtkPolyData) – Centerlines excluding diverging centerlines.

  • smoothed_centerline (vtkPolyData) – Smoothed region of the centerline.

  • smooth_line (bool) – Determines if model becomes smoother or sharper.

  • div_offset (list) – List of offset of the Voronoi diagram for each diverging section.

Returns

Manipulated centerline.

Return type

centerline (vtkPolyData)

manipulate_curvature.read_command_line_curvature(input_path=None, output_path=None)[source]

Read arguments from commandline and return all values in a dictionary. If input_path and output_path are not None, then do not parse command line, but only return default values.

Parameters
  • input_path (str) – Input file path, positional argument with default None.

  • output_path (str) – Output file path, positional argument with default None.

Manipulation of a surface roughness

manipulate_surface.py

manipulate_surface.add_noise_to_existing_voronoi_diagram(voronoi, centerline, translation_noise_factor)[source]

Add noise to existing Voronoi diagram by adjusting the Voronoi points based on the closest point on the centerline. Each point is translated by a small amount, determined by translation noise factor in [0,1].

Parameters
  • voronoi (vtkPolyData) – Voronoi Diagram to be manipulated

  • centerline (vtkPolyData) – Centerline(s) along relevant Voronoi diagram

  • translation_noise_factor (float) – Factor in [0,1] determining amount of translation of existing Voronoi point, used in ‘edit_misr_noise’-method.

Returns

Noisy Voronoi diagram

Return type

new_voronoi (vtkPolyData)

manipulate_surface.add_noise_to_voronoi_diagram_new_points(surface, voronoi, centerline, radius_max, radius_min, frequency, frequency_deviation, lower, upper, absolute)[source]

Add noise to Voronoi diagram by adjusting the MISR size by a factor in [1.0, radius_max], combined with a set frequency + deviation.

Parameters
  • surface (vtkPolyData) – Surface model of model to be smoothed

  • voronoi (vtkPolyData) – Voronoi Diagram to be smoothed

  • centerline (vtkPolyData) – Centerline(s) along relevant Voronoi diagram

  • radius_max (float) – Draw a number from ‘radius-min’ and ‘radius-max’ and multiply with the distance from the new point to the surface to set the radius of the new pointUsed to pick MISR multiplier to create noise on surface.

  • radius_min (float) – Draw a number from ‘radius-min’ and ‘radius-max’ and multiply with the distance from the new point to the surface to set the radius of the new pointUsed to pick MISR multiplier to create noise on surface

  • frequency (float) – Frequency at which noise is added to the voronoi diagram, based on points along the centerline. Drawn from a normal distribution with mean of ‘frequency’.

  • frequency_deviation (float) – Standard deviation of frequency distribution.

  • lower (float) – The new location of a point in the voronoi diagram is a length drawn between ‘lower’ and ‘upper’, either relative to the MISR or in absolute value.

  • upper (float) – The new location of a point in the voronoi diagram is a length drawn between ‘lower’ and ‘upper’, either relative to the MISR or in absolute value.

  • absolute (bool) – Turn on/off an absolute threshold on the values instead of relative with respect to the MISR.

Returns

Noisy Voronoi diagram

Return type

new_voronoi (vtkPolyData)

manipulate_surface.main_surface()[source]
manipulate_surface.manipulate_surface(input_filepath, output_filepath, smooth, smooth_factor, no_smooth, no_smooth_point, poly_ball_size, resampling_step, region_of_interest, region_points, add_noise_lower_limit, add_noise_upper_limit, frequency, frequency_deviation, noise, absolute, radius_max, radius_min, translation_noise_factor, noise_method)[source]

Controll the surface roughness by removing or adding points from the Voronoi diagram of the surface. A less general version of the smoothing algorithm was first presented in Ford et al. (2009).

Parameters
  • noise_method (str) – Method of adding noise: [‘add_misr_noise’ | ‘edit_misr_noise’]

  • input_filepath (str) – Path to input surface.

  • output_filepath (str) – Path to output surface.

  • smooth (bool) – Determine if the voronoi diagram should be smoothed.

  • smooth_factor (float) – Smoothing factor used for voronoi diagram smoothing.

  • no_smooth (bool) – True of part of the model is not to be smoothed.

  • no_smooth_point (ndarray) – Point which is untouched by smoothing.

  • poly_ball_size (list) – Resolution of polyballs used to create surface.

  • resampling_step (float) – Resampling step used to resample centerlines.

  • region_of_interest (str) – Method for setting the region of interest. Supported regions: [‘manual’ | ‘commandline’ | ‘first_line’ | ‘full_model’]

  • region_points (list) – If region_of_interest is ‘commandline’, this a flatten list of the start and endpoint

  • add_noise_lower_limit (float) – Upper bound for adding noise to the surface.

  • add_noise_upper_limit (float) – Upper bound for adding noise to the surface.

  • frequency (float) – Mean number of points added to the Voronoi diagram at each centerlinepoint.

  • frequency_deviation (float) – Standard deviation of frequency

  • noise (bool) – Turn on/off adding noise to the surface.

  • absolute (bool) – Absolute value for the smoothing criteria

  • radius_max (float) – Used to pick MISR multiplier to create noise on surface, upper bound

  • radius_min (float) – Used to pick MISR multiplier to create noise on surface, lower bound

  • translation_noise_factor (float) – Factor in [0,1] determining amount of translation of existing Voronoi point, used in ‘edit_misr_noise’-method.

manipulate_surface.read_command_line_surface(input_path=None, output_path=None)[source]

Read arguments from commandline and return all values in a dictionary. If input_path and output_path are not None, then do not parse command line, but only return default values.

Parameters
  • input_path (str) – Input file path, positional argument with default None.

  • output_path (str) – Output file path, positional argument with default None.

Miscellaneous

Supporting functions to the main algorithms.

common.py

argparse_common.py

argparse_common.add_common_arguments(parser, required=True)[source]
argparse_common.restricted_float(x)[source]
argparse_common.str2bool(boolean)[source]

Convert a string to boolean.

Parameters

boolean (str) – Input string.

Returns

Converted string.

Return type

return (bool)

voronoi_operations.py

voronoi_operations.create_new_surface(complete_voronoi_diagram, poly_ball_size=[120, 120, 120])[source]

Envelops an input voronoi diagram into a new surface model at a given resolution determined by the poly_ball_size.

Parameters
  • complete_voronoi_diagram (vtkPolyData) – Voronoi diagram

  • poly_ball_size (list) – List of dimensional resolution of output model

Returns

Enveloped surface model.

Return type

envelope (vtkPolyData)

voronoi_operations.get_split_voronoi_diagram(voronoi, centerlines)[source]

Given two centerlines, and a Voronoi diagram, return two Voronoi diagrams based on the distance of the two centerlines.

Parameters
  • voronoi (vtkPolyData) – Input Voronoi diagram

  • centerlines (list) – A list of centerlines (vtkPolyData). An entry could alternatively be None as well, the corresponding voronoi diagram would then be None as well.

Returns

voronoi2 (list): A list of Voronoi diagrams closest to each centerline.

voronoi_operations.remove_distant_voronoi_points(voronoi, centerline)[source]

Take a voronoi diagram and a centerline remove points that are far away.

Parameters
  • voronoi (vtkPolyData) – Voronoi data.

  • centerline (vtkPolyData) – centerline.

Returns

Voronoi diagram without the extreme points

Return type

voronoi (vtkPolyData)

voronoi_operations.smooth_voronoi_diagram(voronoi, centerlines, smoothing_factor, no_smooth_cl=None, absolute=False)[source]

Smooth voronoi diagram based on a given smoothing factor. Each voronoi point that has a radius less than MISR*(1-smoothingFactor) at the closest centerline point is removed.

Parameters
  • voronoi (vtkPolyData) – Voronoi diagram to be smoothed.

  • centerlines (vtkPolyData) – Centerline data.

  • smoothing_factor (float) – Smoothing factor: remove points with radius below (1-smoothing_factor)*MISR

  • no_smooth_cl (vktPolyData) – Section of centerline not to smooth along.

  • absolute (bool) – Turn on absolute values for smoothing.

Returns

Smoothed voronoi diagram.

Return type

smoothedDiagram (vtkPolyData)

centerline_operations.py

centerline_operations.compute_discrete_derivatives(line, neigh=10)[source]

Compute the curvature and torsion of a line using ‘neigh’ number of neighboring points.

Parameters
  • line (vtkPolyData) – Line to compute geometry from.

  • neigh (int) – Number of neighboring points.

Returns

Output line with geometrical parameters. curv (vtkPolyData): Output line with geometrical parameters.

Return type

line (vtkPolyData)

centerline_operations.compute_splined_centerline(line, get_curv=False, isline=False, nknots=50, get_stats=True, get_misr=True)[source]

Given the knots and coefficients of a B-spline representation, evaluate the value of the smoothing polynomial and its derivatives. This is a wrapper around the FORTRAN routines splev and splder of FITPACK.

Parameters
  • line (vtkPolyData) – Centerline points.

  • get_curv (bool) – Computes curvature profile if True.

  • isline (bool) – Determines if centerline object is a line or points.

  • nknots (int) – Number of knots.

  • get_stats (bool) – Determines if curve attributes are computed or not.

  • get_misr (bool) – Determines if MISR values are computed or not.

Returns

Spline of centerline data.

Return type

line (vtkPolyData)

Returns

Curvature profile.

Return type

curv (ndarray)

centerline_operations.filter_centerlines(centerlines, diverging_centerline_end)[source]

Filters out diverging centerline from all centerline

Parameters
  • centerlines (vtkPolyData) – Complete set of centerlines

  • diverging_centerline_end (vtkPoint) – End point of diverging centerline

Returns

Complete set of centerlines, except diverging centerline

Return type

filtered_centerlines (vtkPolyData)

centerline_operations.get_bifurcating_and_diverging_point_data(centerline, centerline_bif, tol)[source]

Locate bifurcating point and diverging points in a bifurcation. End points are set based on the MISR at the selected points.

Parameters
  • centerline (vtkPolyData) – Centerline from inlet to relevant outlets.

  • centerline_bif (vtkPolyData) – Centerline through bifurcation.

  • tol (float) – Tolerance parameter.

Returns

Contains info about diverging point locations.

Return type

data (dict)

centerline_operations.get_centerline_between_clipping_points(centerline_relevant_outlets, data)[source]

Get the centerline between two clipping points.

Parameters
  • centerline_relevant_outlets (vtkPolyData) – Centerline to the two relevant outlets.

  • data (dict) – A dictionary data.

Returns

Return clipped centerline.

Return type

centerline (vtkPolyData)

centerline_operations.get_centerline_tolerance(centerline)[source]

Finds tolerance based on average length between points along the input centerline.

Parameters

centerline (vtkPolyData) – Centerline data.

Returns

Tolerance value.

Return type

tolerance (float)

centerline_operations.get_clipped_diverging_centerline(centerline, clip_start_point, clip_end_id)[source]

Clip the ophthalmic artery if present.

Parameters
  • centerline (vtkPolyData) – Line representing the ophthalmic artery centerline.

  • clip_start_point (tuple) – Point at entrance of ophthalmic artery.

  • clip_end_id (int) – ID of point at end of ophthalmic artery.

Returns

Voronoi diagram representing ophthalmic artery.

Return type

patch_eye (vtkPolyData)

centerline_operations.get_curvilinear_coordinate(line)[source]

Get curvilinear coordinates along an input centerline.

Parameters

line (vtkPolyData) – Input centerline

Returns

Array of abscissa points.

Return type

curvilinear_coordinate (ndarray)

centerline_operations.get_diverging_point_id(centerline1, centerline2, tol)[source]

Find ID of diverging point; where two input centerlines diverge due to a bifurcation.

Parameters
  • centerline1 (vtkPolyData) – First centerline.

  • centerline2 (vtkPolyData) – Second centerline.

  • tol (float) – Tolerance.

Returns

ID at diverging point.

Return type

i (int)

centerline_operations.get_end_point(centerline, offset=0)[source]

Get last point(s) of the centerline(s)

Parameters
  • centerline (vtkPolyData) – Centerline(s)

  • offset (int) – Number of points from the end point to be selected

Returns

Point corresponding to end of centerline.

Return type

centerline_end_point (vtkPoint)

centerline_operations.get_k1k2_basis(curvature, line)[source]

Create a k1-k2 basis used to determine the location of each bend of the carotid siphon.

Parameters
  • curvature (floats) – Curvature array.

  • line (vtk) – Centerline points.

Returns

Centerline points including k1-k2 basis.

Return type

line (vtk)

centerline_operations.get_line_to_change(surface, centerline, region_of_interest, method, region_points, stenosis_length)[source]

Extract and spline part of centerline within the geometry where area variations will be performed.

Parameters
  • surface (vtkPolyData) – Surface model.

  • centerline (vtkPolyData) – Centerline in geometry.

  • region_of_interest (str) – Method for setting the region of interest [‘manual’ | ‘commandline’ | ‘first_line’]

  • method (str) – Determines which kind of manipulation is performed.

  • region_points (list) – If region_of_interest is ‘commandline’, a flattened list of the start and endpoint.

  • stenosis_length (float) – Multiplier used to determine the length of the stenosis-affected area.

Returns

Part of centerline.

Return type

line_to_change (vtkPolyData)

centerline_operations.get_manipulated_centerlines(patch_cl, dx, p1, p2, diverging_id, diverging_centerlines, direction, merge_lines=True)[source]

Given a centerline (patch_cl), move the centerline a distance (dx) between two points (p1 and p2).

Parameters
  • patch_cl (vtkPolyData) – Centerlines excluding diverging centerlines.

  • dx (ndarray) – Direction to move geometry.

  • p1 (vtkPolyData) – First region point.

  • p2 – (vtkPolyData): Second region point.

  • diverging_id (int) – List of index where centerlines diverge from region of interest.

  • diverging_centerlines (vtkPolyData) – Centerlines which diverge from region of interest.

  • direction (str) – Manipulation direction parameter.

  • merge_lines (bool) – Merge centerlines and diverging centerlines.

Returns

Manipulated centerline.

Return type

centerline (vtkPolyData)

centerline_operations.get_region_of_interest_and_diverging_centerlines(centerlines_complete, region_points)[source]

Extract the centerline between the region points.

Parameters
  • centerlines_complete (vktPolyData) – Complete set of centerlines in geometry.

  • region_points (ndarray) – Two points determining the region of interest.

Returns

Centerlines excluding diverging lines. diverging_centerlines (vtkPolyData): Centerlines diverging from the region of interest. region_points (ndarray): Sorted region points. region_points_vtk (vtkPoints): Sorted region points as vtkData. diverging_ids (list): List of indices where a diverging centerline starts.

Return type

centerlines (vtkPolyData)

centerline_operations.get_sorted_lines(centerlines_complete)[source]

Compares and sorts centerlines from shortest to longest in actual length

Parameters

centerlines_complete (vtkPolyData) – Centerlines to be sorted

Returns

Sorted centerlines

Return type

sorted_lines (vtkPolyData)

centerline_operations.reverse_centerline(centerline_to_reverse)[source]

Reverse the input centerline.

Parameters

centerline_to_reverse (vtkPolyData) – Centerline to be reversed

Returns

Reversed centerline

Return type

centerline (vtkPolyData)

surface_operations.py

surface_operations.attach_clipped_regions_to_surface(surface, clipped, center)[source]

Check the connectivity of a clipped surface, and attach all sections which are not closest to the center of the clipping plane.

Parameters
  • surface (vtkPolyData) –

  • clipped (vtkPolyData) – The clipped segments of the surface.

  • center (list) – The center of the clipping point

Returns

The surface where only one segment has been removed.

Return type

surface (vtkPolyData)

surface_operations.check_if_surface_is_merged(surface, centerlines, output_filepath)[source]

Check if surface has overlapping regions.

Parameters
  • surface (vtkPolyData) – Surface model.

  • centerlines (vtkPolyData) – New centerlines.

  • output_filepath (str) – Filepath of output model.

surface_operations.compute_centerlines(inlet, outlet, filepath, surface, resampling=1.0, smooth=False, num_iter=100, smooth_factor=0.1, end_point=1, method='pointlist', recompute=False, voronoi=None, pole_ids=None, base_path=None)[source]

Wrapper for vmtkcenterlines and vmtkcenterlinesmoothing.

Parameters
  • inlet (list) – point of the inlet

  • outlet (list) – flatt list of the outlet points

  • filepath (str) – path to where to store the centerline

  • surface (vtkPolyData) – surface to get the centerline from.

  • resampling (float) – resampling step length.

  • smooth (bool) – smooth centerline or not.

  • num_iter (int) – number of iterations in smooth.

  • smooth_factor (float) – smoothing factor.

  • end_point (int) – 0 or 1, include end point in centerline.

  • method (str) – method for setting the inlet and outlet location

  • recompute (bool) – if filepath exists, but the centerline should be computed again

  • anyway.

  • voronoi (vtkPolyData) – Optional argument for setting the Voronoi diagram.

  • pole_ids (vtkIdList) – A vtkIdList coupling the surface with the voronoi diagram

  • base_path (str) – path to the case

Returns

centerline of the surface. voronoi (vtkPolyData): Voronoi data. pole_ids (vtkIdList): vtkIdList coupling the surface and the voronoi diagram.

Return type

centerline (vtkPolyData)

surface_operations.compute_centers(polydata, case_path=None, select_inlet=False)[source]

Compute the center of all the openings in the surface. The inlet is chosen based on the largest area.

Parameters
  • polydata (vtkPolyData) – Centers of the openings

  • case_path (str) – Path to case directory.

  • select_inlet (bool) – Let user select inlet manually

Returns

A list of points. outlet (list): A flattened list with all the outlets.

Return type

inlet (list)

surface_operations.compute_circleness(surface)[source]

Compute the area ratio betwen minimum circle and the maximum circle.

Parameters

surface (vtkPolyData) – Boundary edges of an opening

Returns

Area ratio center (list): Center of the opening.

Return type

circleness (float)

surface_operations.extract_ica_centerline(base_path, input_filepath, resampling_step, relevant_outlets=None)[source]

Extract a centerline from the inlet to the first branch.

Parameters
  • base_path (str) – Path to the case folder.

  • input_filepath (str) – Path to the original model.

  • resampling_step (float) – Resampling step length of the extracted centerline.

  • relevant_outlets (ndarray) – Array containing points corresponding to outlets

Returns

Extracted centerline.

Return type

centerline (vtkPolyData)

surface_operations.get_clipped_capped_surface(surface, centerlines, clipspheres=0)[source]

A method for clipping a capped outlets. The branches will be clipped some distance from the outlets.

Parameters
  • surface (vtkPolyData) – Surface to clipp

  • centerlines (vtkPolyData) – Centerlines to mark the in and outlets.

  • clipspheres (float) – Number of end point spheres

Returns

Clipped surface

Return type

surface (vtkPolyData)

surface_operations.get_inlet_and_outlet_centers(surface, base_path, flowext=False, select_inlet=False)[source]

Get the centers of the inlet and outlets.

Parameters
  • surface (vtkPolyData) – An open surface.

  • base_path (str) – Path to the case file.

  • flowext (bool) – Turn on/off flow extension.

  • select_inlet (bool) – Let user manually select inlet if true

Returns

A flatt list with the point of the inlet outlet (list): A flatt list with the points of all the outlets.

Return type

inlet (list)

surface_operations.get_no_smooth_cl(capped_surface, centerlines, base_path, smooth, no_smooth, voronoi, no_smooth_point, pole_ids, resampling_length, region_points=None)[source]
Extract a section where the Voronoi should not be smoothed
Args:

capped_surface (polydata): Capped surface model to create a Voronoi diagram of. centerlines (vtkPolyData): Centerlines throughout geometry. base_path (str): Absolute path to surface model path. smooth (bool): Voronoi is smoothed if True. no_smooth (bool): Part of Voronoi is not smoothed. voronoi (vtkPolyData): Voronoi diagram. no_smooth_point (vtkPolyData): Point which defines un-smoothed area. pole_ids (vtkIDList): Pole ids of Voronoi diagram. resampling_length (float): Length of resampling the centerline. region_points (list): Flatten list with the region points

Returns:

no_smooth_cl (vtkPolyData): Centerline section where the Voronoi should not be smoothed

surface_operations.get_relevant_outlets(surface, base_path)[source]

Extract relevant outlets of the input surface model.

Parameters
  • surface (vtkPolyData) – Surface model.

  • base_path (str) – Location of info-file.

Returns

List of relevant outlet IDs.

Return type

relevant_outlets (list)

surface_operations.get_uncapped_surface(surface, gradients_limit=0.15, area_limit=0.3, circleness_limit=3)[source]

A rule-based method for removing endcapps on a surface. The method considers the gradient of the normals, the size of the region, and how similar it is to a circle.

Parameters
  • surface (vtkPolyData) – Surface to be uncapped.

  • gradients_limit (float) – Upper limit for gradients of normals.

  • area_limit (float) – Lower limit of the area.

  • circleness_limit (float) – Upper limit of the circleness.

Returns

The uncapped surface.

Return type

surface (vtkPolyData)

surface_operations.is_surface_capped(surface)[source]

Checks if the surface is closed, and how many openings there are.

Parameters

surface (vtkPolyData) – Surface to be checked

Returns

Open or closed surface number (int): Number of integer

Return type

open (boolean)

surface_operations.prepare_output_surface(surface, original_surface, new_centerline, output_filepath, test_merge=False, changed=False, old_centerline=None, removed=[[1000000000.0, 1000000000.0, 1000000000.0]])[source]

After manipulation preparing the surface for output. This method clips the outlets, slightly smooths the surface, and (potentially) tests if the surface is merged.

Parameters
  • surface (vtkPolyData) – The new surface after manipulation.

  • original_surface (vtkPolyData) – The original surface input for manipulation.

  • new_centerline (vtkPolyData) – The centerline after manipulation.

  • output_filepath (str) – The user-defined path to the output.

  • test_merge (bool) – Turn on/off testing if the surface is merged.

  • changed (bool) – If the manipulated surface has changed the location of the

  • inlet/outlet.

  • old_centerline (vtkPolyData) – The old centerline for the original centerline.

Returns

The surface ready for output.

Return type

surface (vtkPolyData)

surface_operations.prepare_surface(base_path, surface_path)[source]

Clean and check connectivity of surface. Caps or uncaps surface at inlet and outlets.

Parameters
  • base_path (str) – Absolute path to base folder.

  • surface_path (str) – Path to surface.

Returns

Open surface.

Return type

open_surface (vtkPolyData)

Returns

Closed surface.

Return type

capped_surface (vtkPolyData)

surface_operations.prepare_voronoi_diagram(capped_surface, centerlines, base_path, smooth, smooth_factor, no_smooth, no_smooth_point, voronoi, pole_ids, resampling_length)[source]

Compute and smooth voronoi diagram of surface model.

Parameters
  • capped_surface (polydata) – Capped surface model to create a Voronoi diagram of.

  • base_path (str) – Absolute path to surface model path.

  • voronoi (vtkPolyData) – Voronoi diagram.

  • pole_ids (vtkIDList) – Pole ids of Voronoi diagram.

  • smooth (bool) – Voronoi is smoothed if True.

  • smooth_factor (float) – Smoothing factor for voronoi smoothing.

  • centerlines (vtkPolyData) – Centerlines throughout geometry.

  • no_smooth (bool) – Part of Voronoi is not smoothed.

  • no_smooth_point (vtkPolyData) – Point which defines un-smoothed area.

  • resampling_length (float) – Length of resampling the centerline.

Returns

Voronoi diagram of surface.

Return type

voronoi (vtkPolyData)

surface_operations.provide_inlet(surface)[source]

Get inlet from user selected point on an input surface

Parameters

surface (vtkPolyData) – Surface model.

Returns

Point located on the inlet, as list

Return type

points (list)

surface_operations.provide_point(surface)[source]

Get inlet from user selected point on an input surface

Parameters

surface (vtkPolyData) – Surface model.

Returns

Point located on the inlet, as list

Return type

points (list)

surface_operations.provide_relevant_outlets(surface, dir_path=None)[source]

Get relevant outlets from user selected points on an input surface.

Parameters
  • surface (vtkPolyData) – Surface model.

  • dir_path (str) – Location of info.json file

Returns

List of relevant outlet IDs

Return type

points (list)

vessel_reconstruction_tools.py

vessel_reconstruction_tools.compute_angle_between_vectors(normal, tangent, vector)[source]

Compute the angle between the vector and the normal component.

Parameters
  • normal (list) – Normal component to the centerline.

  • tangent (list) – Tangent to the centerline.

  • vector (list) – Vector to compute the angle of.

Returns

Angle in degrees.

Return type

angle (float)

vessel_reconstruction_tools.compute_number_of_masked_points(data_array)[source]

Count number of ‘1’ in the data array.

Parameters

data_array (vtkIntArray) – Array to check.

Returns

Number of ‘1’ in array.

Return type

number_of_points (int)

vessel_reconstruction_tools.compute_spline(startValue, endValue, numberOfPoints)[source]

Create a vtkDoubleArray which is a spline between startValue, mean(startValue, endValue), and endValue.

Parameters
  • startValue (float) – The start value.

  • endValue (float) – The end value.

  • numberOfPoints (int) – The number of points.

vessel_reconstruction_tools.compute_voronoi_vector_to_centerline_angle(pointId, vector, centerline)[source]

Compute angle between the normal compontent of the centerline, and the parallel transport normal.

Parameters
  • pointId (int) – Id along centerline of interest.

  • vector (list) – Vector

  • centerline (vtkPolyData) – Centerline

Returns

Angle

Return type

alpha (float)

vessel_reconstruction_tools.create_parent_artery_patches(parentCenterlines, clipPoints, siphon=False, bif=False)[source]

Clip out a segment of the centerline, and create new centerlines with new end and starting points.

Parameters
  • parentCenterlines (vtkPolyData) – Original centerline

  • clipPoints (vtkPoints) – The points where to clip the centerline.

  • siphon (bool) – On/off clipping a siphon

  • bif (bool) – On/off bifurcation.

Returns

New centerline without the segment.

Return type

centerline (vtkPolyData)

vessel_reconstruction_tools.extract_cylindric_interpolation_voronoi_diagram(cellId, pointId, cylinderRadius, voronoi, centerlines, interpolationHalfSize=3)[source]

Extract the voronoi diagram within a cylinder to be used for extrapolation.

Parameters
  • cellId (int) – LineId of the centerline.

  • pointId (int) – Point Id of where to extract the cylinder.

  • cylinderRadius (float) – The radius of the cylinder.

  • voronoi (vtkPolyData) – The voronoi diagram to extract cylinder from.

  • centerlines (vtkPolyData) – Centerline corresponding to the Voronoi diagram.

Returns

The extracted cylinder from the Voronoi diagram.

Return type

interpolationDataset (vtkPolyData)

vessel_reconstruction_tools.extract_patches_ids(parentCl, clipPts)[source]

For each clipping points (clipPts) extract the cooresponding ID for each line in the centerline.

Parameters
  • parentCl (vtkPolyData) –

  • clipPts (vtkPoints) –

Returns

A list of IDs. numberOfPoints (int): Total number of points.

Return type

clipIds (list)

vessel_reconstruction_tools.extract_patches_ids_siphon(parentCl, clipPts, clipped=False)[source]

For each clipping points (clipPts) extract the cooresponding ID for each line in the centerline. (This is for the siphon, see extract_patches_ids as well.)

Parameters
  • parentCl (vtkPolyData) –

  • clipPts (vtkPoints) –

  • clipped (bool) –

Returns

A list of IDs. numberOfPoints (int): Total number of points.

Return type

clipIds (list)

vessel_reconstruction_tools.get_start_ids(points, line)[source]

Sort the points according the the distance from the line.

Parameters
  • points (list) – Nested-list with points.

  • line (vtkPolyData) – Centerline of interest.

Returns

Proximal point order2 (int): Distal point

Return type

order1 (int)

vessel_reconstruction_tools.insert_new_voronoi_points(oldDataset, newPoints, newArray)[source]

Insert new points into an unconnected vtkPolyData object.

Parameters
  • oldDataset (vtkPolyData) – object to insert new points.

  • newPoints (vtkPoints) – New points to insert into the oldDataset.

  • newArray (vtkDoubleArray) – Array corresponding to the points.

Returns

the oldDataset, but with the new points.

Return type

newDataset (vtkPolyData)

vessel_reconstruction_tools.interpolate_patch_centerlines(patchCenterlines, parentCenterlines, additionalPoint, lower, version, tension=0, continuity=0)[source]

Interpolate new centerlines between end and starting points. Given additionalPoiint, lower, and version, then number and method for interpolation varies.

Parameters
  • patchCenterlines (vtkPolyData) – Clipped centerline.

  • parentCenterlines (vtkPolyData) – The original centerline.

  • additionalPoint (vtkPoints) – Additional point to interpolate through.

  • lower (str) – None / ‘lower’ / ‘bif’ to indicate how to interpolate.

  • version (bool) – Method for interpolation.

  • tension (float) – Variable for the Kochanek spline

  • continuity (float) – Variable for the Kochanek spline

Returns

The new centerline, including the new interpolated segment.

Return type

centerline (vtkPolyData)

vessel_reconstruction_tools.interpolate_spline(startCell, endCell, additionalPoint)[source]

Interpolate between two lines using splrep from scipy, potentially with an additional point (additionalPoint).

Parameters
  • startCell (vtkPolyData) – Start line

  • endCell (tkPolyData) – End line

  • additionalPoint (list) – A list with the coordinates to the additional point.

Returns

The new interpolated centerline.

Return type

centerline (vtkPolyData)

vessel_reconstruction_tools.interpolate_two_cells(startCell, endCell, numberOfSplinePoints, additionalPointId, additionalPoint, tension, continuitiy)[source]

Interpolate between two lines using vtkCardinalSpline from vtk, potentially with an additional point (additionalPoint).

Parameters
  • startCell (vtkPolyData) – Start line

  • endCell (tkPolyData) – End line

  • numberOfSplinePoints (int) – Number of spline point.

  • additionalPointId (int) – Id of the additional point.

  • additionalPoint (list) – A list with the coordinates to the additional point.

  • tension (float) – Variable for the Kochanek spline

  • continuity (float) – Variable for the Kochanek spline

Returns

The new interpolated centerline.

Return type

centerline (vtkPolyData)

vessel_reconstruction_tools.interpolate_voronoi_diagram(interpolatedCenterlines, patchCenterlines, clippedVoronoi, clippingPoints, bif, cylinder_factor)[source]

Extrapolate/interpolate a the Voronoi diagram along new centerlines. This is the core of the algorithm to reconstruct a bifurcation in manipulate_branches.py.

Parameters
  • interpolatedCenterlines (vtkPolyData) – Centerlines which has been interpolated.

  • patchCenterlines (vtkPolyData) – Centerlines without the interpolated patch.

  • clippedVoronoi (vtkPolyData) – Clipped Voronoi diagram.

  • clippingPoints (vtkPoints) – Points at where the centerline and Voronoi diagram

  • clipped. (where) –

  • bif (list) – List of extra centerlines to extrapolate along.

  • cylinder_factor (float) – Size of cylinder to extract as the basis of the

  • diagram. (extrapolation of the Voronoi) –

Returns

The modified Voronoi diagram.

Return type

completeVoronoiDiagram (vtkPolyData)

vessel_reconstruction_tools.is_point_inside_interpolation_cylinder(x, t, c, b, r)[source]

Check if a (Voronoi) point is inside a cylinder.

Parameters
  • x (list) – Point to check.

  • t (list) – Top of the cylinder.

  • c (list) – Center of the cylinder.

  • b (list) – Bottom of the cylinder.

  • r (float) – Radius of the cylinder.

Returns

True if inside, False if outside.

Return type

inside (bool)

vessel_reconstruction_tools.normalize(vector)[source]

Normalize a vector to unit length.

Parameters

vector (list/tuple/numpy.ndarray) – Array to be normalized

Returns

Normalized vector.

Return type

vector (numpy.ndarray)

vessel_reconstruction_tools.voronoi_diagram_interpolation(interpolationcellid, id0, id1, voronoiDataset0, voronoiDataset1, centerlines, step, clippingPoints)[source]

Given two Voronoi datasets interpolate the data sets along the centerline.

Parameters
  • interpolationcellid (int) – LineID of the centerline

  • id0 (int) – Start ID.

  • id1 (int) – Stop ID.

  • voronoiDataset0 (vtkPolyData) – First Voronoi dataset.

  • voronoiDataset1 (vtkPolyData) – Second Voronoi dataset.

  • centerlines (vtkPolyData) – Centerline to interpolate along.

  • step (int) – Direction to interpolate

  • clippingPoints (vtkPoints) – Location of clipping points.

Returns

New points to the Voronoi diagram. finalRadiusArray (vtkDoubelArray): Array to hold the radius for each point.

Return type

finalNewVoronoiPoints (vtkPoints)

vmtk_wrapper.py

vmtk_wrapper.vmtk_branch_clipper(centerlines, surface, clip_value=0.0, inside_out=False, use_radius_information=True, interactive=False)[source]

Wrapper for vmtkBranchClipper. Divide a surface in relation to its split and grouped centerlines.

Parameters
  • centerlines (vtkPolyData) – Input centerlines

  • surface (vtkPolyData) – Input surface model

  • clip_value (float) –

  • inside_out (bool) – Get the inverse of the branch clipper output.

  • use_radius_information (bool) – To use MISR info for clipping branches.

  • interactive (bool) – Use interactive mode, requires user input.

Returns

Branch clipper used to divide a surface into regions.

Return type

vmtkBranchClipper

vmtk_wrapper.vmtk_cap_polydata(surface, boundary_ids=None, displacement=0.0, in_plane_displacement=0.0)[source]

Wrapper for vmtkCapPolyData. Close holes in a surface model.

Parameters
  • in_plane_displacement (float) – Displacement of boundary barycenter, at section plane relative to the radius

  • displacement (float) – Displacement of boundary barycenter along boundary normals relative to the radius.

  • boundary_ids (ndarray) – Set ids of the boundaries to cap.

  • surface (vtkPolyData) – Surface to be capped.

Returns

Capped surface.

Return type

surface (vtkPolyData)

vmtk_wrapper.vmtk_compute_branch_extractor(centerlines)[source]

Wrapper for vmtkBranchExtractor. Split and group centerlines along branches:

Parameters

centerlines (vtkPolyData) – Line to split into branches.

Returns

Split centerline.

Return type

vtkPolyData

vmtk_wrapper.vmtk_compute_centerline_attributes(centerlines)[source]

Wrapper for centerline attributes.

Parameters

centerlines (vtkPolyData) – Line to investigate.

Returns

Line with centerline attributes.

Return type

line (vtkPolyData)

vmtk_wrapper.vmtk_compute_centerline_sections(surface, centerlines)[source]

Wrapper for vmtk centerline sections.

Parameters
  • surface (vtkPolyData) – Surface to measure area.

  • centerlines (vtkPolyData) – centerline to measure along.

Returns

centerline with the attributes’ centerline_sections_area (vtkPolyData): sections along the centerline

Return type

line (vtkPolyData)

vmtk_wrapper.vmtk_compute_centerlines(end_point, inlet, method, outlet, pole_ids, resampling_step, surface, voronoi, flip_normals=False, cap_displacement=None, delaunay_tolerance=None, simplify_voronoi=False)[source]

Wrapper for vmtkCenterlines. compute centerlines from a branching tubular surface. Seed points can be interactively selected on the surface, or specified as the barycenters of the open boundaries of the surface.

Parameters
  • end_point (int) – Toggle append open profile barycenters to centerlines

  • surface (vktPolyData) – Surface model

  • voronoi (vtkPolyData) – Voronoi diagram based on previous centerlines (Optional)

  • inlet (ndarray) – List of source point coordinates

  • method (str) – Seed point selection method

  • outlet (ndarray) – List of target point coordinates

  • pole_ids (ndarray) – Pole ID list of Voronoi diagram (Optional)

  • resampling_step (float) – Resampling step

  • flip_normals (float) – Flip normals after outward normal computation

  • cap_displacement (float) – Displacement of the center points of caps at open profiles along their normals

  • delaunay_tolerance (float) – Tolerance for evaluating coincident points during Delaunay tessellation

  • simplify_voronoi (bool) – Toggle simplification of Voronoi diagram

Returns:

vmtk_wrapper.vmtk_compute_geometric_features(centerlines, smooth, output_smoothed=False, factor=1.0, iterations=100)[source]

Wrapper for vmtk centerline geometry.

Parameters
  • centerlines (vtkPolyData) – Line to compute centerline geometry from.

  • smooth (bool) – Turn on and off smoothing before computing the geometric features.

  • output_smoothed (bool) – Turn on and off the smoothed centerline.

  • factor (float) – Smoothing factor.

  • iterations (int) – Number of iterations.

Returns

Line with geometry.

Return type

line (vtkPolyData)

vmtk_wrapper.vmtk_compute_surface_normals(surface, auto_orient_normals=True, orient_normals=True, compute_cell_normals=False, flip_normals=False)[source]

Wrapper for vmtkSurfaceNormals. Computes the normals of the input surface.

Parameters
  • surface (vtkPolyData) – Input surface model

  • auto_orient_normals (bool) – Try to auto orient normals outwards

  • orient_normals (bool) – Try to orient normals so that neighboring points have similar orientations

  • compute_cell_normals (bool) – Compute cell normals instead of point normals

  • flip_normals (bool) – Flip normals after computing them

Returns

Surface model with computed normals

Return type

vtkPolyData

vmtk_wrapper.vmtk_compute_voronoi_diagram(surface, filename, simplify_voronoi=False, cap_displacement=None, flip_normals=False, check_non_manifold=False, delaunay_tolerance=0.001, subresolution_factor=1.0)[source]

Wrapper for vmtkDelanayVoronoi. Creates a surface model’s corresponding voronoi diagram.

Parameters
  • subresolution_factor (float) – Factor for removal of subresolution tetrahedra

  • flip_normals (bool) – Flip normals after outward normal computation.

  • cap_displacement (float) – Displacement of the center points of caps at open profiles along their normals

  • simplify_voronoi (bool) – Use alternative algorith for compute Voronoi diagram, reducing quality, improving speed

  • check_non_manifold (bool) – Check the surface for non-manifold edges

  • delaunay_tolerance (float) – Tolerance for evaluating coincident points during Delaunay tessellation

  • surface (vtkPolyData) – Surface model

  • filename (str) – Path where voronoi diagram is stored

Returns

Voronoi diagram

Return type

new_voronoi (vtkPolyData)

vmtk_wrapper.vmtk_endpoint_extractor(centerlines, number_of_end_point_spheres, number_of_gap_spheres=1)[source]

Wrapper for vmtkEndpointExtractor. Find the endpoints of a split and grouped centerline

Parameters
  • centerlines (vtkPolyData) – Input centerlines.

  • number_of_end_point_spheres (float) – Number of spheres to skip at endpoint

  • number_of_gap_spheres (float) – Number of spheres to skip per gap.

Returns

Endpoint extractor based on centerline

Return type

vmtkEndpointExtractor

vmtk_wrapper.vmtk_polyball_modeller(voronoi_diagram, poly_ball_size)[source]

Wrapper for vtkvmtkPolyBallModeller. Create an image where a polyball or polyball line are evaluated as a function.

Parameters
  • voronoi_diagram (vtkPolyData) – Input Voronoi diagram representing surface model

  • poly_ball_size (list) – Resolution of output

Returns

Image where polyballs have been evaluated over a Voronoi diagram

Return type

vtkvmtkPolyBallModeller

vmtk_wrapper.vmtk_resample_centerline(centerlines, length)[source]

Wrapper for vmtkcenterlineresampling

Parameters
  • centerlines (vtkPolyData) – line to resample.

  • length (float) – resampling step.

Returns

Resampled line.

Return type

line (vtkPolyData)

vmtk_wrapper.vmtk_smooth_centerline(centerlines, num_iter, smooth_factor)[source]

Wrapper for vmtkCenterlineSmoothing. Smooth centerlines with a moving average filter.

Parameters
  • centerlines (vtkPolyDat) – Centerline to be smoothed.

  • num_iter (int) – Number of smoothing iterations.

  • smooth_factor (float) – Smoothing factor

Returns

Smoothed version of input centerline

Return type

vtkPolyData

vmtk_wrapper.vmtk_smooth_surface(surface, method, iterations=800, passband=1.0, relaxation=0.01, normalize_coordinates=True, smooth_boundary=True)[source]

Wrapper for a vmtksurfacesmoothing.

Parameters
  • smooth_boundary (bool) – Toggle allow change of position of boundary points

  • normalize_coordinates (bool) – Normalization of coordinates prior to filtering, minimize spurious translation effects (Taubin only)

  • surface (vtkPolyData) – Input surface to be smoothed.

  • method (str) – Smoothing method.

  • iterations (int) – Number of iterations.

  • passband (float) – The passband for Taubin smoothing.

  • relaxation (float) – The relaxation for laplace smoothing.

Returns

The smoothed surface.

Return type

surface (vtkPolyData)

vmtk_wrapper.vmtk_surface_connectivity(surface, method='largest', clean_output=True, closest_point=None)[source]

Wrapper for vmtkSurfaceConnectivity. Extract the largest connected region, the closest point-connected region or the scalar-connected region from a surface

Parameters
  • surface (vtkPolyData) – Surface model

  • method (str) – Connectivity method, either ‘largest’ or ‘closest’

  • clean_output (bool) – Clean the unused points in the output

  • closest_point (ndarray) – Coordinates of the closest point

Returns

Filter for extracting the largest connected region

Return type

vmtkSurfaceConnectivity

vmtk_wrapper.vmtk_surface_curvature(surface, curvature_type='mean', absolute=False, median_filtering=False, curvature_on_boundaries=False, bounded_reciporcal=False, epsilon=1.0, offset=0.0)[source]

Wrapper for vmtksurfacecurvature

Parameters
  • surface (vtkPolyData) – The input surface

  • curvature_type (str) – The type of surface curvature to compute (mean | gaussian | maximum | minimum)

  • absolute (bool) – Output the absolute value of the curvature

  • median_filtering (bool) – Output curvature after median filtering to suppress numerical noise speckles

  • curvature_on_boundaries (bool) – Turn on/off curvature on boundaries

  • bounded_reciporcal (bool) – Output bounded reciprocal of the curvature

  • epsilon (float) – Bounded reciprocal epsilon at the denominator

  • offset (float) – Offset curvature by the specified value

Returns

Input surface with an point data array with curvature values

Return type

surface (vtkPolydata)

vmtk_wrapper.vmtk_surface_distance(surface1, surface2, distance_array_name='Distance', distance_vectors_array_name='', signed_distance_array_name='', flip_normals=False)[source]

Compute the point-wise minimum distance of the input surface from a reference surface

Parameters
  • surface1 (vtkPolyData) – Input surface

  • surface2 (vtkPolyData) – Reference surface

  • distance_array_name (str) – Name of distance array

  • distance_vectors_array_name (str) – Name of distance array (of vectors)

  • signed_distance_array_name (str) – Name of distance arrays signed as positive or negative

  • flip_normals (bool) – Flip normals relative to reference surface

Returns

Output surface with distance info

Return type

surface (vtkPoyData)

vtk_wrapper.py

vtk_wrapper.create_vtk_array(values, name, k=1)[source]

Given a set of numpy values, and a name of the array create vtk array

Parameters
  • values (list, ndarray) – List of the values.

  • name (str) – Name of the array.

  • k (int) – Length of tuple.

Returns

vtk point array

Return type

vtk_array (vtkPointArray)

vtk_wrapper.extract_single_line(centerlines, line_id, start_id=0, end_id=None)[source]

Extract one line from multiple centerlines. If start_id and end_id is set then only a segment of the centerline is extracted.

Parameters
  • centerlines (vtkPolyData) – Centerline to extract.

  • line_id (int) – The line ID to extract.

  • start_id (int) –

  • end_id (int) –

Returns

The single line extracted

Return type

centerline (vtkPolyData)

vtk_wrapper.get_cell_data_array(array_name, line, k=1)[source]

Get data array from polydata object (CellData).

Parameters
  • array_name (str) – Name of array.

  • line (vtkPolyData) – Centerline object.

  • k (int) – Dimension.

Returns

Array containing data points.

Return type

array (ndarray)

vtk_wrapper.get_number_of_arrays(vtk_polydata)[source]

Returns the names and number of arrays for a vtkPolyData object

Parameters

vtk_polydata (vtkPolyData) – object / line to investigate the array.

Returns

Number of arrays in the line. names (list): A list of names of the arrays.

Return type

count (int)

vtk_wrapper.get_point_data_array(array_name, line, k=1)[source]

Get data array from polydata object (PointData).

Parameters
  • array_name (str) – Name of array.

  • line (vtkPolyData) – Centerline object.

  • k (int) – Dimension.

Returns

Array containing data points.

Return type

array (ndarray)

vtk_wrapper.get_vtk_array(name, comp, num)[source]

An empty vtkDoubleArray.

Parameters
  • name (str) – Name of array.

  • comp (int) – Number of components

  • num (int) – Number of tuples.

Returns

An empty vtk array.

Return type

array (vtkDoubleArray)

vtk_wrapper.get_vtk_cell_locator(surface)[source]

Wrapper for vtkCellLocator

Parameters

surface (vtkPolyData) – input surface

Returns

Cell locator of the input surface.

Return type

return (vtkCellLocator)

vtk_wrapper.get_vtk_point_locator(centerline)[source]

Wrapper for vtkStaticPointLocator.

Parameters

centerline (vtkPolyData) – Input vtkPolyData.

Returns

Point locator of the input surface.

Return type

locator (vtkStaticPointLocator)

vtk_wrapper.move_past_sphere(centerline, center, r, start, step=- 1, stop=0, scale_factor=0.8)[source]

Moves a point along the centerline until it as outside the sphere with radius (r) and a center (center).

Parameters
  • centerline (vtkPolyData) – Centerline to move along.

  • center (list) – point list of the center of the sphere

  • r (float) – the radius of a sphere

  • start (int) – id of the point along the centerline where to start.

  • step (int) – direction along the centerline.

  • stop (int) – ID along centerline, for when to stop searching.

  • scale_factor (float) – Scale the radius with this factor.

Returns

The first point on the centerline outside the sphere r (float): minimal inscribed sphere radius at the new point. i (int): the centerline ID at the new point.

Return type

tmp_point (list)

vtk_wrapper.read_polydata(filename, datatype=None)[source]

Load the given file, and return a vtkPolyData object for it.

Parameters
  • filename (str) – Path to input file.

  • datatype (str) – Additional parameter for vtkIdList objects.

Returns

polyData (vtkSTL/vtkPolyData/vtkXMLStructured/

vtkXMLRectilinear/vtkXMLPolydata/vtkXMLUnstructured/ vtkXMLImage/Tecplot): Output data.

vtk_wrapper.vtk_clean_polydata(surface)[source]

Clean surface by merging duplicate points, and/or removing unused points and/or removing degenerate cells.

Parameters

surface (vtkPolyData) – Surface model.

Returns

Cleaned surface model.

Return type

cleanSurface (vtkPolyData)

vtk_wrapper.vtk_clip_polydata(surface, cutter=None, value=0, get_inside_out=False, generate_clip_scalars=False)[source]

Clip the input vtkPolyData object with a cutter function (plane, box, etc)

Parameters
  • generate_clip_scalars (bool) – If True, output scalar values will be interpolated from implicit function values.

  • get_inside_out (bool) – Get inside out, default is False

  • surface (vtkPolyData) – Input vtkPolyData for clipping

  • cutter (vtkBox, vtkPlane) – Function for cutting the polydata (default None).

  • value (float) – Distance to the ImplicteFunction or scalar value to clip.

Returns

The clipped surface

Return type

clipper (vtkPolyData)

vtk_wrapper.vtk_compute_connectivity(surface, mode='All', closest_point=None, show_color_regions=True, mark_visited_points=False)[source]

Wrapper of vtkPolyDataConnectivityFilter. Compute connectivity.

Parameters
  • show_color_regions (bool) – Turn on/off the coloring of connected regions.

  • mark_visited_points (bool) – Specify whether to record input point ids that appear in the output.

  • surface (vtkPolyData) – Input surface data.

  • mode (str) – Type of connectivity filter.

  • closest_point (list) – Point to be used for mode=’Closest’

vtk_wrapper.vtk_compute_mass_properties(surface, compute_surface_area=True, compute_volume=False)[source]

Calculate the volume from the given polydata

Parameters
  • compute_volume (bool) – Compute surface volume if True

  • compute_surface_area (bool) – Compute surface area if True

  • surface (vtkPolyData) – Surface to compute are off

Returns

Area of the input surface

Return type

area (float)

Returns

Volume of the input surface

Return type

volume (float)

vtk_wrapper.vtk_compute_normal_gradients(cell_normals, use_faster_approximation=False)[source]

Compute gradients of the normals

Parameters
  • cell_normals (vtkPolyData) – Surface to compute normals on

  • use_faster_approximation (bool) – Use a less accurate algorithm that performs fewer calculations, but faster.

vtk_wrapper.vtk_compute_polydata_normals(surface, compute_point_normals=False, compute_cell_normals=False)[source]

Wrapper for vtkPolyDataNormals

Parameters
  • surface (vtkPolyData) – Surface model

  • compute_point_normals (bool) – Turn on/off the computation of point normals.

  • compute_cell_normals (bool) – Turn on/off the computation of cell normals.

Returns

Cell normals of surface model

Return type

vtkPolyData

vtk_wrapper.vtk_compute_threshold(surface, name, lower=0, upper=1, threshold_type='between', source=1)[source]

Wrapper for vtkThreshold. Extract a section of a surface given a criteria.

Parameters
  • surface (vtkPolyData) – The input data to be extracted.

  • name (str) – Name of scalar array.

  • lower (float) – Lower bound.

  • upper (float) – Upper bound.

  • threshold_type (str) – Type of threshold (lower, upper, between)

  • source (int) – PointData or CellData.

Returns

The extracted surface based on the lower and upper limit.

Return type

surface (vtkPolyData)

vtk_wrapper.vtk_convert_unstructured_grid_to_polydata(unstructured_grid)[source]

Wrapper for vtkGeometryFilter, which converts an unstructured grid into a polydata.

Parameters

unstructured_grid (vtkUnstructuredGrid) – An unstructured grid.

Returns

A vtkPolyData object from the unstrutured grid.

Return type

surface (vtkPolyData)

vtk_wrapper.vtk_extract_feature_edges(polydata, compute_feature_edges=False, compute_boundary_edges=True, compute_non_manifold_edges=False)[source]

Wrapper for vtkFeatureedges. Extracts the edges of the cells that are open.

Parameters
  • compute_non_manifold_edges (bool) – Turn on/off the extraction of non-manifold edges.

  • compute_boundary_edges (bool) – Turn on/off the extraction of boundary edges.

  • compute_feature_edges (bool) – Turn on/off the extraction of feature edges.

  • polydata (vtkPolyData) – surface to extract the openings from.

Returns

The boundary edges of the surface.

Return type

feature_edges (vtkPolyData)

vtk_wrapper.vtk_marching_cube(modeller, compute_normals=False, compute_scalars=False, compute_gradients=False)[source]

Wrapper for vtkMarchingCube

Parameters
  • modeller (vtkPolyballModeller) – Modeller of a surface model

  • compute_normals (bool) – Set/Get the computation of normals.

  • compute_scalars (bool) – Set/Get the computation of scalars.

  • compute_gradients (bool) – Set/Get the computation of gradients.

Returns

Isosurface generated from surface

Return type

vtkMarchingCube

vtk_wrapper.vtk_merge_polydata(inputs)[source]

Appends one or more polygonal datasets together into a single polygonal dataset.

Parameters

inputs (list) – List of vtkPolyData objects.

Returns

Single polygonal dataset.

Return type

merged_data (vtkPolyData)

vtk_wrapper.vtk_plane(origin, normal)[source]

Returns a vtk box object based on the bounds

Parameters
  • origin (list) – Center of plane [x, y, z]

  • normal (list) – Planes normal [x, y, z]

Returns

A vtkPlane

Return type

plane (vtkPlane)

vtk_wrapper.vtk_sphere(center, radius)[source]

Returns a vtk sphere object based on the bounds

Parameters
  • center (list) – Center of the sphere

  • radius (float) – Radius of the sphere

Returns

A vtkSphere

Return type

sphere (vtkSphere)

vtk_wrapper.vtk_triangulate_surface(surface, pass_lines=False, pass_verts=False)[source]

Wrapper for vtkTriangleFilter.

Parameters
  • pass_lines (bool) – Turn on/off passing lines through filter. Default is On

  • pass_verts (bool) – Turn on/off passing vertices through filter. Default is On

  • surface (vtkPolyData) – Surface to triangulate.

Returns

Triangulated surface.

Return type

surface (vtkPolyData)

vtk_wrapper.write_polydata(input_data, filename, datatype=None, file_type='ascii')[source]

Write the given input data based on the file name extension.

Parameters
  • file_type (string) – Filetype of output

  • (vtkSTL/vtkPolyData/vtkXMLStructured/ (input_data) – vtkXMLRectilinear/vtkXMLPolydata/vtkXMLUnstructured/ vtkXMLImage/Tecplot): Input data.

  • filename (str) – Save path location.

  • datatype (str) – Additional parameter for vtkIdList objects.

vtk_wrapper.write_vtk_points(points, filename)[source]

Writes input points to file.

Parameters
  • points (vtkPolyData) – Point data.

  • filename (str) – Save location.

automated_landmarking.py

estimate_alpha_and_beta.py

estimate_alpha_and_beta.alpha_beta_intersection(method, f, alphas, betas, tol=0.0)[source]

Iterate through values of alpha and beta and find intersection points with a given tolerance between initial value and initial value plus/minus SD.

Parameters
  • method (function) – Plane defining initial value plus/minus SD.

  • f (interp2d) – Interpolated surface of curvature or angle values.

  • alphas (ndarray) – List of alpha values.

  • betas (ndarray) – List of beta values.

  • tol (float) – Tolerance used for adjusting SD if needed.

Returns

Array containing (alpha,beta) tuples which intersect.

Return type

zeros (ndarray)

estimate_alpha_and_beta.compute_angle(input_filepath, alpha, beta, method, new_centerlines, region_of_interest, region_points, projection=False)[source]

Primary collection of methods for computing the angle of a vessel bend. Three main methods are currently implemented: 1) ODR methods: odrline 2) Tracing point methods: maxcurv, smooth, discrete, frac, MISR 3) Relative tracing point methods: plane, itplane, itplane_clip

Parameters
  • input_filepath (str) – Path to case folder.

  • alpha (float) – Extension / Compression factor in vertical direction.

  • beta (float) – Extension / Compression factor in horizontal direction.

  • method (str) – Method used to compute angle.

  • new_centerlines (vtkPolyData) – New centerline.

  • region_of_interest (str) – Method for setting the region of interest [‘manual’ | ‘commandline’ | ‘landmarking’]

  • region_points (list) – If region_of_interest is ‘commandline’, this a flatten list of the start and endpoint

  • projection (bool) – True / False for computing 2D / 3D angle.

Returns

New angle of a vessel bend from a manipulated centerline.

Return type

new_deg (float)

Returns

Old angle of a vessel bend from a manipulated centerline.

Return type

deg (float)

estimate_alpha_and_beta.compute_curvature(input_filepath, alpha, beta, method, new_centerlines, compute_original, region_of_interest, region_points)[source]

Primary collection of methods for computing curvature of a centerline. Five methods are currently implemented: 1) VMTK - Factor variance (vmtkfactor) 2) VMTK - Iteration variance (vmtkit) 3) Discrete derivatives (disc) 4) B-splines (spline)

Parameters
  • input_filepath (str) – Path to case folder.

  • alpha (float) – Extension / Compression factor in vertical direction.

  • beta (float) – Extension / Compression factor in horizontal direction.

  • method (str) – Method used to compute angle.

  • new_centerlines (vtkPolyData) – New centerline.

  • compute_original (bool) – Computes old curvature value if True.

  • region_of_interest (str) – Method for setting the region of interest [‘manual’ | ‘commandline’ | ‘landmarking’]

  • region_points (list) – If region_of_interest is ‘commandline’, this is a flattened list of the start and endpoint

Returns

Maximum curvature within the manipulated region of interest.

Return type

new_maxcurv (float)

Returns

Maximum curvature within the original region of interest.

Return type

old_maxcurv (float)

estimate_alpha_and_beta.compute_quantities(input_filepath, boundary, quantity, method_curv, method_angle, region_of_interest, region_points, n=50, projection=False)[source]

Initialization for computing curvature and angle. Values are either printed to terminal or stored in a (n x n) matrix.

Parameters
  • input_filepath (str) – Base location of surface model files.

  • boundary (list) – Bounds of grid for computing quantities.

  • method_curv (str) – Method used to compute curvature.

  • method_angle (str) – Method used to compute angle.

  • quantity (string) – Quantity to compute, either curvature or angle.

  • region_of_interest (str) – Method for setting the region of interest [‘manual’ | ‘commandline’ | ‘landmarking’]

  • region_points (list) – If region_of_interest is ‘commandline’, this a flatten list of the start and endpoint

  • n (int) – Determines matrix size when computing multiple values.

  • projection (bool) – Projects angle into 2d plane if True.

Returns

(n x n) matrix with quantity values

Return type

values (ndarray)

estimate_alpha_and_beta.estimate_alpha_and_beta(input_filepath, quantity_to_compute, boundary, radius, grid_size, value_change, method_angle, method_curv, region_of_interest, region_points)[source]

Imports a matrix of parameter values corresponding to a (alpha,beta) point and perform spline interpolation to make a parameter surface. Parameter surface is used to find intersection with initial parameter value plus / minus one standard deviation. Three criteria to find suggested alpha-beta value from intersection.

Parameters
  • input_filepath (str) – Surface model filename and location where data is stored.

  • quantity_to_compute (str) – Parameter name.

  • boundary (list) – Boundary of searching grid.

  • radius (float) – Minimum radius of circle to search outside of.

  • grid_size (int) – Size of searching grid ( grid_size x grid_size matrix)

  • value_change (float) – Desired change in curvature / bend angle to achieve

  • method_angle (str) – Method for computing angle.

  • method_curv (str) – Method for computing curvature.

  • region_of_interest (str) – Method for setting the region of interest [‘manual’ | ‘commandline’ | ‘landmarking’]

  • region_points (list) – If region_of_interest is ‘commandline’, this a flatten list of the start and endpoint

estimate_alpha_and_beta.find_angle(pa, pb, p1, p2, projection)[source]

Compute the angle between two vectors a = pA - p1 and b = pB - p2 using the classical formula.

Parameters
  • pa (ndarray) – Point along the centerline.

  • pb (ndarray) – Point along the centerline.

  • p1 (ndarray) – Point along the centerline.

  • p2 (ndarray) – Point along the centerline.

  • projection (bool) – True / False for 2D / 3D angle.

Returns

Angle between vectors. vector_a (ndarray): First vector. vector_b (ndarraty): Second vector.

Return type

deg (float)

estimate_alpha_and_beta.find_angle_odr(d1, d2, projection)[source]

Compute the angle between two vectors d1 and d2 using the classical formula. Used for the ODR-method, specifically.

Parameters
  • d1 (ndarray) – First vector

  • d2 (ndarray) – Second vector

  • projection (bool) – True / False for 2D / 3D angle.

Returns

Angle between vectors.

Return type

deg (float)

estimate_alpha_and_beta.get_moved_siphon(new_centerlines, centerlines, p1, p2)[source]

Extracts new siphon from new centerline and clipping point information.

Parameters
  • new_centerlines (vtkPolyData) – Centerline data.

  • centerlines (vtkPolyData) – Initial centerlines.

  • p1 (ndarray) – First clipping point.

  • p2 (ndarray) – Second clipping point.

Returns

ID of first clipping point.

Return type

id1 (int)

Returns

ID of second clipping point.

Return type

id2 (int)

Returns

New ID of first clipping point.

Return type

moved_id1 (int)

Returns

New ID of secon clipping point.

Return type

moved_id1 (int)

Returns

New position of first clipping point.

Return type

moved_p1 (ndarray)

Returns

New position of second ipping point.

Return type

moved_p2 (ndarray)

estimate_alpha_and_beta.get_new_centerlines(centerlines, region_points, alpha, beta, p1, p2)[source]

Perform manual centerline manipulation in order to use the centerline as a proxy for computing a selected quantity (angle, curvature). Takes the original centerline, the points defining the region of interest and the manipulation factors alpha and beta before performing a manual movement of the centerline. Returns the new, manipulated centerline as a VTK object.

Parameters
  • centerlines (vtkPolyData) – Centerlines including diverging centerlines

  • region_points (ndarray) – List of region points

  • alpha (float) – Extension / Compression factor in vertical direction.

  • beta (float) – Extension / Compression factor in horizontal direction.

  • p1 – First region point

  • p2 – Second region point

Returns

Centerlines excluding diverging centerlines

Return type

centerlines (vtkPolyData)

Returns

New centerlines including diverging centerlines

Return type

new_centerlines (vtkPolyData)

estimate_alpha_and_beta.odr_line(id1, id2, line, curvature, limit)[source]

Computes the orthogonal distance regression of points along the centerline selected from 1) All points until a cumulative limit is reached or 2) The first 11 points and all points fulfilling curvature less than the mean plus 1.96 x SD

Parameters
  • id1 (int) – ID of first clipping point.

  • id2 (int) – ID of second clipping point.

  • line (vtkPolyData) – Centerline data.

  • curvature (ndarray) – Array of curvature values.

  • limit (ndarray) – Method used as limit

Returns

Direction vector from first clipping point. d2 (ndarray): Direction vector from second clipping point. curvlines (vtkPolyData): Centerline object with corresponding curvature values.

Return type

d1 (ndarray)

estimate_alpha_and_beta.read_command_line()[source]

Read arguments from commandline

estimate_alpha_and_beta.write_alpha_beta_point(base_path, suggested_point, method, quantity_to_compute)[source]

Write suggested choice of (alpha, beta) to file.

Parameters
  • base_path (str) – Path to file directory.

  • suggested_point (ndarray) – Array containing alpha and beta value

  • method (str) – Info about parameter, and increase / decrease of parameter.

  • quantity_to_compute (str) – Quantity to compute.