Skip to content

Comments

Change: more sensible default and handling of ntype#27

Merged
huangziwei merged 6 commits intomainfrom
dev-ntype
Nov 26, 2025
Merged

Change: more sensible default and handling of ntype#27
huangziwei merged 6 commits intomainfrom
dev-ntype

Conversation

@jonathanoesterle
Copy link
Contributor

@jonathanoesterle jonathanoesterle commented Nov 26, 2025

  • changed default ntype handling to root=-1/unknown=0 while preserving labels through all postprocessing steps. skeleton init, SWC/NPZ I/O, plotting palette, and remapping logic honor -1/0, with soma explicitly 1 when detected
  • ntype remapping now aggregates labels when nodes merge (majority with a fixed priority), enforces a single root/soma, and fills zero gaps from neighboring labels.
  • all node/edge-altering post ops (drop/keep, merge_near_soma_nodes, prune_neurites, detect_soma, downsample, reroot) now re-align ntype using the new remap + gap-fill; reroot also fills gaps after clearing duplicate -1/1 labels.
  • visualization: SWC colormap extended to include -1 (“root”) with stable ordering.

skeliner/post.py Outdated
if ntype is None:
return None
mapped = np.full(new_len, 3, dtype=ntype.dtype)
mapped = np.full(new_len, 0, dtype=ntype.dtype)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if we still do this, every post-processing steps will reset the existing ntype to 0.

we need to rethink how to remap ntype but preserve the existing ones.

on the other hand, in reroot, we do ntype[[0, swap]] = ntype[[swap, 0]], which is also too simple. maybe we should take edges into account also.

@jonathanoesterle
Copy link
Contributor Author

Tested on 2 skeletons. Works for plotting, rerooting, pruning and downsampling.

@huangziwei huangziwei changed the title Change ntype defaults to 0 and -1 (instead of 3 and 1). Change: more sensible default and handling of ntype Nov 26, 2025
@huangziwei huangziwei merged commit c5ebd00 into main Nov 26, 2025
5 checks passed
@huangziwei huangziwei deleted the dev-ntype branch January 27, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants