Skip to content

Commit

Permalink
subset_neuron w/ meshes: fix issue with connectors (vertex -> vertex_id)
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Feb 13, 2025
1 parent 3edb345 commit b2d8c7b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions navis/morpho/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ def _subset_meshneuron(x, subset, keep_disc_cn, prevent_fragments):
# our `subset` is always a list of vertex indices)
if not keep_disc_cn and x.has_connectors:
if "vertex_id" not in x.connectors.columns:
x.connectors["vertex"] = x.snap(x.connectors[["x", "y", "z"]].values)[0]
x.connectors["vertex_id"] = x.snap(x.connectors[["x", "y", "z"]].values)[0]

x._connectors = x.connectors[x.connectors.vertex.isin(subset)].copy()
x._connectors = x.connectors[x.connectors.vertex_id.isin(subset)].copy()
x._connectors.reset_index(inplace=True, drop=True)

# Make old -> new indices map
new_ix = dict(zip(subset, np.arange(0, len(subset))))

x.connectors["vertex"] = x.connectors.vertex.map(new_ix)
x.connectors["vertex_id"] = x.connectors.vertex_id.map(new_ix)

if len(subset):
x.vertices, x.faces = submesh(x, vertex_index=subset)
Expand Down

0 comments on commit b2d8c7b

Please sign in to comment.