Skip to content

Commit

Permalink
fix(upgrade): use hierarchy from supervoxels
Browse files Browse the repository at this point in the history
  • Loading branch information
akhileshh committed Sep 26, 2024
1 parent c1af454 commit e23d767
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pychunkedgraph/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.4"
__version__ = "3.0.5"
7 changes: 4 additions & 3 deletions pychunkedgraph/graph/edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion pychunkedgraph/ingest/upgrade/parent_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit e23d767

Please sign in to comment.