Graph Construction API
Commonly Used Functions
RegistrationGraph.generate_elastix_difficulty — Functiongenerate_elastix_difficulty(path_elastix_difficulty::String, t_range, heuristic::Function)Generates an elastix difficulty file based on the given heuristic.
Arguments
path_elastix_difficulty::String: output filet_range: list or range of time points to compute the difficultyheuristic: a heuristic function that evaluates "distance" betwen two frames. The function will be givent1, andt2as input, so be sure its other parameters have been initialized correctly. It is assumed that the function outputs floating-point values.
generate_elastix_difficulty(param_path::Dict, t_range, heuristic::Function)Generates an elastix difficulty file based on the given heuristic.
Arguments
param_path::Dict: Dictionary of paths containingpath_elastix_difficultykey to the path of the elastix difficulty output filet_range: list or range of time points to compute the difficultyheuristic: a heuristic function that evaluates "distance" betwen two frames. The function will be givent1, andt2as input, so be sure its other parameters have been initialized correctly. It is assumed that the function outputs floating-point values.
RegistrationGraph.load_graph — Functionload_graph(elx_difficulty::String; func=nothing, difficulty_importance::Real=0.05)Loads an adjacency matrix from a file and stores it as a graph. You can specify a function to apply to each weight. This is often helpful in cases where the heuristic obeys the triangle inequality, to avoid the function from generating a star graph and mostly ignoring the heuristic. By default, the function is x->x^1.05, which allows the algorithm to split especially difficult registration problems into many steps. If this results in too many failed registrations, try increasnig the difficulty_importance parameter; conversely, if there is too much error accumulation over long chains of registrations, try decreasing it.
Arguments
elx_difficulty::String: a path to a text file containing a list of frames and an adjacency matrix.func(optional): a function to apply to each element of the adjacency matrixdifficulty_importance(optional, default 0.05): iffuncis not provided, it will be set tox->x^(1+difficulty_importance)
Returns a graph graph::SimpleWeightedGraph storing the adjacency matrix.
RegistrationGraph.make_voting_subgraph — Functionmake_voting_subgraph(graph::SimpleWeightedGraph, degree::Integer)Makes a subgraph of a graph, where each node is connected to their degree closest neighbors. Returns the subgraph, and an array of nodes that were disconnected from the rest of the nodes.
RegistrationGraph.output_graph — Functionoutput_graph(subgraph::SimpleWeightedDiGraph, outfile::String; max_fixed_t::Int=0)Outputs subgraph::SimpleWeightedDiGraph to an output file outfile containing a list of edges in subgraph. Can set max_fixed_t::Int parameter if a dataset-alignment registration is being done.
Other Functions
RegistrationGraph.to_dict — Functionto_dict(graph::SimpleWeightedGraph)Converts a graph::SimpleWeightedGraph into an adjacency dictionary node => Dict({neighbor1 => weight1, neighbor2=> weight2, ...})
RegistrationGraph.remove_frame — Functionremove_frame(graph::SimpleWeightedGraph, frame::Integer)s Given a graph graph::SimpleWeightedGraph and a problematic frame::Integer, deletes the frame from the graph without changing frame indices.
RegistrationGraph.update_graph — Functionupdate_graph(reg_quality_arr::Array{String,1}, graph::SimpleWeightedGraph, metric::String; metric_tfm=identity)Recomputes the difficulty graph based on registration quality data. Returns a new graph where difficulties of registration problems are scaled by the quality metric.
Arguments
reg_quality_arr::Array{String,1}is an array of paths to files containing registration quality datagraph::SimpleWeightedGraphis the difficulty graph to be updatedmetric::Stringis which quality metric to use to update the graph
Optional keyword arguments
metric_tfm: Function to apply to each metric value. Default identity.
RegistrationGraph.remove_previous_registrations — Functionremove_previous_registrations(previous_problems, subgraph::SimpleWeightedDiGraph)Removes previous registrations from the subgraph.
Arguments:
previous_problems: list of registration problemssubgraph::SimpleWeightedDiGraph: current subgraph
RegistrationGraph.optimize_subgraph — Functionoptimize_subgraph(graph::SimpleWeightedGraph)Finds the minimum node of a graph, which has the smallest average shortest path length to each other node in that graph. Unconnected nodes are counted as having a path length equal to the highest edge weight.
Parameters
graph::SimpleWeightedGraph: a graph
Returns:
min_node::Integer: the minimum nodesubgraph::SimpleWeightedDiGraph: an unweighted graph whose edges consist of shortest paths from the minimum node of the original graph to other nodes.maximum_problem_chain::Integer: the number of vertices in the longest chain of registration problems in the subgraph.
This graph is directed, and only has edges going away from the minimum node.