Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use voxel size to correct radius #6

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/DBFs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module DBFs

using Base.Cartesian

typealias DBF Vector{Float32}

"""
use segmentation to get binary image to save memory usage
"""
Expand Down
11 changes: 4 additions & 7 deletions src/Skeletons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ function skeletonize{T}( points::Array{T,2}; DBF=DBFs.compute_DBF(points),
if farthest_node == root_node break end #this can happen apparently

new_path = LightGraphs.enumerate_paths( dsp_dbf,farthest_node );

push!(paths, new_path)
#can't do this in-place with arrays
#this fn call is getting ridiculous
Expand All @@ -136,6 +135,7 @@ function skeletonize{T}( points::Array{T,2}; DBF=DBFs.compute_DBF(points),

println("Consolidating Paths")
path_nodes, path_edges = consolidate_paths( paths );

node_radii = DBF[path_nodes];

# build a new graph containing only the skeleton nodes and edges
Expand Down Expand Up @@ -215,9 +215,8 @@ function make_neighbor_graph{T}( points::Array{T,2}, ind2node=nothing, max_dims=
#26-connectivity neighborhood
# weights computed by euc_dist to center voxel
nhood = [[i,j,k] for i=1:3,j=1:3,k=1:3];
map!( x-> (x .- [2,2,2]).*[voxel_size ...] , nhood );
nhood_weights = map( norm, nhood );

map!( x-> (x .- [2,2,2]), nhood );
nhood_weights = map( x -> norm(x.*[voxel_size...]), nhood );
#only adding weights for non-duplicate nodes
_,non_duplicates = findnz( ind2node );

Expand Down Expand Up @@ -392,7 +391,7 @@ end
"""
function remove_path_from_rns( reachable_nodes::Vector, path::Vector,
points, ind2node, dbf, max_dims, inspected_nodes,
scale_param::Int=6, const_param::Int=6 );
scale_param::Int=1000, const_param::Int=1000 );

r = dbf[path]*scale_param + const_param;

Expand Down Expand Up @@ -507,8 +506,6 @@ function distill!{T}(point_array::Array{T,2},
path_edges[i] = (id_map[path_edges[i][1]], id_map[path_edges[i][2]])
end
# rebuild the roots and destinations
@show root_nodes
@show id_map
for i in 1:length(root_nodes)
root_nodes[i] = id_map[ root_nodes[i] ]
end
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using TEASAR
using Base.Test
using HDF5

const DEFAULT_VOXEL_SIZE = (UInt32(80), UInt32(80), UInt32(40))
const DEFAULT_VOXEL_SIZE = (UInt32(80), UInt32(80), UInt32(45))

function get_seg_from_h5()
# read seg data
Expand Down Expand Up @@ -31,8 +31,8 @@ seg[47:54, 47:54, 71:78] = 1


@testset "test teasar" begin
# @time swc = TEASAR.skeletonize(seg; voxel_size=DEFAULT_VOXEL_SIZE)
@time swc = TEASAR.skeletonize( seg )
@time swc = TEASAR.skeletonize(seg; voxel_size=DEFAULT_VOXEL_SIZE)
#@time swc = TEASAR.skeletonize( seg )
@test TEASAR.SWCs.get_points_num(swc) > 1
@show swc
TEASAR.SWCs.save(swc, tempname() * ".swc")
Expand Down