backend.solve

Attributes

logger

PIN_ATTR

_SKIP_ATTRS

Functions

solve(→ tracksdata.graph.GraphView)

Get a tracking solution for the given segmentation and parameters.

build_candidate_graph(→ tracksdata.graph.GraphView)

Build the candidate graph from input data.

_solve_full(→ tracksdata.graph.GraphView)

Solve the tracking problem on the full candidate graph at once.

_solve_window(→ tracksdata.graph.GraphView | None)

Solve a single window subgraph.

_solve_single_window(→ tracksdata.graph.GraphView)

Solve a single window for interactive parameter testing.

_solve_chunked(→ tracksdata.graph.GraphView)

Solve the tracking problem in chunks using a sliding window approach.

_set_pinning_on_graph(→ None)

Set PIN_ATTR on candidate graph nodes/edges in the overlap region.

construct_solver(→ motile.Solver)

Construct a motile solver with the parameters specified in the solver

get_solver_name(→ str)

Return the name of the ILP solver backend that will be used.

Module Contents

backend.solve.logger
backend.solve.PIN_ATTR = 'pinned'
backend.solve.solve(solver_params: backend.solver_params.SolverParams, input_data: numpy.ndarray, on_solver_update: collections.abc.Callable | None = None, scale: list | None = None, cand_graph: tracksdata.graph.GraphView | None = None) tracksdata.graph.GraphView

Get a tracking solution for the given segmentation and parameters.

Constructs a candidate graph from the segmentation (unless one is provided), a solver from the parameters, and then runs solving and returns a networkx graph with the solution. Most of this functionality is implemented in the motile toolbox.

Args:
solver_params (SolverParams): The solver parameters to use when

initializing the solver

input_data (np.ndarray): The input segmentation or points list to run

tracking on. If 2D, assumed to be a list of points, otherwise a segmentation.

on_solver_update (Callable, optional): A function that is called

whenever the motile solver emits an event. The function should take a dictionary of event data, and can be used to track progress of the solver. Defaults to None.

scale (list, optional): The scale of the data in each dimension. cand_graph (td.graph.GraphView, optional): A pre-built candidate graph. If

provided, skips candidate graph construction (except for single-window mode which always builds its own). Defaults to None.

Returns:
td.graph.GraphView: A solution graph where the ids of the nodes correspond to

the time and ids of the passed in segmentation labels. See funtracks for exact implementation details.

backend.solve.build_candidate_graph(input_data: numpy.ndarray, solver_params: backend.solver_params.SolverParams, scale: list | None = None) tracksdata.graph.GraphView

Build the candidate graph from input data.

backend.solve._solve_full(cand_graph: tracksdata.graph.GraphView, solver_params: backend.solver_params.SolverParams, on_solver_update: collections.abc.Callable | None = None) tracksdata.graph.GraphView

Solve the tracking problem on the full candidate graph at once.

backend.solve._solve_window(window_subgraph: tracksdata.graph.GraphView, solver_params: backend.solver_params.SolverParams, on_solver_update: collections.abc.Callable | None = None) tracksdata.graph.GraphView | None

Solve a single window subgraph.

This is the core solving logic shared by both single window mode and chunked solving.

Args:
window_subgraph: The subgraph for this window. If any nodes or edges

have the PIN_ATTR attribute set, a Pin constraint will be used.

solver_params: The solver parameters. on_solver_update: Callback for solver progress updates.

Returns:

The solution graph for this window, or None if the window has no nodes.

backend.solve._solve_single_window(input_data: numpy.ndarray, solver_params: backend.solver_params.SolverParams, on_solver_update: collections.abc.Callable | None = None, scale: list | None = None) tracksdata.graph.GraphView

Solve a single window for interactive parameter testing.

Builds the full candidate graph, filters it to the window frames, and solves. Node times are naturally correct (no adjustment needed).

Args:

input_data: The full input segmentation or points list. solver_params: The solver parameters including window_size and single_window_start. on_solver_update: Callback for solver progress updates. scale: The scale of the data in each dimension.

Returns:

The solution graph for the requested window.

Raises:

ValueError: If single_window_start is beyond the data range.

backend.solve._solve_chunked(cand_graph: tracksdata.graph.GraphView, solver_params: backend.solver_params.SolverParams, on_solver_update: collections.abc.Callable | None = None) tracksdata.graph.GraphView

Solve the tracking problem in chunks using a sliding window approach.

This function solves the tracking problem in windows of window_size frames, with overlap_size frames of overlap between consecutive windows. The overlap region from the previous window is pinned (fixed) when solving the next window to maintain consistency across windows.

Args:

cand_graph: The full candidate graph with all nodes and edges. solver_params: The solver parameters including window_size and overlap_size. on_solver_update: Callback for solver progress updates.

Returns:

The combined solution graph from all windows.

backend.solve._set_pinning_on_graph(cand_graph: tracksdata.graph.GraphView, solution_graph: tracksdata.graph.GraphView, overlap_start: int, overlap_end: int) None

Set PIN_ATTR on candidate graph nodes/edges in the overlap region.

For all nodes and edges in the overlap region [overlap_start, overlap_end), sets PIN_ATTR to True if selected in the solution, False if not selected.

Args:

cand_graph: The full candidate graph to modify in place. solution_graph: The solution graph from the current window. overlap_start: Start frame of overlap region (inclusive). overlap_end: End frame of overlap region (exclusive).

backend.solve._SKIP_ATTRS
backend.solve.construct_solver(cand_graph: tracksdata.graph.GraphView, solver_params: backend.solver_params.SolverParams) motile.Solver

Construct a motile solver with the parameters specified in the solver params object.

Args:

cand_graph (td.graph.GraphView): The candidate graph to use in the solver solver_params (SolverParams): The costs and constraints to use in

the solver

Returns:
Solver: A motile solver with the specified graph, costs, and

constraints.

backend.solve.get_solver_name() str

Return the name of the ILP solver backend that will be used.

Attempts Gurobi first; falls back to SCIP.