Skip to content

Commit 6cd894d

Browse files
authored
Merge pull request #316 from funkelab/47-move-the-graph-creation-code-from-the-toolbox-into-funtracks
47 move the graph creation code from the toolbox into funtracks
2 parents 1d222a1 + 22ecbac commit 6cd894d

File tree

14 files changed

+51
-44
lines changed

14 files changed

+51
-44
lines changed

docs/source/tree_view.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ should be specified in ``Tracks.pos_attr``. If a segmentation is provided but no
5050
The segmentation is expected to be a numpy array with time as the first dimension, followed
5151
by the position dimensions in the same order as the ``Tracks.pos_attr``. The segmentation
5252
must have unique label ids across all time points - there is a helper function in the
53-
motile_toolbox called ensure_unique_labels that relabels a segmentation to be unique
53+
funtracks called ensure_unique_labels that relabels a segmentation to be unique
5454
across time if needed. If a segmentation is provided, the node ids in the graph should
5555
match label id of the corresponding segmentation.
5656

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ classifiers = [
3131

3232
dependencies =[
3333
"napari>=0.6.2,<1",
34-
"funtracks>=1.7.0-a2,<2",
34+
"funtracks>=1.7.0,<2",
3535
"appdirs>=1,<2",
3636
"numpy>=2,<3",
3737
"magicgui>=0.10.1",
3838
"qtpy>=2.4,<3",
3939
"scikit-image>=0.25",
4040
"motile>=0.3",
41-
"motile_toolbox == 0.4.0",
4241
"pydantic>=2,<3",
4342
"tifffile[all]>=2025.1.10",
4443
"tqdm>=4,<5",

src/motile_tracker/data_views/graph_attributes.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/motile_tracker/data_views/views/layers/track_points.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import napari
88
import numpy as np
99
from funtracks.data_model import NodeType, Tracks
10+
from funtracks.data_model.graph_attributes import NodeAttr
1011
from funtracks.exceptions import InvalidActionError
1112
from napari.layers.points._points_mouse_bindings import select
1213
from napari.utils.notifications import show_info
1314
from psygnal import Signal
1415

15-
from motile_tracker.data_views.graph_attributes import NodeAttr
1616
from motile_tracker.data_views.views.layers.click_utils import (
1717
detect_click,
1818
get_click_value,

src/motile_tracker/data_views/views/tree_view/tree_widget_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import numpy as np
88
import pandas as pd
99
from funtracks.data_model import NodeType, Tracks
10-
11-
from motile_tracker.data_views.graph_attributes import NodeAttr
10+
from funtracks.data_model.graph_attributes import NodeAttr
1211

1312

1413
def extract_sorted_tracks(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from .motile_run import MotileRun # noqa
22
from .solver_params import SolverParams # noqa
33
from .solve import solve # noqa
4+
from .graph_to_nx import graph_to_nx # noqa
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import networkx as nx
2+
from motile import TrackGraph
3+
4+
5+
def graph_to_nx(graph: TrackGraph) -> nx.DiGraph:
6+
"""Convert a motile TrackGraph into a networkx DiGraph.
7+
8+
Args:
9+
graph (TrackGraph): TrackGraph to be converted to networkx
10+
11+
Returns:
12+
nx.DiGraph: Directed networkx graph with same nodes, edges, and attributes.
13+
"""
14+
nx_graph = nx.DiGraph()
15+
nodes_list = list(graph.nodes.items())
16+
nx_graph.add_nodes_from(nodes_list)
17+
edges_list = [
18+
(edge_id[0], edge_id[1], data) for edge_id, data in graph.edges.items()
19+
]
20+
nx_graph.add_edges_from(edges_list)
21+
return nx_graph

src/motile_tracker/motile/backend/motile_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import numpy as np
99
from funtracks.data_model import SolutionTracks
10-
from motile_toolbox.candidate_graph.graph_attributes import NodeAttr
10+
from funtracks.data_model.graph_attributes import NodeAttr
1111

1212
from .solver_params import SolverParams
1313

src/motile_tracker/motile/backend/solve.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
import networkx as nx
88
import numpy as np
9-
from motile import Solver, TrackGraph
10-
from motile.constraints import MaxChildren, MaxParents, Pin
11-
from motile.costs import Appear, EdgeDistance, EdgeSelection, Split
12-
from motile_toolbox.candidate_graph import (
13-
EdgeAttr,
14-
NodeAttr,
9+
from funtracks.candidate_graph import (
1510
compute_graph_from_points_list,
1611
compute_graph_from_seg,
17-
graph_to_nx,
1812
)
13+
from funtracks.data_model.graph_attributes import EdgeAttr, NodeAttr
14+
from motile import Solver, TrackGraph
15+
from motile.constraints import MaxChildren, MaxParents, Pin
16+
from motile.costs import Appear, EdgeDistance, EdgeSelection, Split
17+
18+
from motile_tracker.motile.backend.graph_to_nx import graph_to_nx
1919

2020
from .solver_params import SolverParams
2121

@@ -51,8 +51,8 @@ def solve(
5151
5252
Returns:
5353
nx.DiGraph: A solution graph where the ids of the nodes correspond to
54-
the time and ids of the passed in segmentation labels. See the
55-
motile_toolbox for exact implementation details.
54+
the time and ids of the passed in segmentation labels. See funtracks for exact
55+
implementation details.
5656
"""
5757
# Single window mode: slice input, solve, and return early
5858
if (

src/motile_tracker/motile/menus/run_editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import napari.layers
1010
import networkx as nx
1111
import numpy as np
12-
from motile_toolbox.utils.relabel_segmentation import ensure_unique_labels
12+
from funtracks.utils import ensure_unique_labels
1313
from qtpy.QtCore import Signal
1414
from qtpy.QtWidgets import (
1515
QComboBox,

0 commit comments

Comments
 (0)