Skip to content

Commit

Permalink
add number of branching point metric
Browse files Browse the repository at this point in the history
  • Loading branch information
jingpengw committed Oct 23, 2017
1 parent cadb36d commit c78104a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions scripts/skeletonize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function main()
while true
handle, body = fetch(sqsChannel)
d = JSON.parse( body )
println("tracing cell: $(d["id"])")
try
trace(d["id"]; swcDir=d["swcdir"], mip=d["mip"])
catch err
Expand Down
19 changes: 14 additions & 5 deletions scripts/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,37 @@
include("Common.jl")
using Common
using RealNeuralNetworks.SWCs
using RealNeuralNetworks.BranchNets
using HDF5
#using Plots
# use pyplot backend for vectorized output
#Plots.pyplot()

function main()
args = parse_commandline()
lengthList = Vector{Float64}()
numBranchingPointsList = Vector{Int}()
totalPathLengthList = Vector{Float64}()
@sync begin
for fileName in readdir( args["swcdir"] )
if contains(fileName, ".swc")
@async begin
@time swc = SWCs.load( joinpath( args["swcdir"], fileName ) )
total_length = SWCs.get_total_length( swc )
println("length of $(fileName): $(total_length/1000) micron")
push!(lengthList, total_length)
totalPathLength = SWCs.get_total_length( swc )
println("total path length of cell $(fileName): " *
"$(totalPathLength/1000) micron")
push!(totalPathLengthList, totalPathLength)

branchNet = BranchNet(swc)
numBranchingPoints = BranchNets.get_num_branching_points(branchNet)
println("number of branching points of cell $(fileName): $numBranchingPoints")
push!(numBranchingPointsList, numBranchingPoints)
end
end
end
end
@show lengthList
h5write("statistics.h5", "lengthList", lengthList)
h5write("statistics.h5", "totalPathLengthList", totalPathLengthList,
"numBranchingPointsList", numBranchingPointsList)
#p = histogram( lengthList )
# display(p)
end
Expand Down
23 changes: 19 additions & 4 deletions src/BranchNets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,18 @@ function BranchNet{T}( seg::Array{T,3}; obj_id::T = convert(T,1),
BranchNet( nodeNet )
end

function BranchNet( swcString::AbstractString )
swc = SWC(swcString)
function BranchNet( swc::SWC )
nodeNet = NodeNet( swc )
BranchNet( nodeNet )
end

"""
BranchNet( swcString::AbstractString )
transform string from swc content to BranchNet
"""
function BranchNet( swcString::AbstractString )
swc = SWC(swcString)
BranchNet( swc )
end

######################### IO ################
Expand All @@ -155,10 +163,15 @@ end
get the number of branches
"""
function get_num_branches(self::BranchNet) length(self.branchList) end
function get_num_branches(self::BranchNet) length(self.branchList) end
"""
get_num_branching_points(self::BranchNet)
get number of branching points. assume that neuron tree do not have loop,
so the number of branching points is num_branches-1.
"""
function get_num_branching_points(self::BranchNet) get_num_branches(self)-1 end
function get_branch_list(self::BranchNet) self.branchList end
function get_connectivity_matrix(self::BranchNet) self.connectivityMatrix end
function get_num_node_edges(self::BranchNet) error("unimplemented") end

"""
get_branch_length_list( self::BranchNet )
Expand All @@ -184,6 +197,8 @@ function get_num_nodes( self::BranchNet )
sum(map(length, branchList))
end



"""
get_children_branch_index_list(self::BranchNet, parentBranchIndex::Integer)
"""
Expand Down

0 comments on commit c78104a

Please sign in to comment.