Skip to content

Commit

Permalink
Fix labels annotation bug due to uninitialized seg_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
cmalinmayor committed Oct 20, 2024
1 parent bccc5ba commit 301efc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/motile_plugin/data_model/tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,19 +632,18 @@ def _compute_ndim(

def _create_seg_time_to_node(self) -> dict[int, dict[int, Node]]:
"""Create a dictionary mapping seg_id -> dict(time_point -> node_id)"""
seg_time_to_node: dict[int, dict[int, Node]] = {}
self.seg_time_to_node: dict[int, dict[int, Node]] = {}
if self.segmentation is None:
return seg_time_to_node
return

for node in self.graph.nodes():
seg_id = self.get_seg_id(node)
if seg_id is None:
continue
if seg_id not in seg_time_to_node:
seg_time_to_node[seg_id] = {}
if seg_id not in self.seg_time_to_node:
self.seg_time_to_node[seg_id] = {}
time = self.get_time(node)
seg_time_to_node[seg_id][time] = node
return seg_time_to_node
self.seg_time_to_node[seg_id][time] = node

def _set_node_attr(self, node: Node, attr: NodeAttr, value: Any):
if isinstance(value, np.ndarray):
Expand Down
6 changes: 3 additions & 3 deletions src/motile_plugin/motile/menus/motile_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ 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()
return run

def _on_solver_event(self, run: MotileRun, event_data: dict) -> None:
Expand Down Expand Up @@ -206,8 +208,6 @@ def _on_solve_complete(self, run: MotileRun) -> None:
"""
run.status = "done"
self.solver_update.emit()
if run.seg_time_to_node == {}:
run._create_seg_time_to_node()
self.new_run(run, run.run_name)

def _title_widget(self) -> QWidget:
Expand Down

0 comments on commit 301efc0

Please sign in to comment.