Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

KeyError for a neuron while computing persistence diagram #61

@dokato

Description

@dokato

When calling get_persistence_diagram on my neuron ( swc file attached) that looks like this:

Screenshot 2022-11-02 at 17 18 16

I get the following error:

In [18]: perd = tmd.methods.get_persistence_diagram(neuron.neurites[0])
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Input In [18], in <cell line: 1>()
----> 1 perd = tmd.methods.get_persistence_diagram(neuron.neurites[0])

File ~/anaconda3/envs/testnavis/lib/python3.9/site-packages/tmd/Topology/methods.py:102, in get_persistence_diagram(tree, feature, **kwargs)
    100 def get_persistence_diagram(tree, feature='radial_distances', **kwargs):
    101     '''Method to extract ph from tree that contains mutlifurcations'''
--> 102     ph, _ = tree_to_property_barcode(
    103         tree,
    104         filtration_function=_filtration_function(feature, **kwargs),
    105         property_class=NoProperty
    106     )
    107     return ph

File ~/anaconda3/envs/testnavis/lib/python3.9/site-packages/tmd/Topology/methods.py:62, in tree_to_property_barcode(tree, filtration_function, property_class)
     59 while len(alives) > 1:
     60     for alive in alives:
---> 62         p = parents[alive]
     63         c = children[p]
     65         if np.alltrue(active[c]):
KeyError: 15

In fact this is a neuron exported from the navis library.

> import navis
> n = navis.example_neurons(1)
> navis.write_swc(n,'nrn.swc')

nrn.swc.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions