graph
navis.graph.classify_nodes
#
Classify neuron's nodes into end nodes, branches, slabs or root.
Adds a 'type'
column to x.nodes
table.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
categorical |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | |
Examples:
>>> import navis
>>> nl = navis.example_neurons(2)
>>> _ = navis.graph.classify_nodes(nl, inplace=True)
Source code in navis/graph/graph_utils.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
|
navis.graph.connected_subgraph
#
Return set of nodes necessary to connect all nodes in subset ss
.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
ss |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
np.ndarray | Node IDs of connected subgraph. |
root ID | ID of the node most proximal to the old root in the connected subgraph. |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> ends = n.nodes[n.nodes.type.isin(['end', 'root'])].node_id.values
>>> sg, root = navis.graph.graph_utils.connected_subgraph(n, ends)
>>> # Since we asked for a subgraph connecting all terminals + root,
>>> # we expect to see all nodes in the subgraph
>>> sg.shape[0] == n.nodes.shape[0]
True
Source code in navis/graph/graph_utils.py
1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 |
|
navis.graph.generate_list_of_childs
#
Return list of childs.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
dict |
|
Source code in navis/graph/graph_utils.py
1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 |
|
navis.graph.node_label_sorting
#
Return nodes ordered by node label sorting according to Cuntz et al., PLoS Computational Biology (2010).
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
weighted |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
list |
|
Source code in navis/graph/graph_utils.py
1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 |
|
navis.graph.simplify_graph
#
Simplify skeleton graph (networkX or igraph).
This function will simplify the graph by keeping only roots, leafs and branch points. Preserves branch lengths (i.e. weights)!
PARAMETER | DESCRIPTION |
---|---|
G |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
G | Simplified graph. TYPE: |
Examples:
>>> import navis
>>> n = navis.example_neurons(1, kind='skeleton')
>>> # Simplify skeleton's NetworkX graph representation
>>> G_simp_nx = navis.graph.simplify_graph(n.graph)
>>> # Check that we have the expected number of nodes
>>> assert len(G_simp_nx.nodes) == (n.n_branches + n.n_root + n.n_leafs)
>>> # Simplify skeleton's iGraph graph representation
>>> G_simp_ig = navis.graph.simplify_graph(n.igraph)
>>> # Check that we have the expected number of nodes
>>> assert len(G_simp_ig.vs) == (n.n_branches + n.n_root + n.n_leafs)
Source code in navis/graph/converters.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
navis.graph.skeleton_adjacency_matrix
#
Generate adjacency matrix for a skeleton.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
sort |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
pd.DataFrame | Adjacency matrix where rows are nodes and columns are their parents. |
See Also
navis.geodesic_matrix
For distances between all points. navis.distal_to
Check if a node A is distal to node B. navis.dist_between
Get point-to-point geodesic ("along-the-arbor") distances.
Source code in navis/graph/graph_utils.py
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 |
|