Skip to content

Commit

Permalink
Further cleaning and removing unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lidakanari committed Dec 13, 2018
1 parent 7705675 commit 5da070b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 446 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 1 addition & 49 deletions tmd/Topology/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,54 +217,6 @@ def get_section_mean_radii(tree, beg, end):
return ph


def get_ph_branchorder(tree, feature='radial_distances', **kwargs):
"""Returns the ph diagram enhanced with the corresponding encoded radii"""
ph = []

rd = getattr(tree, 'get_point_' + feature)(**kwargs)
bo = tree.get_point_section_branch_orders()

active = tree.get_bif_term() == 0

beg, end = tree.get_sections_2()

beg = np.array(beg)
end = np.array(end)

parents = {e: b for b, e in zip(beg, end)}
children = {b: end[np.where(beg == b)[0]] for b in np.unique(beg)}

bos = tree.get_section_branch_orders()
#bos = np.array(get_section_branchorder(tree, beg, end))

while len(np.where(active)[0]) > 1:
alive = list(np.where(active)[0])
for l in alive:

p = parents[l]
c = children[p]

if np.alltrue(active[c]):
active[p] = True
active[c] = False

mx = np.argmax(abs(rd[c]))
mx_id = c[mx]

c = np.delete(c, mx)

for ci in c:
bosID = np.array(bos)[np.where(beg == p)[0][0]]
ph.append([rd[ci], rd[p], bo[p]])

rd[p] = rd[mx_id]
bo[p] = bo[mx_id]

ph.append([rd[np.where(active)[0][0]], 0, bo[np.where(active)[0][0]]]) # Add the last alive component

return ph


def get_ph_neuron(neuron, feature='radial_distances', neurite_type='all', **kwargs):
'''Method to extract ph from a neuron that contains mutlifurcations'''

Expand Down Expand Up @@ -312,7 +264,7 @@ def get_lifetime(tree, feature='point_radial_distances'):
This can be used as the first step for the approximation of P.H.
of the radial distances of the neuronal branches.
'''
begs, ends = tree.get_sections()
begs, ends = tree.get_sections_2()
rd = getattr(tree, 'get_' + feature)()
lifetime = np.array(len(begs) * [np.zeros(2)])

Expand Down
38 changes: 6 additions & 32 deletions tmd/Tree/Tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@
class Tree(object):
'''Tree class'''
import numpy as _np
from tmd.Tree.methods import size
from tmd.Tree.methods import get_sections
from tmd.Tree.methods import get_sections_2
from tmd.Tree.methods import get_sections_only_points
from tmd.Tree.methods import get_section_points
from tmd.Tree.methods import get_section_number
from tmd.Tree.methods import get_section_lengths
from tmd.Tree.methods import get_section_radial_distances
from tmd.Tree.methods import get_section_path_distances
from tmd.Tree.methods import get_section_branch_orders
from tmd.Tree.methods import get_section_start
from tmd.Tree.methods import get_segment_lengths
from tmd.Tree.methods import get_segment_radial_distances
from tmd.Tree.methods import get_segments
from tmd.Tree.methods import get_bounding_box
from tmd.Tree.methods import get_pca
from tmd.Tree.methods import extract_simplified
from tmd.Tree.methods import get_type
from tmd.Tree.methods import get_direction_between
from tmd.Tree.methods import get_point_radial_distances
from tmd.Tree.methods import get_point_radial_distances_time
from tmd.Tree.methods import get_point_weighted_radial_distances
Expand All @@ -27,25 +22,9 @@ class Tree(object):
from tmd.Tree.methods import get_point_section_lengths
from tmd.Tree.methods import get_point_section_branch_orders
from tmd.Tree.methods import get_bif_term
from tmd.Tree.methods import get_trunk
from tmd.Tree.methods import get_bifurcations
from tmd.Tree.methods import get_multifurcations
from tmd.Tree.methods import get_terminations
from tmd.Tree.methods import get_way_to_root
from tmd.Tree.methods import get_way_to_section_end
from tmd.Tree.methods import get_way_to_section_start
from tmd.Tree.methods import get_bounding_box
from tmd.Tree.methods import get_segments
from tmd.Tree.methods import get_type
from tmd.Tree.methods import get_children
from tmd.Tree.methods import get_bif_angles
from tmd.Tree.methods import get_direction
from tmd.Tree.methods import get_direction_between
from tmd.Tree.methods import get_pca
from tmd.Tree.methods import extract_simplified
from tmd.Tree.methods import get_angle_between
from tmd.Tree.methods import get_branch_order
from tmd.Tree.methods import get_parent_child_angles


def __init__(self, x=_np.array([]), y=_np.array([]), z=_np.array([]),
Expand All @@ -56,19 +35,14 @@ def __init__(self, x=_np.array([]), y=_np.array([]), z=_np.array([]),
----------
x : numpy array
The x-coordinates of neuron's tree segments.
y : numpy array
The y-coordinates of neuron's tree segments.
z : numpy array
The z-coordinate of neuron's tree segments.
d : numpy array
The diameters of neuron's tree segments.
t : numpy array
The types (basal, apical, axon) of neuron's tree segments.
p : numpy array
The index of the parent of neuron's tree segments.
Expand Down

0 comments on commit 5da070b

Please sign in to comment.