Skip to content

Commit

Permalink
asymmetry function
Browse files Browse the repository at this point in the history
  • Loading branch information
jingpengw committed Nov 2, 2017
1 parent caa4486 commit 6991059
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/BranchNets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,28 @@ function get_num_nodes( self::BranchNet )
sum(map(length, branchList))
end

"""
get_mass_center( self::BranchNet )
mass center was computed simply as center of all nodes
"""
function get_mass_center( self::BranchNet )
nodeList = get_node_list(self)
x = sum(map(n->n[1], nodeList)) / length(nodeList)
y = sum(map(n->n[2], nodeList)) / length(nodeList)
z = sum(map(n->n[3], nodeList)) / length(nodeList)
(x,y,z)
end

"""
get_asymmetry( self::BranchNet )
asymmetry was measured by the euclidean distance between root node and mass center
"""
function get_asymmetry( self::BranchNet )
massCenter = get_mass_center( self )
root = get_root_node( self )
norm( [massCenter...] .- [root[1:3]...] )
end

"""
get_children_branch_index_list(self::BranchNet, parentBranchIndex::Integer)
"""
Expand Down
8 changes: 7 additions & 1 deletion test/BranchNets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ end

println("remove subtree in soma...")
@time newBranchNet = BranchNets.remove_subtree_in_soma(branchNet)


println("get asymmetry ...")
@show BranchNets.get_asymmetry( branchNet )

println("get mass center ...")
@show BranchNets.get_mass_center( branchNet )

println("get branching angle ...")
@time angle = BranchNets.get_branching_angle( branchNet, 5 )

Expand Down

0 comments on commit 6991059

Please sign in to comment.