navis-org / navis

Python library for analysis of neuroanatomical data.
https://navis-org.github.io/navis/
GNU General Public License v3.0
83 stars 33 forks source link

improve strahler_index #89

Open schlegelp opened 2 years ago

schlegelp commented 2 years ago

Give more of a summary (perhaps split out into separate function) with e.g. cable per index, distributions, etc.

clbarnes commented 2 years ago

Yeah, sounds like an extra function strahler_summary, which can use a neuron already populated strahler values or populates them if necessary.

schlegelp commented 2 years ago

I ended up writing a segment_analysis function which returns Strahler index plus a bunch of other metrics for each linear segment (see d0590cc8d7bfdf77c09435d7a47a201e7e0670ea).

>>> import navis
>>> n = navis.example_neurons(1, kind='skeleton')
>>> n.reroot(n.soma, inplace=True)
>>> sa = navis.segment_analysis(n)
>>> sa.head()
        length  tortuosity     root_dist  strahler_index
0  1073.535053    1.151022    229.448586               1
1   112.682839    1.092659  10279.037511               1
2   214.124934    1.013030   9557.521377               1
3   159.585328    1.074575   9747.866968               1
4   229.448586    1.000000      0.000000               6

I have another commit in the works that would add radius_min, radius_max, radius_mean and volume to that table. Let me know if you have ideas for more stuff to add.

clbarnes commented 2 years ago

Maybe the node IDs at the root and leaf of each segment?

schlegelp commented 2 years ago

Yeah can add that too! The order is the same as n.small_segments so you could get them like this:

>>> sa['first_node'] = [seg[0] for seg in n.small_segments]
>>> sa['last_node'] = [seg[-1] for seg in n.small_segments]

Minimally, I can add that to the docstring.