graph_corrections#

correct_graph(graph, min_radius=2.9, min_length=13)[source]#

This is the main function to correct the graph. Corrects the graph by removing * spurious branches (small degree 1 branches) * surface branches (branches that are too close to the surface) * auto loops (edges where edge.source == edge.target) * mutual loops (edges share the same source and target and are small(in radius and length))

Parameters:
  • graph

  • min_radius

  • min_length

Returns

The corrected graph

join_neighbouring_degrees_1(graph, min_radius=5, dest_path='', reduction_compatible=True)[source]#

Join degrees one (empty ended branches) that are very close and likely interrupted by a thresholding issue. The distance criterion is defined by min_radius.

Warning

This is meant to be used on the GRAPH BEFORE REDUCTION

graphGraphGt.Graph

the graph to fix

dest_pathstr

The optional path to save the modified graph

min_radiusfloat

The radius around a degree 1 vertex to search for neighbouring vertices

returnsGraphGt.Graph

The modified graph

print_percent_degree(graph, degree=4)[source]#

Print the number of nodes with a degree greater or equal to degree.

Parameters:
  • graph (Graph object) – The graph to consider

  • degree (int) – The degree to consider

Returns

remove_auto_loops(graph, min_length=None)[source]#

Removes auto loops from the graph. Auto loops are defined as edges with the same source and destination.

Parameters:
  • graph (Graph object) – The graph to consider

  • min_length (float) – The minimum length to consider

Returns

The graph with the auto loops removed

remove_mutual_loops_gt(graph, min_radius, min_length)[source]#

Removes mutual loops from the graph. Mutual loops are defined as edges with the same source and destination. In other words, two edges that connect the same pair of vertices in the graph form a mutual loop. This function uses a parallelized version of mutual_loop_detection.

Warning

There is a substantial difference between this function and a standard parallel edge filter. Contrary to a standard parallel edge filter, this function takes into account the length, i.e. the distance between the two vertices along the tract of the vessel, and the radius, i.e. the size of the vessel. For each pair of vertices where these two conditions are met, only the edge with the smallest radius will be removed.

Parameters:
  • graph (Graph object) – The graph to consider

  • min_radius (float) – The minimum radius to consider

  • min_length (float) – The minimum length to consider

Returns

The graph with the mutual loops removed

remove_spurious_branches(graph, r_min=None, min_length=1.0, view=False)[source]#

Removes spurious branches from the graph. Spurious branches are defined as small degree 1 branches (with a radius smaller than r_min).

Parameters:
  • graph (Graph object) – The graph to consider

  • r_min (float) – The minimum radius to consider

  • min_length (float) – The minimum length of the branch

Returns

The graph with the spurious branches removed

test()[source]#