diff --git a/src/motile_plugin/application_menus/__init__.py b/src/motile_plugin/application_menus/__init__.py index 9b63274..d47f2e4 100644 --- a/src/motile_plugin/application_menus/__init__.py +++ b/src/motile_plugin/application_menus/__init__.py @@ -1,2 +1,3 @@ from .main_app import MainApp # noqa from .editing_menu import EditingMenu # noqa +from .menu_widget import MenuWidget # noqa diff --git a/src/motile_plugin/data_model/tracks.py b/src/motile_plugin/data_model/tracks.py index 67812c5..8d0a549 100644 --- a/src/motile_plugin/data_model/tracks.py +++ b/src/motile_plugin/data_model/tracks.py @@ -638,11 +638,11 @@ def _create_seg_time_to_node(self) -> dict[int, dict[int, Node]]: for node in self.graph.nodes(): seg_id = self.get_seg_id(node) - if seg_id is None: + time = self.get_time(node) + if seg_id is None or time is None: continue if seg_id not in self.seg_time_to_node: self.seg_time_to_node[seg_id] = {} - time = self.get_time(node) self.seg_time_to_node[seg_id][time] = node def _set_node_attr(self, node: Node, attr: NodeAttr, value: Any): @@ -733,12 +733,13 @@ def _compute_node_attrs( pos = None else: seg = self.segmentation[time][0] == seg_id + pos_scale = self.scale[1:] if self.scale is not None else None area = np.sum(seg) - if self.scale is not None: - area *= np.prod(self.scale) + if pos_scale is not None: + area *= np.prod(pos_scale) # only include the position if the segmentation was actually there pos = ( - measure.centroid(seg, spacing=self.scale) + measure.centroid(seg, spacing=pos_scale) if area > 0 else np.array( [ diff --git a/src/motile_plugin/data_views/views/__init__.py b/src/motile_plugin/data_views/views/__init__.py index b491f3f..e69de29 100644 --- a/src/motile_plugin/data_views/views/__init__.py +++ b/src/motile_plugin/data_views/views/__init__.py @@ -1,4 +0,0 @@ -from .tree_view.tree_widget import TreeWidget # noqa -from .layers.track_graph import TrackGraph # noqa -from .layers.track_labels import TrackLabels # noqa -from .layers.track_points import TrackPoints # noqa diff --git a/src/motile_plugin/data_views/views_coordinator/__init__.py b/src/motile_plugin/data_views/views_coordinator/__init__.py index e56e2cc..e69de29 100644 --- a/src/motile_plugin/data_views/views_coordinator/__init__.py +++ b/src/motile_plugin/data_views/views_coordinator/__init__.py @@ -1,2 +0,0 @@ -from .node_selection_list import NodeSelectionList # noqa -from .tracks_viewer import TracksViewer # noqa diff --git a/src/motile_plugin/motile/backend/solve.py b/src/motile_plugin/motile/backend/solve.py index bac2c69..71f7a1e 100644 --- a/src/motile_plugin/motile/backend/solve.py +++ b/src/motile_plugin/motile/backend/solve.py @@ -16,7 +16,6 @@ get_candidate_graph_from_points_list, graph_to_nx, ) -from motile_toolbox.visualization.napari_utils import assign_tracklet_ids from .solver_params import SolverParams @@ -71,7 +70,8 @@ def solve( solution_graph = solver.get_selected_subgraph(solution=solution) solution_nx_graph = graph_to_nx(solution_graph) - solution_nx_graph, _, _ = assign_tracklet_ids(solution_nx_graph) + logger.debug("Solution graph has %d nodes", solution_nx_graph.number_of_nodes()) + # solution_nx_graph, _, _ = assign_tracklet_ids(solution_nx_graph) return solution_nx_graph diff --git a/src/motile_plugin/motile/menus/motile_widget.py b/src/motile_plugin/motile/menus/motile_widget.py index a57374f..3b05bdb 100644 --- a/src/motile_plugin/motile/menus/motile_widget.py +++ b/src/motile_plugin/motile/menus/motile_widget.py @@ -166,13 +166,18 @@ def solve_with_motile(self, run: MotileRun) -> MotileRun: lambda event_data: self._on_solver_event(run, event_data), scale=run.scale, ) + + run._initialize_track_ids() if run.input_segmentation is not None: run.segmentation = self.relabel_segmentation( run.graph, run.input_segmentation ) - run._create_seg_time_to_node() - run._initialize_track_ids() + + if run.graph.number_of_nodes() == 0: + show_warning( + "No tracks found - try making your edge selection value more negative" + ) return run def _on_solver_event(self, run: MotileRun, event_data: dict) -> None: