From e23d767662418fc14736942a652c24a6e1c7d8e2 Mon Sep 17 00:00:00 2001 From: Akhilesh Halageri Date: Thu, 26 Sep 2024 14:45:14 +0000 Subject: [PATCH] fix(upgrade): use hierarchy from supervoxels --- pychunkedgraph/__init__.py | 2 +- pychunkedgraph/graph/edits.py | 7 ++++--- pychunkedgraph/ingest/upgrade/parent_layer.py | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pychunkedgraph/__init__.py b/pychunkedgraph/__init__.py index 8e10cb462..e94f36fe8 100644 --- a/pychunkedgraph/__init__.py +++ b/pychunkedgraph/__init__.py @@ -1 +1 @@ -__version__ = "3.0.4" +__version__ = "3.0.5" diff --git a/pychunkedgraph/graph/edits.py b/pychunkedgraph/graph/edits.py index 340cefadd..afe1b3abf 100644 --- a/pychunkedgraph/graph/edits.py +++ b/pychunkedgraph/graph/edits.py @@ -497,7 +497,7 @@ def _update_neighbor_cross_edges( return updated_entries -def _get_supervoxels(cg, node_ids): +def get_supervoxels(cg, node_ids): """Returns the first supervoxel found for each node_id.""" result = {} node_ids_copy = np.copy(node_ids) @@ -606,7 +606,7 @@ def _update_cross_edge_cache(self, parent, children): ) cx_edges_d = concatenate_cross_edge_dicts(cx_edges_d.values()) edge_nodes = np.unique(np.concatenate([*cx_edges_d.values(), types.empty_2d])) - edge_supervoxels = _get_supervoxels(self.cg, edge_nodes) + edge_supervoxels = get_supervoxels(self.cg, edge_nodes) edge_parents = self.cg.get_roots( edge_supervoxels, stop_layer=parent_layer, @@ -671,7 +671,8 @@ def _create_new_parents(self, layer: int): l2c1 = get_l2children(self.cg, c1) l2c2 = get_l2children(self.cg, c2) if np.intersect1d(l2c1, l2c2).size: - msg = f"{self._operation_id}:{c1} {c2} have common children." + c = np.intersect1d(l2c1, l2c2) + msg = f"{self._operation_id}: {layer} {c1} {c2} have common children {c}" raise ValueError(msg) def run(self) -> Iterable: diff --git a/pychunkedgraph/ingest/upgrade/parent_layer.py b/pychunkedgraph/ingest/upgrade/parent_layer.py index 0606ff674..2869fcf85 100644 --- a/pychunkedgraph/ingest/upgrade/parent_layer.py +++ b/pychunkedgraph/ingest/upgrade/parent_layer.py @@ -10,6 +10,7 @@ from pychunkedgraph.graph import ChunkedGraph from pychunkedgraph.graph.attributes import Connectivity, Hierarchy +from pychunkedgraph.graph.edits import get_supervoxels from pychunkedgraph.graph.utils import serializers from pychunkedgraph.graph.types import empty_2d from pychunkedgraph.utils.general import chunked @@ -101,7 +102,8 @@ def update_cross_edges(cg: ChunkedGraph, layer, node, node_ts, earliest_ts) -> l if edges.size == 0: continue nodes = np.unique(edges[:, 1]) - parents = cg.get_roots(nodes, time_stamp=ts, stop_layer=layer, ceil=False) + svs = get_supervoxels(cg, nodes) + parents = cg.get_roots(svs, time_stamp=ts, stop_layer=layer, ceil=False) edge_parents_d = dict(zip(nodes, parents)) val_dict = {} for _layer, layer_edges in cx_edges_d.items():